由于缺乏文档,我对这个库仍然很粗糙。
我有一个 ChartPlotter 对象,它通过从设备捕获数据来实时显示数据。每次我有来自设备的新数据时,都会调用以下事件:
private void OnRawDataChanged(object sender, RawDataChangedEventArgs e)
{
System.Diagnostics.Debugger.Log(0, "event", "event received from data manager\n");
System.Diagnostics.Debugger.Log(0, "event", e.NewRawDataSet.Length + " tuples of data returned\n");
var batchSize = e.NewRawDataSet.Length;
// Expected tuples of 2 values + 2 threshold values
Point[][] points = new Point[4][];
for (int i = 0; i < 4; i++)
{
points[i] = new Point[batchSize];
}
double period = 1.0 / Properties.Settings.Default.SamplingRate;
for (int i = 0; i < batchSize; i++)
{
// Time is expressed in milliseconds
double t = e.NewRawDataSet[i].Time / 1000.0;
points[0][i] = new Point(t, e.NewRawDataSet[i].Sensors[0]);
points[1][i] = new Point(t, e.NewRawDataSet[i].Sensors[1]);
points[2][i] = new Point(t, parentForm.PressureHisteresysOpen);
points[3][i] = new Point(t, parentForm.PressureHisteresysClose);
}
plotter.Dispatcher.Invoke(DispatcherPriority.Normal,
new Action(() =>
{
sensor0.AppendMany(points[0]);
sensor1.AppendMany(points[1]);
pressureOpen.AppendMany(points[2]);
pressureClose.AppendMany(points[3]);
}));
}
使用 ChartPlotter 的标准设置,图形将自动适应窗口。我想让水平轴自动向左滚动,仅显示最后 10 秒(例如)的捕获。有没有办法做到这一点?
谢谢