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

Source for file Pyramid.php

Documentation is available at Pyramid.php

  1. <?php
  2.  
  3. /**
  4.  * Pyramid class
  5.  *
  6.  * Description: Pyramid Series
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @link http://www.steema.com
  13.  */
  14.  
  15.  class Pyramid extends Series {
  16.  
  17.     private $size 50;
  18.     private $pen;
  19.  
  20.     public function Pyramid($c=null{
  21.         parent::Series($c);
  22.         
  23.         $this->calcVisiblePoints = false;
  24.         $this->setColorEach(true);
  25.     }
  26.  
  27.     /**
  28.     * The size of Pyramid base relative to Chart Axis bounding width.<br>
  29.     * Default value: 50
  30.     *
  31.     * <p>Example:
  32.     * <pre><font face="Courier" size="4">
  33.     * series.setSizePercent(60);
  34.     * </font></pre></p>
  35.     *
  36.     * @return int 
  37.     */
  38.     public function getSizePercent({
  39.         return $this->size;
  40.     }
  41.  
  42.     /**
  43.     * Sets size of Pyramid base relative to Chart Axis bounding width.<br>
  44.     * Default value: 50
  45.     *
  46.     * @param value int
  47.     */
  48.     public function setSizePercent($value{
  49.         $this->size $this->setIntegerProperty($this->size$value);
  50.     }
  51.  
  52.     /**
  53.     * Element Pen characteristics.
  54.     *
  55.     * @return ChartPen 
  56.     */
  57.     public function getPen({
  58.         if ($this->pen == null{
  59.             $this->pen new ChartPen($this->chartColor::BLACK());
  60.         }
  61.         return $this->pen;
  62.     }
  63.  
  64.     /**
  65.     * Sets Brush characteristics for the Pyramid Series.
  66.     *
  67.     * @return ChartBrush 
  68.     */
  69.     public function getBrush({
  70.         return $this->bBrush;
  71.     }
  72.  
  73.     private function acumUpTo($upToIndex{
  74.         $result 0;
  75.         for $t 0$t <= $upToIndex$t++{
  76.             $result += $this->mandatory->value[$t];
  77.         }
  78.         return $result;
  79.     }
  80.  
  81.     public function calcHorizMargins($margins{
  82.         $margins->min 20;
  83.         $margins->max 20;
  84.     }
  85.  
  86.     protected function drawMark($valueIndex$s$position{
  87.         $position->leftTop->$this->getVertAxis()->calcPosValue($this->acumUpTo($valueIndex));
  88.         parent::drawMark($valueIndex$s$position);
  89.     }
  90.  
  91.     /**
  92.     * Called internally. Draws the "ValueIndex" point of the Series.
  93.     *
  94.     * @param valueIndex int
  95.     */
  96.     public function drawValue($valueIndex{
  97.         if (!$this->isNull($valueIndex)) {
  98.             $this->chart->setBrushCanvas($this->getValueColor($valueIndex)$this->getBrush(),
  99.                                  $this->getBrush()->getColor());
  100.  
  101.             $this->chart->getGraphics3D()->setPen($this->getPen());
  102.  
  103.             $tmp $this->acumUpTo($valueIndex 1);
  104.             $tmpTrunc 100.0 ($tmp 100.0 $this->getMandatory()->getTotal());
  105.  
  106.             $tmpSize round($this->getSizePercent($this->getHorizAxis()->iAxisSize 0.005);
  107.             $tmpX round($tmpTrunc $tmpSize 0.01);
  108.  
  109.             $r new Rectangle();
  110.             $r->$this->getHorizAxis()->calcPosValue($this->getMinXValue()) $tmpX;
  111.             $r->width $tmpX;
  112.  
  113.             $tmpTruncZ 100.0 $tmpTrunc;
  114.             $tmpZ ($tmpTruncZ 0?
  115.                    round($tmpTruncZ ($this->getEndZ($this->getStartZ()) *
  116.                                        0.0050;
  117.  
  118.             $r->height $this->getVertAxis()->calcPosValue($tmp);
  119.  
  120.             $tmp += $this->mandatory->value[$valueIndex];
  121.             $r->$this->getVertAxis()->calcPosValue($tmp);
  122.  
  123.             $r->height -= $r->y;
  124.  
  125.             $tmpTrunc 100.0 ($tmp 100.0 $this->mandatory->getTotal());
  126.  
  127.             $tmpZ2 ($tmpTrunc 100?
  128.                     round($tmpTrunc ($this->getEndZ($this->getStartZ()) *
  129.                                         0.0050;
  130.  
  131.             $this->chart->getGraphics3D()->pyramidTrunc($r$this->getStartZ($tmpZ,
  132.                $this->getEndZ($tmpZround($tmpTrunc $tmpSize 0.01)$tmpZ2);
  133.         }
  134.     }
  135.  
  136.     /**
  137.     * Returns whether the Series needs to draw points in ascending/descending
  138.     * order.<br>
  139.     * Some Series need to draw their points in descending order (starting
  140.     * from the last point to the first) depending on certain situations.
  141.     * For example, when the horizontal axis Inverted property is true.
  142.     *
  143.     * @return boolean 
  144.     */
  145.     public function drawValuesForward({
  146.         return!$this->getVertAxis()->getInverted();
  147.     }
  148.  
  149.     /**
  150.     * The Maximum Value of the Series X Values List.
  151.     *
  152.     * @return double 
  153.     */
  154.     public function getMaxXValue({
  155.         return $this->getMinXValue();
  156.     }
  157.  
  158.     /**
  159.     * The Maximum Value of the Series Y Values List.
  160.     *
  161.     * @return double 
  162.     */
  163.     public function getMaxYValue({
  164.         return $this->mandatory->getTotalABS();
  165.     }
  166.  
  167.     /**
  168.     * The Minimum Value of the Series X Values List.
  169.     *
  170.     * @return double 
  171.     */
  172.     public function getMinXValue({
  173.         return $this->chart->getSeriesIndexOf($this);
  174.     }
  175.  
  176.     /**
  177.     * The Minimum Value of the Series Y Values List.
  178.     *
  179.     * @return double 
  180.     */
  181.     public function getMinYValue({
  182.         return 0;
  183.     }
  184.  
  185.     /**
  186.     * Gets descriptive text.
  187.     *
  188.     * @return String 
  189.     */
  190.     public function getDescription({
  191.         return Language::getString("GalleryPyramid");
  192.     }
  193. }
  194.  
  195. ?>

Documentation generated on Wed, 16 Jun 2010 12:07:31 +0200 by phpDocumentor 1.4.1