0

我正在尝试构建一个时间序列图,其中 x 轴代表时间,y 轴代表 [0,100] 中的数字。我有一个实时数据流,它为下一个时间序列点提供 [x,y] 坐标。尝试使用 flot 时,我意识到每次情节发生时,前一个情节都会被删除,只剩下新情节,我怎样才能将新点“附加/渲染”到旧情节。

例如在以下代码中:

    $(function () {
        var d1 = [];
        for (var i = 0; i < 14; i += 0.5)
            d1.push([i, Math.sin(i)]);

        var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];

        // a null signifies separate line segments
        var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];


        $.plot($("#placeholder"), [ d2 ]);
        $.plot($("#placeholder"), [ d1 ]);


    });

d2 将被绘制,但随后 d1 将覆盖 d2 绘图。如何在绘图中附加新点以及如何更新 x 秒数?

4

1 回答 1

0

are you wanting to graph them side by side. If so this is what you want:

$.plot($("#placeholder"), [ d2, d1 ]);

this will create two series and plot them on top of one another. as for scrolling through the data by one seconds I suggest looking at this example

于 2012-08-14T23:43:03.413 回答