【问题标题】:Scroll chart with mouse wheel in TeeChart在 TeeChart 中使用鼠标滚轮滚动图表
【发布时间】:2013-12-11 09:47:54
【问题描述】:

滚动图表的默认方式是按住鼠标右键拖动。我需要用鼠标滚轮滚动。我还没有找到任何 API 来启用/禁用鼠标滚轮滚动。

我还尝试将 MouseWheelListener 添加到图表本身,但它从未被调用。

是否可以在 TeeChart 库中使用鼠标滚轮?

我的应用程序是使用 SWT 的 Eclipse RCP。

【问题讨论】:

  • 首先,请添加您正在使用的库的链接。其次,请考虑发布SSCCE,以便我们重现您正在查看的内容。

标签: swt teechart


【解决方案1】:

以下代码在 Eclipse 中使用 TeeChart Java SWT 对我来说效果很好:

Bar bar1 = new Bar(tChart1.getChart());
bar1.fillSampleValues();

tChart1.addMouseWheelListener(new MouseWheelListener() {

    @Override
    public void mouseScrolled(MouseEvent arg0) {
        Axis tmpA = tChart1.getAxes().getLeft();
        double tmpInc = tmpA.getRange()/10;
        if (arg0.count>0)
            tmpA.setMinMax(tmpA.getMinimum()+tmpInc, tmpA.getMaximum()+tmpInc);
        else
            tmpA.setMinMax(tmpA.getMinimum()-tmpInc, tmpA.getMaximum()-tmpInc);
    }
});

【讨论】:

  • 确实是要走的路。我有完全相同的代码,但是直到我手动将焦点设置在图表上之后它才起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-09-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-07
  • 2011-09-18
  • 1970-01-01
相关资源
最近更新 更多