Hiding Axis Labels

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
lilo
Newbie
Newbie
Posts: 18
Joined: Thu Sep 12, 2013 12:00 am

Hiding Axis Labels

Post by lilo » Sun Mar 30, 2014 9:21 pm

Hi,

I need to hide/remove parts of the axes labels for a Points Chart. For example, I do not want to display any labels that less than zero:

Y Axis: -50 to 150
Aim: To display labels on the chart only between 0 and 150

How can I achieve this?

Thanks,

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

Re: Hiding Axis Labels

Post by Christopher » Mon Mar 31, 2014 10:51 am

Hello,
lilo wrote:Y Axis: -50 to 150
Aim: To display labels on the chart only between 0 and 150
You can use the GetNextAxisLabel event, e.g.

Code: Select all

    private Steema.TeeChart.Styles.Points series1;

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      series1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);

      Random rnd = new Random();

      for (int i = 0; i < 20; i++)
      {
        series1.Add(i, rnd.Next(-50, 150));
      }
      tChart1.GetNextAxisLabel += tChart1_GetNextAxisLabel;
    }

    void tChart1_GetNextAxisLabel(object sender, GetNextAxisLabelEventArgs e)
    {
      if(tChart1.Axes.Left.Equals(sender)) 
      {
        e.Stop = false;
        switch (e.LabelIndex)
        {
          case 0: e.LabelValue = 0; break;
          case 1: e.LabelValue = 50; break;
          case 2: e.LabelValue = 100; break;
          case 3: e.LabelValue = 150; break;
          default: e.Stop = true; break;
        }                       
      }                      
    }
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