Using JFreeChart to display recent changes in a time series?

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

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);

 

Using JFreeChart to display recent changes in a time series