[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Image/Graph/Plot/ -> Band.php (source)

   1  <?php
   2  
   3  /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
   4  
   5  /**
   6   * Image_Graph - PEAR PHP OO Graph Rendering Utility.
   7   *
   8   * PHP versions 4 and 5
   9   *
  10   * LICENSE: This library is free software; you can redistribute it and/or modify
  11   * it under the terms of the GNU Lesser General Public License as published by
  12   * the Free Software Foundation; either version 2.1 of the License, or (at your
  13   * option) any later version. This library is distributed in the hope that it
  14   * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15   * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  16   * General Public License for more details. You should have received a copy of
  17   * the GNU Lesser General Public License along with this library; if not, write
  18   * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19   * 02111-1307 USA
  20   *
  21   * @category   Images
  22   * @package    Image_Graph
  23   * @subpackage Plot
  24   * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  25   * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  26   * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  27   * @version    CVS: $Id: Band.php,v 1.12 2005/11/27 22:21:16 nosey Exp $
  28   * @link       http://pear.php.net/package/Image_Graph
  29   * @since      File available since Release 0.3.0dev2
  30   */
  31  
  32  /**
  33   * Include file Image/Graph/Plot.php
  34   */
  35  require_once  'Image/Graph/Plot.php';
  36  
  37  /**
  38   * "Band" (area chart with min AND max) chart.
  39   *
  40   * @category   Images
  41   * @package    Image_Graph
  42   * @subpackage Plot
  43   * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  44   * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  45   * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  46   * @version    Release: 0.7.2
  47   * @link       http://pear.php.net/package/Image_Graph
  48   * @since      Class available since Release 0.3.0dev2
  49   */
  50  class Image_Graph_Plot_Band extends Image_Graph_Plot
  51  {
  52  
  53      /**
  54       * Perform the actual drawing on the legend.
  55       *
  56       * @param int $x0 The top-left x-coordinate
  57       * @param int $y0 The top-left y-coordinate
  58       * @param int $x1 The bottom-right x-coordinate
  59       * @param int $y1 The bottom-right y-coordinate
  60       * @access private
  61       */
  62      function _drawLegendSample($x0, $y0, $x1, $y1)
  63      {
  64          $h = abs($y1 - $y0) / 6;
  65          $w = round(abs($x1 - $x0) / 5);
  66          $y = ($y0 + $y1) / 2;
  67  
  68          $this->_canvas->addVertex(array('x' => $x0, 'y' => $y - $h * 3));
  69          $this->_canvas->addVertex(array('x' => $x0 + $w, 'y' => $y - 4 * $h));
  70          $this->_canvas->addVertex(array('x' => $x0 + 2 * $w, 'y' => $y - $h * 2));
  71          $this->_canvas->addVertex(array('x' => $x0 + 3 * $w, 'y' => $y - $h * 4));
  72          $this->_canvas->addVertex(array('x' => $x0 + 4 * $w, 'y' => $y - $h * 3));
  73          $this->_canvas->addVertex(array('x' => $x1, 'y' => $y - $h * 2));
  74          $this->_canvas->addVertex(array('x' => $x1, 'y' => $y + $h * 3));
  75          $this->_canvas->addVertex(array('x' => $x0 + 4 * $w, 'y' => $y + $h));
  76          $this->_canvas->addVertex(array('x' => $x0 + 3 * $w, 'y' => $y + 2 * $h));
  77          $this->_canvas->addVertex(array('x' => $x0 + 2 * $w, 'y' => $y + 1 * $h));
  78          $this->_canvas->addVertex(array('x' => $x0 + 1 * $w, 'y' => $y));
  79          $this->_canvas->addVertex(array('x' => $x0, 'y' => $y + $h));
  80  
  81          $this->_getLineStyle();
  82          $this->_getFillStyle();
  83          $this->_canvas->polygon(array('connect' => true));
  84      }
  85  
  86      /**
  87       * Output the plot
  88       *
  89       * @return bool Was the output 'good' (true) or 'bad' (false).
  90       * @access private
  91       */
  92      function _done()
  93      {
  94          if (parent::_done() === false) {
  95              return false;
  96          }
  97  
  98          if (!is_array($this->_dataset)) {
  99              return false;
 100          }
 101  
 102          $current = array();
 103  
 104          $this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
 105  
 106          $this->_clip(true);        
 107  
 108  
 109          $keys = array_keys($this->_dataset);
 110          foreach ($keys as $key) {
 111              $dataset =& $this->_dataset[$key];
 112              $dataset->_reset();
 113              $upperBand = array();
 114              $lowerBand = array();
 115              while ($data = $dataset->_next()) {
 116                  if ($this->_parent->_horizontal) {
 117                      $point['X'] = $data['X'];
 118      
 119                      $point['Y'] = $data['Y']['high'];
 120                      $y = $this->_pointY($point);
 121                      $x_high = $this->_pointX($point);
 122      
 123                      $point['Y'] = $data['Y']['low'];
 124                      $x_low = $this->_pointX($point);
 125         
 126                      $data = array('X' => $x_high, 'Y' => $y);
 127                      if (isset($point['data'])) {
 128                          $data['data'] = $point['data'];
 129                      } else {
 130                          $data['data'] = array();
 131                      }             
 132                      $upperBand[] = $data;
 133                      
 134                      $data = array('X' => $x_low, 'Y' => $y);
 135                      if (isset($point['data'])) {
 136                          $data['data'] = $point['data'];
 137                      } else {
 138                          $data['data'] = array();
 139                      }              
 140                      $lowerBand[] = $data;
 141                  }
 142                  else {
 143                      $point['X'] = $data['X'];
 144                      $y = $data['Y'];
 145      
 146                      $point['Y'] = $data['Y']['high'];
 147                      $x = $this->_pointX($point);
 148                      $y_high = $this->_pointY($point);
 149      
 150                      $point['Y'] = $data['Y']['low'];
 151                      $y_low = $this->_pointY($point);
 152         
 153                      $data = array('X' => $x, 'Y' => $y_high);
 154                      if (isset($point['data'])) {
 155                          $data['data'] = $point['data'];
 156                      } else {
 157                          $data['data'] = array();
 158                      }             
 159                      $upperBand[] = $data;
 160                      
 161                      $data = array('X' => $x, 'Y' => $y_low);
 162                      if (isset($point['data'])) {
 163                          $data['data'] = $point['data'];
 164                      } else {
 165                          $data['data'] = array();
 166                      }              
 167                      $lowerBand[] = $data;
 168                  }
 169              }
 170              $lowerBand = array_reverse($lowerBand);
 171              foreach ($lowerBand as $point) {
 172                  $this->_canvas->addVertex(
 173                      $this->_mergeData(
 174                          $point['data'],
 175                          array('x' => $point['X'], 'y' => $point['Y'])
 176                      )
 177                  );
 178              }
 179              foreach ($upperBand as $point) {
 180                  $this->_canvas->addVertex(                
 181                      $this->_mergeData(
 182                          $point['data'],
 183                          array('x' => $point['X'], 'y' => $point['Y'])
 184                      )
 185                  );
 186              }
 187              unset($upperBand);
 188              unset($lowerBand);
 189  
 190              $this->_getLineStyle($key);
 191              $this->_getFillStyle($key);
 192              $this->_canvas->polygon(array('connect' => true, 'map_vertices' => true));
 193          }
 194          unset($keys);
 195          $this->_drawMarker();
 196          $this->_clip(false);        
 197  
 198          $this->_canvas->endGroup();
 199  
 200          return true;
 201      }
 202  
 203  }
 204  
 205  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7