Remove old data points

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
Igor
Posts: 67
Joined: Mon Sep 28, 2015 1:14 pm

Remove old data points

Post by Igor » Mon Dec 21, 2015 9:47 am

Hi,

my chart control should remove automatically old data points.
The buffer size should be configurable by the user, for example the last 10 seconds.

I see currently 2 ways how I can dispose old data points.

1. chart.ViewXY.DropOldSeriesData = true;
But I can't adjust the period of time. Is that correct?

2. In the PointLineSeries I could call "series.DeletePointsBeforeX (_latestX - 10)" manually.
But in the chart that has only an effect when the user interacting with the chart control, for example MouseMove on the PointLineSeries or
when scrolling.

What is the best way to do this?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Remove old data points

Post by ArctionPasi » Tue Dec 22, 2015 11:55 am

Hi Igor,

There's no property to control it directly like that. Deleting extra points every time a new data point is added is very resource consuming and for performance reasons we don't do that. It's eventually a large points array we are dealing with, not a list.

PointLineSeries, SampleDataSeries, HighLowSeries and AreaSeries have ScrollModePointsKeepLevel to control how many pages of data is to be kept before cutting it from X axis minimum. One page = X min ... X Max. The ScrollModePointsKeepLevel 10 = means one page. 20 = two pages. 1 = 0.1 pages. etc.

To manually delete points now then at specific intervals, you can write an event handler for X axis RangeChanged.

Code: Select all

private const double IntervalForDrop = 5; //seconds
private const double DataKeepLen = 2; //seconds

void ExampleTemperatureGraph_RangeChanged(double newMin, double newMax, AxisBase axis, ref bool cancelRendering)
        {
            AxisX xAxis = m_chart.ViewXY.XAxes[0]; 
            
            PointLineSeries pls = m_chart.ViewXY.PointLineSeries[0];
            if(pls.PointCount > 0 && pls.Points[0].X < xAxis.Minimum - IntervalForDrop)
            {
                cancelRendering = true;
            
                m_chart.BeginUpdate();
                pls.DeletePointsBeforeX(m_chart.ViewXY.XAxes[0].Minimum - DataKeepLen); 

                m_chart.EndUpdate();
            } 
        }
LightningChart Support Team, PT

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Remove old data points

Post by ArctionPasi » Tue Dec 22, 2015 12:00 pm

Hi Igor,

There's no property to control it directly like that. Deleting extra points every time a new data point is added is very resource consuming and for performance reasons we don't do that. It's eventually a large points array we are dealing with, not a list.

PointLineSeries, SampleDataSeries, HighLowSeries and AreaSeries have ScrollModePointsKeepLevel to control how many pages of data is to be kept before cutting it from X axis minimum. One page = X min ... X Max. The ScrollModePointsKeepLevel 10 = means one page. 20 = two pages. 1 = 0.1 pages. etc.

To manually delete points now then at specific intervals, you can write an event handler for X axis RangeChanged.

Code: Select all

private const double IntervalForDrop = 5; //seconds
private const double DataKeepLen = 2; //seconds

void ExampleTemperatureGraph_RangeChanged(double newMin, double newMax, AxisBase axis, ref bool cancelRendering)
        {
            AxisX xAxis = m_chart.ViewXY.XAxes[0]; 
            
            PointLineSeries pls = m_chart.ViewXY.PointLineSeries[0];
            if(pls.PointCount > 0 && pls.Points[0].X < xAxis.Minimum - IntervalForDrop)
            {
                cancelRendering = true;
            
                m_chart.BeginUpdate();
                pls.DeletePointsBeforeX(m_chart.ViewXY.XAxes[0].Minimum - DataKeepLen); 

                m_chart.EndUpdate();
            } 
        }
LightningChart Support Team, PT

Igor
Posts: 67
Joined: Mon Sep 28, 2015 1:14 pm

Re: Remove old data points

Post by Igor » Wed Dec 23, 2015 8:27 am

1. Variant: with "Pages" and "ScrollModePointsKeepLevel"
That's unfortunately not works for me, because if the user zooms in it will already delete datapoints.
Hint: To make this work you have to set the Property "Chart.ViewXY.DropOldSeriesData" to true.

2. Variant: Delete manually like in your example:
The performance breaks extremely if you set "DataKeepLen" to a higher value then "IntervalForDrop",
if your chart has more than one PointLineSeries.


My solution:
I call the method "pls.DeletePointsBeforeX (..)" directly after filling the data series.
This runs most fluid and does what I like.

Thank you

Post Reply