SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
0

I would like to get the Y-value of a graph, corresponding to an X-value given as input.

Noting that the given X-value may not necessarily be within the input table of X versus Y values, meaning that some kind of interpolation may be needed to compute the Y-value, is there a SciChart API for getting this Y-value corresponding to a given X-value? Rather than me performing the interpolation through code. Thanks.

Version
Version available on 10 September 2021
  • You must to post comments
0
0

Hi Amarnath

There’s a couple of things to consider here to give you a good answer.

If you’re trying to find the y-value of a series (see attached image), then do this

  1. Iterate through the dataseries.XValues to find the index nearest the x-value, or use dataSeries.FindIndex()
  2. Now get the y-value at that index by getting dataSeries.YValues[i]

If you’re trying to do it based on a x-coordinate (not x-value) then I suggest using the Hit-Test API. Specifically RenderableSeries.HitTestProvider.VerticalSliceHitTest provides an X-First method of searching for y-values.

Which one of those sounds right for you? Do they answer your question?

Best regards,
Andrew

Images
  • You must to post comments
0
0

Yes. It does. Thanks a lot.

Somehow the nearest neighbour method slipped from my mind. Thanks once again.

  • You must to post comments
0
0

As a follow up to this question I have the same question but the answer is not clear to me. I am using the FindIndex(_cursor1Date, SearchMode.RoundDown) method on an XYDataSeries for a given x data value as defined by a cursor position on the chart.

The index I receive is the nearest index rounded down and when I use that index on the yValues I am not receiving the data point at the specified x data value but the nearest sampled value correct?

Like the original poster mentioned, I would have to do the same interpolation as the chart to get the actual value between two data samples like the chart draws.

Note, I am setting the IsDigitalLine property to false and the XYDataSeries does not have a HitTestProvider property to be able to use the VerticalSliceHitTest() method.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.