ScottPlot/ScottPlot

SignalXY: How to get the nearest point to the mouse location

cataclism opened this issue · 4 comments

Question:
For an application of mine I need to track the value of the Signal function as the mouse moves on the X axis.

So I tried to extend the sample code to work with a Signal function.
The problem I'm facing is that I can't find a way to extract the value from the function given the X value of the mouse.

Looking at the documentation it says that I should use the GetNearest method, which unfortunately is not available ( Cannot resolve symbol).
image

I tried converting the Signal to a SignalXY, but the resolution is not enough since I only obtain integer values.

So I really don't know hot to take this task home.

Thanks in advance to everyone

ScottPlot Version: 5.0.32
** .NETFramework 4.6.2

Hi @cataclism, thanks for this question!

To be sure we are starting from the same place, have you seen the code for https://scottplot.net/demo/#show-value-under-mouse ? I think you can do the same thing with a SignalXY plot. I just checked and confirmed it has a GetNearest() function, so your code would look something like

DataPoint nearest = mySignalXyPlot.Data.GetNearest(mouseLocation, formsPlot1.Plot.LastRender);