Pre loader

Getting Y-value corresponding to a given X-value

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


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 available on 10 September 2021
  • You must to post comments

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,

  • You must to post comments

Yes. It does. Thanks a lot.

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

  • You must to post comments

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.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies