Page 1 of 1

I Cant Get Vertical Cursor Tool To Intersect

Posted: Thu Jul 30, 2009 8:49 am
by 13050364
Hello

Im developing a Windows application using Visual C#.
Ive a single window with a TeeChart control called tChart1. I add a line to this chart as follows and it displays OK.

Line line1 = new Line();
line1.Add(wavelengthArray, resultArray);
tChart1.Series.Add(line1);


Ive tried to add a vertical cursor tool so that when it intersects the line I can display the intersection point
This is shown below.

public myClass
{
...
...
verticalCursor = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart);
verticalCursor.FollowMouse = true;
verticalCursor.Snap = true;
verticalCursor.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
verticalCursor.FastCursor = true;
verticalCursor.Pen.Width = 1;
verticalCursor.Pen.Color = Color.Red;
verticalCursor.Change += new CursorChangeEventHandler(verticalCursor_Change);
}


void verticalCursor_Change(object sender, CursorChangeEventArgs e) {

verticalCursor.Series = tChart1.Series[0];

// My code in here that gets the intersection point
}


The vertical cursor moves OK (it follows the mouse) but it doesnt enter the "verticalCursor_Change" function for some reason.
Is there something obvious I may not have done? Or alternatively can someone post a simple example that shows this functionality working

Thanks.

Re: I Cant Get Vertical Cursor Tool To Intersect

Posted: Thu Jul 30, 2009 10:38 am
by yeray
Hi Dave,

The following code seems to work fine for me here:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        CursorTool verticalCursor;

        private void InitializeChart()
        {
            chartController1.Chart = tChart1;

            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;

            Line line1 = new Line(tChart1.Chart);
            line1.FillSampleValues(100);

            verticalCursor = new CursorTool(tChart1.Chart);
            verticalCursor.FollowMouse = true;
            verticalCursor.Snap = true;
            verticalCursor.Style = CursorToolStyles.Vertical;
            verticalCursor.FastCursor = true;
            verticalCursor.Pen.Width = 1;
            verticalCursor.Pen.Color = Color.Red;
            verticalCursor.Change += new CursorChangeEventHandler(verticalCursor_Change);
        }

        void verticalCursor_Change(object sender, CursorChangeEventArgs e)
        {
            tChart1.Header.Text = e.XValue.ToString();
        }
Also you could check the example at All features\Welcome !\Chart styles\Standard\Line(Strip)\Interpolating line series

If after looking at it you still find problems with that, please, attach here a simple example solution we can run as-is to reproduce the problem here.