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 / Radar.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  3.9 KB  |  118 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.11 2005/11/27 22:21:16 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.  * Radar 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_Radar 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.         $p = 10;
  63.         $rx = abs($x1 - $x0) / 2;
  64.         $ry = abs($x1 - $x0) / 2;
  65.         $r = min($rx, $ry);
  66.         $cx = ($x0 + $x1) / 2;
  67.         $cy = ($y0 + $y1) / 2;
  68.         $max = 5;
  69.         for ($i = 0; $i < $p; $i++) {
  70.             $v = 2 * pi() * $i / $p;
  71.             $t = $r * rand(3, $max) / $max;
  72.             $x = $cx + $t * cos($v);
  73.             $y = $cy + $t * sin($v);
  74.             $this->_canvas->addVertex(array('x' => $x, 'y' => $y));
  75.         }
  76.         $this->_canvas->polygon(array('connect' => true));
  77.     }
  78.  
  79.     /**
  80.      * Output the plot
  81.      *
  82.      * @return bool Was the output 'good' (true) or 'bad' (false).
  83.      * @access private
  84.      */
  85.     function _done()
  86.     {
  87.         $this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
  88.         $this->_clip(true);
  89.         if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) {
  90.             $keys = array_keys($this->_dataset);
  91.             foreach ($keys as $key) {
  92.                 $dataset =& $this->_dataset[$key];
  93.                 $maxY = $dataset->maximumY();
  94.                 $count = $dataset->count();
  95.  
  96.                 $dataset->_reset();
  97.                 while ($point = $dataset->_next()) {
  98.                     $this->_canvas->addVertex(array('x' => 
  99.                         $this->_pointX($point), 'y' => 
  100.                         $this->_pointY($point)
  101.                     ));
  102.                 }
  103.                 $this->_getFillStyle($key);
  104.                 $this->_getLineStyle($key);
  105.                 $this->_canvas->polygon(array('connect' => true));
  106.             }
  107.             unset($keys);
  108.         }
  109.         $this->_drawMarker();
  110.  
  111.         $this->_clip(false);
  112.         $this->_canvas->endGroup();        
  113.         return parent::_done();
  114.     }
  115.  
  116. }
  117.  
  118. ?>