Calc Midpoint of chart
Posted: Tue Aug 30, 2011 9:26 am
I need to calculate the x midpoint of a chart in order to plot a string.
I am using:
Midpoint = ((Points1.Chart.Axes.Bottom.Maximum - Points1.Chart.Axes.Bottom.Minimum) / 2) + Points1.Chart.Axes.Bottom.Minimum
This works fine for a manual scale but if I set the chart scale to automatic, the calculation is out by a few percent:
Points1.Chart.Axes.Bottom.AutomaticMaximum = True
Points1.Chart.Axes.Right.AutomaticMaximum = True
Points1.Chart.Axes.Left.AutomaticMaximum = True
Points1.Chart.Axes.Top.AutomaticMaximum = True
Points1.Chart.Axes.Right.AutomaticMinimum = True
Points1.Chart.Axes.Bottom.AutomaticMinimum = True
Points1.Chart.Axes.Left.AutomaticMinimum = True
Points1.Chart.Axes.Top.AutomaticMinimum = True
The Points1.Chart.Axes.Bottom.Maximum and Points1.Chart.Axes.Bottom.Minimum do not match the plotted min and max shown on the x axis.
Is there a better way to calculate the midpoint for automatic scale?
I am using:
Midpoint = ((Points1.Chart.Axes.Bottom.Maximum - Points1.Chart.Axes.Bottom.Minimum) / 2) + Points1.Chart.Axes.Bottom.Minimum
This works fine for a manual scale but if I set the chart scale to automatic, the calculation is out by a few percent:
Points1.Chart.Axes.Bottom.AutomaticMaximum = True
Points1.Chart.Axes.Right.AutomaticMaximum = True
Points1.Chart.Axes.Left.AutomaticMaximum = True
Points1.Chart.Axes.Top.AutomaticMaximum = True
Points1.Chart.Axes.Right.AutomaticMinimum = True
Points1.Chart.Axes.Bottom.AutomaticMinimum = True
Points1.Chart.Axes.Left.AutomaticMinimum = True
Points1.Chart.Axes.Top.AutomaticMinimum = True
The Points1.Chart.Axes.Bottom.Maximum and Points1.Chart.Axes.Bottom.Minimum do not match the plotted min and max shown on the x axis.
Is there a better way to calculate the midpoint for automatic scale?