Cursortool tied to multiple series - revisit

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
CChung
Newbie
Newbie
Posts: 6
Joined: Fri Nov 18, 2005 5:00 am

Cursortool tied to multiple series - revisit

Post by CChung » Tue Feb 27, 2007 6:56 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Feb 28, 2007 12:25 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

CChung
Newbie
Newbie
Posts: 6
Joined: Fri Nov 18, 2005 5:00 am

Post by CChung » Wed Feb 28, 2007 6:22 pm

Yes, the interpolating code is just what I need. Thanks.

Post Reply