0

I'm using OxyPlot in C# to plot a chart based on a finite set of data points, not a function. The resultant chart from OxyPlot has a smooth, continuous curve covering the whole range of points.

My goal is that, given some value y, find the corresponding x value. I want to do that by utilizing the chart plotted with OxyPlot. Are there any straightforward ways (perhaps using some OxyPlot features) to do that?

Note: The y value is determined in the back-end based on some calculations——it's not from the user. The few resources I found online suggested using a mouse click event, but unfortunately that wouldn't work for my case.

6
  • The base class Series has a virtual function GetNearestPoint() - could that be what you need? Commented Jun 28, 2022 at 2:59
  • Please provide enough code so others can better understand or reproduce the problem. Commented Jun 28, 2022 at 8:24
  • @JimFoye The GetNearestPoint() function takes a ScreenPoint as an argument. I'm not sure if it'll be possible for me to know the ScreenPoint from the back-end, since it'll vary based on the application window. Commented Jul 1, 2022 at 15:21
  • I think what you need to do is look at the OxyPlot source and see how the tracker calls GetNearestPoint(). It must be starting with a mouse position and then converting it relative to the plot view, or else GetNearestPoint() does that - but it should be possible to figure out what the tracker is doing, since you want to do the same thing (if I understand your question correctly). Commented Jul 1, 2022 at 16:35
  • @JimFoye This sounds like a reasonable idea. I'll dig into the source code and see how GetNearestPoint() is used. Thank you! Commented Jul 5, 2022 at 12:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.