JFreeChart:更新图表时保留缩放位置 [英] JFreeChart: Preserve zoom position when updating chart

查看:113
本文介绍了JFreeChart:更新图表时保留缩放位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序使用JFreeChart(通过Swing ChartPanel)创建时间序列图表,并允许用户放大(使用ChartPanel的标准缩放功能)。该程序具有可在运行时调整的参数(如平滑);如果进行了调整,则使用ChartPanel的setChart()方法替换图表。但是,时间范围在所有调整中总是保持不变。

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.

调用setChart()时,将重置缩放位置,以便显示整个图表。我现在想要的是在调用setChart()之后保留缩放位置,以便用户可以在任何所需的缩放级别直接观察调整效果。怎么可能?

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 方法 getScaleX() getScaleY()可用于缓存当前缩放状态,以便稍后通过缩放方法之一进行恢复。有一个相关的例子这里

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.

这篇关于JFreeChart:更新图表时保留缩放位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆