2

I am using dynamic data display library to view a dynamic integer value coming in at frequent intervals and plotting it as a linegraph ('line1') onto a chartplotter named 'plotter'. What I want is to have a way to erase all the data from the chartplotter when I uncheck the checkbox and start plotting again once i check it back. I thought I might be able to accomplish it with plotter.Children.Remove(line1), but it does not erase the old data. Instead it plots over the old data again and I have double data lines. Here is the code example (includes some pseudo codes) that I have so far.

ObservableDataSource<System.Windows.Point> source1=new ObservableDataSource<System.Windows.Point>();
LineGraph line1=new LineGraph(source1);
line1.Name = "Data1";
int i=0;
start a timer to CaptureData...
CaptureData(....,...)
{
  if a CheckBox is checked...()
 {
    if (i == 0)
    {
    plotter.Children.Add(line1);
    }
    double graph_x = Convert.ToDouble(i);
    double graph_y = Convert.ToDouble(datapoint that I have);
    System.Windows.Point p1 = new System.Windows.Point(graph_x, graph_y);
    source1.AppendAsync(Dispatcher, p1);
    i++;
    }
 }
 Once the checkBox is unchecked
 {
    if (i != 0)
      {
         i=0;
         plotter.Children.Remove(line1);
      }
 }
}

This is the linegraph that I am getting now with data starting to plot again at the beginning, but the old data is still hanging in there. What I want to achieve is a clean new graph without the old line present. I don't have the minimum points to post an image. So please see the image here: https://dl.dropboxusercontent.com/u/49447650/test5.png

4

1 回答 1

0

您必须清除来源:

source1.RemoveAll(typeof(Point));
于 2014-07-11T14:38:22.387 回答