的MSChart - 自动缩放Y对X坐标轴缩放
我使用的MSChart,我想使变焦在X轴,一旦这种被放大我想要的Y轴自动缩放到一个合适的范围内为数据可见。
I'm using MSChart and I want to enable zoom on the X Axis and once this is zoomed I want the Y Axis to auto zoom into a range appropriate for the data viewable.
任何的问题的援助将大大AP preciated!
Any assistance with the problem would be greatly appreciated!
感谢
那种缩放,你想做的事不能用的MSChart自动完成的。一旦检索到了放大,在X值的范围从用户,你需要写多一点code重置Y轴缩放比例适当。
The kind of zooming that you want to do cannot be automatically accomplished by MSChart. Once you have retrieved the 'Zoom-In' X-value range from the user, you need to write a little more code to reset the Y-axis scaling appropriately.
这工作最容易,如果你使用的是数据系列的线条样式和该系列源数据存储为一个排序列表。
This works most easily if you are using a Line style of data series and your source data for that series is stored as a SortedList.
Dim firstXindex as Int32 = myDataSeries.IndexOfKey(firstXzoomValue)
Dim lastXindex as Int32 = myDataSeries.IndexOfKey(lastXzoomValue)
Dim minY as Double = 1.7E+308
Dim maxY as Double = -1.7E+308
For i = firstXindex To lastXindex
If myDataSeries.GetByIndex(i) > maxY Then
maxY = myDataSeries.GetByIndex(i)
End If
If myDataSeries.GetByIndex(i) < minY Then
minY = myDataSeries.GetByIndex(i)
End If
Next
上面一旦你使用类似的code,让您MINY和MAXY,你就可以使用这些值来重置最小和最大Y轴值的ChartArea:
Once you have used something like the code above to get your minY and maxY, you can then use those values to reset the min and max Y-axis values on the ChartArea:
With myChartArea
.AxisY.Maximum = maxY
.AxisY.Minimum = minY
End With