SolveYCoordAtXCoord returns NoPointsFound

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
kkrambo
Posts: 6
Joined: Thu Oct 22, 2015 1:47 pm

SolveYCoordAtXCoord returns NoPointsFound

Post by kkrambo » Tue Dec 20, 2016 4:04 pm

I'm trying to solve Y for X with a FreeformPointLineSeries object but SolveYCoordAtXCoord always returns NoPointsFound for every xCoord value I have tried. What do I have to do to get FreeformPointLineSeries.SolveYCoordAtXCoord to work?

I have already done something similar for a PointLineSeries using SolveYValueAtXValue and it works well. But now I have a new type of dataset and I need to use a FreeformPointLineSeries for this data. And FreeformPointLineSeries does not support SolveYValueAtXValue. So I am trying to use SolveYCoordAtXCoord instead and it always returns NoPointsFound.

Here is an excerpt of my code. I have verified in the debugger that series.Points contains data and the data is plotted correctly. ValueToCoord returns an xCoord value in the range of 150 to 750 depending on where the cursor is located. The XAxis values range from 1700 to 3900. I've tried passing XValue and other hard-coded values to SolveYCoordAtXCorrd but it always returns NoPointsFound.

Code: Select all

FreeformPointLineSeries series = _ucLC.ViewXY.FreeformPointLineSeries[0];

float xCoord = _ucLC.ViewXY.XAxes[0].ValueToCoord(_ucLC.ViewXY.LineSeriesCursors[0].ValueAtXAxis);
LineSeriesCoordinateSolveResult result = series.SolveYCoordAtXCoord((int)Math.Round(xCoord));
if (result.SolveStatus == LineSeriesSolveStatus.OK)
{
    // write the data to the annotation
}
else
{
    // error
}

kkrambo
Posts: 6
Joined: Thu Oct 22, 2015 1:47 pm

Re: SolveYCoordAtXCoord returns NoPointsFound

Post by kkrambo » Tue Dec 20, 2016 6:37 pm

I've been examining the objects in the VisualStudio debugger looking for anything suspicious. One suspicious thing I found is that series.base.Statistics.VisibleXMax is uninitialized. The property values of series.base.Statistics are:

PointCount = 0x2d
StatDataValid = true
VisiblePointCount = 0x2d
VisibleXMax = -1.79769E+308
VisibleXMin = 1750.0
VisibleYMax = 24.306
VisibleYMin = 23.329
XMax = 3900.071
XMin = 1752.029

All of those values look reasonable except for VisibleXMax. I have no idea whether this is even related to the reason why SolveYCoordAtXCoord returns NoPointsFound but it seems suspicious. Why would VisibleXMax be uninitialized while StatDataValid is true?

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: SolveYCoordAtXCoord returns NoPointsFound

Post by ArctionKestutis » Wed Dec 21, 2016 6:31 am

Please use FreeformPointLineSeries.SolveNearestDataPointByCoord() method. You can check our Demo app example "Scatter, point tracking" (ViewXY -> Cursor tracking).

kkrambo
Posts: 6
Joined: Thu Oct 22, 2015 1:47 pm

Re: SolveYCoordAtXCoord returns NoPointsFound

Post by kkrambo » Wed Dec 21, 2016 7:51 pm

I tried FreeformPointLineSeries.SolveNearestDataPointByCoord() and it seems to work like the name implies but it does not do what I need. I'm drawing a vertical cursor on my chart. The user can move the cursor along the X axis and I want to display the corresponding Y value in the annotation. SolveNearestDataPointByCoord() returns the nearest point, which may be at a different X value. So it doesn't provide me with the Y value at the X value where the cursor is.

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: SolveYCoordAtXCoord returns NoPointsFound

Post by ArctionKestutis » Thu Dec 22, 2016 8:16 am

In contrast to PointLineSeries / SampleDataSeries for the FreeformPointLineSeries the points X values may be NOT in ascending order. Therefore, you may have several points with same x-value but different y-values. SolveNearestDataPointByCoord() method use Euclidean distance as criteria for nearest-point. If you want to use different criteria, you should make your own method by looping through all points.
For the same reason LineSeriesCursor "Snaps To Points" for PointLineSeries, SampleDataSeries, AreaSeries and HighlowSeries , but NOT for FreeformPointLineSeries.

Hope this helps.

P.S. in order to provide further support we need you to renew your subscription.

Post Reply