How to get the value of the right axis?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Elite
Newbie
Newbie
Posts: 1
Joined: Thu Dec 24, 2020 12:00 am

How to get the value of the right axis?

Post by Elite » Thu Jan 21, 2021 6:32 am

The value of the bottom and left axis of the cursor position can be obtained through the cursortool component.How can I get the value of the right axis of the cursor position.

Christopher
Guru
Posts: 1332
Joined: Fri Nov 15, 2002 12:00 am

Re: How to get the value of the right axis?

Post by Christopher » Thu Jan 21, 2021 10:04 am

Hello,

please find following a short code snippet which hopefully shows you how this can be done:

Code: Select all

        private void InitializeTChart(TChart chart)
        {
            void CursorTool_Change(object sender, CursorChangeEventArgs e)
            {
                chart.Header.Text = $"YValue {e.YValue}";

                chart.Header.Text += $" Right axis {chart.Axes.Right.CalcPosPoint(e.y)}";  
            }

            var line1 = new Line(chart.Chart);
            var line2 = new Line(chart.Chart);

            line1.VertAxis = VerticalAxis.Left;
            line2.VertAxis = VerticalAxis.Right;

            var rnd = new Random();

            for (int i = 0; i < 20; i++)
            {
                var val = rnd.Next(0, 100);
                line1.Add(val);
                line2.Add(val * 100);
            }

            var cursorTool = new CursorTool(chart.Chart);
            cursorTool.FollowMouse = true;
            cursorTool.Change += CursorTool_Change;
        }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply