|
Adjust Y-Axis to Fit Only if Necessary |
Posted by Jeff on Jan-20-2025 22:27 |
|
I have this call that will reload my chart and it works great:
loadData()
'Force redraw of axis (Fit in Window)
drawChart(WinChartViewer1)
My problem is that in my XY Box chart if I add an element that is too large, part of the box will now longer be visible.
To combat this, I add the setfullRange like this:
loadData()
'Force redraw of axis (Fit in Window)
WinChartViewer1.setFullRange("y", 0, 0)
drawChart(WinChartViewer1)
But most of the time the box chart will fit in the plot area and I do not wish to change the axis. The resize of the Y-axis all the time is distracting.
I would like to get the MaxY of the highest box and determine if I have to call setFullRange or not. I don't want to loop thru the data if possible. I cant remember if there is a MaxY property I can just use.
Attached are examples that illustrate the issue.
Thanks!
|
Re: Adjust Y-Axis to Fit Only if Necessary |
Posted by Peter Kwan on Jan-21-2025 01:48 |
|
Hi Jeff,
ChartDirector can only tell you the max value of the current y-axis scale, but not the max value of your data. In fact, ChartDirector will not look at your data before drawing the chart, by that time it is too late the change the axis scale.
I think in your code that builds the boxes, you can keep track of the max y-value. If the y-values of the boxes are in an array, ChartDirector also has a function to get the maximum value of the array:
Dim yMax As Double = New ArrayMath(yDataArray).max()
Best Regards
Peter Kwan |
|