滚动图表的默认方式是拖动鼠标按住右键。我需要用鼠标滚轮滚动。我还没有找到任何启用/禁用鼠标滚轮滚动的API。
我还尝试将MouseWheelListener添加到图表本身,但它永远不会被调用。
是否可以在TeeChart lib中使用鼠标滚轮?
我的应用程序是使用SWT的Eclipse RCP。
答案 0 :(得分: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);
}
});