【下载TeeChart for Java最新版本】
(一)如何使用鼠标进行缩放和滚动
1.1 缩放
要放大图表,请在要放大的区域的左上角按鼠标右键,并按住鼠标按钮,将矩形拖动到缩放区域的右下角。释放鼠标按钮将强制图表重绘所选区域。 要撤消缩放,请在“Chart”区域的任意位置按鼠标左键,然后按住鼠标按钮向上和向左拖动。释放按钮将强制图表重绘为最初定义的图表区域。
1.2 滚动
要滚动图表,按下鼠标左键,并保持按下,拖动鼠标在你想滚动图表的方向。释放鼠标按钮时,图表将保留在新位置。 要撤消滚动,请在“Chart”区域的任意位置按鼠标左键,然后按住鼠标按钮向上和向左拖动。释放按钮,图表将重绘为最初定义的图表区域。
(二)如何通过代码缩放和滚动
2.1 缩放
默认情况下,启用缩放。使用Zoom.getAllow方法禁用缩放。要定义缩放的矩形区域,请使用ZoomRect方法,例:
tChart1.getZoom().zoomRect(new com.steema.teechart.Rectangle(100,100,120,120));
ZoomRect坐标以屏幕像素定义,其中0,0是图表面板的左上角。以下代码将放大第2和第5个x轴点之间的区域,将y轴设置为整个图表的最大和最小点的比例:
int x = points1.calcXPos(2);int y = tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMaxYValue());int height = tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMinYValue()) -tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMaxYValue());int width = points1.calcXPos(5) - x;com.steema.teechart.Rectangle r = new com.steema.teechart.Rectangle(x,y,width,height);tChart1.getZoom().zoomRect(r);
使用“Undo”缩小:
tChart1.getZoom().undo();
2.2 动画缩放
动画缩放提供步进缩放。您可以将AnimatedZoom设置为启用并定义缩放的交错步骤,而不是一步跳过“缩小”到“放大”。启用AnimatedZoom后,您可以使用鼠标或代码手动缩放,例:
int x = points1.calcXPos(2);int y = tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMaxYValue());int height = tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMinYValue()) -tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMaxYValue());int width = points1.calcXPos(5) - x;com.steema.teechart.Rectangle r = new com.steema.teechart.Rectangle(x,y,width,height);tChart1.getZoom().setAnimated(true);tChart1.getZoom().setAnimatedSteps(100);tChart1.getZoom().zoomRect(r);
2.3 缩放事件
手动或通过代码放大将触发TChart.Zoomed事件,缩小将触发TChart.UndoneZoom事件。
2.4 滚动
默认情况下,滚动在所有方向上启用。使用Scroll.Allow属性禁用Scroll或将Scroll限制为一个方向。 按代码滚动的最简单方法是使用Axis Scroll方法:
tChart2.getAxes().getBottom().scroll(3, false);
该值是偏移量。’False’指的是TeeChart是否允许滚动超出系列值限制。 控制滚动的另一种方法是定义Axis maximum和minumum以按代码滚动:
private void Load() { int range = com.steema.teechart.Utils.Round((bar1.getXValues().getMaximum() - bar1.getXValues().getMinimum() / 2)); bar1.fillSampleValues(20); tChart1.getPanning().setAllow(ScrollModes.NONE); jScrollBar1.setValue(range); jScrollBar1.setMinimum(range - 50); jScrollBar1.setMaximum(range + 50);} public void jScrollBar1_propertyChange(PropertyChangeEvent evt) { tChart1.getAxes().getBottom().setAutomatic(false); tChart1.getAxes().getBottom().setMinimum(jScrollBar1.getValue()); tChart1.getAxes().getBottom().setMaximum(jScrollBar1.getValue() + bar1.getCount());}
购买TeeChart for Java正版授权,请点击“咨询在线客服”哟!

标签:图表Java图表控件teechart
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!