JFreeChart: DynamicTimeSeries with period of n milliseconds

前端 未结 3 1185
栀梦
栀梦 2020-12-04 00:40

I\'m trying do define an interface in which I want to plot some values received by an external device. These values are received with a frequency that can be set through the

3条回答
  •  旧巷少年郎
    2020-12-04 01:06

    Instead, use the original MilliDTSC & Millisecond, and invoke advanceTime() and append the old data as required before appending the new data. Using 200 ms as an example, do something like this:

    float[] newData = new float[1];
    float[] oldData = new float[1];
    
    @Override
    public void actionPerformed(ActionEvent e) {
        newData[0] = randomValue();
        oldData[0] = newData[0];
        for (int i = 0; i < 200; i++) {
            dataset.advanceTime();
            dataset.appendData(oldData);
        }
        dataset.appendData(newData);
    }
    

    Note that there are now 5 samples/second, spaced 200 ms apart.

    enter image description here

提交回复
热议问题