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

Source for file Smoothing.php

Documentation is available at Smoothing.php

  1. <?php
  2.  
  3. /**
  4.  * Smoothing class
  5.  *
  6.  * Description: Smoothing Function
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2009 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage functions
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16. class Smoothing extends Functions {
  17.  
  18.     private $interpolate true;
  19.     private $factor 4;
  20.  
  21.     public function Smoothing($c=null{
  22.         parent::Functions($c);
  23.         
  24.         $this->canUsePeriod = false;
  25.         $this->SingleSource=true;
  26.         $this->dPeriod = 1;
  27.     }
  28.  
  29.     /**
  30.      * When true, resulting smooth curves will pass exactly over source points.
  31.      * <br>
  32.      * When false, the smooth curves will not necessarily pass over source
  33.      * points. <br>
  34.      * Default value: true
  35.      *
  36.      * @return boolean 
  37.      */
  38.     public function getInterpolate({
  39.         return $this->interpolate;
  40.     }
  41.  
  42.     /**
  43.      * Resulting smooth curves will pass exactly over source points when true.
  44.      * <br>
  45.      * When false, the smooth curves will not necessarily pass over source
  46.      * points. <br>
  47.      * Default value: true
  48.      *
  49.      * @param value boolean
  50.      */
  51.     public function setInterpolate($value{
  52.         if ($this->interpolate != $value{
  53.             $this->interpolate $value;
  54.             $this->recalculate();
  55.         }
  56.     }
  57.  
  58.     /**
  59.      * The number of times the resulting smooth points are compared to source
  60.      * points. <br>
  61.      * For example, a value of 4 means the smooth points will be 4 times
  62.      * the number of source points. <br>
  63.      * The greater the factor value is, the smoother the resulting curves will
  64.      * be. <br>
  65.      * Default value: 4
  66.      *
  67.      * @return int 
  68.      */
  69.     public function getFactor({
  70.         return $this->factor;
  71.     }
  72.  
  73.     /**
  74.      * Sets the number of times the resulting smooth points are
  75.      * compared to source points. <br>
  76.      * Default value: 4
  77.      *
  78.      * @param value int
  79.      */
  80.     public function setFactor($value{
  81.         if ($this->factor != $value{
  82.             $this->factor max(1$value);
  83.             $this->recalculate();
  84.         }
  85.     }
  86.  
  87.     /**
  88.      * gets all points from Source series, performs a function operation on
  89.      * points and finally stores results in ParentSeries. <br>
  90.      *
  91.      * @param source ArrayList
  92.      */
  93.     public  function addPoints($source{
  94.         if (!$this->updating{
  95.             if ($source != null{
  96.                 if (sizeof($source0{
  97.                     $s $source[0];
  98.                     $this->getSeries()->clear();
  99.                     if ($s->getCount(0{
  100.                         $v $this->valueList($s);
  101.                         $sp new Spline();
  102.                         for ($t 0$t $s->getCount()$t++{
  103.                             $sp->addPoint($s->getXValues()->value[$t]$v->value[$t]);
  104.                             $sp->setKnuckle($tfalse);
  105.                         }
  106.                         $sp->setInterpolated($this->interpolate);
  107.                         $sp->setFragments($s->getCount($this->factor);
  108.  
  109.                         for ($t 0$t <= $sp->getFragments()$t++{
  110.                             $p $sp->value((double) $t $sp->getFragments());
  111.                             if ($this->getSeries()->getYMandatory()) {
  112.                               $this->getSeries()->addXY($p->x$p->y);
  113.                             else {
  114.                                 $this->getSeries()->addXY($p->y$p->x);
  115.                             }
  116.                         }
  117.                     }
  118.                 }
  119.             }
  120.         }
  121.     }
  122.  
  123.     /**
  124.      * Gets descriptive text.
  125.      *
  126.      * @return String 
  127.      */
  128.     public function getDescription({
  129.         return Language.getString("FunctionSmooth");
  130.     }
  131. }
  132. ?>

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