home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Image / Graph / Plot / Smoothed / Radar.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  5.1 KB  |  142 lines

  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: Radar.php,v 1.10 2005/11/27 22:21:17 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/Smoothed/Bezier.php
  34.  */
  35. require_once 'Image/Graph/Plot/Smoothed/Bezier.php';
  36.  
  37. /**
  38.  * Smoothed radar 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_Smoothed_Radar extends Image_Graph_Plot_Smoothed_Bezier
  51. {
  52.  
  53.     /**
  54.      * Output the plot
  55.      *
  56.      * @return bool Was the output 'good' (true) or 'bad' (false).
  57.      * @access private
  58.      */
  59.     function _done()
  60.     {
  61.         $this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
  62.         $this->_clip(true);
  63.         if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) {
  64.             $keys = array_keys($this->_dataset);
  65.             foreach ($keys as $key) {
  66.                 $dataset =& $this->_dataset[$key];
  67.                 if ($dataset->count() >= 3) {
  68.                     $dataset->_reset();
  69.                     $p1_ = $dataset->_next();
  70.                     $p2_ = $dataset->_next();
  71.                     $p3_ = $dataset->_next();
  72.                     $plast_ = false;
  73.                     if ($p3_) {
  74.                         while ($p = $dataset->_next()) {
  75.                             $plast_ = $p;
  76.                         }
  77.                     }
  78.  
  79.                     if ($plast_ === false) {
  80.                         $plast_ = $p3_;
  81.                     }
  82.                     $dataset->_reset();
  83.                     while ($p1 = $dataset->_next()) {
  84.                         $p0 = $dataset->_nearby(-2);
  85.                         $p2 = $dataset->_nearby(0);
  86.                         $p3 = $dataset->_nearby(1);
  87.  
  88.                         if ($p0 === false) {
  89.                             $p0 = $plast_;
  90.                         }
  91.  
  92.                         if ($p2 === false) {
  93.                             $p2 = $p1_;
  94.                             $p3 = $p2_;
  95.                         } elseif ($p3 === false) {
  96.                             $p3 = $p1_;
  97.                         }
  98.  
  99.  
  100.                         $cp = $this->_getControlPoints($p1, $p0, $p2, $p3);
  101.                         $this->_canvas->addSpline(
  102.                             array(
  103.                                 'x' => $cp['X'],
  104.                                 'y' => $cp['Y'],
  105.                                 'p1x' => $cp['P1X'],
  106.                                 'p1y' => $cp['P1Y'],
  107.                                 'p2x' => $cp['P2X'],
  108.                                 'p2y' => $cp['P2Y']
  109.                             )
  110.                         );
  111.  
  112.                         $next2last = $p0;
  113.                         $last = $p1;
  114.                     }
  115.  
  116.                     $cp = $this->_getControlPoints($p1_, $plast_, $p2_, $p3_);
  117.                     $this->_canvas->addSpline(
  118.                         array(
  119.                             'x' => $cp['X'],
  120.                             'y' => $cp['Y'],
  121.                             'p1x' => $cp['P1X'],
  122.                             'p1y' => $cp['P1Y'],
  123.                             'p2x' => $cp['P2X'],
  124.                             'p2y' => $cp['P2Y']
  125.                         )
  126.                     );
  127.                     $this->_getFillStyle($key);
  128.                     $this->_getLineStyle($key);
  129.                     $this->_canvas->polygon(array('connect' => true));
  130.                 }
  131.             }
  132.             unset($keys);
  133.         }
  134.         $this->_drawMarker();
  135.         $this->_clip(false);
  136.         $this->_canvas->endGroup($this->_title);
  137.         return parent::_done();
  138.     }
  139.  
  140. }
  141.  
  142. ?>