Page 1 of 1

Cursortool tied to multiple series - revisit

Posted: Tue Feb 27, 2007 6:56 pm
by 9639245
Hello,

I'm trying to get a single cursor working with multiple series (with Datetime x-axis) on a recent teechart.net version (2.0.2546.16099) and it seems that it is not working. It seems that the problem I'm having is same as that in the topic "Cursortool tied to multiple series" i.e. problem with the XValues.IndexOf not working with DateTime. And I do not want to implement the CPU-intensive solution suggested in that topic. Is there some way around this problem? My test code is attached:

Code: Select all

        private void button2_Click(object sender, EventArgs e)
        {
            tChart1.Aspect.View3D = false;

            DateTime[] a = new DateTime[400];
            double[] b = new double[400];

            DateTime[] c = new DateTime[200];
            double[] d = new double[200];

            Random r = new Random();
            for (int i = 0; i < 400; i++)
            {
                a[i] = new DateTime(1, 1, 1, 5, 5, 0) + new TimeSpan(0, 0, i);
                b[i] = r.NextDouble() * 10;
            }
            for (int j = 0; j < 200; j++)
            {
                c[j] = new DateTime(1, 1, 1, 5, 5, 0) + new TimeSpan(0, 0, j + 200);
                d[j] = r.NextDouble() * 10;
            }

            fastLine1.Clear();
            fastLine1.Add(a, b);
            fastLine2.Clear();
            fastLine2.Add(c, d);

            cursorTool1.XValue = (new DateTime(1, 1, 1, 5, 5, 0)).ToOADate();

        }

        private void cursorTool1_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
        {
 
            int i = fastLine1.XValues.IndexOf(e.XValue);
            if (i >= 0)
                label5.Text = fastLine1.YValues[i].ToString();

            i = fastLine2.XValues.IndexOf(e.XValue);
            if (i >= 0)
                label6.Text = fastLine2.YValues[i].ToString();
        }
Thx,
Chuck

Posted: Wed Feb 28, 2007 12:25 pm
by narcis
Hi Chuck,

IndexOf returns -1 because the requested value doesn't exists in the series' ValueLists. To achieve what you request you may be interested in doing something like in the What's New?\Welcome !\New in Series\Interpolating line series example in TeeChart's features demo. The demo can be found at TeeChart's program group.

Posted: Wed Feb 28, 2007 6:22 pm
by 9639245
Yes, the interpolating code is just what I need. Thanks.