550, 'height' => 350); /** * Add a legend to the graph? * @var bool */ protected $legend = true; /** * Title of the graph * @var string */ protected $title = 'ISSO Pie Chart'; // ################################################################### /** * Constructor */ public function __construct() { $this->setScale(0); } // ################################################################### /** * Sets the width and height by using scale factors of 550x350; you * can specify a positive value to multiply by that many times or a * negative one to divide * * @param float Scale factor */ public function setScale($scale) { $this->dimensions['width'] = 550; $this->dimensions['height'] = 350; if ($scale > 0) { $this->dimensions['width'] *= $scale; $this->dimensions['height'] *= $scale; } else if ($scale < 0) { $scale = abs($scale); $this->dimensions['width'] /= $scale; $this->dimensions['height'] /= $scale; } if (!is_null($this->image)) { imagedestroy($this->image); } $this->image = imagecreate($this->dimensions['width'], $this->dimensions['height']); } // ################################################################### /** * Sets whether or not a legend is created for the graph * * @param bool Draw a legend? */ public function setLegend($yesno) { $this->legend = (bool)$yesno; } // ################################################################### /** * Sets the title of the chart to be drawn above the graph * * @param string Title of the chart */ public function setTitle($title) { $this->title = $title; } // ################################################################### /** * Graphs the actual data and returns then sends the image result to * the output buffer */ public abstract function graph(); // ################################################################### /** * Adds an entry to the data set without specifying a color to add. * This is the standard method as the color should only be overridden * if necessary. * * @param string Data column name * @param integer Amount */ public abstract function addDataSet($name, $amount); // ################################################################### /** * Adds an entry ot the data set with specifying a color. This works * the same as addDataSet() but requires an array() as the 3rd parameter * of R,G,B values * * @param string Data column name * @param integer Percent of 100 * @param array Array of R,G,B values */ public abstract function addDataSetColor($name, $amount, $color); // ################################################################### /** * Fetches a color from the allocated color list and returns the value * * @return integer Allocated color resource */ protected function _fetchColor() { static $colorlist = array( array(100, 60, 175), array(221, 110, 21), array(179, 34, 31), array(69, 196, 243), array(128, 186, 33), array(28, 101, 155), array(246, 204, 95), array(6, 43, 147), array(204, 61, 7), array(170, 169, 174), array(90, 15, 24), array(45, 130, 195) ); static $allocated = 0; $color = $colorlist["$allocated"]; $allocated++; return imagecolorallocate($this->image, $color[0], $color[1], $color[2]); } } /*=====================================================================* || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>