1

ドキュメントが不足しているため、このライブラリについてはまだかなり大雑把です。

デバイスからのデータのキャプチャによってキャプチャされたデータをリアルタイムで表示する 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 秒 (たとえば) のみを表示したいと思います。これを達成する方法はありますか?

ありがとう

4

1 に答える 1

2

これを実現するには、plotter.ViewPort.Visible プロパティを変更する必要があります。このプロパティは、四角形を形成する値を使用して構築する DataRect オブジェクトを受け取ります。新しいデータを受け取るたびに、グラフがスクロールして表示されるように、この四角形を再計算する必要があります。

DataRect を構築する例を次に示します。

        double yMin = 1;
        double yMax = 10;
        double xMin = 1;
        double xMax = 10;
        plotter.ViewPort.Visible = new DataRect(xMin, yMin, xMax - xMin, yMax - yMin); 

最小値と最大値は、軸のデータの種類に基づきます。

于 2012-11-26T16:03:32.293 に答える