How to orepend points to a PointLineSeries

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

Posts: 1
Joined: Wed Sep 02, 2020 7:57 am

How to orepend points to a PointLineSeries

Post by FireCurver » Wed Sep 02, 2020 8:23 am

For an application we are creating we have a somewhat special requirement. We conduct measurements where we need to plot measurement results (e.g. the temperature) on a display system. These results come in sequentially (the X of newer points is always higher than the previous point), which allows us to simply call .AddPoints on a PointLineSeries instance, as this "Add points to end of series."

Such display system, however, can be attached to the measurement system at any point in time, while the measurement has been running for a long period of time. When attached, the display system will immediately show new measurement results as they come in (by calling .AddPoints). So far so good.

A late-attached display system, however, obviously misses the information that happened before it was attached. As this “historical” information is crucial for an operator in production, we send this historical information to the display system, in parallel with newly arrived measurement results. This allows the display system to build up the "past" while seeing new results in real-time. But here lies the problem.

Calling .AddPoints for historical information completely screws up the PointLineSeries, as it plots a line between every point “n” and “n+1”, while this historical information doesn’t conform to the “n+1” rule (as their X are lower, not higher).

Is there a way to efficiently add new points to the beginning of the PointLineSeries?

I was looking for something like “.PrependPoint”, but this doesn’t exist. Prepend would work nicely for us, because this second stream with historical measurement results is sent in reverse order. In other words: every newer received historical point has an X that is always lower than the previously received point.

Is this achievable or is there another way to fulfill our business requirement?

Posts: 113
Joined: Wed Mar 27, 2019 1:05 pm

Re: How to orepend points to a PointLineSeries

Post by Arction_LasseP » Wed Sep 02, 2020 11:21 am


One solution could be to replace the whole Points array whenever you need to add historical data as well.

pointLineSeries.Points = pointsArray; // pointArray contains both the historical data and the new points

This can be slightly slower performance-wise compared to AddPoints(), but if you are not constantly doing this, this shouldn't have any noticeable effect. Whenever you are adding only new points, it is still recommended to use AddPoints().

Hope this helps.
Best regards,