Search code examples
plotjfreecharttimeserieschart

JFreeChart - prohibit initial stretching of TimeSeries


I would like to adopt sample, well-known demo in JFreeChart showing memory consumption : http://www.koders.com/java/fidAC2CC42CB6511A1240DFE1A6BE1B9D04D34CF001.aspx

Problem:
I don't want it to be initially stretched between both ends of the plot and when the maximumItemAge is reached begin to "scroll".
I want the time range to be of the constant width, and the measurements representation starting with the left side left blank, filling the plot from the right.

Scrolling after filling-up the whole plot (free.setMaximumItemAge(MAXIMUM_AGE);) is perfectly fine with me.

I've already tried bunch of staff involving setRange(.., ..) and setAutoRange(false).
Seems it's more tricky as the TimeSeries are used


Solution

  • You just need to add the following line: domain.setFixedAutoRange(MAXIMUM_AGE);

    That will fill your plot from the right and scroll when it's full.