2
我正在使用動態數據顯示庫查看以頻繁間隔進入的動態整數值,並將其作爲linegraph('line1')繪製到名爲「plotter」的chartplotter上。我想要的是有一種方法來清除chartplotter中的所有數據,當我取消選中該複選框並再次開始繪圖時,我會再次檢查它。我想我可以用plotter.Children.Remove(line1)來完成它,但它並沒有擦除舊的數據。相反,它再次繪製舊數據,並有雙倍的數據線。這裏是我迄今爲止的代碼示例(包括一些僞代碼)。重置C#上的chartplotter數據WPF
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);
}
}
}
這是我與從頭開始重新繪製數據現在得到linegraph,但舊的數據仍然掛在那裏。我想實現的是一個沒有舊線路的乾淨的新圖。我沒有發佈圖片的最低分數。所以,請在這裏看到的圖像:https://dl.dropboxusercontent.com/u/49447650/test5.png
人嗎?任何人?沒有人? :( – user2408579