How to get axis on Click or double click on axis.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

How to get axis on Click or double click on axis.

Post by amol » Fri Jul 15, 2016 5:26 am

Hi steema support,

We have one regarding how to get axis click or double click on Multiple Custom axis as shown in attached image.
In this i have four custom axis and i want to get that particular axis when i click or double click on axis.
Custom multiple Axis.png
custom multiple axis.
Custom multiple Axis.png (31.62 KiB) Viewed 6103 times
Kindly suggest any solution asap.
Thanks in advance.

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

Re: How to get axis on Click or double click on axis.

Post by Christopher » Fri Jul 15, 2016 8:51 am

Hello!

Yes, you should be able to use code such as this:

Code: Select all

    private void InitializeChart()
    {
      Line line1 = new Line(tChart1.Chart);
      Line line2 = new Line(tChart1.Chart);

      Axis axis = tChart1.Axes.Custom.Add();
      axis.RelativePosition = 20;
      line2.CustomVertAxis = axis;

      line1.FillSampleValues();
      line2.FillSampleValues();

      tChart1.ClickAxis += TChart1_ClickAxis;
    }

    private void TChart1_ClickAxis(object sender, MouseEventArgs e)
    {
      Axis axis = sender as Axis;
      string message = "";

      int custIndex = tChart1.Axes.Custom.IndexOf(axis);

      if (custIndex > -1)
      {
        message = "Custom Axis " + custIndex.ToString();
      }
      else
      {
        if(tChart1.Axes.Left.Equals(axis))
        {
          message = "Left Axis";
        }
        else if(tChart1.Axes.Bottom.Equals(axis))
        {
          message = "Bottom Axis";
        }
      }

      MessageBox.Show(message);
    }
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