Page 1 of 1

Associating data points with data structures

Posted: Tue Jul 03, 2007 3:47 pm
by 13045819
I am interested in storing data about each data point in a series. When I mouse over the series, I want to be able to display the detailed data in text boxes below the graph. Anyone know if this is possible or how to do it?

Thanks, LC

Posted: Wed Jul 04, 2007 8:33 am
by 9348258
Hi LC

You can use the e.X and e.Y values of the "mouseMove" event of the chart and the clicked method of the series, to know if the mouse is on some Series. You can do something similar as below code:

Code: Select all

 private void Form1_Load(object sender, EventArgs e)
        {
            bar1.Add(1, 2, "first");
            bar1.Add(2, 1, "second");
            bar1.Add(3, 5, "third");
            bar2.FillSampleValues(3);
        }
        private void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            foreach (Series s in tChart1.Chart.Series)
            {
                if (s.Clicked(e.X, e.Y) != -1)
                {
                    tChart1.Text = s.ToString() + "[" + s.Clicked(e.X, e.Y) + "] "+s[s.Clicked(e.X,e.Y)].Label;
                    break;
                }
                else
                    tChart1.Text = "";
            }
        }

Posted: Thu Jul 05, 2007 3:35 pm
by 13045819
Thanks...that'll help. What I am trying to do is associate details with each point on the graph. Can I get which data point in the series is begin moused over? I've been reading, and I think I can use hotspots to do that. I thought in the past that there was a data tag for each point, but I guess I was mistaken. Then again, I was using the ActiveX version before.

Thanks,
Larry

Posted: Thu Jul 05, 2007 5:20 pm
by narcis
Hi Larry,

Ok, in that case you may be interested in using MarkTips tool for that. You can find an example at All Features\Welcome !\Tools\Mark tips in the features demo. Demo can be found at TeeChart's program group. Also notice that you can customize the text displayed by the tool using its Style property and GetText event too.

Regarding data tag for each point, for now and as Edu told you, only a label can be added to each point. This can be done using Add method or directly accessing the label's StringList, for example:

Code: Select all

            line1.Labels[i]:="My Label";