Removing a single point from an OxyPlot Series

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

lhhc wrote at 2013-05-26 19:25:

My question is simple. If you can add a point using OxySeries.Points.Add, is it possible to remove a single point from the series?

objo wrote at 2013-06-08 11:28:

Yes, use the Points.RemoveAt method.
Remember to invalidate/redraw the plot afterwards (the model is not listening to changes in the Points collection).

lhhc wrote at 2013-06-08 21:05:

Thanks, would you mind providing me with an example of the syntax. Is Points.RemoveAt(0) mean that it would remove the last point of the series?

objo wrote at 2013-06-08 22:25:

No, index 0 is the first point, see http://msdn.microsoft.com/en-us/library/5cw9x18z.aspx

lhhc wrote at 2013-06-08 22:31:

Thanks for the fast reply. So I've created a line series called hrseries and a plotmodel called hrtmp. When I call HR=hrtmp, it triggers the RaisePropertyChanged which I confirmed works correctly. Currently I'm clearing the lineseries and adding all the points to the lineseries every time I add a new point, which is slow. So I changed the code to remove one point at index 0 when its longer than 1000 points. Now my graph is empty. Is the code correct?
if (hrseries.Points.Count > 1000)
{
     hrseries.Points.RemoveAt(0);
}
hrseries.Points.Add(new DataPoint(xval, yval));
hrtmp.RefreshPlot(true);
HR = hrtmp;

lhhc wrote at 2013-06-08 23:12:

Actually I found my mistake. Forgot to add:
hrtmp.Series.Add(hrseries);