JFreeChart: Preserve zoom position when updating chart

空扰寡人 提交于 2019-12-07 03:32:03

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/7482505/jfreechart-preserve-zoom-position-when-updating-chart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!