Using JFreeChart to display recent changes in a time series

后端 未结 3 1918
陌清茗
陌清茗 2020-11-21 10:56

How can I use JFreeChart to display just the most recent data in a continually updated time series?

Addenda: A complete, working example that incorporates the accept

3条回答
  •  不知归路
    2020-11-21 11:50

    One alternative approach to @thrashgod's answer would be to use TimeSeriesCollection and setting item age on the TimeSeries. Below code can setup a graph to show last 1 hour of data with 1 minute intervals.

    private TimeSeriesCollection dataset;
    private TimeSeries sensorSeries;
    sensorSeries = new TimeSeries("name", Minute.class);
    sensorSeries.setMaximumItemAge(60);
    dataset = new TimeSeriesCollection();
    dataset.addSeries(sensorSeries);
    

    ..and you will add the data as it comes with:

    sensorSeries.add(new Minute(new Date()), newData);
    

提交回复
热议问题