JFreechart series movement with fixed x-axis

2019-07-29 13:26发布

First question here. I'm doing an Arduino serial port plotter with Java and JFreeChart. Everything's working fine with the DynamicTimeSeries dataset, as I'm able to plot data nice and softly.

What I need to do now is this: given an established period of time (let's say 60 seconds) I want to plot the DynamicTimeSeries dataset on the chart for that period without moving the axis; I mean, like drawing a line for 60 seconds on the fixed chart.

Is there any way to do this? Every example I've watched shows the x-axis (time axis) start running along with the series.

If I'm not clear enough please let me know.

Any help will be deeply appreciated!

Thanks!

PS: my code is based on this: Using JFreeChart to display recent changes in a time series, and this: JFreeChart: DynamicTimeSeries with period of n milliseconds

1条回答
成全新的幸福
2楼-- · 2019-07-29 14:09

For a 60 second chart, I'd expect domain indexes in the range 0..59. Depending on your requirements,

  • You can put the next value at index 0, or

  • You can invoke advanceTime() and put the next value at index 59.

Also consider invoking setDateFormatOverride() on the domain axis, as shown here. See also Real time graph plotting starting time and this answer about Using SwingWorker with JFreeChart.

查看更多
登录 后发表回答