1
votes

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
Assuming you start at zero, where does the data for the 60th second go? Back at zero? See also Real time graph plotting starting time, cited in your first reference, and be sure you're doing this.trashgod
The plot stops at 60 secs, until I press a reset button. I'll check your suggestions and see what happens. Thank you so muchArturo Navarro

1 Answers

1
votes

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.