JFreeChart: maintaining zoom position when updating a chart

My program creates a time series chart using JFreeChart (via Swing ChartPanel) and allows the user to scale it (using the standard ChartPanel scaling function). The program has parameters (such as anti-aliasing) that can be changed at run time; if it is changed, the chart is replaced using the ChartPanel method "setChart ()". Timing, however, invariably remains unchanged in all tricks.

When "setChart ()" is called, the zoom position is reset so that the entire chart is displayed. Now I want the zoom position to be preserved after calling the "setChart ()" function, so that the user can observe the effects of the setting directly at any desired zoom level. How is this possible?

+6
source share
1 answer

ChartPanel has getScaleX() and getScaleY() methods that can be used to cache the current zoom state for subsequent recovery using one of the zoom methods. Here is an example here .

+6
source

Source: https://habr.com/ru/post/897666/


All Articles