Solve nearest data point (for line-series)
Solve at X
The series implementing ITrackable interface (SampleDataSeries, SampleDataBlockSeries, PointLineSeries, LiteLineSeries, DigitalLineSeries, AreaSeries, HighLowSeries) can be solved by X screen coordinate or by X axis value.
Trackable series have methods for accurate and coarse value solving. The accurate method SolveYValueAtXValue loops through data points if necessary and finds the nearest data point match. The coarse method SolveYCoordAtXCoord uses cached rendering data of the series for solving the matching Y screen coordinate.
Accurate method, solving Y value by X value using data points array
LineSeriesValueSolveResult result = series.SolveYValueAtXValue(cursor.ValueAtXAxis);
if (result.SolveStatus == LineSeriesSolveStatus.OK)
{
//PointLineSeries may have two or more points at same X value. If so, center it between min and max
yValue =(result.YMax + result.YMin) / 2.0;
return true;
}
Note! When cursor.SnapToPoints is disabled, the SolveYValueAtXValue returns interpolated value between the points adjacent to it (the intersection of cursor line and the series line).
SolveYValueAtXValue interpolates the value between adjacent data points when SnapToPoints is disabled.
Coarse method, solving Y screen coordinate by X coordinate using data points array
LineSeriesCoordinateSolveResult result = series.SolveYCoordAtXCoord((int)Math.Round(fCoordX));
if (result.SolveStatus == LineSeriesSolveStatus.OK)
{
fCoordY = (result.CoordBottom + result.CoordTop) / 2f;
if (axisY.CoordToValue((int)Math.Round(fCoordY), out yValue) == false)
{
return false;
}
}
When the series holds a lot of data points, say > 100.000, it’s typically much faster to use the coarse method. However, it can be very inaccurate if the chart size or Y segment height in pixels is low. The coarse method’s screen coordinates can be converted into axis values by calling CoordToValue method of X and Y axis.
SolveYValue* methods will return interpolated point, if x-value is between adjacent points. In contrast, SolveYCoord* methods tries to find nearest point (NO interpolation).
It is a good practice to use an AnnotationXY object to display values next to the cursor.

LineSeriesCursor used to track PointLineSeries. The values are shown in an AnnotationXY object.
Solving the data values from FreeformPointLineSeries / LiteFreeformLineSeries
FreeFormPointLineSeries and LiteFreeformLineSeries implements methods for accurate and coarse value solving, which are mostly similar to the methods used for solving data values in the position of LineSeriesCursor for series implementing the ITrackable interface.
Note! FreeformPointLineSeries does not implement ITrackable interface and therefore cannot be tracked with LineSeriesCursor.
The accurate method SolveYValuesAtXValue solves all Y-values for the given X-axis value and returns an iterable list of LineSeriesValueSolveResult-structs.
IList<LineSeriesValueSolveResult> resultsAtValue = series.SolveYValuesAtXValue(value);
foreach (LineSeriesValueSolveResult result in resultsAtValue)
{
if (result.SolveStatus == LineSeriesSolveStatus.OK)
{
// Do something
}
else if (result.SolveStatus == LineSeriesSolveStatus.NoPointsFound)
{
// Do something
}
}
if (resultsAtValue.Count == 0)
{
// no points either
}
The coarse method SolveYCoordsAtXCoord solves all Y screen coordinates for given X screen coordinate and returns an iterable list of LineSeriesCoordinateSolveResult-structs.
IList<LineSeriesCoordinateSolveResult> resultsAtCoord = series.SolveYCoordsAtXCoord(value);
foreach (LineSeriesCoordinateSolveResult result in resultsAtCoord)
{
if (result.SolveStatus == LineSeriesSolveStatus.OK)
{
// Do something
}
else if (result.SolveStatus == LineSeriesSolveStatus.NoPointsFound)
{
// Do something
}
}
if (resultsAtCoord.Count == 0)
{
// no points either
}
If the given X-axis value or X screen coordinate hits between points, the result(s) will be formed from the interpolated value(s) / coordinate(s).
Solve at X & Y
Line-series also have method resolve nearest data point then X and Y given either as screen coordinates or as axes values. As in above description, method which uses axes-values is more accurate. When the series holds a lot of data points, say > 100.000, it’s typically much faster to use the coarse method. However, it can be very inaccurate if the chart size or Y segment height in pixels is low.
There are slight difference in methods name used between line-series.
For PointLineSeries and FreeformPointLineSeries method names are: SolveNearestDataPointByCoord() and SolveNearestDataPointByValue().
For SampleDataBlockSeries, SampleDataSeries, LiteLineSeries, LiteFreeformLineSeries and DigitalLineSeries method names are: SolveNearestSampleByValue() and SolveNearestSampleByCoord().
To see feature demonstration as example, check ExampleScatterTracking, ExampleCursorProjectOnAxes from our Demo.