Pre loader

Tag: interpolate

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

0 votes
2k views

I would like to get the Y-value of a line, corresponding to a given X-value as input. The x-value is coming from a cursor (VerticalLineAnnotation) that the user drags on the chart.

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.

We are using the LineRenderableSeriesViewModel, which is databound to the RenderableSeries of the SciChartSurface so at the viewmodel we don’t really have access to the RenderableDataSeries used by the chart. The viewmodel, however, is where we are data binding to the needed Y-value.

Here is a sampling of the code:

    <s:SciChartSurface x:Name="_sciChartSurface" RenderableSeries="{s:SeriesBinding PlotViewModels}"  
                       YAxes="{s:AxesBinding VerticalAxes}" ZoomState="{Binding ZoomState, Mode=TwoWay}"
                       Margin="{Binding ChartMargin, ElementName=_root}"
                       BorderBrush="{Binding ChartBorderBrush, ElementName=_root}"
                       BorderThickness="{Binding ChartBorderThickness, ElementName=_root}"
                       RenderPriority="Low" MaxFrameRate="12">
    </s:SciChartSurface>



 public class PlotViewModel : LineRenderableSeriesViewModel, IDisposable {
        XyDataSeries<DateTime, double> _dataSeries = new XyDataSeries<DateTime, double>();

    public string Cursor1Value =>
        _cursor1Value.ToString(_plot.NumberFormat.ToString());

          public void SetCursorDates(DateTime cursor1Date, DateTime cursor2Date) {
        _cursor1Date = cursor1Date;
        _cursor2Date = cursor2Date;
        CalculateValues();
    }

    double CalculateValues(DateTime cursor1Date) {
        //need to get to the HitTest API
    }

}

Showing 1 result

Try SciChart Today

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

Start TrialCase Studies