缩放和滚动是有用的辅助工具,可用于关注人口稠密图表中的特定数据。本教程将会介绍如何在TeeChart for PHP中缩放和滚动图表。
TeeChart for PHP包含100%的PHP源代码。它支持PHP5及更高的版本。它可作为一个调色板组件整合到针对PHP的Delphi编程环境中,从而让其他人在运行时以创建组件的方式来引用。第一个版本提供17种图表类型(2D和3D的多种组合),11个数学函数和一些图表工具组件以扩展功能。
TeeChart for PHP试用版
缩放和滚动是有用的辅助工具,可用于关注人口稠密图表中的特定数据。本教程是TeeChart for PHP教程中缩放与滚动这一节。本章节的内容主要介绍如何使用代码进行缩放和滚动。
如何通过代码缩放和滚动
缩放
要定义要缩放的矩形区域,请使用ZoomRect方法。
例:
$tChart1->getZoom()->zoomRect(new Rectangle(100,100,120,120));
ZoomRect坐标以屏幕像素定义,其中0,0是图表面板的左上角。以下代码将放大第2和第5个x轴点之间的区域,将y轴设置为整个图表的最大和最小点的比例:
$x = $points1->calcXPos(2); $y = $tChart1->getAxes()->getLeft()->calcYPosValue($tChart1->getAxes()->getLeft()->getMaxYValue()); $height = $tChart1->getAxes()->getLeft()->calcYPosValue($tChart1->getAxes()->getLeft()->getMinYValue()) - $tChart1->getAxes()->getLeft()->calcYPosValue($tChart1->getAxes()->getLeft()->getMaxYValue()); $width = $points1->calcXPos(5) - $x; $r = new Rectangle($x,$y,$width,$height); $tChart1->getZoom()->zoomRect($r);
使用撤销指令就能够取消。
$tChart1->getZoom()->undo();
缩放事件
目前,在运行时没有可用于缩放和滚动的事件。
滚动
默认情况下,滚动在所有方向启用。使用Scroll-> Allow属性禁用Scroll或将Scroll限制为一个方向。按代码滚动的最简单方法是使用Axis Scroll方法:
$tChart2->getAxes()->getBottom()->scroll(3, false);
该值是偏移量。False指的是TeeChart是否允许滚动超出系列值限制。
控制滚动的另一种方法是定义Axis maximum和minumum以按代码滚动:
private function Load() { $range = round(($bar1->getXValues()->getMaximum() - $bar1->getXValues()->getMinimum() / 2)); $bar1->fillSampleValues(20); $tChart1->getPanning()->setAllow(ScrollModes::$E); $jScrollBar1->setValue($range); $jScrollBar1->setMinimum($range - 50); $jScrollBar1->setMaximum($range + 50); } public funcion ScrollBar1_propertyChange() { $tChart1->getAxes()->getBottom()->setAutomatic(false); $tChart1->getAxes()->getBottom()->setMinimum($jScrollBar1->getValue()); $tChart1->getAxes()->getBottom()->setMaximum($jScrollBar1->getValue() + $bar1->getCount()); }
本节教程就是这样了,下一节我们将会介绍图表的导出和导入,您可以多多关注我们的TeeChart for PHP教程哦!
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!