How to save fixed points?

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
allenfd1218
Posts: 4
Joined: Thu Apr 14, 2022 1:09 am

How to save fixed points?

Post by allenfd1218 » Thu Apr 14, 2022 3:00 pm

Hello
if I enable the _chart.ViewXY.DropOldSeriesData = true;
then it can only save the point in the chart window
if I need to save the fixed point like 100k points
What should I do?
example :
xAxis.SetRange(0, 10);
x interval is 0.001
so it can only save 10k points if _chart.ViewXY.DropOldSeriesData = true;
but I would like it to save the latest 100K points.

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: How to save fixed points?

Post by Arction_LasseP » Tue Apr 19, 2022 6:40 am

Hello,

As you have found out, DropOldSeriesData drops all data points that are out of visible range, and therefore is not very suitable for what you are trying to achieve.

Fortunately, there is an alternative. You could use DeletePointsBeforeX() method, which automatically drops data points before given X-axis value. Unlike DropOldSeriesData which affects all series, this method is specific to the specific series it is called upon. For instance, with the example values you gave (X-axis range 0 - 10, interval 0.001), you could call:

double dropValue = _chart.ViewXY.XAxes[0].Maximum - 0.001 * 100000;
_chart.ViewXY.PointLineSeries[0].DeletePointsBeforeX(dropValue);

This will drop all points from the series except the latest 100k points.

A couple of notes when using this method. First, if the series doesn't seem to update itself after the call, try calling InvalidateData(). Second, if you use SampleDataSeries or SampleDataBlockSeries, the method is called DeleteSamplesBeforeX, but it still works similarly. Third, if you are having real-time data, in other words constantly adding more points to the series, you need to call this method after every point addition, as it is not fired automatically.

Best regards,
Lasse

Post Reply