/** * Create the text * @param int $x The X position (horizontal) position of the text (center point) on the canvas * @param int $y The Y position (vertical) position of the text (center point) on the canvas * @param string $text The text to display * @param Font $font The font to use in printing */ function &Image_Graph_Text($x, $y, $text, & $font) { parent::__construct(); $this->_alignment = IMAGE_GRAPH_ALIGN_LEFT + IMAGE_GRAPH_ALIGN_TOP; $this->_font = & $font; $this->_setCoords($x, $y, $x, $y); $this->setText($text); }
/** * PlotType [Constructor] * @param Dataset $dataset The data set (value containter) to plot * @param string $title The title of the plot (used for legends, {@see Image_Graph_Legend}) */ function &Image_Graph_Plot(& $dataset, $title = "") { parent::__construct(); if ($dataset) { $this->_dataset = & $dataset; if ($title) { $this->_title = $title; } } }
/** * Logo [Constructor] * @param string $filename The filename and path of the image to use for logo */ function &Image_Graph_Logo($fileName, $alignment = IMAGE_GRAPH_ALIGN_TOP_RIGHT) { parent::__construct(); if (file_exists($fileName)) { if (strtolower(substr($fileName, -4)) == ".png") { $this->_image = ImageCreateFromPNG($this->_fileName = $fileName); } else { $this->_image = ImageCreateFromJPEG($this->_fileName = $fileName); } } else { $this->_image = false; } $this->_alignment = $alignment; }
/** * Logo [Constructor] * * @param string $filename The filename and path of the image to use for logo */ function Image_Graph_Logo($filename, $alignment = IMAGE_GRAPH_ALIGN_TOP_RIGHT) { parent::__construct(); $this->_filename = $filename; $this->_alignment = $alignment; }
/** * Rectangle [Construcor] * * @param int $x The leftmost pixel of the box on the canvas * @param int $y The topmost pixel of the box on the canvas * @param int $width The width in pixels of the box on the canvas * @param int $height The height in pixels of the box on the canvas */ function Image_Graph_Figure_Rectangle($x, $y, $width, $height) { parent::__construct(); $this->_setCoords($x, $y, $x + $width, $y + $height); }
/** * Image_Graph [Constructor]. * * If passing the 3 parameters they are defined as follows:' * * Fx.: * * $Graph =& new Image_Graph(400, 300); * * or using the factory method: * * $Graph =& Image_Graph::factory('graph', array(400, 300)); * * This causes a 'png' canvas to be created by default. * * Otherwise use a single parameter either as an associated array or passing * the canvas along to the constructor: * * 1) Create a new canvas with the following parameters: * * 'canvas' - The canvas type, can be any of 'gd', 'jpg', 'png' or 'svg' * (more to come) - if omitted the default is 'gd' * * 'width' - The width of the graph * * 'height' - The height of the graph * * An example of this usage: * * $Graph =& Image_Graph::factory('graph', array(array('width' => 400, * 'height' => 300, 'canvas' => 'jpg'))); * * NB! In thïs case remember the "double" array (see {@link Image_Graph:: * factory()}) * * 2) Use the canvas specified, pass a valid Image_Canvas as * parameter. Remember to pass by reference, i. e. &$canvas, fx.: * * $Graph =& new Image_Graph($Canvas); * * or using the factory method: * * $Graph =& Image_Graph::factory('graph', $Canvas)); * * @param mixed $params The width of the graph, an indexed array * describing a new canvas or a valid {@link Image_Canvas} object * @param int $height The height of the graph in pixels * @param bool $createTransparent Specifies whether the graph should be * created with a transparent background (fx for PNG's - note: transparent * PNG's is not supported by Internet Explorer!) */ function Image_Graph($params, $height = false, $createTransparent = false) { parent::__construct(); $this->setFont(Image_Graph::factory('Image_Graph_Font')); if (defined('IMAGE_GRAPH_DEFAULT_CANVAS_TYPE')) { $canvasType = IMAGE_GRAPH_DEFAULT_CANVAS_TYPE; } else { $canvasType = 'png'; // use GD as default, if nothing else is specified } if (is_array($params)) { if (isset($params['canvas'])) { $canvasType = $params['canvas']; } $width = 0; $height = 0; if (isset($params['width'])) { $width = $params['width']; } if (isset($params['height'])) { $height = $params['height']; } } elseif (is_a($params, 'Image_Canvas')) { $this->_canvas =& $params; $width = $this->_canvas->getWidth(); $height = $this->_canvas->getHeight(); } elseif (is_numeric($params)) { $width = $params; } if ($this->_canvas == null) { include_once 'Image/Canvas.php'; $this->_canvas =& Image_Canvas::factory($canvasType, array('width' => $width, 'height' => $height)); } $this->_setCoords(0, 0, $width - 1, $height - 1); }
/** * Ellipse [Constructor] * * @param int $x The center pixel of the ellipse on the canvas * @param int $y The center pixel of the ellipse on the canvas * @param int $radiusX The width in pixels of the box on the canvas * @param int $radiusY The height in pixels of the box on the canvas */ function Image_Graph_Figure_Ellipse($x, $y, $radiusX, $radiusY) { parent::__construct(); $this->_setCoords($x - $radiusX, $y - $radiusY, $x + $radiusX, $y + $radiusY); }
/** * Image_Graph_Axis [Constructor]. * Normally a manual creation should not be necessary, axis are created automatically * by the {@see Image_Graph_Plotarea} constructor unless explicitly defined otherwise * @param int $type The type (direction) of the Axis, use IMAGE_GRAPH_AXIS_X for an X-axis (default, may be omitted) and IMAGE_GRAPH_AXIS_Y for Y-axis) */ function &Image_Graph_Axis($type = IMAGE_GRAPH_AXIS_X) { parent::__construct(); $this->_type = $type; }
/** * Image_Graph_Layout [Constructor] * @access private */ function &_image_GraPHPite_Layout() { parent::__construct(); $this->_padding = 2; }
/** * Rectangle [Construcor] * * @param int $x The leftmost pixel of the box on the canvas * @param int $y The topmost pixel of the box on the canvas * @param int $width The width in pixels of the box on the canvas * @param int $height The height in pixels of the box on the canvas */ function __construct($x, $y, $width, $height) { parent::__construct(); $this->_setCoords($x, $y, $x + $width, $y + $height); }
/** * GraPHP [Constructor] * @param int $width The width of the graph in pixels * @param int $height The height of the graph in pixels */ function &Image_Graph($width, $height) { parent::__construct(); $this->_setCoords(0, 0, $width -1, $height -1); if (isset($GLOBALS['_Image_Graph_gd2'])) { $this->_canvas = ImageCreateTrueColor($width, $height); ImageAlphaBlending($this->_canvas(), true); } else { $this->_canvas = ImageCreate($width, $height); } if (file_exists($filename = (dirname(__FILE__)."/Graph/named_colors.txt"))) { $colorLines = file($filename); while (list ($id, $colorLine) = each($colorLines)) { list ($colorName, $colorRed, $colorGreen, $colorBlue) = explode("\t", trim($colorLine)); define("IMAGE_GRAPH_" . $colorName, ($colorRed << 16) + ($colorGreen << 8) + $colorBlue); } } define("IMAGE_GRAPH_TRANSPARENT", 0xabe123); $ID = ImageColorAllocate($this->_canvas, 0xab, 0xe1, 0x23); ImageColorTransparent($this->_canvas, $ID); $this->addFont($GLOBALS['_Image_Graph_font']); $this->addFont($GLOBALS['_Image_Graph_vertical_font']); ImageFilledRectangle($this->_canvas(), 0, 0, $width -1, $height -1, $this->_color(IMAGE_GRAPH_WHITE)); }
/** * Ellipse [Constructor] * * @param int $x The center pixel of the ellipse on the canvas * @param int $y The center pixel of the ellipse on the canvas * @param int $radiusX The width in pixels of the box on the canvas * @param int $radiusY The height in pixels of the box on the canvas */ function __construct($x, $y, $radiusX, $radiusY) { parent::__construct(); $this->_setCoords($x - $radiusX, $y - $radiusY, $x + $radiusX, $y + $radiusY); }