TeeChartPHP
[ class tree: TeeChartPHP ] [ index: TeeChartPHP ] [ all elements ]

Source for file tchart.inc.php

Documentation is available at tchart.inc.php

  1. <?php
  2.  
  3.   /**
  4.   *  This file is part of Steema Software
  5.   *  It generates the design time TChart component.
  6.   *
  7.   *  Copyright (c) 2008 Steema Software <info@steema.com>
  8.   */
  9.  
  10.   use_unit("classes.inc.php");
  11.   use_unit("controls.inc.php");
  12.   use_unit("stdctrls.inc.php");
  13.   // use_unit("teechart/sources/TChart.php");  // for Deploy
  14.  
  15.   /* use the following line in case that TeeChart for PHP library is placed on another place */
  16.   include ("E:\Steema\Root\TeeChart PHP\Version 1\sources\TChart.php");
  17.  
  18.  
  19. class TChartObj extends GraphicControl
  20. {
  21.         protected $_onclick = null;
  22.         protected $_chart = null;
  23.         protected $_axes = null;
  24.         protected $_legend = null;
  25.         protected $_title = null;
  26.         public $serialized;
  27.  
  28.         // Events
  29.  
  30.         //OnBeforeDrawAxes event
  31.         protected $_onBeforeDrawAxes = null;
  32.         function getOnBeforeDrawAxes(return $this->_onBeforeDrawAxes}
  33.         function setOnBeforeDrawAxes($value$this->_onBeforeDrawAxes = $value}
  34.         function defaultOnBeforeDrawAxes(return ""}
  35.  
  36.         //OnBeforeDrawSeries event
  37.         protected $_onBeforeDrawSeries = null;
  38.         function getOnBeforeDrawSeries(return $this->_onBeforeDrawSeries}
  39.         function setOnBeforeDrawSeries($value$this->_onBeforeDrawSeries = $value}
  40.         function defaultOnBeforeDrawSeries(return ""}
  41.  
  42.  
  43. //    function getAxes() { return $this->_axes; }
  44. //    function setAxes($value) { if(is_object($value)) $this->_axes = $value; }
  45.  
  46. //    function getLegend() { return $this->_legend; }
  47. //    function setLegend($value) { if(is_object($value)) $this->_legend = $value; }
  48.  
  49. //    function getTitle() { return $this->_title; }
  50. //    function setTitle($value) { if(is_object($value)) $this->_title = $value; }
  51.  
  52.         function __construct($aowner=null)
  53.         {
  54.                 //Calls inherited constructor
  55.                 parent::__construct($aowner);
  56.  
  57.                 $this->Width 400;
  58.                 $this->Height 250;
  59.  
  60.                 // Makes sure the framework knows that this component dumps binary image data
  61.                 $this->ControlStyle="csImageContent=1";
  62.  
  63.                 $this->ControlStyle="csRenderOwner=1";
  64.                 $this->ControlStyle="csRenderAlso=StyleSheet";
  65.  
  66.                 // Creates the chart
  67.                 $this->createChart();
  68.  
  69. /*                //Creates the axis properties
  70.                 $this->_axes = new Axes($this->_chart);
  71.                 $this->_axes->_control = $this;
  72.  
  73.                 //Creates the legend properties
  74.                 $this->_legend = new Legend($this->_chart);
  75.                 $this->_legend->_control = $this;
  76.  
  77.                 //Creates the legend properties
  78.                 $this->_title = new Title($this->_chart->getChart());
  79.                 $this->_title->_control = $this;
  80. */
  81.         }
  82.  
  83.         /**
  84.         * Creates a new chart and updates the protected chart variable.
  85.         * @return object Chart object.
  86.         */
  87.         function createChart()
  88.         {
  89.                     $this->_chart = new TChart($this->Width,$this->Height);
  90.                 return $this->_chart;
  91.         }
  92.  
  93.         function init()
  94.         {
  95.                 parent::init();
  96.  
  97.                 $submitEventValue $this->input->{$this->readJSWrapperHiddenFieldName()};
  98.  
  99.                 if (is_object($submitEventValue))
  100.                 {
  101.                         // Checks if the a click event has been fired
  102.                         if ($this->_onclick != null && $submitEventValue->asString(== $this->readJSWrapperSubmitEventValue($this->_onclick))
  103.                         {
  104.                                 $this->callEvent('onclick'array());
  105.                         }
  106.                 }
  107.         }
  108.  
  109.         function dumpHeaderCode()
  110.         {
  111.                 parent::dumpHeaderCode();
  112.                 // Dumps only the header if not in design mode
  113.                 if (($this->ControlState csDesigning!= csDesigning)
  114.                 {
  115.                         // Tries to prevent the browser from caching the image
  116.                         echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\" />\n";
  117.                 }
  118.         }
  119.  
  120.         /**
  121.          * Dumps the TChart graphic.
  122.          *
  123.          * This method dumps the chart graphic by dumping binary image data to the
  124.          * browser. The browser is instructed to show image data because of the headers
  125.          * sent first. You don't need to call this method directly.
  126.          *
  127.          * @see Control::readControlStyle()
  128.          * @link http://www.php.net/manual/en/function.header.php
  129.          */
  130.         function dumpGraphic()
  131.         {
  132.                 // Graphic component that dumps binary data
  133.                 header("Content-type: image/png");
  134.  
  135.                 // Tries to prevent the browser from caching the image
  136.                 header("Pragma: no-cache");
  137.                 header("Cache-Control: no-cache, must-revalidate")// HTTP/1.1
  138.                 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT")// Date in the past
  139.  
  140.                 $this->_chart->height $this->Height;
  141.                 $this->_chart->setWidth($this->Width);
  142.                 $this->_chart->doInvalidate();
  143.  
  144.                 $this->_chart->render();
  145.         }
  146.  
  147.         function serialize()
  148.         {
  149.                 parent::serialize();
  150.  
  151.                 // Serializes the TChart
  152.                 $owner $this->readOwner();
  153.                 if ($owner != null)
  154.                 {
  155.                      $prefix $owner->readNamePath().".".$this->_name.".TChartObj.";
  156.  
  157.                      $this->_chart->serialize($this->_chart,$prefix);
  158.                 }
  159.         }
  160.  
  161.         function unserialize()
  162.         {
  163.                 parent::unserialize();
  164.  
  165.                 // Unserializes the TChart
  166.                 $owner $this->readOwner();
  167.  
  168.                 if ($this->_chart != null && $owner != null)
  169.                 {
  170.                         $prefix $owner->readNamePath().".".$this->_name.".TChartObj.";
  171.                         $this->_chart->unserialize($this->_chart,$prefix);
  172.                 }
  173.  
  174.                 $key md5($this->owner->Name.$this->Name.$this->Left.$this->Top.$this->Width.$this->Height);
  175.                 $bchart $this->input->bchart;
  176.  
  177.  
  178.                 // Checks if the request is for this chart
  179.                 if ((is_object($bchart)) && ($bchart->asString(== $key))
  180.                 {
  181.                         $this->dumpGraphic();
  182.                 }
  183.         }
  184.  
  185.         function dumpContents()
  186.         {
  187.                 if (($this->ControlState csDesigning== csDesigning)
  188.                 {
  189.                         $this->dumpGraphic();
  190.                 }
  191.                 else
  192.                 {
  193.                         $events $this->readJsEvents();
  194.                         // Adds or replaces the JS events with the wrappers if necessary
  195.                         $this->addJSWrapperToEvents($events$this->_onclick,    $this->_jsonclick,    "onclick");
  196.  
  197.                         $hint $this->getHintAttribute();
  198.                         $alt htmlspecialchars($this->_chart->getChart()->getHeader()->getText());
  199.                         $style "";
  200.                         if ($this->Style=="")
  201.                         {
  202.                                 // Adds the cursor to the style
  203.                                 if ($this->_cursor != "")
  204.                                 {
  205.                                         $cr strtolower(substr($this->_cursor2));
  206.                                         $style .= "cursor: $cr;";
  207.                                 }
  208.                         }
  209.  
  210.                         $class ($this->Style != """class=\"$this->StyleClass\""";
  211.  
  212.                         if ($style != ""$style "style=\"$style\"";
  213.  
  214.                         if ($this->_onshow != null)
  215.                         {
  216.                                 $this->callEvent('onshow'array());
  217.                         }
  218.  
  219.                         $key md5($this->owner->Name.$this->Name.$this->Left.$this->Top.$this->Width.$this->Height);
  220.                         $url $_SERVER['PHP_SELF']//$GLOBALS
  221.                         // Outputs an image generated by a URL requesting this script
  222.                         echo "<img src=\"$url?bchart=$key\" width=\"$this->Width\" height=\"$this->Height\" id=\"$this->_name\" name=\"$this->_name\" alt=\"$alt\" $hint $style $class $events />";
  223.                 }
  224.         }
  225.  
  226.         function dumpFormItems()
  227.         {
  228.                         // Adds a hidden field so we can determine for which event the chart was fired
  229.                         if ($this->_onclick != null)
  230.                         {
  231.                                 $hiddenwrapperfield $this->readJSWrapperHiddenFieldName();
  232.                                 echo "<input type=\"hidden\" id=\"$hiddenwrapperfield\" name=\"$hiddenwrapperfield\" value=\"\" />";
  233.                         }
  234.         }
  235.  
  236.         function dumpJavascript()
  237.         {
  238.                 parent::dumpJavascript();
  239.  
  240.                 if ($this->_onclick != null && !defined($this->_onclick))
  241.                 {
  242.                         // Outputs the same function only once in case two
  243.                         // or more objects use the same OnClick event handler.
  244.                         // Otherwise, if for example two buttons use the same
  245.                         // OnClick event handler, it would be output twice.
  246.                         $def=$this->_onclick;
  247.                         define($def,1);
  248.  
  249.                         // Outputs the wrapper function
  250.                         echo $this->getJSWrapperFunction($this->_onclick);
  251.                 }
  252.         }
  253.  
  254.         function loaded()
  255.         {
  256.           parent::loaded();
  257.           $this->writeBackImage($this->_chart->getChart()->getPanel()->getImage());
  258.         }
  259.  
  260.         protected function writeBackImage($value)
  261.         {
  262.             $this->_chart->getChart()->getPanel()->setImage($this->fixupProperty($value));
  263.         }
  264.  
  265.  
  266.         /**
  267.         * Occurs when the user clicks the control.
  268.         * @return mixed 
  269.         */
  270.         function getOnClick                     (return $this->_onclick}
  271.         function setOnClick                     ($value$this->_onclick=$value}
  272.         function defaultOnClick                 (return null}
  273.  
  274.  
  275.         /*
  276.         * Publishes the JS events for the Chart component
  277.         */
  278.         function getjsOnClick                   (return $this->readjsOnClick()}
  279.         function setjsOnClick                   ($value$this->writejsOnClick($value)}
  280.  
  281.         function getjsOnDblClick                (return $this->readjsOnDblClick()}
  282.         function setjsOnDblClick                ($value$this->writejsOnDblClick($value)}
  283.  
  284.         function getjsOnMouseDown               (return $this->readjsOnMouseDown()}
  285.         function setjsOnMouseDown               ($value$this->writejsOnMouseDown($value)}
  286.  
  287.         function getjsOnMouseUp                 (return $this->readjsOnMouseUp()}
  288.         function setjsOnMouseUp                 ($value$this->writejsOnMouseUp($value)}
  289.  
  290.         function getjsOnMouseOver               (return $this->readjsOnMouseOver()}
  291.         function setjsOnMouseOver               ($value$this->writejsOnMouseOver($value)}
  292.  
  293.         function getjsOnMouseMove               (return $this->readjsOnMouseMove()}
  294.         function setjsOnMouseMove               ($value$this->writejsOnMouseMove($value)}
  295.  
  296.         function getjsOnMouseOut                (return $this->readjsOnMouseOut()}
  297.         function setjsOnMouseOut                ($value$this->writejsOnMouseOut($value)}
  298.  
  299.         function getjsOnKeyPress                (return $this->readjsOnKeyPress()}
  300.         function setjsOnKeyPress                ($value$this->writejsOnKeyPress($value)}
  301.  
  302.         function getjsOnKeyDown                 (return $this->readjsOnKeyDown()}
  303.         function setjsOnKeyDown                 ($value$this->writejsOnKeyDown($value)}
  304.  
  305.         function getjsOnKeyUp                   (return $this->readjsOnKeyUp()}
  306.         function setjsOnKeyUp                   ($value$this->writejsOnKeyUp($value)}
  307.  
  308.  
  309.         /**
  310.         * TChart object
  311.         * See the TChart class to understand the functionallity
  312.         * of the chart object.
  313.         *
  314.         * @link http://www.steema.com/products/teechart/php/documentation/
  315.         *
  316.         * @see getChart()
  317.         *
  318.         * @return object 
  319.         */
  320.         function readChart(return $this->_chart}
  321.  
  322.         function getParentShowHint(return $this->readParentShowHint()}
  323.         function setParentShowHint($value$this->writeParentShowHint($value)}
  324.  
  325.         function getShowHint(return $this->readShowHint()}
  326.         function setShowHint($value$this->writeShowHint($value)}
  327.  
  328.         function getStyle()             return $this->readstyle()}
  329.         function setStyle($value)       $this->writestyle($value)}
  330.  
  331.         function getVisible(return $this->readVisible()}
  332.         function setVisible($value$this->writeVisible($value)}
  333.  
  334.         // TChart - Designtime properties (Object Inspector)
  335.         // Published
  336.  
  337.         function getView3D(return $this->_chart->getChart()->getAspect()->getView3D()}
  338.         function setView3D($value$this->_chart->getChart()->getAspect()->setView3D($value)}
  339.  
  340.         function getTitle(return $this->_chart->getChart()->getHeader()->getText()}
  341.         function setTitle($value$this->_chart->getChart()->getHeader()->setText($value)}
  342.         function defaultTitle(return "TeeChart"}
  343.  
  344.         function getBorderRound(return $this->_chart->getChart()->getPanel()->getBorderRound()}
  345.         function setBorderRound($value$this->_chart->getChart()->getPanel()->setBorderRound($value)}
  346.         function defaultBorderRound(return 0}
  347.  
  348.         function getAxisBehind(return $this->_chart->getChart()->getAxes()->getDrawBehind()}
  349.         function setAxisBehind($value$this->_chart->getChart()->getAxes()->setDrawBehind($value)}
  350.         function defaultAxisBehind(return true}
  351.  
  352.         function getAxisVisible(return $this->_chart->getAxes()->getVisible()}
  353.         function setAxisVisible($value$this->_chart->getAxes()->setVisible($value)}
  354.         function defaultAxisVisible(return true}
  355.  
  356.         function getBackImageInside(return $this->_chart->getPanel()->getBackImageInside()}
  357.         function setBackImageInside($value$this->_chart->getPanel()->setBackImageInside($value)}
  358.         function defaultBackImageInside(return false}
  359.  
  360. //        function getBackWall() { return $this->_chart->getWalls()->getBack(); }
  361. //        function setBackWall($value) { if(is_object($value)) $this->_chart->getWalls()->backWall=$value; }
  362.  
  363. //        function getLeftAxis() { return $this->_chart->getAxes()->getLeft(); }
  364. //        function setLeftAxis($value) { if(is_object($value)) $this->_chart->getAxes()->left=$value; }
  365.  
  366. //        function getLegend() { return $this->_chart->getLegend(); }
  367. //        function setLegend($value) { if(is_object($value)) $this->_chart->setLegend($value); }
  368.  
  369.         function getChart3DPercent(return $this->_chart->getAspect()->getChart3DPercent()}
  370.         function setChart3DPercent($value$this->_chart->getAspect()->setChart3DPercent($value)}
  371.         function defaultChart3DPercent(return 15}
  372.  
  373.         function getClipPoints(return $this->_chart->getAspect()->getClipPoints()}
  374.         function setClipPoints($value$this->_chart->getAspect()->setClipPoints($value)}
  375.         function defaultClipPoints(return true}
  376.  
  377.         function getMarginBottom(return $this->_chart->getPanel()->getMarginBottom()}
  378.         function setMarginBottom($value$this->_chart->getPanel()->setMarginBottom($value)}
  379.         function defaultMarginBottom(return 4}
  380.  
  381.         function getMarginLeft(return $this->_chart->getPanel()->getMarginLeft()}
  382.         function setMarginLeft($value$this->_chart->getPanel()->setMarginLeft($value)}
  383.         function defaultMarginLeft(return 3}
  384.  
  385.         function getMarginRight(return $this->_chart->getPanel()->getMarginRight()}
  386.         function setMarginRight($value$this->_chart->getPanel()->setMarginRight($value)}
  387.         function defaultMarginRight(return 3}
  388.  
  389.         function getMarginTop(return $this->_chart->getPanel()->getMarginTop()}
  390.         function setMarginTop($value$this->_chart->getPanel()->setMarginTop($value)}
  391.         function defaultMarginTop(return 4}
  392.  
  393. }
  394. ?>

Documentation generated on Wed, 16 Jun 2010 12:08:29 +0200 by phpDocumentor 1.4.1