具有可选域轴和缩放的JFreeChart [英] JFreeChart with selectable domain axis and zoom
问题描述
如何使用 https://www .amcharts.com/demos/line-chart-with-scroll-and-zoom/
我对这些功能特别感兴趣
I am specifically interested in these functionalities
- 要能够使用这两个选择控件来选择域轴窗口.
- 通过选择部分域轴进行缩放.
- 能够放大并查看大图.
- 为了能够映射到范围轴(Y)并在任意点(无标记)像工具提示一样看到该气球上的值
我在此处进行了初步尝试可滚动的JFree域轴和自定义标记标签在垃圾桶的帮助下,我使域可滚动.
I made initial attempt here Scrollable JFree domain axis and custom marker label with help of trashgod I made domain scrollable.
我仍然缺少这些功能,无法有效使用图形.
I am still missing these functionality to be able to use graph effectively.
推荐答案
您将不得不结合几种方法:
You'll have to combine several approaches:
-
平移控件:调用
setDomainPannable(true)
启用平移;在控件中,使用实现/javadoc/org/jfree/chart/ChartPanel.html#mouseDragged-java.awt.event.MouseEvent-"rel =" nofollow noreferrer>mouseDragged()
;根据建议的此处使用鼠标.
Panning controls: Invoke,
setDomainPannable(true)
to enable panning; in your controls, usepanDomainAxes()
, as shown in the implementation ofmouseDragged()
; use the mouse as suggested here.
缩放:不支持通过在轴上拖动进行缩放,但支持在图上进行拖动;拖动 right 可以看到选择矩形.要确保鼠标滚轮在滚动时仅缩放域轴,请在ChartPanel
上调用setRangeZoomable(false)
;否则,请单击setRangeZoomable(false)
.反之亦然.
Zooming: Zooming by dragging on the axis is not supported, but dragging on the plot is supported; drag right to see the selection rectangle. To ensure the mouse wheel only zooms the domain axis when is rolled, invoke setRangeZoomable(false)
on the ChartPanel
; vice-versa for the range axis.
Zooming out: Drag left to zoom out or use a button handler, as shown here.
工具提示:在您选择的ChartFactory
中启用工具提示.如果需要,请创建自定义XYToolTipGenerator
,如此处所示.
Tooltips: Enable tooltips in your chosen ChartFactory
. If needed, create a custom XYToolTipGenerator
, as shown here.
这篇关于具有可选域轴和缩放的JFreeChart的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!