Skip to content

Demo: Add example for Scatter.GetNearest() using multiple scatter plots #3503

@RubensMigliore

Description

@RubensMigliore

I successfully implemented suggestion for handling the MouseMove event in charts with only one dataset with ScottPlot 5 in VB .NET. However, I’m facing another situation with multiple curves being drawn, but MyCrosshair is only triggered for the last dataset. I suspect this problem is related to the following method that uses ‘PltPerfElev.Plot.LastRender’:

Dim nearest As DataPoint = splt.Data.GetNearest(mouseLocation, PltPerfElev.Plot.LastRender)

Is it possible to review the following code to present CrossHair for the entire dataset?

Here is my VB. NET implementation.
Capturar-2

 Private Sub MouseMoveHandler(
      s As Object, e As MouseEventArgs)

  Dim mousePixel As New Pixel(
      e.Location.X, e.Location.Y)
  Dim mouseLocation As Coordinates =
      PltPerfElev.Plot.GetCoordinates(mousePixel)
  Dim nearest As DataPoint = splt.Data.
      GetNearest(mouseLocation, PltPerfElev.Plot.LastRender)

  If nearest.IsReal Then
      MyCrosshair.IsVisible = True
      MyCrosshair.Position = nearest.Coordinates
      PltPerfElev.Refresh()
      lbPerfElev.Text = $"  X = {nearest.X:#,##0.0} m " &
          $"   -    Y = {nearest.Y:#,##0.0} cm"
  ElseIf MyCrosshair.IsVisible Then
      MyCrosshair.IsVisible = False
      PltPerfElev.Refresh()
      lbPerfElev.Text = $""
  End If
End Sub

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help WantedScott won't do this soon, but PRs from the community are welcome!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions