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
}
}
- patrick milinazzo asked 2 years ago
- last active 2 years ago