|
|
|
Zoom and Scroll are useful aids for focusing on specific data in a densely populated Chart.
Contents |
How to
Zoom and Scroll using the Mouse
How to
Zoom and Scroll by code
|
See the Zoom Class for a
full list of methods associated with Zoom. To define a rectangular area over
which to Zoom use the ZoomRect method.
Example
$tChart1->getZoom()->zoomRect(new Rectangle(100,100,120,120));
The ZoomRect co-ordinates
are defined in screen pixels where 0,0 is the top left hand point of the Chart
Panel. The following code will zoom in on an area between the 2nd and 5th
x-axis points, setting the y-axis to the scale of the maximum and minimum
points of the entire Chart:
$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);
Use 'Undo' to Zoom back
out.
$tChart1->getZoom()->undo();
For the moment there aren't available events for zoom and scroll at runtime.
Scroll is enabled in all
directions as default. Use the Scroll->Allow property to disable Scroll or
limit Scroll to one direction.
The easiest way to scroll by code is to use the Axis Scroll method:
Example
$tChart2->getAxes()->getBottom()->scroll(3, false);
The value is the offset. 'False'
refers to whether or not TeeChart will allow scrolling beyond Series value
limits.
Another way to control scroll is to define Axis maximum and minumum to scroll
by code:
Example
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());
}
© 1996-2010 Steema Software SL. All rights reserved.