AddSeries() add more point than expected point count.
Posted: 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:
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.
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;
Is there any way to solve this situation?
Attachment is my solution, please download.
Thx.