MouseDown HitTestResult
Imports Oxyplot.Axes
Imports Oxyplot.Series
Public Class Form
Private WithEvents Line As LineSeries
Private WithEvents Scatter As ScatterSeries
Private plotModel As PlotModel
Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
plotModel = New PlotModel With {
.Subtitle = "Index of nearest point in LineSeries: 0",
.Title = "MouseDown HitTestResult",
.Background = OxyColors.White
}
Dim linearAxisX = New LinearAxis With {
.Position = AxisPosition.Bottom
}
Dim linearAxisY = New LinearAxis()
plotModel.Axes.Add(linearAxisX)
plotModel.Axes.Add(linearAxisY)
Line = New LineSeries()
Line.Points.Add(New DataPoint(0, 10))
Line.Points.Add(New DataPoint(10, 40))
Line.Points.Add(New DataPoint(40, 20))
Line.Points.Add(New DataPoint(60, 30))
plotModel.Series.Add(Line)
Scatter = New ScatterSeries()
Scatter.Points.Add(New ScatterPoint(0, 15))
Scatter.Points.Add(New ScatterPoint(10, 45))
Scatter.Points.Add(New ScatterPoint(40, 25))
Scatter.Points.Add(New ScatterPoint(60, 35))
plotModel.Series.Add(Scatter)
PlotView.Model = plotModel
End Sub
Private Sub Line_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Line.MouseDown
plotModel.Subtitle = String.Format("Index of nearest point in LineSeries: {0}", Math.Round(e.HitTestResult.Index))
plotModel.InvalidatePlot(False)
End Sub
Private Sub Scatter_MouseDown(sender As Object, e As OxyMouseDownEventArgs) Handles Scatter.MouseDown
plotModel.Subtitle = String.Format("Index of nearest point in ScatterSeries: {0}", CInt(e.HitTestResult.Index))
plotModel.InvalidatePlot(False)
End Sub
End Class

0 件のコメント:
コメントを投稿