Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

ScatterGraph - how to delete points from plot?

Dear all,

 

What is the correct way to delete one or more of the oldest points in a plot (to make room for new points)?

 

Let's say I have a plot with the following points plotted (and HistoryCapacity set to 10), where 0 is the oldest point, and 9 the most recent:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

 

If I now want to delete e.g. the three oldest points I can do it by setting the HistoryCapacity to 7 and then set it back to 10 again,

but is this the correct way to do this?

 

I miss some kind of function like scatterGraph1.Plots[0].Delete(int index, int count).

 

Thanks in advance!

0 Kudos
Message 1 of 4
(5,865 Views)

Hi PureNI

 

If you set the HistoryCapacity to 10, the graph would automatically delete the oldest point when you draw the 11'th point. Try this:

 

MyGraph.Plots[0].HistoryCapacity = 5;

for(int i = 0; i < 10; i++)

{

   MyGraph.Plots[0].PlotXYAppend(i,i);

}

 

That would give you a graph of only the 5 last points.

 

With that being said it could be a nice function to have to be able to delete one point but unfortunatly there is not such one. If I was to do the task I would do the following:

 

1) Get array of X values

2) Get array of Y values

3) Create a subset of the 2 arrays

4) Clear the Graph 

5) Plot using the subset arrays (don't use the append just plot once using the arrays). 

 

That would also allow you with more flexibility than just chaning the history as you do.

 

 

Best Regards

Anders Rohde

Applications Engineer

National Instruments Denmark

0 Kudos
Message 2 of 4
(5,844 Views)

Hi Anders,

 

I'm aware of the function of HistoryCapacity, but it is too slow deleting one point every time I add a new.

Therefore I delete e.g. 10 points in one shot every 10th time I add a new point.

It is a lot faster to delete 10 points at ones instead of deleting 1 point 10 times.

 

The alternative sequence you wrote, isn't that too slow when doing this for all plots (50 plots with 100.000 points) ones a second?  

0 Kudos
Message 3 of 4
(5,827 Views)

Hi PureNI

 

I don't think it is the deleting of the points that is slow, I think it is more due to the fact that plotting one point would still require you to update the entire graph (since you are moving all points to the left). So when you are deleting 10 points you only have to redraw the graph every 10'th time. 

 

I haven't tried with such high data ranges as you are using but I think you could benefit from a sweep chart functionality where you actually only update one column of points in the graph at a time. It would give you a little different type of display but with faster update rate. 

 

Take a look at this example:

 

http://zone.ni.com/devzone/cda/epd/p/id/3279

 

 

Best Regards

Anders Rohde

Applications Engineer

National Instruments Denmark

0 Kudos
Message 4 of 4
(5,820 Views)