具有可选域轴和缩放功能的 JFreeChart [英] JFreeChart with selectable domain axis and zoom

查看:35
本文介绍了具有可选域轴和缩放功能的 JFreeChart的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何拥有像 https://www.amcharts.com/demos/line-chart-with-scroll-and-zoom/

我对这些功能特别感兴趣

I am specifically interested in these functionalities

  1. 能够使用这两个选择控件选择域轴的窗口.
  2. 能够通过选择域轴的一部分进行缩放.
  3. 能够缩小并看到更大的图景.
  4. 能够映射到范围轴 (Y) 并在任何点(无标记)查看该气球上的值,例如工具提示

我在这里做了初步尝试 可滚动 JFree 域轴和自定义标记标签 在trashgod 的帮助下,我使域可滚动.

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.

推荐答案

您必须结合多种方法:

  1. 平移控件:调用,setDomainPannable(true) 以启用平移;在您的控件中,使用 panDomainAxes(),如实施 mouseDragged();按照此处的建议使用鼠标.

  1. Panning controls: Invoke, setDomainPannable(true) to enable panning; in your controls, use panDomainAxes(), as shown in the implementation of mouseDragged(); use the mouse as suggested here.

缩放:支持在轴上拖动缩放,但支持在绘图上拖动向右拖动以查看选择矩形.为确保鼠标滚轮仅在滚动时缩放域轴,请在 ChartPanel 上调用 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屋!

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