For example I have chart with 2 points - 0,0 and 10,10 and chart type is FastLine. I want to know what Y value will be in chart in choosen X value.
For example when X is 5 I want to know that Y is 5.
My charts more complicated and have tons of points, I need to get Y value through X.
How can I do this?
The problem boils down to two tasks:
If the x-values are indeed steadily increasing this should solve both:
It uses Linq to find the previous and next datapoint and then uses simple math to find the interpolated value.
Note that most checks are omitted!
Here I have added an identical point series and a third one to add the interpolated values:
To convert between chart pixels and values there are
Axis
functionsValueToPixelPosition
andPixelPositionToValue
, btw.