Removing a single point from an OxyPlot Series

May 26, 2013 at 5:25 PM
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?
Coordinator
Jun 8, 2013 at 9:28 AM
Yes, use the Points.RemoveAt method.
Remember to invalidate/redraw the plot afterwards (the model is not listening to changes in the Points collection).
Jun 8, 2013 at 7:05 PM
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?
Coordinator
Jun 8, 2013 at 8:25 PM
No, index 0 is the first point, see http://msdn.microsoft.com/en-us/library/5cw9x18z.aspx
Jun 8, 2013 at 8:31 PM
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;
Jun 8, 2013 at 9:12 PM
Actually I found my mistake. Forgot to add:
hrtmp.Series.Add(hrseries);