I have a JFreeChart line plot that is updated dynamically with one data point for every iteration of my algorithm. Because the number of data points can quickly become very large, I have used the setFixedAutoRange(double) method on the domain axis. This restricts the graph to displaying the n most recent iterations (200 in my case).
This works well, except during the first 200 iterations. The problem is that, until there have been 200 iterations, the axis includes negative values (for example, after 50 iterations, the range is from -150 to 50). Negative iterations make no sense. I would like the axis to start at zero rather than a negative value. How can I achieve this?
I don't mind whether the axis goes from 0 to 200 initially (with the right hand part of the chart left blank until the plot fills it up) or whether it starts at 0 to 1 and grows (so that the plot is always stretched across the full width of the chart). Either would acceptable, though I have a slight preference for the former.
Things I have tried:
- Calling setLowerBound doesn't play nicely with setFixedAutoRange.
- Calling setRangeType(RangeType.POSITIVE) doesn't seem to make any difference.
Any ideas?