我有一个带有系列 (SeriesChartType.Point) 的 MSChart 对象;启用缩放以允许用户放大数据的特定区域。用户放大该区域后,我有兴趣了解仍然可见的数据点集。
有没有办法确定哪些数据点仍然可见?
像下面这样的东西应该适合你。我用 a 对其进行了测试Line
ChartType
,但只要数据是X,Y
(而不是X,Y,Y
)就应该适用于任何绘图类型
Dim Xmin As Double = aChart.ChartAreas(0).AxisX.ScaleView.ViewMinimum
Dim Xmax As Double = aChart.ChartAreas(0).AxisX.ScaleView.ViewMaximum
Dim Ymin As Double = aChart.ChartAreas(0).AxisY.ScaleView.ViewMinimum
Dim Ymax As Double = aChart.ChartAreas(0).AxisY.ScaleView.ViewMaximum
Dim VisibleDataPoints As New Series
For Each pt As System.Windows.Forms.DataVisualization.Charting.DataPoint In aChart.Series(0).Points
If pt.XValue >= Xmin And pt.XValue <= Xmax Then
If pt.YValues(0) >= Ymin And pt.YValues(0) <= Ymax Then
VisibleDataPoints.Points.Add(pt)
End If
End If
Next
VisibleDataPoints.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line
VisibleDataPoints.Color = Color.Red
aChart.Series.Add(VisibleDataPoints)
高温高压