AddSeries() add more point than expected point count.

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
Harry943
Posts: 8
Joined: Tue Dec 26, 2017 6:46 am

AddSeries() add more point than expected point count.

Post by Harry943 » Thu Dec 13, 2018 2:45 am

Hi,
I'm using FreeformLineSeries.AddPoint() in a real-time refresh application. I found that I've added point is more than I real added, that is the series.PointCount not equal to series.Points.Length! My application need change series.PointCountLimitEnabled in run-time, when I set PointCountLimitEnabled to true, unexpected point is lost. Code as follow:

Code: Select all

List<SeriesPoint> pts = new List<SeriesPoint>();
Random rand = new Random(Environment.TickCount);

for (int i = 0; i < 20; i++)
    pts.Add(new SeriesPoint { X = i, Y = rand.Next(50) });

//series.Points = pts.ToArray();  // This approach is Okay, series.PointsCount == series.Points.Length
series.AddPoints(pts.ToArray(), false);	// series.PointsCount != series.Points.Length

series.PointCountLimitEnabled = true;
I add 20 points, and set the limit to 10, I checked series.PointsCount is 20 while the series.Points.Length is 30, last 10 point data are all default(SeriesPoint) which they're X and Y both 0. Then I set PointCountLimitEnabled to true, only the last 10 point still exist, but what I want is the last 10 points of I added 20 points before. Only use series.Points=pts.ToArray() rather than series.AddPoints() could get the right result. But this is in real-time refresh which need more performance.
Is there any way to solve this situation?
Attachment is my solution, please download.
Thx.
Attachments
LCTempSemi.7z
(210.93 KiB) Downloaded 577 times

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

Re: AddSeries() add more point than expected point count.

Post by ArctionKestutis » Fri Dec 14, 2018 7:44 am

Hi,

Thank you for the project. You raised an interesting point. I did quick check of the code and may need to verify preliminary findings latter. But at this points it looks that you will be able to solve your problems, if enable PointCountLimitEnabled from the start. Otherwise, you are initializing Series as having no limit. Which leads to array-coping-optimization. That is, to minimize cost of array copping (on adding new points) the Series Point's array is increased a little bit more (in anticipation of new point addition). Series' PointCount keeps correct count of real points. This optimization is applicable for all LineSeries.

Update: we will fix Points' array resize operation (on PointCountLimit) to handle above usage.

Hope this helps.

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

Re: AddSeries() add more point than expected point count.

Post by ArctionKestutis » Thu Oct 10, 2019 9:22 am

Starting at least from v8.4.2.4001 issue should be fixed.
That is, points adding order and disabling/enabling PointCountLimitEnabled have no side effect (behaves as expected).
Therefore, it should be no data loss.

All the best.

Post Reply