How to draw grid lines with given values

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

How to draw grid lines with given values

Post by Larry » Sun Dec 12, 2021 4:18 pm

Hi

I have an RSI line chart and the grid value range is from 0 - 100. I need only two grid lines with values 20 and 80. Currently the grid lines are generated automatically but not at 20 and 80.

Thanks

Larry

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

Re: How to draw grid lines with given values

Post by Christopher » Mon Dec 13, 2021 11:54 am

Hello Larry,

probably the easiest way to achieve what you want is to use 'custom labels,' e.g.

Code: Select all

        private void InitializeChart(TChart chart)
        {
            Random rnd = new();
            Line line = new(chart.Chart);
            for (int i = 0; i < 20; i++)
            {
                line.Add(rnd.Next(0, 100));
            }

            chart.Axes.Left.Grid.DrawEvery = 1;
            chart.Axes.Left.Labels.Items.Add(20, "20");
            chart.Axes.Left.Labels.Items.Add(80, "80");
        }
Which here gives me this chart:
Screenshot from 2021-12-13 12-51-53.png
Screenshot from 2021-12-13 12-51-53.png (23.91 KiB) Viewed 5143 times
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