Page 1 of 1

How to obtain largest Left Axis (y-axis) label?

Posted: Fri Jan 04, 2019 5:11 pm
by 13050364
Dear Support

My chart is being updated about 10 times per second. The values displayed in the left axis are integers and can sometimes vary quite a lot. Is there an easy way to obtain the largest DISPLAYED label in the left axis. Note its not the largest left-axis value Im interested in because that may not be displayed.

If you check the attached image the largest displayed left axis label is 3,600. However that could drop to say 850 which would change the position of the bottom chart relative to the top image.


many thanks

Dave

Re: How to obtain largest Left Axis (y-axis) label?

Posted: Mon Jan 07, 2019 7:54 am
by Christopher
Hello Dave,
Dave wrote:
Fri Jan 04, 2019 5:11 pm
My chart is being updated about 10 times per second. The values displayed in the left axis are integers and can sometimes vary quite a lot. Is there an easy way to obtain the largest DISPLAYED label in the left axis. Note its not the largest left-axis value Im interested in because that may not be displayed.
You should be able to use the Axis.Maximum property, as this displays the maximum value of the drawn axis. An example of this would be the following, where we set the left axis to a maximum value 200 units below the actual maximum, but still the actual (drawn) value is calculated in the Maximum property, e.g.

Code: Select all

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

			line.FillSampleValues();

			tChart1.Axes.Left.SetMinMax(line.YValues.Minimum, line.YValues.Maximum - 200);
		}

		private void button2_Click(object sender, EventArgs e)
		{
			MessageBox.Show(tChart1.Axes.Left.Maximum.ToString());
		}

Re: How to obtain largest Left Axis (y-axis) label?

Posted: Mon Jan 07, 2019 8:09 am
by 13050364
Thanks Chris!