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

Source for file Area.php

Documentation is available at Area.php

  1. <?php
  2.  
  3. /**
  4.  * Area Class
  5.  *
  6.  * Description: Area Series
  7.  *
  8.  * @author
  9.  * @copyright Copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage styles
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16.  class Area extends Custom {
  17.  
  18.     private $useOrigin;
  19.     private $origin;
  20.  
  21.     // Interceptors
  22.     function __get$property {
  23.       $method ="get{$property}";
  24.       if method_exists$this$method ) ) {
  25.         return $this->$method();
  26.       }
  27.     }
  28.  
  29.     function __set $property,$value {
  30.       $method ="set{$property}";
  31.       if method_exists$this$method ) ) {
  32.         return $this->$method($value);
  33.       }
  34.     }
  35.  
  36.     public function Area($c=null{
  37.         parent::Custom($c);
  38.        
  39.         $this->drawArea = true;
  40.         $this->allowSinglePoint=false;
  41.         $this->getPointer()->setDefaultVisible(false);
  42.  
  43.         $tmpColor new Color(0,0,0);  // Black
  44.         $this->pAreaLines = new ChartPen($this->chart$tmpColor);
  45.         $this->pAreaLines->setVisible(false);
  46.         //$tmpColor->setEmpty(true);
  47.         $this->bAreaBrush = new ChartBrush($this->chart$this->bBrush->getColor()true)// TODO review $tmpColor->getEmpty());
  48.     }
  49.  
  50.         /**
  51.           * Determines how Multi-AreaSeries are displayed.<br>
  52.           * Determines the kind of displayed Area when there's more than one Area
  53.           * Series with the same ParentChart. The default value is None, meaning all
  54.           * Areas will be drawn one behind the other. <br>
  55.           * Stacked and Stacked100 modes will draw each Area on top of previous one.
  56.           * <br>
  57.           * Stacked100 adjusts each individual point to a common 0..100 axis scale.
  58.           * <br>
  59.           * The order which Series are accumulated depends on the Chart.SeriesList
  60.           * method.<br>
  61.           * Default value: None
  62.           *
  63.           * @see #setMultiArea
  64.           *
  65.           * @return MultiAreas 
  66.           */
  67.     public function getMultiArea({
  68.         if ($this->iStacked == CustomStack::$STACK{
  69.             return MultiAreas::$STACKED;
  70.         else
  71.         if ($this->iStacked == CustomStack::$STACK100{
  72.             return MultiAreas::$STACKED100;
  73.         else {
  74.             return MultiAreas::$NONE;
  75.         }
  76.     }
  77.  
  78.         /**
  79.           * Sets how multiple areas are displayed.
  80.           *
  81.           * @see #getMultiArea
  82.           * @param value MultiAreas
  83.           */
  84.     public function setMultiArea($value{
  85.         if ($value != $this->getMultiArea()) {
  86.             if ($value == MultiAreas::$NONE{
  87.                 $this->setStackedCustomStack::$NONE);
  88.             else
  89.             if ($value == MultiAreas::$STACKED{
  90.                 $this->setStackedCustomStack::$STACK);
  91.             else
  92.             if ($value == MultiAreas::$STACKED100{
  93.                 $this->setStackedCustomStack::$STACK100);
  94.             }
  95.         }
  96.     }
  97.  
  98.         /**
  99.           * Determines the Brush used to fill the background Area region.<br>
  100.           * You can control the Area background color by using the Series.Color
  101.           * method. <br>
  102.           * Default value: Solid
  103.           *
  104.           * @return ChartBrush 
  105.           */
  106.     public function getAreaBrush({
  107.         return $this->bAreaBrush;
  108.     }
  109.  
  110.         /**
  111.           *Determines how to fill the top 3D Area region.
  112.           *
  113.           * @return Gradient 
  114.           */
  115.     public function getTopGradient({
  116.         return $this->bBrush->getGradient();
  117.     }
  118.  
  119.         /**
  120.           * Determines Gradient to fill the background Area region.
  121.           * <p>Example:
  122.           * <pre><font face="Courier" size="4">
  123.           * areaSeries = new Area(myChart.getChart());
  124.           * areaSeries.getMarks().setVisible(false);
  125.           * areaSeries.setColor(Color.RED);
  126.           * areaSeries.fillSampleValues(10);
  127.           * areaSeries.setTransparency(0);
  128.           * areaSeries.setStacked(CustomStack.NONE);
  129.           *
  130.           * com.steema.teechart.drawing.Gradient tmpGradient = areaSeries.getGradient();
  131.           * tmpGradient.setVisible(true);
  132.           * tmpGradient.setUseMiddle(true);
  133.           * tmpGradient.setDirection(GradientDirection.HORIZONTAL);
  134.           * tmpGradient.setStartColor(Color.RED);
  135.           * tmpGradient.setMiddleColor(Color.BLUE);
  136.           * tmpGradient.setEndColor(Color.GREEN);
  137.           * tmpGradient.setTransparency(0);
  138.           * </font></pre></p>
  139.           *
  140.           * @return Gradient 
  141.           */
  142.     public function getGradient({
  143.         return $this->getAreaBrush()->getGradient();
  144.     }
  145.  
  146.         /**
  147.           * Obsolete.&nbsp;Please use AreaLines instead.
  148.           * @return ChartPen 
  149.           */
  150.     public function getAreaLinesPen({        
  151.         return $this->getAreaLines();        
  152.     }
  153.  
  154.         /**
  155.           * Determines Pen to draw AreaLines.<br>
  156.           * By default AreaLines .Visible is false, so you need first to set it to
  157.           * true. You can control the Area Brush style by using AreaBrush.<br>
  158.           * Default value: null
  159.           *
  160.           * @return ChartPen 
  161.           */
  162.     public function getAreaLines({
  163.         return $this->pAreaLines;
  164.     }
  165.  
  166.         /**
  167.           * Aligns bottom of AreaSeries to the Origin property value.<br>
  168.           * Default value: false
  169.           *
  170.           * @return boolean 
  171.           */
  172.     public function getUseOrigin({
  173.         return $this->useOrigin;
  174.     }
  175.  
  176.         /**
  177.           * Enables/disables the setting of the Y value (via the Origin
  178.           * property) that defines the bottom position for area points.
  179.           * Default value: false
  180.           *
  181.           * <p>Example:
  182.           * <pre><font face="Courier" size="4">
  183.           * areaSeries = new Area(myChart.getChart());
  184.           * areaSeries.getMarks().setVisible(false);
  185.           * areaSeries.fillSampleValues(20);
  186.           * areaSeries.setStacked(CustomStack.NONE);
  187.           * areaSeries.setUseOrigin(false);
  188.           * areaSeries.setOrigin(200);
  189.           * </font></pre></p>
  190.           *
  191.           * @see #getOrigin
  192.           * @param value boolean
  193.           */
  194.     public function setUseOrigin($value{
  195.         $this->useOrigin $this->setBooleanProperty($this->useOrigin$value);
  196.     }
  197.  
  198.         /**
  199.           * The axis value as a common bottom for all AreaSeries points.<br>
  200.           * Default value: O
  201.           *
  202.           * @return double 
  203.           */
  204.     public function getOrigin({
  205.         return $this->origin;
  206.     }
  207.  
  208.         /**
  209.           * Sets axis value as a common bottom for all AreaSeries points.<br>
  210.           * Default value: O
  211.           *
  212.           * <p>Example:
  213.           * <pre><font face="Courier" size="4">
  214.           * areaSeries = new Area(myChart.getChart());
  215.           * areaSeries.getMarks().setVisible(false);
  216.           * areaSeries.fillSampleValues(20);
  217.           * areaSeries.setStacked(CustomStack.NONE);
  218.           * areaSeries.setUseOrigin(false);
  219.           * areaSeries.setOrigin(200);
  220.           * </font></pre></p>
  221.           *
  222.           * @param value double
  223.           */
  224.     public function setOrigin($value{
  225.         $this->origin $this->setDoubleProperty($this->origin$value);
  226.     }
  227.  
  228.         /**
  229.           * Returns the highest of all the current Series Y point values.
  230.           *
  231.           * @return double 
  232.           */
  233.     public function getMaxYValue({
  234.          $result parent::getMaxYValue();
  235.         if ($this->yMandatory && $this->useOrigin && ($result $this->origin)) {
  236.             $result $this->origin;
  237.         }
  238.         return $result;
  239.     }
  240.  
  241.         /**
  242.           * Returns the Minimum Value of the Series Y Values List.<br>
  243.           * As some Series have more than one Y Values List, this Minimum Value is
  244.           * the "Minimum of Minimums" of all Series Y Values lists.
  245.           *
  246.           * @return double 
  247.           */
  248.     public function getMinYValue({
  249.          $result parent::getMinYValue();
  250.         if ($this->yMandatory && $this->useOrigin && ($result $this->origin)) {
  251.             $result $this->origin;
  252.         }
  253.         return $result;
  254.     }
  255.  
  256.         /**
  257.           * The Maximum Value of the Series X Values List.
  258.           *
  259.           * @return double 
  260.           */
  261.     public function getMaxXValue({
  262.          $result parent::getMaxXValue();
  263.         if ((!$this->yMandatory&& $this->useOrigin && ($result $this->origin)) {
  264.             $result $this->origin;
  265.         }
  266.         return $result;
  267.     }
  268.  
  269.         /**
  270.           * The Minimum Value of the Series X Values List.
  271.           *
  272.           * @return double 
  273.           */
  274.     public function getMinXValue({
  275.          $result parent::getMinXValue();
  276.         if ((!$this->yMandatory&& $this->useOrigin && ($result $this->origin)) {
  277.             $result $this->origin;
  278.         }
  279.         return $result;
  280.     }
  281.  
  282.         /**
  283.           * Gets descriptive text.
  284.           *
  285.           * @return String 
  286.           */
  287.     public function getDescription({
  288.         return Language::getString("GalleryArea");
  289.     }
  290.  
  291.     protected function getOriginPos($valueIndex{
  292.         if ($this->useOrigin{
  293.             return $this->calcPosValue($this->origin);
  294.         else {
  295.             return parent::getOriginPos($valueIndex);
  296.         }
  297.     }
  298.  
  299.     protected function prepareLegendCanvas($g$valueIndex$backColor,$aBrush{
  300.         $backColor $this->getAreaBrushColor($g->getBrush()->getForegroundColor());
  301.         $g->setPen($this->getAreaLines());
  302.         $aBrush $this->getAreaBrush();
  303.     }
  304.  
  305.     public function createSubGallery($addSubChart{
  306.         parent::createSubGallery($addSubChart);
  307.         $addSubChart->createSubChart(Language::getString("Stairs"));
  308.         $addSubChart->createSubChart(Language::getString("Marks"));
  309.         $addSubChart->createSubChart(Language::getString("Colors"));
  310.         $addSubChart->createSubChart(Language::getString("Hollow"));
  311.         $addSubChart->createSubChart(Language::getString("NoLines"));
  312.         //  AType.NumGallerySeries:=2;
  313.         $addSubChart->createSubChart(Language::getString("Stack"));
  314.         $addSubChart->createSubChart(Language::getString("Stack"));
  315.         //  AType.NumGallerySeries:=1;
  316.         $addSubChart->createSubChart(Language::getString("Points"));
  317.         $addSubChart->createSubChart(Language::getString("Gradient"));
  318.     }
  319.  
  320.     public function setSubGallery($index{
  321.         switch ($index{
  322.         case 1:
  323.             $this->setStairs(true);
  324.             break;
  325.         case 2:
  326.             $this->getMarks()->setVisible(true);
  327.             break;
  328.         case 3:
  329.             $this->setColorEach(true);
  330.             break;
  331.         case 4:
  332.             $this->getAreaBrush()->setVisible(false);
  333.             break;
  334.         case 5:
  335.             $this->getAreaLines()->setVisible(false);
  336.             break;
  337.         case 6:
  338.             $this->setMultiArea(MultiAreas::$STACKED);
  339.             break;
  340.         case 7:
  341.             $this->setMultiArea(MultiAreas::$STACKED100);
  342.             break;
  343.         case 8:
  344.             $this->getPointer()->setVisible(true);
  345.             break;
  346.         case 9:
  347.             $this->getGradient()->setVisible(true);
  348.             break;
  349.         defaultbreak;
  350.         }
  351.     }
  352. }
  353. ?>

Documentation generated on Wed, 16 Jun 2010 12:02:35 +0200 by phpDocumentor 1.4.1