Source for file TChart.php
Documentation is available at TChart.php
* Description: TChart contents
* @copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
// increases the memory to 64M
// set_time_limit ( 60 );
// set_include_path(dirname(__FILE__) . PATH_SEPARATOR);
require_once 'libTeeChart.php';
class TChart implements IChart, IEventListener
public static $controlName= 'TChart';
foreach ($this->listeners->getRaw() as $listener) {
$listener->onMyEvent($event);
echo "Taking short break...\n";
* Serializes the TChart and Chart objects
$this->tmpImg= $chart_s->getChart()->getGraphics3D()->img;
$_SESSION[$prefix. "Chart"] = $serialized;
* Unserializes the TChart and Chart objects
$chart_s->setChart($unserialized);
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
function TChart($width= 300,$height= 200,$handlers= null)
$this->chart = new Chart($this, null);
//ThemesList::_applyTheme($this->getChart(),new DefaultTheme(($this->getChart())));
if ($this->events->Contains($handler->GetEventName()))
private function InitEvents()
* Cleans up any resources being used.
* @param disposing boolean
protected function dispose($disposing) {
$this->chart->removeAllComponents();
* Returns a Dimension object of prefered size.
* Determines which Chart is being printed.
return $this->chart->printing;
* Determines which Chart is being printed.
$this->chart->printing = $value;
* True when the Chart is internally drawing into a Metafile image.
return $this->chart->getGraphics3D()->getMetafiling();
* Obsolete. Please use Aspect->ClipPoints instead.
return $this->chart->getAspect()->getClipPoints();
* Obsolete. Please use Aspect->ClipPoints instead.
$this->chart->getAspect()->setClipPoints($value);
* Obsolete. Please use getSeries.getApplyZOrder() instead.
return $this->chart->getSeries()->getApplyZOrder();
* Obsolete. Please use getSeries().setApplyZOrder() instead.
$this->chart->getSeries()->setApplyZOrder($value);
* The color the Chart rectangle is filled with.<br>
* The chart rectangle is the screen area between axes. <br>
* Setting BackColor to Color.EMPTY does not fill the rectangle. <br>
* Assigning Color->_empty to tChart->getBackColor() makes TeeChart NOT fill the
* Chart back area, so Gradient fills and Background Bitmaps can be shown.
return $this->chart->getPanel()->getColor();
* Sets the color the Chart rectangle is filled with.<br>
$this->chart->getPanel()->setColor($value);
return $this->chart->getPanel()->getColor();
* Captures current mouse position every time the mouse is moved.
* Obsolete. Please use mousePosition field instead.
$s->setChart($this->chart);
$series = $this->chart->getSeries()->add($s);
// TODO $this->fireChartAdded(new ChartEvent($s, ChartEvent.CHART_ADDED));
* Enables/Disables repainting of Chart when points are added.<br>
* Use AutoRepaint false to disable Chart repainting whilst, for example,
* adding a large number of points to a Chart Series. This avoidss
* repainting of the Chart whilst the points are added. <br>
* AutoRepaint may be re-enabled, followed by a manual Repaint command
* when all points are added. <br>
return $this->chart->getAutoRepaint();
* Enables/Disables repainting of Chart when points are added.<br>
* @see TChart#getAutoRepaint
$this->chart->setAutoRepaint($value);
// Do not call invalidate here.
$tmpImg = imagecreatetruecolor($this->width, $this->height);
imagecopyresized($tmpImg,$g->img,0,0,0,0,$this->width,
$this->height,ImageSX($g->img),ImageSY($g->img));
$tmpImg = imagecreatetruecolor($this->width, $this->height);
imagecopyresized($tmpImg,$g->img,0,0,0,0,$this->width,
$this->height,ImageSX($g->img),ImageSY($g->img));
$this->chart->getSeries()->clear();
* Obsolete. Use TChart.<!-- -->Series.<!-- -->Exchange() instead.
$this->chart->getSeries()->exchange($series1, $series2);
* Use TChart.<!-- -->getWalls()<!-- -->getPen() instead.
return $this->chart->getWalls()->getBack()->getPen();
* Returns the number of Series in Chart.
return sizeof($this->chart->getSeries());
* Returns background image of TChart
if ($this->backImage == null) {
$this->backImage = new BufferedImage($this->width, $this->height, 0);
if ($this->chart->getPanel()->getImage() != null) {
$g->draw($this->chart->getChartRect(), $this->chart->getPanel()->getImage(),
$this->getPanel()->getBrush()->getImageMode(),
$this->getPanel()->getShapeBorders(),false);
public function paint($g, $rectangle) {
TChart::$controlName = 'TChart';
$g= $this->chart->getGraphics3D();
if ($this->getBorder() != null) {
$rectangle->x += $i->left;
$rectangle->y += $i->top;
$rectangle->width -= ($i->left + $i->right);
$rectangle->height -= ($i->top + $i->bottom);
$this->chart->paint($g, $rectangle);
if ($this->getBorder() != null) {
$this->getBorder()->paintBorder($this, $g, 0, 0, $this->width, $this->height);
public function _paint($g, $width, $height) {
$this-> callEvent('onBeforeDrawAxes', array());
$this->fireChartPaint(new ChartDrawEvent($this, ChartDrawEvent.PAINTING,
$this->fireChartPaint(new ChartDrawEvent($this, ChartDrawEvent::$PAINTING,
ChartDrawEvent::$SERIES));
$this->fireSeriesClick(new SeriesMouseEvent($s, SeriesMouseEvent. SERIES_CLICKED,
$result = $this->scrollable->isScrollable($a, $result);
if ($this->fireChartClicked(new ChartMouseEvent($sender,
ChartMouseEvent. MOUSE_CLICKED,
ClickedParts. CHARTRECT, e))) {
$this->chart->cancelMouse = true;
$this->chart->iClicked = $this->chart->cancelMouse;
// return parent::getCursor();
$this->chart->setAxes($axes);
$this->chart->setFooter($footer);
$this->chart->setHeader($header);
$this->chart->setLegend($legend);
$this->chart->setSubFooter($subFooter);
$this->chart->setSubHeader($subHeader);
$this->chart->setWalls($walls);
$this->chart->setZoom($zoom);
$this->chart->setPrinter($printer);
$this->chart->setPanning($panning);
$this->chart->setPanel($panel);
$this->chart->setPage($page);
$screen = $this->getLocationOnScreen();
$p->move( - $screen->x, - $screen->y);
// parent::setCursor($c);
$this->chart->originalCursor = $c;
$this->paintImmediately($this->chart->chartBounds);
return new JMultiLineToolTip();
* Defines the Chart to display.
* The text for the Footer, Header, SubFooter and SubHeader.
return ($this->chart == null) ? "" : $this->chart->getHeader()->getText();
* Sets the text for the Footer, Header, SubFooter and SubHeader.
if ($this->chart != null) {
$this->chart->getHeader()->setText($value);
* Background visible attributes.<br>
* Provides access, via the Panel Interface, to all Chart Panel properties.
* Printing related attributes.
* Accesses multiple page characteristics of the Chart.
return $this->chart->getPage();
* Legend characteristics.<br>
* The Legend property determines the text and drawing attributes of
* Chart's textual representation of Series and Series values. <br>
* The Legend class draws a rectangle and for each Series in a Chart
* (or for each point in a Series) outputs a text representation of
* that Series (or that point). <br>
* You can use the Legend.LegendStyle and Legend.TextStyle properties to
* control the text used to draw the legend. <br>
* The Legend can be positioned at Left, Right, Top and Bottom chart sides
* using the Legend.Alignment property. <br>
* Use the Legend.Visible property to show / hide the Legend. <br>
* The Inverted property makes Legend to draw text starting from bottom.<br>
* The Frame, Font and Color properties allow you to change Legend
* The Legend.ColorWidth property determines the percent width of each
* item's "colored" mark. <br>
* The Legend.FirstValue property controls which Series (or Series point)
* will be used to draw first Legend item. <br>
return $this->chart->getLegend();
* Defines the Text and formatting properties to be drawn at the top of
* Use Text to enter the desired Header lines, set Visible to True and
* change the Font, Frame and Brush methods.<br>
* Use Alignment to control text output position.
* Defines Text shown directly below Header.<br>
* Use the Text method to enter the desired SubHeader lines, set Visible
* to True and change the Font, Frame and Brush methods.<br>
* Use the Alignment method to control text output position.
return $this->chart->getSubHeader();
* Determines the Font characteristics.
* Defines Text shown at the bottom of the Chart.<br>
* Use Text to enter the desired Footer lines, set Visible to True and
* change the Font, Frame and Brush methods.<br>
* Use Alignment to control text output position.
return $this->chart->getFooter();
* Accesses the Zoom characteristics of the Chart.
return $this->chart->getZoom();
* Accesses Panning characteristics. <br><br>
* Scrolling speed depends on: <br>
* The number of Series and Series Points. <br>
* The Chart Width and Height. <br>
* The computer processor and Video card processor speed. <br>
* The Video resolution and number of colors. <br>
* The Windows version and the Video driver. <br>
* The speed when dragging the mouse !
return $this->chart->getPanning();
* Defines Text shown directly above Footer.<br>
* Use Text to enter the desired SubFooter lines, set Visible to True and
* change the Font, Frame and Brush methods.<br>
* Use Alignment to control text output position.
return $this->chart->getSubFooter();
* Accesses view characteristics of the Chart.<br>
return $this->chart->getAspect();
* Obsolete. Please use getGraphics3D function.
* Obsolete. Please use setGraphics3D method.
* @param IGraphics3D $value
* Used to access TeeChart Draw attributes.
* @param IGraphics3D $value
$this->chart->setGraphics3D($value);
* Collection of Series contained in this Chart.<br><br>
* TeeChart Series are the data display method type, e.g. Line Series,
* Bar Series, Pie Series etc. You can mix different Series types in a
* Chart according to your requirements, thus your design is not limited to
* just one 'Chart type' defined by TeeChart. The concept of Chart type
* being virtually obsolete in terms of the number of permutations of
* Charts (Series type mix) you may create. <br><br>
* For more information please see "Tutorial 6 - Working with Series".
* @return SeriesCollection or Series depending if parameter has been passed
return $this->chart->getSeries();
return $this->chart->getSeries($index);
* Collection of Tool components contained in this Chart.
* @return ToolsCollection
return $this->chart->getTools();
* Accesses left, bottom and back wall characteristics of the Chart.
return $this->chart->getWalls();
* Collection of predefined and custom axis objects.
return $this->chart->getAxes();
* Accesses Chart export attributess.
* Accesses Chart import attributes.
return $this->chart->getImport();
$this->chart->setSeries($series);
$this->chart->series->setSeries($index, $value);
private function prepareGraphics() {
$this->tool->setToolTip($this, $text);
$this->chart->setTools($value);
$tmp->width= $this->width;
$this->chart->_paint($this->chart->getGraphics3D(),$tmp);
* @param string Name of the file to render the image to (optional)
function render($fileName = null)
$this->chart->setAutoRepaint(true);
$g= $this->chart->getGraphics3D();
/*TODO if ($g->getImageReflection()==true) {
$reflection=$g->doReflection($g->img);
$g->getImg()->save($fileName);
if ($g->getImageInterlace()== true) {
imageinterlace($g->img,true);
imagepng($g->img, $fileName);
$this->chart->setGraphics3D($g3D);
* Used to access TeeChart Draw attributes.
return ($this->chart == null) ? null : $this->chart->getGraphics3D();
return Texts::$BuildNumber;
// fireChartMotion(new ChartEvent(sender, ChartEvent.CHART_ZOOMED));
|