Scroll chart with mouse wheel in TeeChart

假如想象 提交于 2019-12-11 14:15:46

问题


Default way to scroll chart is to drag mouse holding right button. I need to scroll with mouse wheel. I haven't found any API to enable/disable mouse wheel scrolling.

I also tried to add MouseWheelListener to the chart itself, but it never gets called.

Is it possible to use mouse wheel in TeeChart lib?

My application is Eclipse RCP using SWT.


回答1:


The following code works fine for me with TeeChart Java SWT in Eclipse:

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);
    }
});


来源:https://stackoverflow.com/questions/20515757/scroll-chart-with-mouse-wheel-in-teechart

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