[ 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/ -> Impulse.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: Impulse.php,v 1.13 2005/11/27 22:21:17 nosey Exp $
  28   * @link       http://pear.php.net/package/Image_Graph
  29   */
  30  
  31  /**
  32   * Include file Image/Graph/Plot.php
  33   */
  34  require_once  'Image/Graph/Plot.php';
  35  
  36  /**
  37   * Impulse chart.
  38   *
  39   * @category   Images
  40   * @package    Image_Graph
  41   * @subpackage Plot
  42   * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  43   * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  44   * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  45   * @version    Release: 0.7.2
  46   * @link       http://pear.php.net/package/Image_Graph
  47   */
  48  class Image_Graph_Plot_Impulse extends Image_Graph_Plot
  49  {
  50  
  51      /**
  52       * Perform the actual drawing on the legend.
  53       *
  54       * @param int $x0 The top-left x-coordinate
  55       * @param int $y0 The top-left y-coordinate
  56       * @param int $x1 The bottom-right x-coordinate
  57       * @param int $y1 The bottom-right y-coordinate
  58       * @access private
  59       */
  60      function _drawLegendSample($x0, $y0, $x1, $y1)
  61      {
  62          $x = ($x0 + $x1) / 2;
  63          $this->_canvas->line(array('x0' => $x, 'y0' => $y0, 'x1' => $x, 'y1' => $y1));
  64      }
  65  
  66      /**
  67       * Output the plot
  68       *
  69       * @return bool Was the output 'good' (true) or 'bad' (false).
  70       * @access private
  71       */
  72      function _done()
  73      {
  74          if (parent::_done() === false) {
  75              return false;
  76          }
  77  
  78          if (!is_array($this->_dataset)) {
  79              return false;
  80          }
  81          
  82          $this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
  83          $this->_clip(true);       
  84  
  85          if ($this->_multiType == 'stacked100pct') {
  86              $total = $this->_getTotals();
  87          }
  88          $current = array();
  89          $number = 0;
  90  
  91          $minYaxis = $this->_parent->_getMinimum($this->_axisY);
  92          $maxYaxis = $this->_parent->_getMaximum($this->_axisY);
  93  
  94          $keys = array_keys($this->_dataset);
  95          foreach ($keys as $key) {
  96              $dataset =& $this->_dataset[$key];
  97              $dataset->_reset();
  98              while ($point = $dataset->_next()) {
  99                  $x0 = $this->_pointX($point);
 100                  if (($this->_multiType == 'stacked') ||
 101                      ($this->_multiType == 'stacked100pct'))
 102                  {
 103                      $x = $point['X'];
 104  
 105                      if ($point['Y'] >= 0) {
 106                          if (!isset($current[$x])) {
 107                              $current[$x] = 0;
 108                          }
 109  
 110                          if ($this->_multiType == 'stacked') {
 111                              $p0 = array(
 112                                  'X' => $point['X'],
 113                                  'Y' => $current[$x]
 114                              );
 115                              $p1 = array(
 116                                  'X' => $point['X'],
 117                                  'Y' => $current[$x] + $point['Y']
 118                              );
 119                          } else {
 120                              $p0 = array(
 121                                  'X' => $point['X'],
 122                                  'Y' => 100 * $current[$x] / $total['TOTAL_Y'][$x]
 123                              );
 124                              $p1 = array(
 125                                  'X' => $point['X'],
 126                                  'Y' => 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x]
 127                              );
 128                          }
 129                          $current[$x] += $point['Y'];
 130                      } else {
 131                          if (!isset($currentNegative[$x])) {
 132                              $currentNegative[$x] = 0;
 133                          }
 134  
 135                          $p0 = array(
 136                                  'X' => $point['X'],
 137                                  'Y' => $currentNegative[$x]
 138                              );
 139                          $p1 = array(
 140                                  'X' => $point['X'],
 141                                  'Y' => $currentNegative[$x] + $point['Y']
 142                              );
 143                          $currentNegative[$x] += $point['Y'];
 144                      }
 145                  } else {
 146                      $p0 = array('X' => $point['X'], 'Y' => 0);
 147                      $p1 = $point;
 148                  }
 149  
 150                  if ((($minY = min($p0['Y'], $p1['Y'])) < $maxYaxis) &&
 151                      (($maxY = max($p0['Y'], $p1['Y'])) > $minYaxis)
 152                  ) {
 153                      $p0['Y'] = $minY;
 154                      $p1['Y'] = $maxY;
 155  
 156                      if ($p0['Y'] < $minYaxis) {
 157                          $p0['Y'] = '#min_pos#';
 158                      }
 159                      if ($p1['Y'] > $maxYaxis) {
 160                          $p1['Y'] = '#max_neg#';
 161                      }
 162  
 163                      $x1 = $this->_pointX($p0);
 164                      $y1 = $this->_pointY($p0);
 165  
 166                      $x2 = $this->_pointX($p1);
 167                      $y2 = $this->_pointY($p1);
 168  
 169                      if ($this->_multiType == 'normal') {
 170                          $offset = 5*$number;
 171                          $x1 += $offset;
 172                          $x2 += $offset;
 173                      }
 174  
 175                      $ID = $point['ID'];
 176                      if (($ID === false) && (count($this->_dataset) > 1)) {
 177                          $ID = $key;
 178                      }
 179                      $this->_getLineStyle($key);
 180                      $this->_canvas->line(
 181                          $this->_mergeData(
 182                              $point,
 183                              array(
 184                                  'x0' => $x1, 
 185                                  'y0' => $y1, 
 186                                  'x1' => $x2, 
 187                                  'y1' => $y2
 188                              )
 189                          )
 190                      );
 191                  }
 192              }
 193              $number++;
 194          }
 195          unset($keys);
 196          $this->_drawMarker();
 197          $this->_clip(false);
 198          $this->_canvas->endGroup();        
 199          return true;
 200      }
 201  
 202  }
 203  
 204  ?>


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