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.

Mustafa
  • 1
  • 1
  • The base class Series has a virtual function GetNearestPoint() - could that be what you need? – Jim Foye Jun 28 '22 at 02:59
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 28 '22 at 08: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. – Mustafa Jul 01 '22 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). – Jim Foye Jul 01 '22 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! – Mustafa Jul 05 '22 at 12:41
  • hope this helps .. https://stackoverflow.com/a/54079198/7299782 – Anu Viswan Jul 07 '22 at 05:13

0 Answers0