Cursor tool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
mch
Newbie
Newbie
Posts: 1
Joined: Wed Dec 22, 2010 12:00 am

Cursor tool

Post by mch » Tue Jan 04, 2011 5:52 pm

I have just started developing my first app with TChart and am finding it a great product!! I do, however, have a couple of questions on the cursor tool:

1. I have a menu option to turn on and off the cursor (In my app this is just the vertical line). When the cursor is turned on, i want it to appear in the middle of my TChart, how do i do this.

2. When the TChart is scrolled (Panned) or zoomed, if the cursor is no longer on the currently displayed graph I want to be able to put it back in the middle of the chart again.

3. I want to be able to get the current X axis series index at the cursor position, so I can retreive the Y value of all my series at the cursor position. (They are all fast lines).

I am sure these are all fairly simple tasks, but I have not been able to find out how just yet.

Martin

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Cursor tool

Post by Sandra » Wed Jan 05, 2011 11:47 am

Hello Martin,
1. I have a menu option to turn on and off the cursor (In my app this is just the vertical line). When the cursor is turned on, i want it to appear in the middle of my TChart, how do i do this.
You can use XValue for change position of cursortool, you can do something similar as next code:

Code: Select all

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            cursor = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart);
            line1.FillSampleValues();
            cursor.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
            checkBox1.Checked = true;
            tChart1.Draw();
            Middlepos = tChart1.Axes.Bottom.CalcPosPoint((tChart1.Axes.Bottom.IAxisSize) / 2 + tChart1.Axes.Bottom.IStartPos);
            cursor.XValue = Middlepos;
      }
void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            cursor.Active = checkBox1.Checked;
            if (!cursor.Active)
            {
                cursor.XValue = Middlepos;
            }
        }
There is another option, if you want you can save initial Xvalue of cursorTool and assign when you believe necessary.
2. When the TChart is scrolled (Panned) or zoomed, if the cursor is no longer on the currently displayed graph I want to be able to put it back in the middle of the chart again.
I suggest use event UndoneZoom of Chart and in the event do something as below code:

Code: Select all

  void tChart1_UndoneZoom(object sender, EventArgs e)
        {
            cursor.XValue = Middlepos;
        }
3. I want to be able to get the current X axis series index at the cursor position, so I can retreive the Y value of all my series at the cursor position. (They are all fast lines).
I suggest you take a look in Demo project concretely All Features\Welcome !\Chart styles\Standard\Line(Strip)\Interpolating line series.

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

Post Reply