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 / Simple.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  3.9 KB  |  121 lines

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * Image_Graph - Main class for the graph creation.
  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.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  24.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  25.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  26.  * @version    CVS: $Id: Simple.php,v 1.8 2005/08/24 20:35:54 nosey Exp $
  27.  * @link       http://pear.php.net/package/Image_Graph
  28.  */
  29.  
  30. /**
  31.  * Include file Image/Graph.php
  32.  */
  33. require_once 'Image/Graph.php';
  34.  
  35. /**
  36.  * Class for simple creation of graphs
  37.  *
  38.  * @category   Images
  39.  * @package    Image_Graph
  40.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  41.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  42.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  43.  * @version    Release: 0.7.2
  44.  * @link       http://pear.php.net/package/Image_Graph
  45.  */
  46. class Image_Graph_Simple extends Image_Graph
  47. {
  48.  
  49.     /**
  50.      * Image_Graph_Simple [Constructor]
  51.      *
  52.      * @param int $width The width of the graph in pixels
  53.      * @param int $height The height of the graph in pixels
  54.      */
  55.     function Image_Graph_Simple($width, $height, $plotType, $data, $title, $lineColor = 'black', $fillColor = 'white', $font = false)
  56.     {
  57.         parent::Image_Graph($width, $height);
  58.  
  59.         $plotarea =& Image_Graph::factory('plotarea');
  60.  
  61.         $dataset =& Image_Graph::factory('dataset', array($data));
  62.  
  63.         if ($font === false) {
  64.             $font =& Image_Graph::factory('Image_Graph_Font');
  65.         } elseif (is_string($font)) {
  66.             $font =& Image_Graph::factory('ttf_font', $font);
  67.             $font->setSize(8);
  68.         }
  69.  
  70.         $this->setFont($font);
  71.  
  72.         $this->add(
  73.             Image_Graph::vertical(
  74.                 Image_Graph::factory('title',
  75.                     array(
  76.                         $title,
  77.                         array('size_rel' => 2)
  78.                     )
  79.                 ),
  80.                 $plotarea,
  81.                 10
  82.             )
  83.         );
  84.  
  85.         $plotarea->addNew('line_grid', array(), IMAGE_GRAPH_AXIS_Y);
  86.  
  87.         $plot =& $plotarea->addNew($plotType, array(&$dataset));
  88.         $plot->setLineColor($lineColor);
  89.         $plot->setFillColor($fillColor);
  90.  
  91.         $axisX =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
  92.         $axisX->showLabel(
  93.             IMAGE_GRAPH_LABEL_MINIMUM +
  94.             IMAGE_GRAPH_LABEL_ZERO +
  95.             IMAGE_GRAPH_LABEL_MAXIMUM
  96.         );
  97.  
  98.     }
  99.  
  100.     /**
  101.      * Factory method to create the Image_Simple_Graph object.
  102.      */
  103.     function &factory($width, $height, $plotType, $data, $title, $lineColor = 'black', $fillColor = 'white', $font = false)
  104.     {
  105.         $obj =& Image_Graph::factory('Image_Graph_Simple',
  106.             array(
  107.                 $width,
  108.                 $height,
  109.                 $plotType,
  110.                 $data,
  111.                 $title,
  112.                 $lineColor,
  113.                 $fillColor,
  114.                 $font
  115.             )
  116.         );
  117.         return $obj;
  118.     }
  119.  
  120. }
  121. ?>