My program creates a time series chart using JFreeChart (via Swing ChartPanel) and allows the user to zoom into it (using the ChartPanel's standard zoom feature). The program has parameters (such as smoothing) that can be tweaked at runtime; if tweaked, the chart is replaced using the ChartPanel's "setChart()" method. The timeframe, however, invariably stays the same across all tweaks.
When "setChart()" is called, the zoom position is reset so that the entire chart is shown. What I now want is for the zoom position to be preserved after the call to "setChart()", so that the user can observe tweak effects directly at any desired zoom level. How is that possible?
ChartPanel
has methods getScaleX()
and getScaleY()
that could be used to cache the current zoom state for later restoration by one of the zoom methods. There's a related example here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With