2012-07-27 Miguel de Dios <miguel.dedios@artica.es>

* include/Image/Graph/*, include/Image/Graph.php,
	include/Image/Canvas/*, include/Image/Canvas.php,
	include/Image/Color.php: deleted unused old code.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6820 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-27 08:53:20 +00:00
parent 45e4e10193
commit 765cb7860b
116 changed files with 6 additions and 26379 deletions

View File

@ -1,3 +1,9 @@
2012-07-27 Miguel de Dios <miguel.dedios@artica.es>
* include/Image/Graph/*, include/Image/Graph.php,
include/Image/Canvas/*, include/Image/Canvas.php,
include/Image/Color.php: deleted unused old code.
2012-07-27 Junichi Satoh <junichi@rworks.jp>
* godmode/setup/setup.php: Changed to use DateTimeZone instead of

View File

@ -1,711 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Canvas.php,v 1.5 2005/09/30 18:59:35 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Specfies the path to the system location of font files.
*
* Remember trailing slash!
*
* This is set by default on Windows systems to %SystemRoot%\Fonts\
*/
if (!defined('IMAGE_CANVAS_SYSTEM_FONT_PATH')) {
if (isset($_SERVER['SystemRoot'])) {
define('IMAGE_CANVAS_SYSTEM_FONT_PATH', $_SERVER['SystemRoot'] . '/Fonts/');
} else {
/**
* @ignore
*/
define('IMAGE_CANVAS_SYSTEM_FONT_PATH', '');
}
}
/**
* Class for handling different output formats
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @abstract
*/
class Image_Canvas
{
/**
* The leftmost pixel of the element on the canvas
* @var int
* @access private
*/
var $_left = 0;
/**
* The topmost pixel of the element on the canvas
* @var int
* @access private
*/
var $_top = 0;
/**
* The width of the graph
* @var int
* @access private
*/
var $_width = 0;
/**
* The height of the graph
* @var int
* @access private
*/
var $_height = 0;
/**
* Polygon vertex placeholder
* @var array
* @access private
*/
var $_polygon = array();
/**
* The thickness of the line(s)
* @var int
* @access private
*/
var $_thickness = 1;
/**
* The line style
* @var mixed
* @access private
*/
var $_lineStyle = 'transparent';
/**
* The fill style
* @var mixed
* @access private
*/
var $_fillStyle = 'transparent';
/**
* The font options
* @var array
* @access private
*/
var $_font = array();
/**
* The default font
* @var array
* @access private
*/
var $_defaultFont = array('name' => 'Courier New', 'color' => 'black', 'size' => 9);
/**
* Create the canvas.
*
* Parameters available:
*
* 'width' The width of the graph on the canvas
*
* 'height' The height of the graph on the canvas
*
* 'left' The left offset of the graph on the canvas
*
* 'top' The top offset of the graph on the canvas
*
* @param array $params Parameter array
* @abstract
*/
function Image_Canvas($params)
{
if (isset($params['left'])) {
$this->_left = $params['left'];
}
if (isset($params['top'])) {
$this->_top = $params['top'];
}
if (isset($params['width'])) {
$this->_width = $params['width'];
}
if (isset($params['height'])) {
$this->_height = $params['height'];
}
$this->setDefaultFont($this->_defaultFont);
}
/**
* Get the x-point from the relative to absolute coordinates
*
* @param float $x The relative x-coordinate (in percentage of total width)
* @return float The x-coordinate as applied to the canvas
* @access private
*/
function _getX($x)
{
return floor($this->_left + $x);
}
/**
* Get the y-point from the relative to absolute coordinates
*
* @param float $y The relative y-coordinate (in percentage of total width)
* @return float The y-coordinate as applied to the canvas
* @access private
*/
function _getY($y)
{
return floor($this->_top + $y);
}
/**
* Get the width of the canvas
*
* @return int The width
*/
function getWidth()
{
return $this->_width;
}
/**
* Get the height of the canvas
*
* @return int The height
*/
function getHeight()
{
return $this->_height;
}
/**
* Sets the thickness of the line(s) to be drawn
*
* @param int $thickness The actual thickness (in pixels)
*/
function setLineThickness($thickness)
{
$this->_thickness = $thickness;
}
/**
* Sets the color of the line(s) to be drawn
*
* @param mixed $color The color of the line
*/
function setLineColor($color)
{
$this->_lineStyle = $color;
}
/**
* Sets the style of the filling of drawn objects.
*
* This method gives simple access to setFillColor(), setFillImage() and
* setGradientFill()
*
* @param mixed $fill The fill style
*/
function setFill($fill)
{
if (is_array($fill)) {
$this->setGradientFill($fill);
} elseif (file_exists($fill)) {
$this->setFillImage($fill);
} else {
$this->setFillColor($fill);
}
}
/**
* Sets the color of the filling of drawn objects
*
* @param mixed $color The fill color
*/
function setFillColor($color)
{
$this->_fillStyle = $color;
}
/**
* Sets an image that should be used for filling
*
* @param string $filename The filename of the image to fill with
*/
function setFillImage($filename)
{
}
/**
* Sets a gradient fill
*
* @param array $gradient Gradient fill options
*/
function setGradientFill($gradient)
{
$this->_fillStyle = $gradient;
}
/**
* Sets the font options.
*
* The $font array may have the following entries:
*
* 'name' The name of the font. This name must either be supported
* natively by the canvas or mapped to a font using the font-mapping scheme
*
* 'size' Size in pixels
*
* 'angle' The angle with which to write the text
*
* @param array $fontOptions The font options.
*/
function setFont($fontOptions)
{
$this->_font = $fontOptions;
if (!isset($this->_font['color'])) {
$this->_font['color'] = 'black';
}
if (!(isset($this->_font['angle'])) || ($this->_font['angle'] === false)) {
$this->_font['angle'] = 0;
}
if (isset($this->_font['angle'])) {
if ((($this->_font['angle'] > 45) && ($this->_font['angle'] < 135)) ||
(($this->_font['angle'] > 225) && ($this->_font['angle'] < 315))
) {
$this->_font['vertical'] = true;
}
}
if ((!isset($this->_font['file'])) && (isset($this->_font['name']))) {
include_once 'Image/Canvas/Tool.php';
$this->_font['file'] = Image_Canvas_Tool::fontMap($this->_font['name']);
}
}
function setClipping($params = false)
{
}
/**
* Sets the default font options.
*
* The $font array may have the following entries:
*
* 'name' The name of the font. This name must either be supported
* natively by the canvas or mapped to a font using the font-mapping scheme
*
* 'size' Size in pixels
*
* 'angle' The angle with which to write the text
*
* @param array $fontOptions The font options.
*/
function setDefaultFont($fontOptions)
{
$this->setFont($fontOptions);
$this->_defaultFont = $this->_font;
}
/**
* Resets the canvas.
*
* Includes fillstyle, linestyle, thickness and polygon
*
* @access private
*/
function _reset()
{
$this->_lineStyle = false;
$this->_fillStyle = false;
$this->_thickness = 1;
$this->_polygon = array();
$this->_font = $this->_defaultFont;
}
/**
* Draw a line end
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* 'end': string The end type of the end
* 'angle': int [optional] The angle with which to draw the end
* @param array $params Parameter array
*/
function drawEnd($params)
{
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'end0': string [optional] The end type of end0 (the start)
* 'end1': string [optional] The end type of end1 (the end)
* 'size0': int [optional] The size of end0
* 'size1': int [optional] The size of end1
* 'color': mixed [optional] The line color
* @param array $params Parameter array
*/
function line($params)
{
$x0 = $this->_getX($params['x0']);
$y0 = $this->_getY($params['y0']);
$x1 = $this->_getX($params['x1']);
$y1 = $this->_getY($params['y1']);
if (isset($params['end0'])) {
$angle = Image_Canvas_Tool::getAngle($x1, $y1, $x0, $y0);
$this->drawEnd(
array(
'end' => $params['end0'],
'x' => $params['x0'],
'y' => $params['y0'],
'angle' => $angle,
'color' => (isset($params['color0']) ? $params['color0'] : false),
'size' => $params['size0']
)
);
}
if (isset($params['end1'])) {
$angle = Image_Canvas_Tool::getAngle($x0, $y0, $x1, $y1);
$this->drawEnd(
array(
'end' => $params['end1'],
'x' => $params['x1'],
'y' => $params['y1'],
'angle' => $angle,
'color' => (isset($params['color1']) ? $params['color1'] : false),
'size' => $params['size1']
)
);
}
$this->_reset();
}
/**
* Adds vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* 'url': string [optional] URL to link the vertex to (must be used with 'map_vertices' in polygon() on a canvas that support image maps)
* 'alt': string [optional] Alternative text to show in the image map (must be used with 'map_vertices' in polygon() on a canvas that support image maps)
* 'target': string [optional] The link target on the image map (must be used with 'map_vertices' in polygon() on a canvas that support image maps)
* 'mapsize': int [optional] The size of the "map", i.e. the size of the hot spot (must be used with 'map_vertices' in polygon() on a canvas that support image maps)
* @param array $params Parameter array
*/
function addVertex($params)
{
$params['X'] = $this->_getX($params['x']);
$params['Y'] = $this->_getY($params['y']);
$this->_polygon[] = $params;
}
/**
* Adds "splined" vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* 'p1x': int X Control point 1
* 'p1y': int Y Control point 1
* 'p2x': int X Control point 2
* 'p2y': int Y Control point 2
* 'url': string [optional] URL to link the vertex to (must be used with 'map_vertices' in polygon() on a canvas that support image maps)
* 'alt': string [optional] Alternative text to show in the image map (must be used with 'map_vertices' in polygon() on a canvas that support image maps)
* 'target': string [optional] The link target on the image map (must be used with 'map_vertices' in polygon() on a canvas that support image maps)
* 'mapsize': int [optional] The size of the "map", i.e. the size of the hot spot (must be used with 'map_vertices' in polygon() on a canvas that support image maps)
* @param array $params Parameter array
*/
function addSpline($params)
{
$params['X'] = $this->_getX($params['x']);
$params['Y'] = $this->_getY($params['y']);
$params['P1X'] = $this->_getX($params['p1x']);
$params['P1Y'] = $this->_getY($params['p1y']);
$params['P2X'] = $this->_getX($params['p2x']);
$params['P2Y'] = $this->_getY($params['p2y']);
$this->_polygon[] = $params;
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function polygon($params)
{
$this->_reset();
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
$this->_reset();
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
$this->_reset();
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
$this->_reset();
}
/**
* Get the width of a text,
*
* @param string $text The text to get the width of
* @return int The width of the text
*/
function textWidth($text)
{
}
/**
* Get the height of a text,
*
* @param string $text The text to get the height of
* @return int The height of the text
*/
function textHeight($text)
{
}
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
$this->_reset();
}
/**
* Overlay image
*
* Parameter array:
* 'x': int X-point of overlayed image
* 'y': int Y-point of overlayed image
* 'filename': string The filename of the image to overlay
* 'width': int [optional] The width of the overlayed image (resizing if possible)
* 'height': int [optional] The height of the overlayed image (resizing if possible)
* 'alignment': array [optional] Alignment
*/
function image($params)
{
}
/**
* Start a group.
*
* What this does, depends on the canvas/format.
*
* @param string $name The name of the group
*/
function startGroup($name = false)
{
}
/**
* End the "current" group.
*
* What this does, depends on the canvas/format.
*/
function endGroup()
{
}
/**
* Output the result of the canvas to the browser
*
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function show($params = false)
{
if ($params === false) {
header('Expires: Tue, 2 Jul 1974 17:41:00 GMT'); // Date in the past
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
header('Pragma: no-cache');
}
}
/**
* Save the result of the canvas to a file
*
* Parameter array:
* 'filename': string The file to output to
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function save($params = false)
{
}
/**
* Get a canvas specific HTML tag.
*
* This method implicitly saves the canvas to the filename in the
* filesystem path specified and parses it as URL specified by URL path
*
* Parameter array:
* 'filename': string
* 'filepath': string Path to the file on the file system. Remember the final slash
* 'urlpath': string Path to the file available through an URL. Remember the final slash
*/
function toHtml($params)
{
$this->save(array('filename' => $params['filepath'] . $params['filename']));
}
/**
* Canvas factory method.
*
* Supported canvass are:
*
* 'png': output in PNG format (using GD)
*
* 'jpg': output in JPEG format (using GD)
*
* 'pdf': output in PDF format (using PDFlib)
*
* 'svg': output in SVG format
*
* 'imagemap': output as a html image map
*
* An example of usage:
*
* <code>
* <?php
* $Canvas =& Image_Graph::factory('png',
* array('width' => 800, 'height' => 600, 'antialias' => 'native')
* );
* ?>
* </code>
*
* @param string $canvas The canvas type
* @param array $params The parameters for the canvas constructor
* @return Image_Canvas The newly created canvas
* @static
*/
function &factory($canvas, $params)
{
$canvas = strtoupper($canvas);
if (($canvas == 'PNG') || ($canvas == 'GD')) {
$canvas = 'GD_PNG';
}
if (($canvas == 'JPG') || ($canvas == 'JPEG')) {
$canvas = 'GD_JPG';
}
if ($canvas == 'IMAGEMAP') {
$canvas = 'ImageMap';
}
$class = 'Image_Canvas_'. $canvas;
include_once 'Image/Canvas/'. str_replace('_', '/', $canvas) . '.php';
$obj =& new $class($params);
return $obj;
}
}
?>

View File

@ -1,182 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+
//
// $Id: Color.php,v 1.3 2005/09/14 17:25:46 nosey Exp $
/**
* Class for color-handling
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @category images
* @license The PHP License, version 2.02
*/
/**
* Color class to be extended; from package PEAR::Image_Color
*/
require_once 'Image/Color.php';
/**
* Class for color-handling
*
* This is used to extend the functionality of the current PEAR::Image_Color v0.4.
* I hope to be allowed to incorporate some of the improvements in a new Image_Color release.
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @access public
*/
class Image_Canvas_Color extends Image_Color
{
/**
* Allocates a color in the given image.
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param resource GD-resource
* @param mixed any color representation supported by color2RGB()
* @return resource Image color handle
* @see color2RGB()
* @access public
* @static
*/
function allocateColor(&$img, $color)
{
$color = Image_Canvas_Color::color2RGB($color);
if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) {
return imagecolorallocate($img, $color[0], $color[1], $color[2]);
} else {
return imagecolorallocatealpha($img, $color[0], $color[1], $color[2], 127-round(($color[3]*127)/255));
}
}
/**
* Convert any color-representation into an array of 4 ints (RGBA).
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param mixed any color representation supported by Image_Canvas_Color::color2RGB()
* @return array Array of 4 ints (RGBA-representation)
* @access public
* @static
*/
function color2RGB($color)
{
if (is_array($color)) {
if (!is_numeric($color[0])) {
return null; // error
}
if (count($color) == 3) { // assume RGB-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
255);
}
if (count($color) == 4) { // assume RGBA-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
(int) $color[3]);
}
return null; // error
} elseif (is_string($color)) {
$alphaPos = strpos($color, '@');
if ($alphaPos === false) {
$alpha = 255;
} else {
$alphaFloat = (float) substr($color, $alphaPos+1);
// restrict to range 0..1
$alphaFloat = max(min($alphaFloat, 1), 0);
$alpha = (int) round((float) 255 * $alphaFloat);
$color = substr($color, 0, $alphaPos);
}
if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4
$tempColor = parent::hex2rgb($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
if (strpos($color,'%') !== false) {
$tempColor = parent::percentageColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
} else {
$tempColor = parent::namedColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
} else {
return null; // error
}
}
/**
* getRange
* Given a degree, you can get the range of colors between one color and
* another color.
*
* @access public
* @param string How much each 'step' between the colors we should take.
* @return array Returns an array of all the colors, one element for each color.
*/
function getRange ($degrees)
{
$tempColors = parent::getRange($degrees);
// now add alpha-channel information
$steps = count($tempColors);
for($counter=0;$counter<$steps;$counter++) {
$tempColors[$counter] = parent::hex2rgb($tempColors[$counter]);
unset($tempColors[$counter]['hex']);
$tempColors[$counter][3] = (int) round(
(((float) $this->color1[3]*($steps-$counter))+
((float) $this->color2[3]*($counter))
) / $steps
);
}
return $tempColors;
}
/**
* Internal method to correctly set the colors.
*
* @param mixed color 1
* @param mixed color 2
* @access private
*/
function _setColors ( $col1, $col2 )
{
$this->color1 = Image_Canvas_Color::color2RGB($col1);
$this->color2 = Image_Canvas_Color::color2RGB($col2);
}
}
?>

View File

@ -1,12 +0,0 @@
This is where the font files are located.
Font files can be found at:
MS CoreFonts
http://corefonts.sourceforge.net/
Divide By Zero (most are cartoonish)
http://fonts.tom7.com/
MING FDB Fonts
http://ming.sf.net/

View File

@ -1,25 +0,0 @@
Arial,arial.ttf
Arial Bold,arialbd.ttf
Arial Bold Italic,arialbi.ttf
Arial Italic,ariali.ttf
Courier New,cour.ttf
Courier New Bold,courbd.ttf
Courier New Bold Italic,courbi.ttf
Courier New Italic,couri.ttf
Garamond,gara.ttf
Garamond Bold,garabd.ttf
Garamond Italic,garait.ttf
Gothic,gothic.ttf
Gothic Bold,gothicb.ttf
Gothic Bold Italic,gothicbi.ttf
Gothic Italic,gothici.ttf
Sans Serif,micross.ttf
Reference Sans Serif,refsan.ttf
Times New Roman,times.ttf
Times New Roman Bold,timesbd.ttf
Times New Roman Bold Italic,timesbi.ttf
Times New Roman Italic,timesi.ttf
Verdana,verdana.ttf
Verdana Bold,verdanab.ttf
Verdana Bold Italic,verdanaz.ttf
Verdana Italic,verdanai.ttf

File diff suppressed because it is too large Load Diff

View File

@ -1,119 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle JPEG format.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: JPG.php,v 1.2 2005/08/24 20:37:34 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* JPEG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_JPG extends Image_Canvas_GD
{
/**
* The JPEG quality
* @var int
* @access private
*/
var $_quality = 75;
/**
* Create the JPEG canvas
*
* Additional parameters other than those available for common {@link
* Image_Graph_Canvas_GD} class are:
*
* 'quality' The JPEG quality in as a percentage value from 0 (lowest
* quality, smallest file) to 100 (highest quality, biggest file)
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_JPG($param)
{
parent::Image_Canvas_GD($param);
if (isset($param['quality'])) {
$this->_quality = max(0, min(100, $param['quality']));
}
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/jpg');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.jpg\"');
ImageJPEG($this->_canvas, '', $this->_quality);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImageJPEG($this->_canvas, $param['filename'], $this->_quality);
ImageDestroy($this->_canvas);
}
}
?>

View File

@ -1,125 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle PNG format.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: PNG.php,v 1.3 2005/08/24 20:37:34 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* PNG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_PNG extends Image_Canvas_GD
{
/**
* Create the PNG canvas
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_PNG($param)
{
parent::Image_Canvas_GD($param);
if ((isset($param['transparent'])) && ($param['transparent']) &&
($this->_gd2)
) {
if ($param['transparent'] === true) {
$transparent = '#123ABD';
} else {
$transparent = $param['transparent'];
}
$color = $this->_color($transparent);
$trans = ImageColorTransparent($this->_canvas, $color);
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'opague',
'line' => 'transparent'
)
);
} else {
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/png');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.png\"');
ImagePNG($this->_canvas);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImagePNG($this->_canvas, $param['filename']);
ImageDestroy($this->_canvas);
}
}
?>

View File

@ -1,354 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Class for handling output as a HTML imagemap
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: ImageMap.php,v 1.6 2005/08/17 17:59:11 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling output as a HTML imagemap
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
*/
class Image_Canvas_ImageMap extends Image_Canvas
{
/**
* The image map (if any)
* @var array
* @access private
*/
var $_map = array();
/**
* Add a map tag
* @param string $shape The shape, either rect, circle or polygon
* @param string $coords The list of coordinates for the shape
* @param array $params Parameter array
*/
function _addMapTag($shape, $coords, $params)
{
if (isset($params['url'])) {
$url = $params['url'];
$target = (isset($params['target']) ? $params['target'] : false);
$alt = (isset($params['alt']) ? $params['alt'] : false);
$tags = '';
if (isset($params['htmltags'])) {
foreach ($params['htmltags'] as $key => $value) {
$tags .= ' ';
if (strpos($value, '"') >= 0) {
$tags .= $key . '=\'' . $value . '\'';
} else {
$tags .= $key . '="' . $value . '"';
}
}
}
$this->_map[] =
'<area shape="' . $shape . '" coords="' . $coords . '" href="' . $url . '"' .
($target ? ' target="' . $target . '"' : '') .
($alt ? ' alt="' . $alt . '"' : '') .
(isset($params['id']) ? ' id="' . $params['id'] . '"' : '') .
$tags .
'>';
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* 'mapsize': int [optional] The size of the image map (surrounding the line)
* @param array $params Parameter array
*/
function line($params)
{
if (isset($params['url'])) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
$this->_addMapTag(
'polygon',
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] + $mapsize) . ',' .
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] + $mapsize),
$params
);
}
parent::line($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* 'map_vertices': bool [optional] Specifies whether the image map should map the vertices instead of the polygon as a whole
* 'url': string [optional] URL to link the polygon as a whole to (also used for default in case 'map_vertices' is used)
* 'alt': string [optional] Alternative text to show in the image map (also used for default in case 'map_vertices' is used)
* 'target': string [optional] The link target on the image map (also used for default in case 'map_vertices' is used)
* @param array $params Parameter array
*/
function polygon($params)
{
if ((isset($params['map_vertices'])) && ($params['map_vertices'] === true)) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
foreach ($this->_polygon as $point) {
$vertex_param = $params;
if (isset($point['url'])) {
$vertex_param['url'] = $point['url'];
}
if (isset($point['target'])) {
$vertex_param['target'] = $point['target'];
}
if (isset($point['alt'])) {
$vertex_param['alt'] = $point['alt'];
}
$vertex_mapsize = $mapsize;
if (isset($point['mapsize'])) {
$vertex_mapsize = $point['mapsize'];
}
if (isset($point['htmltags'])) {
$vertex_param['htmltags'] = $point['htmltags'];
}
$this->_addMapTag(
'circle',
$this->_getX($point['X']) . ',' .
$this->_getY($point['Y']) . ',' .
$mapsize,
$vertex_param
);
}
}
else if (isset($params['url'])) {
$points = '';
foreach ($this->_polygon as $point) {
if ($points != '') {
$points .= ',';
}
$points .= $this->_getX($point['X']) . ',' . $this->_getY($point['Y']);
}
$this->_addMapTag('polygon', $points, $params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($params['url'])) {
$this->_addMapTag(
'rect',
$this->_getX($params['x0']) . ',' .
$this->_getY($params['y0']) . ',' .
$this->_getX($params['x1']) . ',' .
$this->_getY($params['y1']),
$params
);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($params['url'])) {
if ($params['rx'] == $params['ry']) {
$this->_addMapTag(
'circle',
$this->_getX($params['x']) . ',' .
$this->_getY($params['y']) . ',' .
$this->_getX($params['rx']),
$params
);
} else {
$points = '';
for ($v = 0; $v <= 360; $v += 30) {
if ($points != '') {
$points .= ',';
}
$points .=
round($this->_getX($params['x']) + $this->_getX($params['rx']) * cos(deg2rad($v % 360))) . ',' .
round($this->_getY($params['y']) + $this->_getX($params['ry']) * sin(deg2rad($v % 360)));
}
$this->_addMapTag(
'polygon',
$points,
$params
);
}
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($params['url'])) {
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$rx = $params['rx'];
$ry = $params['ry'];
$v1a = $params['v1'];
$v2a = $params['v2'];
$v1 = min($v1a, $v2a);
$v2 = max($v1a, $v2a);
$srx = (isset($params['srx']) ? $params['srx'] : 0);
$sry = (isset($params['sry']) ? $params['sry'] : 0);
$points =
round(($x + $srx * cos(deg2rad($v1 % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v1 % 360)))) . ',';
for ($v = $v1; $v < $v2; $v += 30) {
$points .=
round(($x + $rx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v % 360)))) . ',';
}
$points .=
round(($x + $rx * cos(deg2rad($v2 % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v2 % 360))));
if (($srx != 0) || ($sry != 0)) {
$points .= ',';
for ($v = $v2; $v > $v1; $v -= 30) {
$points .=
round(($x + $srx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v % 360)))) . ',';
}
}
$this->_addMapTag('polygon', $points, $params);
}
parent::pieslice($params);
}
/**
* Output the result of the canvas to the browser
*
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function show($params = false)
{
parent::show($params);
if (count($this->_map) > 0) {
print $this->toHtml($params);
}
}
/**
* Save the result of the canvas to a file
*
* Parameter array:
* 'filename': string The file to output to
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function save($params = false)
{
parent::save($params);
$file = fopen($param['filename'], 'w+');
fwrite($file, $this->toHtml($params));
fclose($file);
}
/**
* Get a canvas specific HTML tag.
*
* Parameter array:
* 'name': string The name of the image map
*/
function toHtml($params)
{
if (count($this->_map) > 0) {
return '<map name="' . $params['name'] . '">' . "\n\t" . implode($this->_map, "\n\t") . "\n</map>";
}
return '';
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,885 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for handling output in SVG format.
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: SVG.php,v 1.6 2005/08/24 20:37:35 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas.php
*/
require_once 'Image/Canvas.php';
/**
* Include file Image/Canvas/Color.php
*/
require_once 'Image/Canvas/Color.php';
/**
* SVG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_SVG extends Image_Canvas
{
/**
* The SVG elements
* @var string
* @access private
*/
var $_elements = '';
/**
* The SVG defines
* @var string
* @access private
*/
var $_defs = '';
/**
* The current indention level
* @var string
* @access private
*/
var $_indent = ' ';
/**
* A unieuq id counter
* @var int
* @access private
*/
var $_id = 1;
/**
* The current group ids
* @var array
* @access private
*/
var $_groupIDs = array();
/**
* Create the SVG canvas.
*
* Parameters available:
*
* 'width' The width of the graph
*
* 'height' The height of the graph
*
* @param array $param Parameter array
*/
function Image_Canvas_SVG($param)
{
parent::Image_Canvas($param);
$this->_reset();
}
/**
* Add a SVG "element" to the output
*
* @param string $element The element
* @access private
*/
function _addElement($element, $params) {
$elementdata = $this->_indent . $element . "\n";
if (isset($params['url'])) {
$url = $params['url'];
$target = (isset($params['target']) ? $params['target'] : false);
$alt = (isset($params['alt']) ? $params['alt'] : false);
$tags = '';
if (isset($params['htmltags'])) {
foreach ($params['htmltags'] as $key => $value) {
$tags .= ' ';
if (strpos($value, '"') >= 0) {
$tags .= $key . '=\'' . $value . '\'';
} else {
$tags .= $key . '="' . $value . '"';
}
}
}
$elementdata =
$this->_indent . '<a xlink:href="' . $url . '"' . ($target ? ' target="' . $target . '"' : '') . '>' . "\n" .
' ' . $elementdata .
$this->_indent . '</a>' . "\n";
}
$this->_elements .= $elementdata;
}
/**
* Add a SVG "define" to the output
*
* @param string $def The define
* @access private
*/
function _addDefine($def) {
$this->_defs .= ' ' . $def . "\n";
}
/**
* Get the color index for the RGB color
*
* @param int $color The color
* @return int A SVG compatible color
* @access private
*/
function _color($color = false)
{
if ($color === false) {
return 'transparent';
} else {
$color = Image_Canvas_Color::color2RGB($color);
return 'rgb(' . $color[0] . ',' . $color[1] . ',' . $color[2] . ')';
}
}
/**
* Get the opacity for the RGB color
*
* @param int $color The color
* @return int A SVG compatible opacity value
* @access private
*/
function _opacity($color = false)
{
if ($color === false) {
return false;
} else {
$color = Image_Canvas_Color::color2RGB($color);
if ($color[3] != 255) {
return sprintf('%0.1f', $color[3]/255);
} else {
return false;
}
}
}
/**
* Get the SVG applicable linestyle
*
* @param mixed $lineStyle The line style to return, false if the one
* explicitly set
* @return mixed A SVG compatible linestyle
* @access private
*/
function _getLineStyle($lineStyle = false)
{
$result = '';
if ($lineStyle === false) {
$lineStyle = $this->_lineStyle;
}
// TODO Linestyles (i.e. fx. dotted) does not work
if (($lineStyle != 'transparent') && ($lineStyle !== false)) {
$result = 'stroke-width:' . $this->_thickness . ';';
$result .= 'stroke:' .$this->_color($lineStyle) . ';';
if ($opacity = $this->_opacity($lineStyle)) {
$result .= 'stroke-opacity:' . $opacity . ';';
}
}
return $result;
}
/**
* Get the SVG applicable fillstyle
*
* @param mixed $fillStyle The fillstyle to return, false if the one
* explicitly set
* @return mixed A SVG compatible fillstyle
* @access private
*/
function _getFillStyle($fillStyle = false)
{
$result = '';
if ($fillStyle === false) {
$fillStyle = $this->_fillStyle;
}
if (is_array($fillStyle)) {
if ($fillStyle['type'] == 'gradient') {
$id = 'gradient_' . ($this->_id++);
$startColor = $this->_color($fillStyle['start']);
$endColor = $this->_color($fillStyle['end']);
$startOpacity = $this->_opacity($fillStyle['start']);
$endOpacity = $this->_opacity($fillStyle['end']);
switch ($fillStyle['direction']) {
case 'horizontal':
case 'horizontal_mirror':
$x1 = '0%';
$y1 = '0%';
$x2 = '100%';
$y2 = '0%';
break;
case 'vertical':
case 'vertical_mirror':
$x1 = '0%';
$y1 = '100%';
$x2 = '0%';
$y2 = '0%';
break;
case 'diagonal_tl_br':
$x1 = '0%';
$y1 = '0%';
$x2 = '100%';
$y2 = '100%';
break;
case 'diagonal_bl_tr':
$x1 = '0%';
$y1 = '100%';
$x2 = '100%';
$y2 = '0%';
break;
case 'radial':
$cx = '50%';
$cy = '50%';
$r = '100%';
$fx = '50%';
$fy = '50%';
break;
}
if ($fillStyle['direction'] == 'radial') {
$this->_addDefine(
'<radialGradient id="' . $id . '" cx="' .
$cx .'" cy="' . $cy .'" r="' . $r .'" fx="' .
$fx .'" fy="' . $fy .'">'
);
$this->_addDefine(
' <stop offset="0%" style="stop-color:' .
$startColor. ';' . ($startOpacity ? 'stop-opacity:' .
$startOpacity . ';' : ''). '"/>'
);
$this->_addDefine(
' <stop offset="100%" style="stop-color:' .
$endColor. ';' . ($endOpacity ? 'stop-opacity:' .
$endOpacity . ';' : ''). '"/>'
);
$this->_addDefine(
'</radialGradient>'
);
} elseif (($fillStyle['direction'] == 'vertical_mirror') ||
($fillStyle['direction'] == 'horizontal_mirror'))
{
$this->_addDefine(
'<linearGradient id="' . $id . '" x1="' .
$x1 .'" y1="' . $y1 .'" x2="' . $x2 .'" y2="' .
$y2 .'">'
);
$this->_addDefine(
' <stop offset="0%" style="stop-color:' .
$startColor. ';' . ($startOpacity ? 'stop-opacity:' .
$startOpacity . ';' : ''). '"/>'
);
$this->_addDefine(
' <stop offset="50%" style="stop-color:' .
$endColor. ';' . ($endOpacity ? 'stop-opacity:' .
$endOpacity . ';' : ''). '"/>'
);
$this->_addDefine(
' <stop offset="100%" style="stop-color:' .
$startColor. ';' . ($startOpacity ? 'stop-opacity:' .
$startOpacity . ';' : ''). '"/>'
);
$this->_addDefine(
'</linearGradient>'
);
} else {
$this->_addDefine(
'<linearGradient id="' . $id . '" x1="' .
$x1 .'" y1="' . $y1 .'" x2="' . $x2 .'" y2="' .
$y2 .'">'
);
$this->_addDefine(
' <stop offset="0%" style="stop-color:' .
$startColor. ';' . ($startOpacity ? 'stop-opacity:' .
$startOpacity . ';' : ''). '"/>'
);
$this->_addDefine(
' <stop offset="100%" style="stop-color:' .
$endColor. ';' . ($endOpacity ? 'stop-opacity:' .
$endOpacity . ';' : ''). '"/>'
);
$this->_addDefine(
'</linearGradient>'
);
}
return 'fill:url(#' . $id . ');';
}
} elseif (($fillStyle != 'transparent') && ($fillStyle !== false)) {
$result = 'fill:' . $this->_color($fillStyle) . ';';
if ($opacity = $this->_opacity($fillStyle)) {
$result .= 'fill-opacity:' . $opacity . ';';
}
return $result;
} else {
return 'fill:none;';
}
}
/**
* Sets an image that should be used for filling
*
* @param string $filename The filename of the image to fill with
*/
function setFillImage($filename)
{
}
/**
* Sets a gradient fill
*
* @param array $gradient Gradient fill options
*/
function setGradientFill($gradient)
{
$this->_fillStyle = $gradient;
$this->_fillStyle['type'] = 'gradient';
}
/**
* Sets the font options.
*
* The $font array may have the following entries:
* 'type' = 'ttf' (TrueType) or omitted for default<br>
* If 'type' = 'ttf' then the following can be specified<br>
* 'size' = size in pixels<br>
* 'angle' = the angle with which to write the text
* 'file' = the .ttf file (either the basename, filename or full path)
*
* @param array $font The font options.
*/
function setFont($fontOptions)
{
parent::setFont($fontOptions);
if (!isset($this->_font['size'])) {
$this->_font['size'] = 10;
}
}
/**
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* @param array $params Parameter array
*/
function line($params)
{
$x0 = $this->_getX($params['x0']);
$y0 = $this->_getY($params['y0']);
$x1 = $this->_getX($params['x1']);
$y1 = $this->_getY($params['y1']);
$color = (isset($params['color']) ? $params['color'] : false);
$style = $this->_getLineStyle($color) . $this->_getFillStyle('transparent');
if ($style != '') {
$this->_addElement(
'<line ' .
'x1="' . round($x0) . '" ' .
'y1="' . round($y0) . '" ' .
'x2="' . round($x1) . '" ' .
'y2="' . round($y1) . '" ' .
'style="' . $style . '"' .
'/>',
$params
);
}
parent::line($params);
}
/**
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function polygon($params = array())
{
$connectEnds = (isset($params['connect']) ? $params['connect'] : false);
$fillColor = (isset($params['fill']) ? $params['line'] : false);
$lineColor = (isset($params['line']) ? $params['line'] : false);
if (!$connectEnds) {
$fillColor = 'transparent';
}
$style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor);
$first = true;
$spline = false;
$lastpoint = false;
foreach($this->_polygon as $point) {
if ($first) {
$points = 'M';
} elseif (!$spline) {
$points .= ' L';
}
if (($spline) && ($lastpoint !== false)) {
$points .= ' ' .round($lastpoint['P1X']) . ',' . round($lastpoint['P1Y']) . ' ' .
round($lastpoint['P2X']) . ',' . round($lastpoint['P2Y']);
}
$points .= ' ' . round($point['X']) . ',' . round($point['Y']);
if ((isset($point['P1X'])) && (isset($point['P1Y'])) &&
(isset($point['P2X'])) && (isset($point['P2Y'])))
{
if (($first) || (!$spline)) {
$points .= ' C';
}
$lastpoint = $point;
$spline = true;
} else {
$spline = false;
}
$first = false;
}
if ($connectEnds) {
$point .= ' Z';
}
$this->_addElement(
'<path ' .
'd="' . $points . '" ' .
'style="' . $style . '"' .
'/>',
$params
);
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
$x0 = $this->_getX($params['x0']);
$y0 = $this->_getY($params['y0']);
$x1 = $this->_getX($params['x1']);
$y1 = $this->_getY($params['y1']);
$fillColor = (isset($params['fill']) ? $params['line'] : false);
$lineColor = (isset($params['line']) ? $params['line'] : false);
$style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor);
if ($style != '') {
$this->_addElement(
'<rect ' .
'x="' . round($x0) . '" ' .
'y="' . round($y0) . '" ' .
'width="' . round(abs($x1 - $x0)) . '" ' .
'height="' . round(abs($y1 - $y0)) . '" ' .
'style="' . $style . '"' .
'/>',
$params
);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$rx = $this->_getX($params['rx']);
$ry = $this->_getY($params['ry']);
$fillColor = (isset($params['fill']) ? $params['line'] : false);
$lineColor = (isset($params['line']) ? $params['line'] : false);
$style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor);
if ($style != '') {
$this->_addElement(
'<ellipse ' .
'cx="' . round($x) . '" ' .
'cy="' . round($y) . '" ' .
'rx="' . round($rx) . '" ' .
'ry="' . round($ry) . '" ' .
'style="' . $style . '"' .
'/>',
$params
);
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$rx = $this->_getX($params['rx']);
$ry = $this->_getY($params['ry']);
$v1 = $this->_getX($params['v1']);
$v2 = $this->_getY($params['v2']);
$srx = (isset($params['srx']) ? $this->_getX($params['srx']) : false);
$sry = (isset($params['sry']) ? $this->_getX($params['sry']) : false);
$fillColor = (isset($params['fill']) ? $params['line'] : false);
$lineColor = (isset($params['line']) ? $params['line'] : false);
$dv = max($v2, $v1) - min($v2, $v1);
if ($dv >= 360) {
$this->ellipse($params);
}
else {
$style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor);
if ($style != '') {
$x1 = ($x + $rx * cos(deg2rad(min($v1, $v2) % 360)));
$y1 = ($y + $ry * sin(deg2rad(min($v1, $v2) % 360)));
$x2 = ($x + $rx * cos(deg2rad(max($v1, $v2) % 360)));
$y2 = ($y + $ry * sin(deg2rad(max($v1, $v2) % 360)));
$this->_addElement(
'<path d="' .
'M' . round($x) . ',' . round($y) . ' ' .
'L' . round($x1) . ',' . round($y1) . ' ' .
'A' . round($rx) . ',' . round($ry) . ($dv > 180 ? ' 0 1,1 ' : ' 0 0,1 ') .
round($x2) . ',' . round($y2) . ' ' .
'Z" ' .
'style="' . $style . '"' .
'/>',
$params
);
}
parent::pieslice($params);
}
}
/**
* Get the width of a text,
*
* @param string $text The text to get the width of
* @return int The width of the text
*/
function textWidth($text)
{
if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
return $this->_font['size'];
} else {
return round($this->_font['size'] * 0.7 * strlen($text));
}
}
/**
* Get the height of a text,
*
* @param string $text The text to get the height of
* @return int The height of the text
*/
function textHeight($text)
{
if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
return round($this->_font['size'] * 0.7 * strlen($text));
} else {
return $this->_font['size'];
}
}
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$text = $params['text'];
$color = (isset($params['color']) ? $params['color'] : false);
$alignment = (isset($params['alignment']) ? $params['alignment'] : false);
$textHeight = $this->textHeight($text);
if (!is_array($alignment)) {
$alignment = array('vertical' => 'top', 'horizontal' => 'left');
}
if (!isset($alignment['vertical'])) {
$alignment['vertical'] = 'top';
}
if (!isset($alignment['horizontal'])) {
$alignment['horizontal'] = 'left';
}
$align = '';
if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
$align .= 'writing-mode: tb-rl;';
if ($alignment['vertical'] == 'bottom') {
$align .= 'text-anchor:end;';
//$y = $y + $textHeight;
} elseif ($alignment['vertical'] == 'center') {
//$y = $y + ($textHeight / 2);
$align .= 'text-anchor:middle;';
}
} else {
if ($alignment['horizontal'] == 'right') {
$align .= 'text-anchor:end;';
} elseif ($alignment['horizontal'] == 'center') {
$align .= 'text-anchor:middle;';
}
if ($alignment['vertical'] == 'top') {
$y = $y + $textHeight;
} elseif ($alignment['vertical'] == 'center') {
$y = $y + ($textHeight / 2);
}
}
if (($color === false) && (isset($this->_font['color']))) {
$color = $this->_font['color'];
}
$textColor = $this->_color($color);
$textOpacity = $this->_opacity($color);
$this->_addElement(
'<text ' .
'x="' . round($x) . '" ' .
'y="' . round($y) . '" ' .
/* (isset($this->_font['angle']) && ($this->_font['angle'] > 0) ?
'rotate="' . $this->_font['angle'] . '" ' :
''
) .*/
'style="' .
(isset($this->_font['name']) ?
'font-family:' . $this->_font['name'] . ';' : '') .
'font-size:' . $this->_font['size'] . 'px;fill=' .
$textColor . ($textOpacity ? ';fill-opacity:' .
$textOpacity :
''
) . ';' . $align . '">' .
str_replace('&', '&amp;', $text) .
'</text>',
$params
);
parent::addText($params);
}
/**
* Overlay image
*
* Parameter array:
* 'x': int X-point of overlayed image
* 'y': int Y-point of overlayed image
* 'filename': string The filename of the image to overlay
* 'width': int [optional] The width of the overlayed image (resizing if possible)
* 'height': int [optional] The height of the overlayed image (resizing if possible)
* 'alignment': array [optional] Alignment
*/
function image($params)
{
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$filename = $params['filename'];
list($width, $height, $type, $attr) = getimagesize($filename);
$width = (isset($params['width']) ? $params['width'] : $width);
$height = (isset($params['height']) ? $params['height'] : $height);
$alignment = (isset($params['alignment']) ? $params['alignment'] : false);
$file = fopen($filename, 'rb');
$filedata = fread($file, filesize($filename));
fclose($file);
$data = 'data:' . image_type_to_mime_type($type) . ';base64,' . base64_encode($filedata);
$this->_addElement(
'<image xlink:href="' . $data . '" x="' . $x . '" y="' . $y . '"' .
($width ? ' width="' . $width . '"' : '') .
($height ? ' height="' . $height . '"' : '') .
' preserveAspectRatio="none"/>',
$params
);
parent::image($params);
}
/**
* Start a group.
*
* What this does, depends on the canvas/format.
*
* @param string $name The name of the group
*/
function startGroup($name = false)
{
$name = strtolower(str_replace(' ', '_', $name));
if (in_array($name, $this->_groupIDs)) {
$name .= $this->_id;
$this->_id++;
}
$this->_groupIDs[] = $name;
$this->_addElement('<g id="' . $name . '">');
$this->_indent .= ' ';
}
/**
* End the "current" group.
*
* What this does, depends on the canvas/format.
*/
function endGroup()
{
$this->_indent = substr($this->_indent, 0, -4);
$this->_addElement('</g>');
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
*/
function show($param = false)
{
parent::show($param);
$output = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n" .
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"' . "\n\t" .
' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n" .
'<svg width="' . $this->_width . '" height="' . $this->_height .
'" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' . "\n" .
($this->_defs ?
' <defs>' . "\n" .
$this->_defs .
' </defs>' . "\n" :
''
) .
$this->_elements .
'</svg>';
header('Content-Type: image/svg+xml');
header('Content-Disposition: inline; filename = "' . basename($_SERVER['PHP_SELF'], '.php') . '.svg"');
print $output;
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
*/
function save($param = false)
{
parent::save($param);
$output = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n" .
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"' . "\n\t" .
' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n" .
'<svg width="' . $this->_width . '" height="' . $this->_height .
'" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' . "\n" .
($this->_defs ?
' <defs>' . "\n" .
$this->_defs .
' </defs>' . "\n" :
''
) .
$this->_elements .
'</svg>';
$file = fopen($param['filename'], 'w+');
fwrite($file, $output);
fclose($file);
}
/**
* Get a canvas specific HTML tag.
*
* This method implicitly saves the canvas to the filename in the
* filesystem path specified and parses it as URL specified by URL path
*
* Parameter array:
* 'filename': string
* 'filepath': string Path to the file on the file system. Remember the final slash
* 'urlpath': string Path to the file available through an URL. Remember the final slash
* 'width': int The width in pixels
* 'height': int The height in pixels
*/
function toHtml($params)
{
parent::toHtml($params);
return '<embed src="' . $params['urlpath'] . $params['filename'] . '" width=' . $params['width'] . ' height=' . $params['height'] . ' type="image/svg+xml">';
}
}
?>

View File

@ -1,217 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Tool.php,v 1.3 2005/08/22 20:52:11 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* This class contains a set of tool-functions.
*
* These functions are all to be called statically
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @abstract
*/
class Image_Canvas_Tool
{
/**
* Maps a font name to an actual font file (fx. a .ttf file)
*
* Used to translate names (i.e. 'Courier New' to 'cour.ttf' or
* '/Windows/Fonts/Cour.ttf')
*
* Font names are translated using the tab-separated file
* Image/Canvas/Tool/fontmap.txt.
*
* The translated font-name (or the original if no translation) exists is
* then returned if it is an existing file, otherwise the file is searched
* first in the path specified by IMAGE_CANVAS_SYSTEM_FONT_PATH defined in
* Image/Canvas.php, then in the Image/Canvas/Fonts folder. If a font is
* still not found and the name is not beginning with a '/' the search is
* left to the library, otherwise the font is deemed non-existing.
*
* @param string $name The name of the font
* @param string $type The needed file type of the font
* @return string The filename of the font
* @static
*/
function fontMap($name, $type = '.ttf')
{
static $_fontMap;
if (!is_array($_fontMap)) {
if (file_exists($fontmap = (dirname(__FILE__) . '/Fonts/fontmap.txt'))) {
$file = file($fontmap);
foreach($file as $fontmapping) {
list($fontname, $filenames) = explode(',', $fontmapping, 2);
$fontname = trim($fontname);
$filenames = trim($filenames);
$filenames = explode(',', $filenames);
foreach ($filenames as $filename) {
$type_pos = strrpos($filename, '.');
$type = substr($filename, $type_pos);
$_fontMap[$fontname][$type] = $filename;
}
}
}
}
$type = strtolower($type);
if ((isset($_fontMap[$name])) && (isset($_fontMap[$name][$type]))) {
$filename = $_fontMap[$name][$type];
} else {
$filename = $name;
}
if (substr($filename, -strlen($type)) !== $type) {
$filename .= $type;
}
$result = false;
if (file_exists($filename)) {
$result = $filename;
} elseif (file_exists($file = (IMAGE_CANVAS_SYSTEM_FONT_PATH . $filename))) {
$result = $file;
} elseif (file_exists($file = (dirname(__FILE__) . '/Fonts/' . $filename))) {
$result = $file;
} elseif (substr($name, 0, 1) !== '/') {
// leave it to the library to find the font
$result = $name;
}
return str_replace('\\', '/', $result);
}
/**
* Return the average of 2 points
*
* @param double P1 1st point
* @param double P2 2nd point
* @return double The average of P1 and P2
* @static
*/
function mid($p1, $p2)
{
return ($p1 + $p2) / 2;
}
/**
* Mirrors P1 in P2 by a amount of Factor
*
* @param double $p1 1st point, point to mirror
* @param double $o2 2nd point, mirror point
* @param double $factor Mirror factor, 0 returns $p2, 1 returns a pure
* mirror, ie $p1 on the exact other side of $p2
* @return double $p1 mirrored in $p2 by Factor
* @static
*/
function mirror($p1, $p2, $factor = 1)
{
return $p2 + $factor * ($p2 - $p1);
}
/**
* Calculates a Bezier control point, this function must be called for BOTH
* X and Y coordinates (will it work for 3D coordinates!?)
*
* @param double $p1 1st point
* @param double $p2 Point to
* @param double $factor Mirror factor, 0 returns P2, 1 returns a pure
* mirror, i.e. P1 on the exact other side of P2
* @return double P1 mirrored in P2 by Factor
* @static
*/
function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75)
{
$sa = Image_Canvas_Tool::mirror($p1, $p2, $smoothFactor);
$sb = Image_Canvas_Tool::mid($p2, $sa);
$m = Image_Canvas_Tool::mid($p2, $factor);
$pC = Image_Canvas_Tool::mid($sb, $m);
return $pC;
}
/**
* Calculates a Bezier point, this function must be called for BOTH X and Y
* coordinates (will it work for 3D coordinates!?)
*
* @param double $t A position between $p2 and $p3, value between 0 and 1
* @param double $p1 Point to use for calculating control points
* @param double $p2 Point 1 to calculate bezier curve between
* @param double $p3 Point 2 to calculate bezier curve between
* @param double $p4 Point to use for calculating control points
* @return double The bezier value of the point t between $p2 and $p3 using
* $p1 and $p4 to calculate control points
* @static
*/
function bezier($t, $p1, $p2, $p3, $p4)
{
// (1-t)^3*p1 + 3*(1-t)^2*t*p2 + 3*(1-t)*t^2*p3 + t^3*p4
return pow(1 - $t, 3) * $p1 +
3 * pow(1 - $t, 2) * $t * $p2 +
3 * (1 - $t) * pow($t, 2) * $p3 +
pow($t, 3) * $p4;
}
/**
* Gets the angle / slope of a line relative to horizontal (left -> right)
*
* @param double $x0 The starting x point
* @param double $y0 The starting y point
* @param double $x1 The ending x point
* @param double $y1 The ending y point
* @param double The angle in degrees of the line
* @static
*/
function getAngle($x0, $y0, $x1, $y1)
{
$dx = ($x1 - $x0);
$dy = ($y1 - $y0);
$l = sqrt($dx * $dx + $dy * $dy);
$v = rad2deg(asin(($y0 - $y1) / $l));
if ($dx < 0) {
$v = 180 - $v;
}
return $v;
}
}
?>

View File

@ -1,278 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: WithMap.php,v 1.3 2005/08/24 20:37:35 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling different output formats including a HTML image map
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
* @abstract
*/
class Image_Canvas_WithMap extends Image_Canvas
{
/**
* The image map
* @var Image_Canvas_ImageMap
* @access private
*/
var $_imageMap = null;
/**
* Create the canvas.
*
* Parameters available:
*
* 'width' The width of the graph on the canvas
*
* 'height' The height of the graph on the canvas
*
* 'left' The left offset of the graph on the canvas
*
* 'top' The top offset of the graph on the canvas
*
* 'usemap' Initialize an image map
*
* @param array $params Parameter array
* @abstract
*/
function Image_Canvas_WithMap($params)
{
parent::Image_Canvas($params);
if ((isset($params['usemap'])) && ($params['usemap'] === true)) {
$this->_imageMap =& Image_Canvas::factory(
'ImageMap',
array(
'left' => $this->_left,
'top' => $this->_top,
'width' => $this->_width,
'height' => $this->_height
)
);
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* @param array $params Parameter array
*/
function line($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->line($params);
}
parent::line($params);
}
/**
* Adds vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* @param array $params Parameter array
*/
function addVertex($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addVertex($params);
}
parent::addVertex($params);
}
/**
* Adds "splined" vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* 'p1x': X Control point 1
* 'p1y': Y Control point 1
* 'p2x': X Control point 2
* 'p2y': Y Control point 2
* @param array $params Parameter array
*/
function addSpline($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addSpline($params);
}
parent::addSpline($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function polygon($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->polygon($params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->rectangle($params);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->ellipse($params);
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->pieslice($params);
}
parent::pieslice($params);
}
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addText($params);
}
parent::addText($params);
}
/**
* Overlay image
*
* Parameter array:
* 'x': int X-point of overlayed image
* 'y': int Y-point of overlayed image
* 'filename': string The filename of the image to overlay
* 'width': int [optional] The width of the overlayed image (resizing if possible)
* 'height': int [optional] The height of the overlayed image (resizing if possible)
* 'alignment': array [optional] Alignment
*/
function image($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->image($params);
}
parent::image($params);
}
/**
* Get the imagemap
* @return Image_Graph_ImageMap The image map (or false if none)
*/
function &getImageMap()
{
$result = null;
if (isset($this->_imageMap)) {
$result =& $this->_imageMap;
}
return $result;
}
}
?>

View File

@ -1,719 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Color.php is the implementation of Image_Color.
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category Image
* @package Image_Color
* @author Jason Lotito <jason@lehighweb.com>
* @author Andrew Morton <drewish@katherinehouse.com>
* @copyright 2003-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: Color.php,v 1.15 2005/09/12 19:12:02 drewish Exp $
* @link http://pear.php.net/package/Image_Color
*/
/**
* Image_Color handles color conversion and mixing.
*
* The class is quick, simple to use, and does its job fairly well but it's got
* some code smells:
* - Call setColors() for some functions but not others.
* - Different functions expect different color formats. setColors() only
* accepts hex while allocateColor() will accept named or hex (provided the
* hex ones start with the # character).
* - Some conversions go in only one direction, ie HSV->RGB but no RGB->HSV.
* I'm going to try to straighten out some of this but I'll be hard to do so
* without breaking backwards compatibility.
*
* @category Image
* @package Image_Color
* @author Jason Lotito <jason@lehighweb.com>
* @author Andrew Morton <drewish@katherinehouse.com>
* @copyright 2003-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 0.1.2
* @link http://pear.php.net/package/Image_Color
*/
class Image_Color
{
/**
* First color that the class handles for ranges and mixes.
* @var array
* @access public
* @see setColors()
*/
var $color1 = array();
/**
* Second color that the class handles for ranges and mixes.
* @var array
* @access public
* @see setColors()
*/
var $color2 = array();
/**
* Boolean value for determining whether colors outputted should be limited
* to the web safe pallet or not.
*
* @var boolean
* @access private
* @see setWebSafe()
*/
var $_websafeb = false;
/**
* Mix two colors together by finding their average. If the colors are not
* passed as parameters, the class's colors will be mixed instead.
*
* @param string $col1 The first color you want to mix
* @param string $col2 The second color you want to mix
* @return string The mixed color.
* @access public
* @author Jason Lotito <jason@lehighweb.com>
* @uses _setColors() to assign the colors if any are passed to the
* class.
*/
function mixColors($col1 = false, $col2 = false)
{
if ($col1) {
$this->_setColors($col1, $col2);
}
// after finding the average, it will be a float. add 0.5 and then
// cast to an integer to properly round it to an integer.
$color3[0] = (int) ((($this->color1[0] + $this->color2[0]) / 2) + 0.5);
$color3[1] = (int) ((($this->color1[1] + $this->color2[1]) / 2) + 0.5);
$color3[2] = (int) ((($this->color1[2] + $this->color2[2]) / 2) + 0.5);
if ($this->_websafeb) {
array_walk($color3, '_makeWebSafe');
}
return Image_Color::rgb2hex($color3);
}
/**
* Determines whether colors the returned by this class will be rounded to
* the nearest web safe value.
*
* @param boolean $bool Indicates if colors should be limited to the
* websafe pallet.
* @return void
* @access public
* @author Jason Lotito <jason@lehighweb.com>
*/
function setWebSafe($bool = true)
{
$this->_websafeb = (boolean) $bool;
}
/**
* Set the two colors this class uses for mixing and ranges.
*
* @param string $col1 The first color in hex format
* @param string $col2 The second color in hex format
* @return void
* @access public
* @author Jason Lotito <jason@lehighweb.com>
*/
function setColors($col1, $col2)
{
$this->_setColors($col1, $col2);
}
/**
* Get the range of colors between the class's two colors, given a degree.
*
* @param integer $degrees How large a 'step' we should take between the
* colors.
* @return array Returns an array of hex strings, one element for each
* color.
* @access public
* @author Jason Lotito <jason@lehighweb.com>
* @todo Allow for degrees for individual parts of the colors.
*/
function getRange($degrees = 2)
{
if ($degrees == 0) {
$degrees = 1;
}
// The degrees give us how much we should advance each color at each
// phase of the loop. This way, the advance is equal throughout all
// the colors.
$red_steps = ($this->color2[0] - $this->color1[0]) / $degrees;
$green_steps = ($this->color2[1] - $this->color1[1]) / $degrees;
$blue_steps = ($this->color2[2] - $this->color1[2]) / $degrees;
$allcolors = array();
/**
* The loop stops once any color has gone beyond the end color.
*/
// Loop through all the degrees between the colors
for ($x = 0; $x < $degrees; $x++) {
$col[0] = $red_steps * $x;
$col[1] = $green_steps * $x;
$col[2] = $blue_steps * $x;
// Loop through each R, G, and B
for ($i = 0; $i < 3; $i++) {
$partcolor = $this->color1[$i] + $col[$i];
// If the color is less than 256
if ($partcolor < 256) {
// Makes sure the colors is not less than 0
if ($partcolor > -1) {
$newcolor[$i] = $partcolor;
} else {
$newcolor[$i] = 0;
}
// Color was greater than 255
} else {
$newcolor[$i] = 255;
}
}
if ($this->_websafeb) {
array_walk($newcolor, '_makeWebSafe');
}
$allcolors[] = Image_Color::rgb2hex($newcolor);
}
return $allcolors;
}
/**
* Change the lightness of the class's two colors.
*
* @param integer $degree The degree of the change. Positive values
* lighten the color while negative values will darken it.
* @return void
* @access public
* @author Jason Lotito <jason@lehighweb.com>
* @uses Image_Color::$color1 as an input and return value.
* @uses Image_Color::$color2 as an input and return value.
*/
function changeLightness($degree = 10)
{
$color1 =& $this->color1;
$color2 =& $this->color2;
for ($x = 0; $x < 3; $x++) {
if (($color1[$x] + $degree) < 256) {
if (($color1[$x] + $degree) > -1) {
$color1[$x] += $degree;
} else {
$color1[$x] = 0;
}
} else {
$color1[$x] = 255;
}
if (($color2[$x] + $degree) < 256) {
if (($color2[$x] + $degree) > -1) {
$color2[$x] += $degree;
} else {
$color2[$x] = 0;
}
} else {
$color2[$x] = 255;
}
}
}
/**
* Determine if a light or dark text color would be more readable on a
* background of a given color. This is determined by the G(reen) value of
* RGB. You can change the dark and the light colors from their default
* black and white.
*
* @param string $color The hex color to analyze
* @param string $light The light color value to return if we should
* have light text.
* @param string $dark The dark color value to return if we should have
* dark text.
* @return string The light or dark value which would make the text most
* readable.
* @access public
* @static
* @author Jason Lotito <jason@lehighweb.com>
*/
function getTextColor($color, $light = '#FFFFFF', $dark = '#000000')
{
$color = Image_Color::_splitColor($color);
if ($color[1] > hexdec('66')) {
return $dark;
} else {
return $light;
}
}
/**
* Internal method to set the colors.
*
* @param string $col1 First color, either a name or hex value
* @param string $col2 Second color, either a name or hex value
* @return void
* @access private
* @author Jason Lotito <jason@lehighweb.com>
*/
function _setColors($col1, $col2)
{
if ($col1) {
$this->color1 = Image_Color::_splitColor($col1);
}
if ($col2) {
$this->color2 = Image_Color::_splitColor($col2);
}
}
/**
* Given a color, properly split it up into a 3 element RGB array.
*
* @param string $color The color.
* @return array A three element RGB array.
* @access private
* @static
* @author Jason Lotito <jason@lehighweb.com>
*/
function _splitColor($color)
{
$color = str_replace('#', '', $color);
$c[] = hexdec(substr($color, 0, 2));
$c[] = hexdec(substr($color, 2, 2));
$c[] = hexdec(substr($color, 4, 2));
return $c;
}
/**
* This is deprecated. Use rgb2hex() instead.
* @access private
* @deprecated Function deprecated after 1.0.1
* @see rgb2hex().
*/
function _returnColor ( $color )
{
return Image_Color::rgb2hex($color);
}
/**
* Convert an RGB array to a hex string.
*
* @param array $color 3 element RGB array.
* @return string Hex color string.
* @access public
* @static
* @author Jason Lotito <jason@lehighweb.com>
* @see hex2rgb()
*/
function rgb2hex($color)
{
return sprintf('%02X%02X%02X',$color[0],$color[1],$color[2]);
}
/**
* Convert a hex color string into an RGB array. An extra fourth element
* will be returned with the original hex value.
*
* @param string $hex Hex color string.
* @return array RGB color array with an extra 'hex' element containing
* the original hex string.
* @access public
* @static
* @author Jason Lotito <jason@lehighweb.com>
* @see rgb2hex()
*/
function hex2rgb($hex)
{
$return = Image_Color::_splitColor($hex);
$return['hex'] = $hex;
return $return;
}
/**
* Convert an HSV (Hue, Saturation, Brightness) value to RGB.
*
* @param integer $h Hue
* @param integer $s Saturation
* @param integer $v Brightness
* @return array RGB array.
* @access public
* @static
* @author Jason Lotito <jason@lehighweb.com>
* @uses hsv2hex() to convert the HSV value to Hex.
* @uses hex2rgb() to convert the Hex value to RGB.
*/
function hsv2rgb($h, $s, $v)
{
return Image_Color::hex2rgb(Image_Color::hsv2hex($h, $s, $v));
}
/**
* Convert HSV (Hue, Saturation, Brightness) to a hex color string.
*
* Originally written by Jurgen Schwietering. Integrated into the class by
* Jason Lotito.
*
* @param integer $h Hue
* @param integer $s Saturation
* @param integer $v Brightness
* @return string The hex string.
* @access public
* @static
* @author Jurgen Schwietering <jurgen@schwietering.com>
* @uses rgb2hex() to convert the return value to a hex string.
*/
function hsv2hex($h, $s, $v)
{
$s /= 256.0;
$v /= 256.0;
if ($s == 0.0) {
$r = $g = $b = $v;
return '';
} else {
$h = $h / 256.0 * 6.0;
$i = floor($h);
$f = $h - $i;
$v *= 256.0;
$p = (integer)($v * (1.0 - $s));
$q = (integer)($v * (1.0 - $s * $f));
$t = (integer)($v * (1.0 - $s * (1.0 - $f)));
switch($i) {
case 0:
$r = $v;
$g = $t;
$b = $p;
break;
case 1:
$r = $q;
$g = $v;
$b = $p;
break;
case 2:
$r = $p;
$g = $v;
$b = $t;
break;
case 3:
$r = $p;
$g = $q;
$b = $v;
break;
case 4:
$r = $t;
$g = $p;
$b = $v;
break;
default:
$r = $v;
$g = $p;
$b = $q;
break;
}
}
return $this->rgb2hex(array($r, $g, $b));
}
/**
* Allocates a color in the given image.
*
* User defined color specifications get translated into an array of RGB
* values.
*
* @param resource $img Image handle
* @param string|array $color Name or hex string or an RGB array.
* @return resource Image color handle.
* @access public
* @static
* @uses ImageColorAllocate() to allocate the color.
* @uses color2RGB() to parse the color into RGB values.
*/
function allocateColor(&$img, $color) {
$color = Image_Color::color2RGB($color);
return ImageColorAllocate($img, $color[0], $color[1], $color[2]);
}
/**
* Convert a named or hex color string to an RGB array. If the color begins
* with the # character it will be treated as a hex value. Everything else
* will be treated as a named color. If the named color is not known, black
* will be returned.
*
* @param string $color
* @return array RGB color
* @access public
* @static
* @author Laurent Laville <pear@laurent-laville.org>
* @uses hex2rgb() to convert colors begining with the # character.
* @uses namedColor2RGB() to convert everything not starting with a #.
*/
function color2RGB($color)
{
$c = array();
if ($color{0} == '#') {
$c = Image_Color::hex2rgb($color);
} else {
$c = Image_Color::namedColor2RGB($color);
}
return $c;
}
/**
* Convert a named color to an RGB array. If the color is unknown black
* is returned.
*
* @param string $color Case insensitive color name.
* @return array RGB color array. If the color was unknown, the result
* will be black.
* @access public
* @static
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
*/
function namedColor2RGB($color)
{
static $colornames;
if (!isset($colornames)) {
$colornames = array(
'aliceblue' => array(240, 248, 255),
'antiquewhite' => array(250, 235, 215),
'aqua' => array( 0, 255, 255),
'aquamarine' => array(127, 255, 212),
'azure' => array(240, 255, 255),
'beige' => array(245, 245, 220),
'bisque' => array(255, 228, 196),
'black' => array( 0, 0, 0),
'blanchedalmond' => array(255, 235, 205),
'blue' => array( 0, 0, 255),
'blueviolet' => array(138, 43, 226),
'brown' => array(165, 42, 42),
'burlywood' => array(222, 184, 135),
'cadetblue' => array( 95, 158, 160),
'chartreuse' => array(127, 255, 0),
'chocolate' => array(210, 105, 30),
'coral' => array(255, 127, 80),
'cornflowerblue' => array(100, 149, 237),
'cornsilk' => array(255, 248, 220),
'crimson' => array(220, 20, 60),
'cyan' => array( 0, 255, 255),
'darkblue' => array( 0, 0, 13),
'darkcyan' => array( 0, 139, 139),
'darkgoldenrod' => array(184, 134, 11),
'darkgray' => array(169, 169, 169),
'darkgreen' => array( 0, 100, 0),
'darkkhaki' => array(189, 183, 107),
'darkmagenta' => array(139, 0, 139),
'darkolivegreen' => array( 85, 107, 47),
'darkorange' => array(255, 140, 0),
'darkorchid' => array(153, 50, 204),
'darkred' => array(139, 0, 0),
'darksalmon' => array(233, 150, 122),
'darkseagreen' => array(143, 188, 143),
'darkslateblue' => array( 72, 61, 139),
'darkslategray' => array( 47, 79, 79),
'darkturquoise' => array( 0, 206, 209),
'darkviolet' => array(148, 0, 211),
'deeppink' => array(255, 20, 147),
'deepskyblue' => array( 0, 191, 255),
'dimgray' => array(105, 105, 105),
'dodgerblue' => array( 30, 144, 255),
'firebrick' => array(178, 34, 34),
'floralwhite' => array(255, 250, 240),
'forestgreen' => array( 34, 139, 34),
'fuchsia' => array(255, 0, 255),
'gainsboro' => array(220, 220, 220),
'ghostwhite' => array(248, 248, 255),
'gold' => array(255, 215, 0),
'goldenrod' => array(218, 165, 32),
'gray' => array(128, 128, 128),
'green' => array( 0, 128, 0),
'greenyellow' => array(173, 255, 47),
'honeydew' => array(240, 255, 240),
'hotpink' => array(255, 105, 180),
'indianred' => array(205, 92, 92),
'indigo' => array(75, 0, 130),
'ivory' => array(255, 255, 240),
'khaki' => array(240, 230, 140),
'lavender' => array(230, 230, 250),
'lavenderblush' => array(255, 240, 245),
'lawngreen' => array(124, 252, 0),
'lemonchiffon' => array(255, 250, 205),
'lightblue' => array(173, 216, 230),
'lightcoral' => array(240, 128, 128),
'lightcyan' => array(224, 255, 255),
'lightgoldenrodyellow' => array(250, 250, 210),
'lightgreen' => array(144, 238, 144),
'lightgrey' => array(211, 211, 211),
'lightpink' => array(255, 182, 193),
'lightsalmon' => array(255, 160, 122),
'lightseagreen' => array( 32, 178, 170),
'lightskyblue' => array(135, 206, 250),
'lightslategray' => array(119, 136, 153),
'lightsteelblue' => array(176, 196, 222),
'lightyellow' => array(255, 255, 224),
'lime' => array( 0, 255, 0),
'limegreen' => array( 50, 205, 50),
'linen' => array(250, 240, 230),
'magenta' => array(255, 0, 255),
'maroon' => array(128, 0, 0),
'mediumaquamarine' => array(102, 205, 170),
'mediumblue' => array( 0, 0, 205),
'mediumorchid' => array(186, 85, 211),
'mediumpurple' => array(147, 112, 219),
'mediumseagreen' => array( 60, 179, 113),
'mediumslateblue' => array(123, 104, 238),
'mediumspringgreen' => array( 0, 250, 154),
'mediumturquoise' => array(72, 209, 204),
'mediumvioletred' => array(199, 21, 133),
'midnightblue' => array( 25, 25, 112),
'mintcream' => array(245, 255, 250),
'mistyrose' => array(255, 228, 225),
'moccasin' => array(255, 228, 181),
'navajowhite' => array(255, 222, 173),
'navy' => array( 0, 0, 128),
'oldlace' => array(253, 245, 230),
'olive' => array(128, 128, 0),
'olivedrab' => array(107, 142, 35),
'orange' => array(255, 165, 0),
'orangered' => array(255, 69, 0),
'orchid' => array(218, 112, 214),
'palegoldenrod' => array(238, 232, 170),
'palegreen' => array(152, 251, 152),
'paleturquoise' => array(175, 238, 238),
'palevioletred' => array(219, 112, 147),
'papayawhip' => array(255, 239, 213),
'peachpuff' => array(255, 218, 185),
'peru' => array(205, 133, 63),
'pink' => array(255, 192, 203),
'plum' => array(221, 160, 221),
'powderblue' => array(176, 224, 230),
'purple' => array(128, 0, 128),
'red' => array(255, 0, 0),
'rosybrown' => array(188, 143, 143),
'royalblue' => array( 65, 105, 225),
'saddlebrown' => array(139, 69, 19),
'salmon' => array(250, 128, 114),
'sandybrown' => array(244, 164, 96),
'seagreen' => array( 46, 139, 87),
'seashell' => array(255, 245, 238),
'sienna' => array(160, 82, 45),
'silver' => array(192, 192, 192),
'skyblue' => array(135, 206, 235),
'slateblue' => array(106, 90, 205),
'slategray' => array(112, 128, 144),
'snow' => array(255, 250, 250),
'springgreen' => array( 0, 255, 127),
'steelblue' => array( 70, 130, 180),
'tan' => array(210, 180, 140),
'teal' => array( 0, 128, 128),
'thistle' => array(216, 191, 216),
'tomato' => array(255, 99, 71),
'turquoise' => array( 64, 224, 208),
'violet' => array(238, 130, 238),
'wheat' => array(245, 222, 179),
'white' => array(255, 255, 255),
'whitesmoke' => array(245, 245, 245),
'yellow' => array(255, 255, 0),
'yellowgreen' => array(154, 205, 50)
);
}
$color = strtolower($color);
if (isset($colornames[$color])) {
return $colornames[$color];
} else {
return array(0, 0, 0);
}
}
/**
* Convert an RGB percentage string into an RGB array.
*
* @param string $color Percentage color string like "50%,20%,100%".
* @return array RGB color array.
* @access public
* @static
*/
function percentageColor2RGB($color)
{
// remove spaces
$color = str_replace(' ', '', $color);
// remove the percent signs
$color = str_replace('%', '', $color);
// split the string by commas
$color = explode(',', $color);
$ret = array();
foreach ($color as $k => $v) {
// range checks
if ($v <= 0) {
$ret[$k] = 0;
} else if ($v <= 100) {
// add 0.5 then cast to an integer to round the value.
$ret[$k] = (integer) ((2.55 * $v) + 0.5);
} else {
$ret[$k] = 255;
}
}
return $ret;
}
}
// For Array Walk
// {{{
/**
* Function for array_walk() to round colors to the closest web safe value.
*
* @param integer $color One channel of an RGB color.
* @return integer The websafe equivalent of the color channel.
* @author Jason Lotito <jason@lehighweb.com>
* @author Andrew Morton <drewish@katherinehouse.com>
* @access private
* @static
*/
function _makeWebSafe(&$color)
{
if ($color < 0x1a) {
$color = 0x00;
} else if ($color < 0x4d) {
$color = 0x33;
} else if ($color < 0x80) {
$color = 0x66;
} else if ($color < 0xB3) {
$color = 0x99;
} else if ($color < 0xE6) {
$color = 0xCC;
} else {
$color = 0xFF;
}
return $color;
}
// }}}
?>

View File

@ -1,852 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Graph.php,v 1.58 2005/11/27 18:48:05 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include PEAR.php
*/
require_once 'PEAR.php';
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Include file Image/Graph/Constants.php
*/
require_once 'Image/Graph/Constants.php';
/**
* Main class for the graph creation.
*
* This is the main class, it manages the canvas and performs the final output
* by sequentialy making the elements output their results. The final output is
* handled using the {@link Image_Canvas} classes which makes it possible
* to use different engines (fx GD, PDFlib, libswf, etc) for output to several
* formats with a non-intersecting API.
*
* This class also handles coordinates and the correct managment of setting the
* correct coordinates on child elements.
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph extends Image_Graph_Element
{
/**
* Show generation time on graph
* @var bool
* @access private
*/
var $_showTime = false;
/**
* Display errors on the canvas
* @var boolean
* @access private
*/
var $_displayErrors = false;
/**
* 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<EFBFBD>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. &amp;$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::Image_Graph_Element();
$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);
}
/**
* Gets the canvas for this graph.
*
* The canvas is set by either passing it to the constructor {@link
* Image_Graph::ImageGraph()} or using the {@link Image_Graph::setCanvas()}
* method.
*
* @return Image_Canvas The canvas used by this graph
* @access private
* @since 0.3.0dev2
*/
function &_getCanvas()
{
return $this->_canvas;
}
/**
* Sets the canvas for this graph.
*
* Calling this method makes this graph use the newly specified canvas for
* handling output. This method should be called whenever multiple
* 'outputs' are required. Invoke this method after calls to {@link
* Image_Graph:: done()} has been performed, to switch canvass.
*
* @param Image_Canvas $canvas The new canvas
* @return Image_Canvas The new canvas
* @since 0.3.0dev2
*/
function &setCanvas(&$canvas)
{
if (!is_a($this->_canvas, 'Image_Canvas')) {
return $this->_error('The canvas introduced is not an Image_Canvas object');
}
$this->_canvas =& $canvas;
$this->_setCoords(
0,
0,
$this->_canvas->getWidth() - 1,
$this->_canvas->getHeight() - 1
);
return $this->_canvas;
}
/**
* Gets a very precise timestamp
*
* @return The number of seconds to a lot of decimals
* @access private
*/
function _getMicroTime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
/**
* Gets the width of this graph.
*
* The width is returned as 'defined' by the canvas.
*
* @return int the width of this graph
*/
function width()
{
return $this->_canvas->getWidth();
}
/**
* Gets the height of this graph.
*
* The height is returned as 'defined' by the canvas.
*
* @return int the height of this graph
*/
function height()
{
return $this->_canvas->getHeight();
}
/**
* Enables displaying of errors on the output.
*
* Use this method to enforce errors to be displayed on the output. Calling
* this method makes PHP uses this graphs error handler as default {@link
* Image_Graph::_default_error_handler()}.
*/
function displayErrors()
{
$this->_displayErrors = true;
set_error_handler(array(&$this, '_default_error_handler'));
}
/**
* Sets the log method for this graph.
*
* Use this method to enable logging. This causes any errors caught
* by either the error handler {@see Image_Graph::displayErrors()}
* or explicitly by calling {@link Image_Graph_Common::_error()} be
* logged using the specified logging method.
*
* If a filename is specified as log method, a Log object is created (using
* the 'file' handler), with a handle of 'Image_Graph Error Log'.
*
* Logging requires {@link Log}.
*
* @param mixed $log The log method, either a Log object or filename to log
* to
* @since 0.3.0dev2
*/
function setLog($log)
{
}
/**
* Factory method to create Image_Graph objects.
*
* Used for 'lazy including', i.e. loading only what is necessary, when it
* is necessary. If only one parameter is required for the constructor of
* the class simply pass this parameter as the $params parameter, unless the
* parameter is an array or a reference to a value, in that case you must
* 'enclose' the parameter in an array. Similar if the constructor takes
* more than one parameter specify the parameters in an array, i.e
*
* Image_Graph::factory('MyClass', array($param1, $param2, &$param3));
*
* Variables that need to be passed by reference *must* have the &amp;
* before the variable, i.e:
*
* Image_Graph::factory('line', &$Dataset);
*
* or
*
* Image_graph::factory('bar', array(array(&$Dataset1, &$Dataset2),
* 'stacked'));
*
* Class name can be either of the following:
*
* 1 The 'real' Image_Graph class name, i.e. Image_Graph_Plotarea or
* Image_Graph_Plot_Line
*
* 2 Short class name (leave out Image_Graph) and retain case, i.e.
* Plotarea, Plot_Line *not* plot_line
*
* 3 Class name 'alias', the following are supported:
*
* 'graph' = Image_Graph
*
* 'plotarea' = Image_Graph_Plotarea
*
* 'line' = Image_Graph_Plot_Line
*
* 'area' = Image_Graph_Plot_Area
*
* 'bar' = Image_Graph_Plot_Bar
*
* 'pie' = Image_Graph_Plot_Pie
*
* 'radar' = Image_Graph_Plot_Radar
*
* 'step' = Image_Graph_Plot_Step
*
* 'impulse' = Image_Graph_Plot_Impulse
*
* 'dot' or 'scatter' = Image_Graph_Plot_Dot
*
* 'smooth_line' = Image_Graph_Plot_Smoothed_Line
*
* 'smooth_area' = Image_Graph_Plot_Smoothed_Area
* 'dataset' = Image_Graph_Dataset_Trivial
*
* 'random' = Image_Graph_Dataset_Random
*
* 'function' = Image_Graph_Dataset_Function
*
* 'vector' = Image_Graph_Dataset_VectorFunction
*
* 'category' = Image_Graph_Axis_Category
*
* 'axis' = Image_Graph_Axis
*
* 'axis_log' = Image_Graph_Axis_Logarithmic
*
* 'title' = Image_Graph_Title
*
* 'line_grid' = Image_Graph_Grid_Lines
*
* 'bar_grid' = Image_Graph_Grid_Bars
*
* 'polar_grid' = Image_Graph_Grid_Polar
*
* 'legend' = Image_Graph_Legend
*
* 'font' = Image_Graph_Font
*
* 'ttf_font' = Image_Graph_Font
*
* 'Image_Graph_Font_TTF' = Image_Graph_Font (to maintain BC with Image_Graph_Font_TTF)
*
* 'gradient' = Image_Graph_Fill_Gradient
*
* 'icon_marker' = Image_Graph_Marker_Icon
*
* 'value_marker' = Image_Graph_Marker_Value
*
* @param string $class The class for the new object
* @param mixed $params The paramaters to pass to the constructor
* @return object A new object for the class
* @static
*/
function &factory($class, $params = null)
{
static $Image_Graph_classAliases = array(
'graph' => 'Image_Graph',
'plotarea' => 'Image_Graph_Plotarea',
'line' => 'Image_Graph_Plot_Line',
'area' => 'Image_Graph_Plot_Area',
'bubble' => 'Image_Graph_Plot_Bubble',
'bar' => 'Image_Graph_Plot_Bar',
'smooth_line' => 'Image_Graph_Plot_Smoothed_Line',
'smooth_area' => 'Image_Graph_Plot_Smoothed_Area',
'pie' => 'Image_Graph_Plot_Pie',
'radar' => 'Image_Graph_Plot_Radar',
'step' => 'Image_Graph_Plot_Step',
'impulse' => 'Image_Graph_Plot_Impulse',
'dot' => 'Image_Graph_Plot_Dot',
'scatter' => 'Image_Graph_Plot_Dot',
'dataset' => 'Image_Graph_Dataset_Trivial',
'random' => 'Image_Graph_Dataset_Random',
'function' => 'Image_Graph_Dataset_Function',
'vector' => 'Image_Graph_Dataset_VectorFunction',
'category' => 'Image_Graph_Axis_Category',
'axis' => 'Image_Graph_Axis',
'axis_log' => 'Image_Graph_Axis_Logarithmic',
'title' => 'Image_Graph_Title',
'line_grid' => 'Image_Graph_Grid_Lines',
'bar_grid' => 'Image_Graph_Grid_Bars',
'polar_grid' => 'Image_Graph_Grid_Polar',
'legend' => 'Image_Graph_Legend',
'font' => 'Image_Graph_Font',
'ttf_font' => 'Image_Graph_Font',
'Image_Graph_Font_TTF' => 'Image_Graph_Font', // BC with Image_Graph_Font_TTF
'gradient' => 'Image_Graph_Fill_Gradient',
'icon_marker' => 'Image_Graph_Marker_Icon',
'value_marker' => 'Image_Graph_Marker_Value'
);
if (substr($class, 0, 11) != 'Image_Graph') {
if (isset($Image_Graph_classAliases[$class])) {
$class = $Image_Graph_classAliases[$class];
} else {
$class = 'Image_Graph_' . $class;
}
}
include_once str_replace('_', '/', $class) . '.php';
$obj = null;
if (is_array($params)) {
switch (count($params)) {
case 1:
$obj =& new $class(
$params[0]
);
break;
case 2:
$obj =& new $class(
$params[0],
$params[1]
);
break;
case 3:
$obj =& new $class(
$params[0],
$params[1],
$params[2]
);
break;
case 4:
$obj =& new $class(
$params[0],
$params[1],
$params[2],
$params[3]
);
break;
case 5:
$obj =& new $class(
$params[0],
$params[1],
$params[2],
$params[3],
$params[4]
);
break;
case 6:
$obj =& new $class(
$params[0],
$params[1],
$params[2],
$params[3],
$params[4],
$params[5]
);
break;
case 7:
$obj =& new $class(
$params[0],
$params[1],
$params[2],
$params[3],
$params[4],
$params[5],
$params[6]
);
break;
case 8:
$obj =& new $class(
$params[0],
$params[1],
$params[2],
$params[3],
$params[4],
$params[5],
$params[6],
$params[7]
);
break;
case 9:
$obj =& new $class(
$params[0],
$params[1],
$params[2],
$params[3],
$params[4],
$params[5],
$params[6],
$params[7],
$params[8]
);
break;
case 10:
$obj =& new $class(
$params[0],
$params[1],
$params[2],
$params[3],
$params[4],
$params[5],
$params[6],
$params[7],
$params[8],
$params[9]
);
break;
default:
$obj =& new $class();
break;
}
} else {
if ($params == null) {
$obj =& new $class();
} else {
$obj =& new $class($params);
}
}
return $obj;
}
/**
* Factory method to create layouts.
*
* This method is used for easy creation, since using {@link Image_Graph::
* factory()} does not work with passing newly created objects from
* Image_Graph::factory() as reference, this is something that is
* fortunately fixed in PHP5. Also used for 'lazy including', i.e. loading
* only what is necessary, when it is necessary.
*
* Use {@link Image_Graph::horizontal()} or {@link Image_Graph::vertical()}
* instead for easier access.
*
* @param mixed $layout The type of layout, can be either 'Vertical'
* or 'Horizontal' (case sensitive)
* @param Image_Graph_Element $part1 The 1st part of the layout
* @param Image_Graph_Element $part2 The 2nd part of the layout
* @param int $percentage The percentage of the layout to split at
* @return Image_Graph_Layout The newly created layout object
* @static
*/
function &layoutFactory($layout, &$part1, &$part2, $percentage = 50)
{
if (($layout != 'Vertical') && ($layout != 'Horizontal')) {
return $this->_error('Layouts must be either \'Horizontal\' or \'Vertical\'');
}
if (!(is_a($part1, 'Image_Graph_Element'))) {
return $this->_error('Part 1 is not a valid Image_Graph element');
}
if (!(is_a($part2, 'Image_Graph_Element'))) {
return $this->_error('Part 2 is not a valid Image_Graph element');
}
if ((!is_numeric($percentage)) || ($percentage < 0) || ($percentage > 100)) {
return $this->_error('Percentage has to be a number between 0 and 100');
}
include_once "Image/Graph/Layout/$layout.php";
$class = "Image_Graph_Layout_$layout";
$obj =& new $class($part1, $part2, $percentage);
return $obj;
}
/**
* Factory method to create horizontal layout.
*
* See {@link Image_Graph::layoutFactory()}
*
* @param Image_Graph_Element $part1 The 1st (left) part of the layout
* @param Image_Graph_Element $part2 The 2nd (right) part of the layout
* @param int $percentage The percentage of the layout to split at
* (percentage of total height from the left side)
* @return Image_Graph_Layout The newly created layout object
* @static
*/
function &horizontal(&$part1, &$part2, $percentage = 50)
{
$obj =& Image_Graph::layoutFactory('Horizontal', $part1, $part2, $percentage);
return $obj;
}
/**
* Factory method to create vertical layout.
*
* See {@link Image_Graph::layoutFactory()}
*
* @param Image_Graph_Element $part1 The 1st (top) part of the layout
* @param Image_Graph_Element $part2 The 2nd (bottom) part of the layout
* @param int $percentage The percentage of the layout to split at
* (percentage of total width from the top edge)
* @return Image_Graph_Layout The newly created layout object
* @static
*/
function &vertical(&$part1, &$part2, $percentage = 50)
{
$obj =& Image_Graph::layoutFactory('Vertical', $part1, $part2, $percentage);
return $obj;
}
/**
* The error handling routine set by set_error_handler().
*
* This method is used internaly by Image_Graph and PHP as a proxy for {@link
* Image_Graph::_error()}.
*
* @param string $error_type The type of error being handled.
* @param string $error_msg The error message being handled.
* @param string $error_file The file in which the error occurred.
* @param integer $error_line The line in which the error occurred.
* @param string $error_context The context in which the error occurred.
* @access private
*/
function _default_error_handler($error_type, $error_msg, $error_file, $error_line, $error_context)
{
switch( $error_type ) {
case E_ERROR:
$level = 'error';
break;
case E_USER_ERROR:
$level = 'user error';
break;
case E_WARNING:
$level = 'warning';
break;
case E_USER_WARNING:
$level = 'user warning';
break;
case E_NOTICE:
$level = 'notice';
break;
case E_USER_NOTICE:
$level = 'user notice';
break;
default:
$level = '(unknown)';
break;
}
$this->_error("PHP $level: $error_msg",
array(
'type' => $error_type,
'file' => $error_file,
'line' => $error_line,
'context' => $error_context
)
);
}
/**
* Displays the errors on the error stack.
*
* Invoking this method cause all errors on the error stack to be displayed
* on the graph-output, by calling the {@link Image_Graph::_displayError()}
* method.
*
* @access private
*/
function _displayErrors()
{
return true;
}
/**
* Display an error from the error stack.
*
* This method writes error messages caught from the {@link Image_Graph::
* _default_error_handler()} if {@Image_Graph::displayErrors()} was invoked,
* and the error explicitly set by the system using {@link
* Image_Graph_Common::_error()}.
*
* @param int $x The horizontal position of the error message
* @param int $y The vertical position of the error message
* @param array $error The error context
*
* @access private
*/
function _displayError($x, $y, $error)
{
}
/**
* Outputs this graph using the canvas.
*
* This causes the graph to make all elements perform their output. Their
* result is 'written' to the output using the canvas, which also performs
* the actual output, fx. it being to a file or directly to the browser
* (in the latter case, the canvas will also make sure the correct HTTP
* headers are sent, making the browser handle the output correctly, if
* supported by it).
*
* Parameters are the ones supported by the canvas, common ones are:
*
* 'filename' To output to a file instead of browser
*
* 'tohtml' Return a HTML string that encompasses the current graph/canvas - this
* implies an implicit save using the following parameters: 'filename' The "temporary"
* filename of the graph, 'filepath' A path in the file system where Image_Graph can
* store the output (this file must be in DOCUMENT_ROOT scope), 'urlpath' The URL that the
* 'filepath' corresponds to (i.e. filepath + filename must be reachable from a browser using
* urlpath + filename)
*
* @param mixed $param The output parameters to pass to the canvas
* @return bool Was the output 'good' (true) or 'bad' (false).
*/
function done($param = false)
{
$result = $this->_reset();
if (PEAR::isError($result)) {
return $result;
}
return $this->_done($param);
}
/**
* Outputs this graph using the canvas.
*
* This causes the graph to make all elements perform their output. Their
* result is 'written' to the output using the canvas, which also performs
* the actual output, fx. it being to a file or directly to the browser
* (in the latter case, the canvas will also make sure the correct HTTP
* headers are sent, making the browser handle the output correctly, if
* supported by it).
*
* @param mixed $param The output parameters to pass to the canvas
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done($param = false)
{
$timeStart = $this->_getMicroTime();
if ($this->_shadow) {
$this->setPadding(20);
$this->_setCoords(
$this->_left,
$this->_top,
$this->_right - 10,
$this->_bottom - 10);
}
$result = $this->_updateCoords();
if (PEAR::isError($result)) {
return $result;
}
if ($this->_getBackground()) {
$this->_canvas->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_right,
'y1' => $this->_bottom
)
);
}
$result = parent::_done();
if (PEAR::isError($result)) {
return $result;
}
if ($this->_displayErrors) {
$this->_displayErrors();
}
$timeEnd = $this->_getMicroTime();
if (($this->_showTime) ||
((isset($param['showtime'])) && ($param['showtime'] === true))
) {
$text = 'Generated in ' .
sprintf('%0.3f', $timeEnd - $timeStart) . ' sec';
$this->write(
$this->_right,
$this->_bottom,
$text,
IMAGE_GRAPH_ALIGN_RIGHT + IMAGE_GRAPH_ALIGN_BOTTOM,
array('color' => 'red')
);
}
if (isset($param['filename'])) {
if ((isset($param['tohtml'])) && ($param['tohtml'])) {
return $this->_canvas->toHtml($param);
}
else {
return $this->_canvas->save($param);
}
} else {
return $this->_canvas->show($param);
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,437 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Category.php,v 1.19 2006/03/02 12:15:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis.php
*/
require_once 'Image/Graph/Axis.php';
/**
* A normal axis thats displays labels with a 'interval' of 1.
* This is basically a normal axis where the range is
* the number of labels defined, that is the range is explicitly defined
* when constructing the axis.
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Category extends Image_Graph_Axis
{
/**
* The labels shown on the axis
* @var array
* @access private
*/
var $_labels = false;
/**
* Image_Graph_Axis_Category [Constructor].
*
* @param int $type The type (direction) of the Axis
*/
function Image_Graph_Axis_Category($type = IMAGE_GRAPH_AXIS_X)
{
parent::Image_Graph_Axis($type);
$this->_labels = array();
$this->setlabelInterval(1);
}
/**
* Gets the minimum value the axis will show.
*
* This is always 0
*
* @return double The minumum value
* @access private
*/
function _getMinimum()
{
return 0;
}
/**
* Gets the maximum value the axis will show.
*
* This is always the number of labels passed to the constructor.
*
* @return double The maximum value
* @access private
*/
function _getMaximum()
{
return count($this->_labels) - 1;
}
/**
* Sets the minimum value the axis will show.
*
* A minimum cannot be set on a SequentialAxis, it is always 0.
*
* @param double Minimum The minumum value to use on the axis
* @access private
*/
function _setMinimum($minimum)
{
}
/**
* Sets the maximum value the axis will show
*
* A maximum cannot be set on a SequentialAxis, it is always the number
* of labels passed to the constructor.
*
* @param double Maximum The maximum value to use on the axis
* @access private
*/
function _setMaximum($maximum)
{
}
/**
* Forces the minimum value of the axis
*
* <b>A minimum cannot be set on this type of axis</b>
*
* To modify the labels which are displayed on the axis, instead use
* setLabelInterval($labels) where $labels is an array containing the
* values/labels the axis should display. <b>Note!</b> Only values in
* this array will then be displayed on the graph!
*
* @param double $minimum A minimum cannot be set on this type of axis
*/
function forceMinimum($minimum, $userEnforce = true)
{
}
/**
* Forces the maximum value of the axis
*
* <b>A maximum cannot be set on this type of axis</b>
*
* To modify the labels which are displayed on the axis, instead use
* setLabelInterval($labels) where $labels is an array containing the
* values/labels the axis should display. <b>Note!</b> Only values in
* this array will then be displayed on the graph!
*
* @param double $maximum A maximum cannot be set on this type of axis
*/
function forceMaximum($maximum, $userEnforce = true)
{
}
/**
* Sets an interval for where labels are shown on the axis.
*
* The label interval is rounded to nearest integer value.
*
* @param double $labelInterval The interval with which labels are shown
*/
function setLabelInterval($labelInterval = 'auto', $level = 1)
{
if (is_array($labelInterval)) {
parent::setLabelInterval($labelInterval);
} elseif ($labelInterval == 'auto') {
parent::setLabelInterval(1);
} else {
parent::setLabelInterval(round($labelInterval));
}
}
/**
* Preprocessor for values, ie for using logarithmic axis
*
* @param double $value The value to preprocess
* @return double The preprocessed value
* @access private
*/
function _value($value)
{
// $the_value = array_search($value, $this->_labels);
if (isset($this->_labels[$value])) {
$the_value = $this->_labels[$value];
if ($the_value !== false) {
return $the_value + ($this->_pushValues ? 0.5 : 0);
} else {
return 0;
}
}
}
/**
* Get the minor label interval with which axis label ticks are drawn.
*
* For a sequential axis this is always disabled (i.e false)
*
* @return double The minor label interval, always false
* @access private
*/
function _minorLabelInterval()
{
return false;
}
/**
* Get the size in pixels of the axis.
*
* For an x-axis this is the width of the axis including labels, and for an
* y-axis it is the corrresponding height
*
* @return int The size of the axis
* @access private
*/
function _size()
{
if (!$this->_visible) {
return 0;
}
$this->_canvas->setFont($this->_getFont());
$maxSize = 0;
foreach($this->_labels as $label => $id) {
$labelPosition = $this->_point($label);
if (is_object($this->_dataPreProcessor)) {
$labelText = $this->_dataPreProcessor->_process($label);
} else {
$labelText = $label;
}
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
(($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose)))
{
$maxSize = max($maxSize, $this->_canvas->textHeight($labelText));
} else {
$maxSize = max($maxSize, $this->_canvas->textWidth($labelText));
}
}
if ($this->_title) {
$this->_canvas->setFont($this->_getTitleFont());
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
(($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose)))
{
$maxSize += $this->_canvas->textHeight($this->_title);
} else {
$maxSize += $this->_canvas->textWidth($this->_title);
}
$maxSize += 10;
}
return $maxSize +3;
}
/**
* Apply the dataset to the axis.
*
* This calculates the order of the categories, which is very important
* for fx. line plots, so that the line does not "go backwards", consider
* these X-sets:<p>
* 1: (1, 2, 3, 4, 5, 6)<br>
* 2: (0, 1, 2, 3, 4, 5, 6, 7)<p>
* If they are not ordered, but simply appended, the categories on the axis
* would be:<p>
* X: (1, 2, 3, 4, 5, 6, 0, 7)<p>
* Which would render the a line for the second plot to show incorrectly.
* Instead this algorithm, uses and 'value- is- before' method to see that
* the 0 is before a 1 in the second set, and that it should also be before
* a 1 in the X set. Hence:<p>
* X: (0, 1, 2, 3, 4, 5, 6, 7)
*
* @param Image_Graph_Dataset $dataset The dataset
* @access private
*/
function _applyDataset(&$dataset)
{
$newLabels = array();
$allLabels = array();
$dataset->_reset();
$count = 0;
$count_new = 0;
while ($point = $dataset->_next()) {
if ($this->_type == IMAGE_GRAPH_AXIS_X) {
$data = $point['X'];
} else {
$data = $point['Y'];
}
if (!isset($this->_labels[$data])) {
$newLabels[$data] = $count_new++;
//$this->_labels[] = $data;
}
$allLabels[$data] = $count++;
}
if (count($this->_labels) == 0) {
$this->_labels = $newLabels;
} elseif ((is_array($newLabels)) && (count($newLabels) > 0)) {
// get all intersecting labels
$intersect = array_intersect(array_keys($allLabels), array_keys($this->_labels));
// traverse all new and find their relative position withing the
// intersec, fx value X0 is before X1 in the intersection, which
// means that X0 should be placed before X1 in the label array
foreach($newLabels as $newLabel => $id) {
$key = $allLabels[$newLabel];
reset($intersect);
$this_value = false;
// intersect indexes are the same as in allLabels!
$first = true;
while ((list($id, $value) = each($intersect)) &&
($this_value === false))
{
if (($first) && ($id > $key)) {
$this_value = $value;
} elseif ($id >= $key) {
$this_value = $value;
}
$first = false;
}
if ($this_value === false) {
// the new label was not found before anything in the
// intersection -> append it
$this->_labels[$newLabel] = count($this->_labels);
} else {
// the new label was found before $this_value in the
// intersection, insert the label before this position in
// the label array
// $key = $this->_labels[$this_value];
$keys = array_keys($this->_labels);
$key = array_search($this_value, $keys);
$pre = array_slice($keys, 0, $key);
$pre[] = $newLabel;
$post = array_slice($keys, $key);
$this->_labels = array_flip(array_merge($pre, $post));
}
}
unset($keys);
}
$labels = array_keys($this->_labels);
$i = 0;
foreach ($labels as $label) {
$this->_labels[$label] = $i++;
}
// $this->_labels = array_values(array_unique($this->_labels));
$this->_calcLabelInterval();
}
/**
* Return the label distance.
*
* @return int The distance between 2 adjacent labels
* @access private
*/
function _labelDistance($level = 1)
{
reset($this->_labels);
list($l1) = each($this->_labels);
list($l2) = each($this->_labels);
return abs($this->_point($l2) - $this->_point($l1));
}
/**
* Get next label point
*
* @param doubt $point The current point, if omitted or false, the first is
* returned
* @return double The next label point
* @access private
*/
function _getNextLabel($currentLabel = false, $level = 1)
{
if ($currentLabel === false) {
reset($this->_labels);
}
$result = false;
$count = ($currentLabel === false ? $this->_labelInterval() - 1 : 0);
while ($count < $this->_labelInterval()) {
$result = (list($label) = each($this->_labels));
$count++;
}
if ($result) {
return $label;
} else {
return false;
}
}
/**
* Is the axis numeric or not?
*
* @return bool True if numeric, false if not
* @access private
*/
function _isNumeric()
{
return false;
}
/**
* Output the axis
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$result = true;
if (Image_Graph_Element::_done() === false) {
$result = false;
}
$this->_canvas->startGroup(get_class($this));
$this->_drawAxisLines();
$this->_canvas->startGroup(get_class($this) . '_ticks');
$label = false;
while (($label = $this->_getNextLabel($label)) !== false) {
$this->_drawTick($label);
}
$this->_canvas->endGroup();
$this->_canvas->endGroup();
return $result;
}
}
?>

View File

@ -1,152 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Logarithmic.php,v 1.15 2006/03/02 12:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis.php
*/
require_once 'Image/Graph/Axis.php';
/**
* Diplays a logarithmic axis (either X- or Y-axis).
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis
{
/**
* Image_Graph_AxisLogarithmic [Constructor].
*
* Normally a manual creation should not be necessary, axis are
* created automatically by the {@link 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_Logarithmic($type = IMAGE_GRAPH_AXIS_X)
{
parent::Image_Graph_Axis($type);
$this->showLabel(IMAGE_GRAPH_LABEL_MINIMUM + IMAGE_GRAPH_LABEL_MAXIMUM);
$this->_minimum = 1;
$this->_minimumSet = true;
}
/**
* Calculate the label interval
*
* If explicitly defined this will be calucated to an approximate best.
*
* @return double The label interval
* @access private
*/
function _calcLabelInterval()
{
$result = parent::_calcLabelInterval();
$this->_axisValueSpan = $this->_value($this->_axisSpan);
return $result;
}
/**
* Preprocessor for values, ie for using logarithmic axis
*
* @param double $value The value to preprocess
* @return double The preprocessed value
* @access private
*/
function _value($value)
{
return log10($value) - log10($this->_minimum);
}
/**
* Get next label point
*
* @param doubt $point The current point, if omitted or false, the first is
* returned
* @return double The next label point
* @access private
*/
function _getNextLabel($currentLabel = false, $level = 1)
{
if (is_array($this->_labelOptions[$level]['interval'])) {
return parent::_getNextLabel($currentLabel, $level);
}
if ($currentLabel !== false) {
$value = log10($currentLabel);
$base = floor($value);
$frac = $value - $base;
for ($i = 2; $i < 10; $i++) {
if ($frac <= (log10($i)-0.01)) {
$label = pow(10, $base)*$i;
if ($label > $this->_getMaximum()) {
return false;
} else {
return $label;
}
}
}
return pow(10, $base+1);
}
return max(1, $this->_minimum);
}
/**
* Get the axis intersection pixel position
*
* This is only to be called prior to output! I.e. between the user
* invokation of Image_Graph::done() and any actual output is performed.
* This is because it can change the axis range.
*
* @param double $value the intersection value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _intersectPoint($value)
{
if (($value <= 0) && ($value !== 'max') && ($value !== 'min')) {
$value = 1;
}
return parent::_intersectPoint($value);
}
}
?>

View File

@ -1,156 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class file containing a axis marker used for explicitly highlighting a area
* on the graph, based on an interval specified on an axis.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Area.php,v 1.11 2005/08/24 20:36:04 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display a grid
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Marker_Area extends Image_Graph_Grid
{
/**
* The lower bound
* @var double
* @access private
*/
var $_lower = false;
/**
* The upper bound
* @var double
* @access private
*/
var $_upper = false;
/**
* [Constructor]
*/
function Image_Graph_Axis_Marker_Area()
{
parent::Image_Graph_Grid();
$this->_lineStyle = false;
}
/**
* Sets the lower bound of the area (value on the axis)
*
* @param double $lower the lower bound
*/
function setLowerBound($lower)
{
$this->_lower = $lower;
}
/**
* Sets the upper bound of the area (value on the axis)
*
* @param double $upper the upper bound
*/
function setUpperBound($upper)
{
$this->_upper = $upper;
}
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$i = 0;
$this->_lower = max($this->_primaryAxis->_getMinimum(), $this->_lower);
$this->_upper = min($this->_primaryAxis->_getMaximum(), $this->_upper);
$secondaryPoints = $this->_getSecondaryAxisPoints();
reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('Y' => $secondaryValue, 'X' => $this->_lower);
$p2 = array ('Y' => $previousSecondaryValue, 'X' => $this->_lower);
$p3 = array ('Y' => $previousSecondaryValue, 'X' => $this->_upper);
$p4 = array ('Y' => $secondaryValue, 'X' => $this->_upper);
} else {
$p1 = array ('X' => $secondaryValue, 'Y' => $this->_lower);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_lower);
$p3 = array ('X' => $previousSecondaryValue, 'Y' => $this->_upper);
$p4 = array ('X' => $secondaryValue, 'Y' => $this->_upper);
}
$this->_canvas->addVertex(array('x' => $this->_pointX($p1), 'y' => $this->_pointY($p1)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p2), 'y' => $this->_pointY($p2)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p3), 'y' => $this->_pointY($p3)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p4), 'y' => $this->_pointY($p4)));
$previousSecondaryValue = $secondaryValue;
$this->_getLineStyle();
$this->_getFillStyle();
$this->_canvas->polygon(array('connect' => true));
}
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,124 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class file containing a axis marker used for explicitly highlighting a point
* (line) on the graph, based on an value specified on an axis.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Line.php,v 1.11 2005/08/03 21:21:58 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display a grid
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Marker_Line extends Image_Graph_Grid
{
/**
* The value
* @var double
* @access private
*/
var $_value = false;
/**
* Sets the value of the line marker (value on the axis)
*
* @param double $value the value
*/
function setValue($value)
{
$this->_value = $value;
}
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$i = 0;
$this->_value = min($this->_primaryAxis->_getMaximum(), max($this->_primaryAxis->_getMinimum(), $this->_value));
$secondaryPoints = $this->_getSecondaryAxisPoints();
reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('X' => $this->_value, 'Y' => $secondaryValue);
$p2 = array ('X' => $this->_value, 'Y' => $previousSecondaryValue);
} else {
$p1 = array ('X' => $secondaryValue, 'Y' => $this->_value);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_value);
}
$x1 = $this->_pointX($p1);
$y1 = $this->_pointY($p1);
$x2 = $this->_pointX($p2);
$y2 = $this->_pointY($p2);
$previousSecondaryValue = $secondaryValue;
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x1, 'y0' => $y1, 'x1' => $x2, 'y1' => $y2));
}
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,204 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radar.php,v 1.6 2005/08/03 21:22:11 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis/Category.php
*/
require_once 'Image/Graph/Axis/Category.php';
/**
* Displays an 'X'-axis in a radar plot chart.
*
* This axis maps the number of elements in the dataset to a angle (from 0-
* 360 degrees). Displaying the axis consist of drawing a number of lines from
* center to the edge of the 'circle' than encloses the radar plot. The labels
* are drawn on the 'ends' of these radial lines.
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Radar extends Image_Graph_Axis_Category
{
/**
* Specifies the number of pixels, the labels is offsetted from the end of
* the axis
*
* @var int
* @access private
*/
var $_distanceFromEnd = 5;
/**
* Gets the minimum value the axis will show.
*
* This is always 0
*
* @return double The minumum value
* @access private
*/
function _getMinimum()
{
return 0;
}
/**
* Gets the maximum value the axis will show.
*
* This is always the number of labels passed to the constructor.
*
* @return double The maximum value
* @access private
*/
function _getMaximum()
{
return count($this->_labels);
}
/**
* Calculate the delta value (the number of pixels representing one unit
* on the axis)
*
* @return double The label interval
* @access private
*/
function _calcDelta()
{
if (abs($this->_getMaximum() - $this->_getMinimum()) == 0) {
$this->_delta = false;
} else {
$this->_delta = 360 / ($this->_getMaximum() - $this->_getMinimum());
}
}
/**
* Get the pixel position represented by a value on the canvas
*
* @param double $value the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _point($value)
{
return (90 + (int) ($this->_value($value) * $this->_delta)) % 360;
}
/**
* Get the size in pixels of the axis.
*
* For a radar plot this is always 0
*
* @return int The size of the axis
* @access private
*/
function _size()
{
return 0;
}
/**
* Sets the distance from the end of the category lines to the label.
*
* @param int $distance The distance in pixels
*/
function setDistanceFromEnd($distance = 5)
{
$this->_distanceFromEnd = $distance;
}
/**
* Draws axis lines.
*
* @access private
*/
function _drawAxisLines()
{
}
/**
* Output an axis tick mark.
*
* @param int $value The value to output
* @access private
*/
function _drawTick($value, $level = 1)
{
$centerX = (int) (($this->_left + $this->_right) / 2);
$centerY = (int) (($this->_top + $this->_bottom) / 2);
$radius = min($this->height(), $this->width()) / 2;
$endPoint = array ('X' => $value, 'Y' => '#max#');
$dX = $this->_pointX($endPoint);
$dY = $this->_pointY($endPoint);
$offX = ($dX - $centerX);
$offY = ($dY - $centerY);
$hyp = sqrt($offX*$offX + $offY*$offY);
if ($hyp != 0) {
$scale = $this->_distanceFromEnd / $hyp;
} else {
$scale = 1;
}
$adX = $dX + $offX * $scale;
$adY = $dY + $offY * $scale;
if (is_object($this->_dataPreProcessor)) {
$labelText = $this->_dataPreProcessor->_process($value);
} else {
$labelText = $value;
}
if ((abs($dX - $centerX) < 1.5) && ($dY < $centerY)) {
$align = IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_CENTER_X;
} elseif ((abs($dX - $centerX) < 1.5) && ($dY > $centerY)) {
$align = IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_CENTER_X;
} elseif ($dX < $centerX) {
$align = IMAGE_GRAPH_ALIGN_RIGHT + IMAGE_GRAPH_ALIGN_CENTER_Y;
} else {
$align = IMAGE_GRAPH_ALIGN_LEFT + IMAGE_GRAPH_ALIGN_CENTER_Y;
}
$this->write($adX, $adY, $labelText, $align);
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $centerX, 'y0' => $centerY, 'x1' => $dX, 'y1' => $dY));
}
}
?>

View File

@ -1,313 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Common.php,v 1.16 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
if (!function_exists('is_a')) {
/**
* Check if an object is of a given class, this function is available as of PHP 4.2.0, so if it exist it will not be declared
*
* @link http://www.php.net/manual/en/function.is-a.php PHP.net Online Manual for function is_a()
* @param object $object The object to check class for
* @param string $class_name The name of the class to check the object for
* @return bool Returns TRUE if the object is of this class or has this class as one of its parents
*/
function is_a($object, $class_name)
{
if (empty ($object)) {
return false;
}
$object = is_object($object) ? get_class($object) : $object;
if (strtolower($object) == strtolower($class_name)) {
return true;
}
return is_a(get_parent_class($object), $class_name);
}
}
/**
* Include file Image/Canvas.php
*/
require_once 'Image/Canvas.php';
/**
* The ultimate ancestor of all Image_Graph classes.
*
* This class contains common functionality needed by all Image_Graph classes.
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Common
{
/**
* The parent container of the current Image_Graph object
*
* @var Image_Graph_Common
* @access private
*/
var $_parent = null;
/**
* The sub-elements of the current Image_Graph container object
*
* @var array
* @access private
*/
var $_elements;
/**
* The canvas for output.
*
* Enables support for multiple output formats.
*
* @var Image_Canvas
* @access private
*/
var $_canvas = null;
/**
* Is the object visible?
*
* @var bool
* @access private
*/
var $_visible = true;
/**
* Constructor [Image_Graph_Common]
*/
function Image_Graph_Common()
{
}
/**
* Resets the elements
*
* @access private
*/
function _reset()
{
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this);
$result = $this->_elements[$key]->_reset();
if (PEAR::isError($result)) {
return $result;
}
}
}
unset($keys);
}
return true;
}
/**
* Sets the parent. The parent chain should ultimately be a GraPHP object
*
* @see Image_Graph_Common
* @param Image_Graph_Common $parent The parent
* @access private
*/
function _setParent(& $parent)
{
$this->_parent =& $parent;
$this->_canvas =& $this->_parent->_getCanvas();
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this);
}
}
unset($keys);
}
}
/**
* Hide the element
*/
function hide()
{
$this->_visible = false;
}
/**
* Get the canvas
*
* @return Image_Canvas The canvas
* @access private
*/
function &_getCanvas()
{
if (($this->_canvas !== null) || ($this->_canvas !== false)) {
return $this->_canvas;
} elseif (is_a($this->_parent, 'Image_Graph_Common')) {
$this->_canvas =& $this->_parent->_getCanvas();
return $this->_canvas;
} else {
$this->_error('Invalid canvas');
$result = null;
return $result;
}
}
/**
* Adds an element to the objects element list.
*
* The new Image_Graph_elements parent is automatically set.
*
* @param Image_Graph_Common $element The new Image_Graph_element
* @return Image_Graph_Common The new Image_Graph_element
*/
function &add(& $element)
{
if (!is_a($element, 'Image_Graph_Font')) {
$this->_elements[] = &$element;
}
$element->_setParent($this);
return $element;
}
/**
* Creates an object from the class and adds it to the objects element list.
*
* Creates an object from the class specified and adds it to the objects
* element list. If only one parameter is required for the constructor of
* the class simply pass this parameter as the $params parameter, unless the
* parameter is an array or a reference to a value, in that case you must
* 'enclose' the parameter in an array. Similar if the constructor takes
* more than one parameter specify the parameters in an array.
*
* @see Image_Graph::factory()
* @param string $class The class for the object
* @param mixed $params The paramaters to pass to the constructor
* @return Image_Graph_Common The new Image_Graph_element
*/
function &addNew($class, $params = null, $additional = false)
{
include_once 'Image/Graph.php';
$element =& Image_Graph::factory($class, $params);
if ($additional === false) {
$obj =& $this->add($element);
} else {
$obj =& $this->add($element, $additional);
}
return $obj;
}
/**
* Shows an error message box on the canvas
*
* @param string $text The error text
* @param array $params An array containing error specific details
* @param int $error_code Error code
* @access private
*/
function _error($text, $params = false, $error_code = IMAGE_GRAPH_ERROR_GENERIC)
{
if ((is_array($params)) && (count($params) > 0)) {
foreach ($params as $name => $key) {
if (isset($parameters)) {
$parameters .= ' ';
}
else {
$parameters = '';
}
$parameters .= $name . '=' . $key;
}
}
$error =& PEAR::raiseError(
$text .
($error_code != IMAGE_GRAPH_ERROR_GENERIC ? ' error:' . IMAGE_GRAPH_ERROR_GENERIC : '') .
(isset($parameters) ? ' parameters:[' . $parameters . ']' : '')
);
}
/**
* Causes the object to update all sub elements coordinates
*
* (Image_Graph_Common, does not itself have coordinates, this is basically
* an abstract method)
*
* @access private
*/
function _updateCoords()
{
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_updateCoords();
}
}
unset($keys);
}
return true;
}
/**
* Causes output to canvas
*
* The last method to call. Calling Done causes output to the canvas. All
* sub elements done() method will be invoked
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (($this->_canvas == null) || (!is_a($this->_canvas, 'Image_Canvas'))) {
return false;
}
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (($this->_elements[$key]->_visible) && ($this->_elements[$key]->_done() === false)) {
return false;
}
}
unset($keys);
}
return true;
}
}
?>

View File

@ -1,30 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Config.php,v 1.7 2005/08/03 21:21:52 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
?>

View File

@ -1,225 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Constants.php,v 1.7 2005/08/03 21:21:52 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Font.php
*/
require_once 'Image/Graph/Font.php';
// Constant declarations
/**
* Defines an X (horizontal) axis
*/
define('IMAGE_GRAPH_AXIS_X', 1);
/**
* Defines an Y (vertical) axis
*/
define('IMAGE_GRAPH_AXIS_Y', 2);
/**
* Defines an Y (vertical) axis
*/
define('IMAGE_GRAPH_AXIS_Y_SECONDARY', 3);
/**
* Defines an horizontal (X) axis
*/
define('IMAGE_GRAPH_AXIS_HORIZONTAL', 1);
/**
* Defines an vertical (Y) axis
*/
define('IMAGE_GRAPH_AXIS_VERTICAL', 2);
/**
* Define if label should be shown for axis minimum value
*/
define('IMAGE_GRAPH_LABEL_MINIMUM', 1);
/**
* Define if label should be shown for axis 0 (zero) value
*/
define('IMAGE_GRAPH_LABEL_ZERO', 2);
/**
* Define if label should be shown for axis maximum value
*/
define('IMAGE_GRAPH_LABEL_MAXIMUM', 4);
/**
* Defines a horizontal gradient fill
*/
define('IMAGE_GRAPH_GRAD_HORIZONTAL', 1);
/**
* Defines a vertical gradient fill
*/
define('IMAGE_GRAPH_GRAD_VERTICAL', 2);
/**
* Defines a horizontally mirrored gradient fill
*/
define('IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED', 3);
/**
* Defines a vertically mirrored gradient fill
*/
define('IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED', 4);
/**
* Defines a diagonal gradient fill from top-left to bottom-right
*/
define('IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR', 5);
/**
* Defines a diagonal gradient fill from bottom-left to top-right
*/
define('IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR', 6);
/**
* Defines a radial gradient fill
*/
define('IMAGE_GRAPH_GRAD_RADIAL', 7);
/**
* Defines the default builtin font
*/
define('IMAGE_GRAPH_FONT', 1);
/**
* Defines a X value should be used
*/
define('IMAGE_GRAPH_VALUE_X', 0);
/**
* Defines a Y value should be used
*/
define('IMAGE_GRAPH_VALUE_Y', 1);
/**
* Defines a min X% value should be used
*/
define('IMAGE_GRAPH_PCT_X_MIN', 2);
/**
* Defines a max X% value should be used
*/
define('IMAGE_GRAPH_PCT_X_MAX', 3);
/**
* Defines a min Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_MIN', 4);
/**
* Defines a max Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_MAX', 5);
/**
* Defines a total Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_TOTAL', 6);
/**
* Defines a ID value should be used
*/
define('IMAGE_GRAPH_POINT_ID', 7);
/**
* Align text left
*/
define('IMAGE_GRAPH_ALIGN_LEFT', 0x1);
/**
* Align text right
*/
define('IMAGE_GRAPH_ALIGN_RIGHT', 0x2);
/**
* Align text center x (horizontal)
*/
define('IMAGE_GRAPH_ALIGN_CENTER_X', 0x4);
/**
* Align text top
*/
define('IMAGE_GRAPH_ALIGN_TOP', 0x8);
/**
* Align text bottom
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM', 0x10);
/**
* Align text center y (vertical)
*/
define('IMAGE_GRAPH_ALIGN_CENTER_Y', 0x20);
/**
* Align text center (both x and y)
*/
define('IMAGE_GRAPH_ALIGN_CENTER', IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_CENTER_Y);
/**
* Align text top left
*/
define('IMAGE_GRAPH_ALIGN_TOP_LEFT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_LEFT);
/**
* Align text top right
*/
define('IMAGE_GRAPH_ALIGN_TOP_RIGHT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_RIGHT);
/**
* Align text bottom left
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM_LEFT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_LEFT);
/**
* Align text bottom right
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM_RIGHT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_RIGHT);
/**
* Align vertical
*/
define('IMAGE_GRAPH_ALIGN_VERTICAL', IMAGE_GRAPH_ALIGN_TOP);
/**
* Align horizontal
*/
define('IMAGE_GRAPH_ALIGN_HORIZONTAL', IMAGE_GRAPH_ALIGN_LEFT);
// Error codes
define('IMAGE_GRAPH_ERROR_GENERIC', 0);
?>

View File

@ -1,74 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: DataPreprocessor.php,v 1.7 2005/08/24 20:35:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Data preprocessor used for preformatting a data.
*
* A data preprocessor is used in cases where a value from a dataset or label must be
* displayed in another format or way than entered. This could for example be the need
* to display X-values as a date instead of 1, 2, 3, .. or even worse unix-timestamps.
* It could also be when a {@link Image_Graph_Marker_Value} needs to display values as percentages
* with 1 decimal digit instead of the default formatting (fx. 12.01271 -> 12.0%).
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_DataPreprocessor
{
/**
* Image_Graph_DataPreprocessor [Constructor].
*/
function Image_Graph_DataPreprocessor()
{
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return $value;
}
}
?>

View File

@ -1,103 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Array.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Format data as looked up in an array.
*
* ArrayData is useful when a numercal value is to be translated to
* something thats cannot directly be calculated from this value, this could for
* example be a dataset meant to plot population of various countries. Since x-
* values are numerical and they should really be country names, but there is no
* linear correlation between the number and the name, we use an array to 'map'
* the numbers to the name, i.e. $array[0] = 'Denmark'; $array[1] = 'Sweden';
* ..., where the indexes are the numerical values from the dataset. This is NOT
* usefull when the x-values are a large domain, i.e. to map unix timestamps to
* date-strings for an x-axis. This is because the x-axis will selecte arbitrary
* values for labels, which would in principle require the ArrayData to hold
* values for every unix timestamp. However ArrayData can still be used to solve
* such a situation, since one can use another value for X-data in the dataset
* and then map this (smaller domain) value to a date. That is we for example
* instead of using the unix-timestamp we use value 0 to represent the 1st date,
* 1 to represent the next date, etc.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Array extends Image_Graph_DataPreprocessor
{
/**
* The data label array
* @var array
* @access private
*/
var $_dataArray;
/**
* Image_Graph_ArrayData [Constructor].
*
* @param array $array The array to use as a lookup table
*/
function Image_Graph_DataPreprocessor_Array($array)
{
parent::Image_Graph_DataPreprocessor();
$this->_dataArray = $array;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
if ((is_array($this->_dataArray)) && (isset ($this->_dataArray[$value]))) {
return $this->_dataArray[$value];
} else {
return $value;
}
}
}
?>

View File

@ -1,66 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Currency.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor/Formatted.php
*/
require_once 'Image/Graph/DataPreprocessor/Formatted.php';
/**
* Format data as a currency.
*
* Uses the {@link Image_Graph_DataPreprocessor_Formatted} to represent the
* values as a currency, i.e. 10 => 10.00
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Currency extends Image_Graph_DataPreprocessor_Formatted
{
/**
* Image_Graph_CurrencyData [Constructor].
*
* @param string $currencySymbol The symbol representing the currency
*/
function Image_Graph_DataPreprocessor_Currency($currencySymbol)
{
parent::Image_Graph_DataPreprocessor_Formatted("$currencySymbol %0.2f");
}
}
?>

View File

@ -1,90 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Date.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formats Unix timestamp as a date using specified format.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Date extends Image_Graph_DataPreprocessor
{
/**
* The format of the Unix time stamp.
* See <a href = 'http://www.php.net/manual/en/function.date.php'>PHP
* Manual</a> for a description
* @var string
* @access private
*/
var $_format;
/**
* Create a DateData preprocessor [Constructor]
*
* @param string $format See {@link http://www.php.net/manual/en/function.date.php
* PHP Manual} for a description
*/
function Image_Graph_DataPreprocessor_Date($format)
{
parent::Image_Graph_DataPreprocessor();
$this->_format = $format;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
if (!$value) {
return false;
} else {
return date($this->_format, $value);
}
}
}
?>

View File

@ -1,90 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Formatted.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Format data using a (s)printf pattern.
*
* This method is useful when data must displayed using a simple (s) printf
* pattern as described in the {@link http://www.php. net/manual/en/function.
* sprintf.php PHP manual}
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Formatted extends Image_Graph_DataPreprocessor
{
/**
* A (s)printf format string.
* See {@link http://www.php.net/manual/en/function.sprintf.php PHP Manual}
* for a description
* @var string
* @access private
*/
var $_format;
/**
* Create a (s)printf format data preprocessor
*
* @param string $format See {@link http://www.php.net/manual/en/function.sprintf.php
* PHP Manual} for a description
*/
function Image_Graph_DataPreprocessor_Formatted($format)
{
parent::Image_Graph_DataPreprocessor();
$this->_format = $format;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return sprintf($this->_format, $value);
}
}
?>

View File

@ -1,92 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Function.php,v 1.7 2005/11/11 17:53:44 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formatting a value using a userdefined function.
*
* Use this method to convert/format a value to a 'displayable' lable using a (perhaps)
* more complex function. An example could be (not very applicable though) if one would
* need for values to be displayed on the reverse order, i.e. 1234 would be displayed as
* 4321, then this method can solve this by creating the function that converts the value
* and use the FunctionData datapreprocessor to make Image_Graph use this function.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Function extends Image_Graph_DataPreprocessor
{
/**
* The name of the PHP function
* @var string
* @access private
*/
var $_dataFunction;
/**
* Create a FunctionData preprocessor
*
* @param string $function The name of the PHP function to use as
* a preprocessor, this function must take a single parameter and return a
* formatted version of this parameter
*/
function Image_Graph_DataPreprocessor_Function($function)
{
parent::Image_Graph_DataPreprocessor();
$this->_dataFunction = $function;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
$function = $this->_dataFunction;
return call_user_func($function, $value);
}
}
?>

View File

@ -1,89 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: NumberText.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formatting a number as its written in languages supported by Numbers_Words.
*
* Used to display values as text, i.e. 123 is displayed as one hundred and twenty three.
* Requires Numbers_Words
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_NumberText extends Image_Graph_DataPreprocessor
{
/**
* The language identifier
* @var string
* @access private
*/
var $_language;
/**
* Image_Graph_NumberText [Constructor].
*
* Supported languages see {@link http://pear.php.net/package/Numbers_Words Numbers_Words}
*
* @param string $langugage The language identifier for the language.
*/
function Image_Graph_DataPreprocessor_NumberText($language = 'en_US')
{
parent::Image_Graph_DataPreprocessor();
$this->_language = $language;
require_once 'Numbers/Words.php';
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return Numbers_Words::toWords($value, $this->_language);
}
}
?>

View File

@ -1,79 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: RomanNumerals.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formatting a value as a roman numerals.
*
* Values are formatted as roman numeral, i.e. 1 = I, 2 = II, 9 = IX, 2004 = MMIV.
* Requires Numbers_Roman
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_RomanNumerals extends Image_Graph_DataPreprocessor
{
/**
* Create a RomanNumerals preprocessor
*
* See {@link http://pear.php.net/package/Numbers_Roman Numbers_Roman}
*/
function Image_Graph_DataPreprocessor_RomanNumerals()
{
parent::Image_Graph_DataPreprocessor();
include_once 'Numbers/Roman.php';
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return Numbers_Roman::toNumeral($value);
}
}
?>

View File

@ -1,67 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Sequential.php,v 1.5 2005/02/21 20:49:50 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor/Array.php
*/
require_once 'Image/Graph/DataPreprocessor/Array.php';
/**
* Formatting values using a sequential data label array, ie. returning the
* 'next label' when asked for any label.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Sequential extends Image_Graph_DataPreprocessor_Array
{
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
list ($id, $value) = each($this->_dataArray);
return $value;
}
}
?>

View File

@ -1,67 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: DataSelector.php,v 1.7 2005/08/24 20:35:56 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Filter used for selecting which data to show as markers
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector
{
/**
* Image_Graph_DataSelector [Constructor]
*/
function Image_Graph_DataSelector()
{
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false if not
* @access private
*/
function _select($values)
{
return true;
}
}
?>

View File

@ -1,97 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: EveryNthPoint.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all points except every Nth point.
*
* Use this dataselector if you have a large number of datapoints, but only want to
* show markers for a small number of them, say every 10th.
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_EveryNthPoint extends Image_Graph_DataSelector
{
/**
* The number of points checked
* @var int
* @access private
*/
var $_pointNum = 0;
/**
* The number of points between every 'show', default: 10
* @var int
* @access private
*/
var $_pointInterval = 10;
/**
* EvertNthPoint [Constructor]
*
* @param int $pointInterval The number of points between every 'show',
* default: 10
*/
function Image_Graph_DataSelector_EveryNthpoint($pointInterval = 10)
{
parent::Image_Graph_DataSelector();
$this->_pointInterval = $pointInterval;
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown,
* false if not
* @access private
*/
function _select($values)
{
$oldPointNum = $this->_pointNum;
$this->_pointNum++;
return (($oldPointNum % $this->_pointInterval) == 0);
}
}
?>

View File

@ -1,68 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: NoZeros.php,v 1.5 2005/02/21 20:49:58 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all zero's.
*
* Display all Y-values as markers, except those with Y = 0
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_NoZeros extends Image_Graph_DataSelector
{
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false
* if not
* @access private
*/
function _select($values)
{
return ($values['Y'] != 0);
}
}
?>

View File

@ -1,90 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Values.php,v 1.2 2005/10/05 20:51:21 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all but the specified values.
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_Values extends Image_Graph_DataSelector {
/**
* The array with values that should be included
* @var array
* @access private
*/
var $_values;
/**
* ValueArray [Constructor]
*
* @param array $valueArray The array to use as filter (default empty)
*/
function &Image_Graph_DataSelector_Values($values)
{
parent::Image_Graph_DataSelector();
$this->_values = $values;
}
/**
* Sets the array to use
*/
function setValueArray($values)
{
$this->_values = $values;
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false
* if not
* @access private
*/
function _select($values)
{
return ( in_array($values['Y'], $this->_values) );
}
}
?>

View File

@ -1,483 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Dataset.php,v 1.10 2005/08/24 20:35:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Data set used to represent a data collection to plot in a chart
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Dataset
{
/**
* The pointer of the data set
* @var int
* @access private
*/
var $_posX = 0;
/**
* The minimum X value of the dataset
* @var int
* @access private
*/
var $_minimumX = 0;
/**
* The maximum X value of the dataset
* @var int
* @access private
*/
var $_maximumX = 0;
/**
* The minimum Y value of the dataset
* @var int
* @access private
*/
var $_minimumY = 0;
/**
* The maximum Y value of the dataset
* @var int
* @access private
*/
var $_maximumY = 0;
/**
* The number of points in the dataset
* @var int
* @access private
*/
var $_count = 0;
/**
* The name of the dataset, used for legending
* @var string
* @access private
*/
var $_name = '';
/**
* Image_Graph_Dataset [Constructor]
*/
function Image_Graph_Dataset()
{
}
/**
* Sets the name of the data set, used for legending
*
* @param string $name The name of the dataset
*/
function setName($name)
{
$this->_name = $name;
}
/**
* Add a point to the dataset
*
* $ID can contain either the ID of the point, i.e. 'DK', 123, 'George', etc. or it can contain
* values used for creation of the HTML image map. This is achieved using is an an associated array
* with the following values:
*
* 'url' The URL to create the link to
*
* 'alt' [optional] The alt text on the link
*
* 'target' [optional] The target of the link
*
* 'htmltags' [optional] An associated array with html tags (tag as key), fx. 'onMouseOver' => 'history.go(-1);', 'id' => 'thelink'
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
if ($y !== null) {
if (is_array($y)) {
$maxY = max($y);
$minY = min($y);
} else {
$maxY = $y;
$minY = $y;
}
}
if ($this->_count) {
$this->_minimumX = min($x, $this->_minimumX);
$this->_maximumX = max($x, $this->_maximumX);
if ($y !== null) {
$this->_minimumY = min($minY, $this->_minimumY);
$this->_maximumY = max($maxY, $this->_maximumY);
}
} else {
$this->_minimumX = $x;
$this->_maximumX = $x;
if ($y !== null) {
$this->_minimumY = $minY;
$this->_maximumY = $maxY;
}
}
$this->_count++;
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
*/
function count()
{
return $this->_count;
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a vector
* function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
return $x;
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return var The Y value of the variable
* @access private
*/
function _getPointY($x)
{
return $x;
}
/**
* Gets a ID from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return var The ID value of the variable
* @access private
*/
function _getPointID($x)
{
return false;
}
/**
* Gets point data from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return array The data for the point
* @access private
*/
function _getPointData($x)
{
return false;
}
/**
* The minimum X value
*
* @return var The minimum X value
*/
function minimumX()
{
return $this->_minimumX;
}
/**
* The maximum X value
*
* @return var The maximum X value
*/
function maximumX()
{
return $this->_maximumX;
}
/**
* The minimum Y value
*
* @return var The minimum Y value
*/
function minimumY()
{
return $this->_minimumY;
}
/**
* The maximum Y value
*
* @return var The maximum Y value
*/
function maximumY()
{
return $this->_maximumY;
}
/**
* The first point
*
* @return array The last point
*/
function first()
{
return array('X' => $this->minimumX(), 'Y' => $this->minimumY());
}
/**
* The last point
*
* @return array The first point
*/
function last()
{
return array('X' => $this->maximumX(), 'Y' => $this->maximumY());
}
/**
* The minimum X value
*
* @param var $value The minimum X value
* @access private
*/
function _setMinimumX($value)
{
$this->_minimumX = $value;
}
/**
* The maximum X value
*
* @param var $value The maximum X value
* @access private
*/
function _setMaximumX($value)
{
$this->_maximumX = $value;
}
/**
* The minimum Y value
*
* @param var $value The minimum X value
* @access private
*/
function _setMinimumY($value)
{
$this->_minimumY = $value;
}
/**
* The maximum Y value
*
* @param var $value The maximum X value
* @access private
*/
function _setMaximumY($value)
{
$this->_maximumY = $value;
}
/**
* The interval between 2 adjacent X values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return 1;
}
/**
* The interval between 2 adjacent Y values
*
* @return var The interval
* @access private
*/
function _stepY()
{
return 1;
}
/**
* Reset the intertal dataset pointer
*
* @return var The first X value
* @access private
*/
function _reset()
{
$this->_posX = $this->_minimumX;
return $this->_posX;
}
/**
* Get a point close to the internal pointer
*
* @param int Step Number of points next to the internal pointer, negative
* Step is towards lower X values, positive towards higher X values
* @return array The point
* @access private
*/
function _nearby($step = 0)
{
$x = $this->_getPointX($this->_posX + $this->_stepX() * $step);
$y = $this->_getPointY($this->_posX + $this->_stepX() * $step);
$ID = $this->_getPointID($this->_posX + $this->_stepX() * $step);
$data = $this->_getPointData($this->_posX + $this->_stepX() * $step);
if (($x === false) || ($y === false)) {
return false;
} else {
return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
}
/**
* Get the next point the internal pointer refers to and advance the pointer
*
* @return array The next point
* @access private
*/
function _next()
{
if ($this->_posX > $this->_maximumX) {
return false;
}
$x = $this->_getPointX($this->_posX);
$y = $this->_getPointY($this->_posX);
$ID = $this->_getPointID($this->_posX);
$data = $this->_getPointData($this->_posX);
$this->_posX += $this->_stepX();
return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
/**
* Get the average of the dataset's Y points
*
* @return var The Y-average across the dataset
* @access private
*/
function _averageY()
{
$posX = $this->_minimumX;
$count = 0;
$total = 0;
while ($posX < $this->_maximumX) {
$count ++;
$total += $this->_getPointY($posX);
$posX += $this->_stepX();
}
if ($count != 0) {
return $total / $count;
} else {
return false;
}
}
/**
* Get the median of the array passed Y points
*
* @param array $data The data-array to get the median from
* @param int $quartile The quartile to return the median from
* @return var The Y-median across the dataset from the specified quartile
* @access private
*/
function _median($data, $quartile = 'second')
{
sort($data);
$point = (count($data) - 1) / 2;
if ($quartile == 'first') {
$lowPoint = 0;
$highPoint = floor($point);
} elseif ($quartile == 'third') {
$lowPoint = round($point);
$highPoint = count($data) - 1;
} else {
$lowPoint = 0;
$highPoint = count($data) - 1;
}
$point = ($lowPoint + $highPoint) / 2;
if (floor($point) != $point) {
$point = floor($point);
return ($data[$point] + $data[($point + 1)]) / 2;
} else {
return $data[$point];
}
}
/**
* Get the median of the datasets Y points
*
* @param int $quartile The quartile to return the median from
* @return var The Y-median across the dataset from the specified quartile
* @access private
*/
function _medianY($quartile = 'second')
{
$pointsY = array();
$posX = $this->_minimumX;
while ($posX <= $this->_maximumX) {
$pointsY[] = $this->_getPointY($posX);
$posX += $this->_stepX();
}
return $this->_median($pointsY, $quartile);
}
}
?>

View File

@ -1,147 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Function.php,v 1.7 2005/08/24 20:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Function data set, points are generated by calling an external function.
*
* The function must be a single variable function and return a the result,
* builtin functions that are fx sin() or cos(). User defined function can be
* used if they are such, i.e: function myFunction($variable)
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Function extends Image_Graph_Dataset
{
/**
* The name of the function
* @var string
* @access private
*/
var $_dataFunction;
/**
* Image_Graph_FunctionDataset [Constructor]
*
* @param double $minimumX The minimum X value
* @param double $maximumX The maximum X value
* @param string $function The name of the function, if must be a single
* parameter function like fx sin(x) or cos(x)
* @param int $points The number of points to create
*/
function Image_Graph_Dataset_Function($minimumX, $maximumX, $function, $points)
{
parent::Image_Graph_Dataset();
$this->_minimumX = $minimumX;
$this->_maximumX = $maximumX;
$this->_dataFunction = $function;
$this->_count = $points;
$this->_calculateMaxima();
}
/**
* Add a point to the dataset.
*
* You can't add points to a function dataset
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to apply the function to
* @return var The function applied to the X value
* @access private
*/
function _getPointY($x)
{
$function = $this->_dataFunction;
return $function ($x);
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
* @access private
*/
function _count()
{
return $this->_count;
}
/**
* The interval between 2 adjacent Y values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return ($this->_maximumX - $this->_minimumX) / $this->_count();
}
/**
* Calculates the Y extrema of the function
*
* @access private
*/
function _calculateMaxima()
{
$x = $this->_minimumX;
while ($x <= $this->_maximumX) {
$y = $this->_getPointY($x);
$this->_minimumY = min($y, $this->_minimumY);
$this->_maximumY = max($y, $this->_maximumY);
$x += $this->_stepX();
}
}
}
?>

View File

@ -1,77 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Random.php,v 1.6 2005/08/24 20:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset/Trivial.php
*/
require_once 'Image/Graph/Dataset/Trivial.php';
/**
* Random data set, points are generated by random.
*
* This dataset is mostly (if not solely) used for demo-purposes.
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Random extends Image_Graph_Dataset_Trivial
{
/**
* RandomDataset [Constructor]
*
* @param int $count The number of points to create
* @param double $minimum The minimum value the random set can be
* @param double $maximum The maximum value the random set can be
* @param bool $includeZero Whether 0 should be included or not as an X
* value, may be omitted, default: false</false>
*/
function Image_Graph_Dataset_Random($count, $minimum, $maximum, $includeZero = false)
{
parent::Image_Graph_Dataset_Trivial();
$i = 0;
while ($i < $count) {
$this->addPoint(
$ixc = ($includeZero ? $i : $i +1),
rand($minimum, $maximum)
);
$i ++;
}
}
}
?>

View File

@ -1,114 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Sequential.php,v 1.7 2005/08/24 20:35:58 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset/Trivial.php
*/
require_once 'Image/Graph/Dataset/Trivial.php';
/**
* Sequential data set, simply add points (y) 1 by 1.
*
* This is a single point (1D) dataset, all points are of the type (0, y1), (1,
* y2), (2, y3)... Where the X-value is implicitly incremented. This is useful
* for example for barcharts, where you could fx. use an {@link
* Image_Graph_Dataset_Array} datapreprocessor to make sence of the x-values.
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Sequential extends Image_Graph_Dataset_Trivial
{
/**
* Image_Graph_SequentialDataset [Constructor]
*/
function Image_Graph_Dataset_Sequential($dataArray = false)
{
parent::Image_Graph_Dataset_Trivial();
if (is_array($dataArray)) {
reset($dataArray);
foreach ($dataArray as $value) {
$this->addPoint($value);
}
}
}
/**
* Add a point to the dataset
*
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($y, $ID = false)
{
parent::addPoint($this->count(), $y);
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a
* vector function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
return ((int) $x);
}
/**
* The minimum X value
* @return var The minimum X value
*/
function minimumX()
{
return 0;
}
/**
* The maximum X value
* @return var The maximum X value
*/
function maximumX()
{
return $this->count();
}
}
?>

View File

@ -1,260 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Trivial.php,v 1.10 2005/09/25 18:08:56 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Trivial data set, simply add points (x, y) 1 by 1
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Trivial extends Image_Graph_Dataset
{
/**
* Data storage
* @var array
* @access private
*/
var $_data;
/**
* Image_Graph_Dataset_Trivial [Constructor]
*
* Pass an associated array ($data[$x] = $y) to the constructor for easy
* data addition. Alternatively (if multiple entries with same x value is
* required) pass an array with (x, y) values: $data[$id] = array('x' => $x,
* 'y' => $y);
*
* NB! If passing the 1st type array at this point, the x-values will also
* be used for ID tags, i.e. when using {@link Image_Graph_Fill_Array}. In
* the 2nd type the key/index of the "outermost" array will be the id tag
* (i.e. $id in the example)
*
* @param array $dataArray An associated array with values to the dataset
*/
function Image_Graph_Dataset_Trivial($dataArray = false)
{
parent::Image_Graph_Dataset();
$this->_data = array ();
if (is_array($dataArray)) {
reset($dataArray);
$keys = array_keys($dataArray);
foreach ($keys as $x) {
$y =& $dataArray[$x];
if ((is_array($y)) && (isset($y['x'])) && (isset($y['y']))) {
$this->addPoint($y['x'], $y['y'], (isset($y['id']) ? $y['id'] : $x));
} else {
$this->addPoint($x, $y, $x);
}
}
}
}
/**
* Add a point to the dataset
*
* $ID can contain either the ID of the point, i.e. 'DK', 123, 'George', etc. or it can contain
* values used for creation of the HTML image map. This is achieved using is an an associated array
* with the following values:
*
* 'url' The URL to create the link to
*
* 'alt' [optional] The alt text on the link
*
* 'target' [optional] The target of the link
*
* 'htmltags' [optional] An associated array with html tags (tag as key), fx. 'onMouseOver' => 'history.go(-1);', 'id' => 'thelink'
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
parent::addPoint($x, $y, $ID);
if (is_array($ID)) {
$data = $ID;
$ID = (isset($data['id']) ? $data['id'] : false);
} else {
$data = false;
}
$this->_data[] = array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
if (!is_numeric($x)) {
$this->_maximumX = count($this->_data);
}
}
/**
* The first point
*
* @return array The last point
*/
function first()
{
reset($this->_data);
return current($this->_data);
}
/**
* The last point
*
* @return array The first point
*/
function last()
{
return end($this->_data);
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a
* vector function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['X'];
} else {
return false;
}
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to return an Y value from, fx in a
* vector function data set
* @return var The Y value of the variable
* @access private
*/
function _getPointY($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['Y'];
} else {
return false;
}
}
/**
* Gets a ID from the dataset
*
* @param var $x The variable to return an Y value from, fx in a
* vector function data set
* @return var The ID value of the variable
* @access private
*/
function _getPointID($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['ID'];
} else {
return false;
}
}
/**
* Gets point data from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return array The data for the point
* @access private
*/
function _getPointData($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['data'];
} else {
return false;
}
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
*/
function count()
{
return count($this->_data);
}
/**
* Reset the intertal dataset pointer
*
* @return var The first X value
* @access private
*/
function _reset()
{
$this->_posX = 0;
return $this->_posX;
}
/**
* Get the next point the internal pointer refers to and advance the pointer
*
* @return array The next point
* @access private
*/
function _next()
{
if ($this->_posX >= $this->count()) {
return false;
}
$x = $this->_getPointX($this->_posX);
$y = $this->_getPointY($this->_posX);
$ID = $this->_getPointID($this->_posX);
$data = $this->_getPointData($this->_posX);
$this->_posX += $this->_stepX();
return array('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
}
?>

View File

@ -1,185 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: VectorFunction.php,v 1.6 2005/08/24 20:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Vector Function data set.
*
* Points are generated by calling 2 external functions, fx. x = sin(t) and y =
* cos(t)
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_VectorFunction extends Image_Graph_Dataset
{
/**
* The name of the X function
* @var string
* @access private
*/
var $_functionX;
/**
* The name of the Y function
* @var string
* @access private
*/
var $_functionY;
/**
* The minimum of the vector function variable
* @var double
* @access private
*/
var $_minimumT;
/**
* The maximum of the vector function variable
* @var double
* @access private
*/
var $_maximumT;
/**
* Image_Graph_VectorFunctionDataset [Constructor]
*
* @param double $minimumT The minimum value of the vector function variable
* @param double $maximumT The maximum value of the vector function variable
* @param string $functionX The name of the X function, if must be a single
* parameter function like fx sin(x) or cos(x)
* @param string $functionY The name of the Y function, if must be a single
* parameter function like fx sin(x) or cos(x)
* @param int $points The number of points to create
*/
function Image_Graph_Dataset_VectorFunction($minimumT, $maximumT, $functionX, $functionY, $points)
{
parent::Image_Graph_Dataset();
$this->_minimumT = $minimumT;
$this->_maximumT = $maximumT;
$this->_functionX = $functionX;
$this->_functionY = $functionY;
$this->_count = $points;
$this->_calculateMaxima();
}
/**
* Add a point to the dataset
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to apply the X function to
* @return var The X function applied to the X value
* @access private
*/
function _getPointX($x)
{
$functionX = $this->_functionX;
return $functionX ($x);
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to apply the Y function to
* @return var The Y function applied to the X value
* @access private
*/
function _getPointY($x)
{
$functionY = $this->_functionY;
return $functionY ($x);
}
/**
* Reset the intertal dataset pointer
*
* @return var The first T value
* @access private
*/
function _reset()
{
$this->_posX = $this->_minimumT;
return $this->_posX;
}
/**
* The interval between 2 adjacent T values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return ($this->_maximumT - $this->_minimumT) / $this->count();
}
/**
* Calculates the X and Y extrema of the functions
*
* @access private
*/
function _calculateMaxima()
{
$t = $this->_minimumT;
while ($t <= $this->_maximumT) {
$x = $this->_getPointX($t);
$y = $this->_getPointY($t);
$this->_minimumX = min($x, $this->_minimumX);
$this->_maximumX = max($x, $this->_maximumX);
$this->_minimumY = min($y, $this->_minimumY);
$this->_maximumY = max($y, $this->_maximumY);
$t += $this->_stepX();
}
}
}
?>

View File

@ -1,763 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Element.php,v 1.18 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Common.php
*/
require_once 'Image/Graph/Common.php';
/**
* Representation of a element.
*
* The Image_Graph_Element can be drawn on the canvas, ie it has coordinates,
* {@link Image_Graph_Line}, {@link Image_Graph_Fill}, border and background -
* although not all of these may apply to all children.
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Element extends Image_Graph_Common
{
/**
* The leftmost pixel of the element on the canvas
* @var int
* @access private
*/
var $_left = 0;
/**
* The topmost pixel of the element on the canvas
* @var int
* @access private
*/
var $_top = 0;
/**
* The rightmost pixel of the element on the canvas
* @var int
* @access private
*/
var $_right = 0;
/**
* The bottommost pixel of the element on the canvas
* @var int
* @access private
*/
var $_bottom = 0;
/**
* Background of the element. Default: None
* @var FillStyle
* @access private
*/
var $_background = null;
/**
* Borderstyle of the element. Default: None
* @var LineStyle
* @access private
*/
var $_borderStyle = null;
/**
* Line style of the element. Default: None
* @var LineStyle
* @access private
*/
var $_lineStyle = 'black';
/**
* Fill style of the element. Default: None
* @var FillStyle
* @access private
*/
var $_fillStyle = 'white';
/**
* Font of the element. Default: Standard font - FONT
* @var Font
* @access private
* @see $IMAGE_GRAPH_FONT
*/
var $_font = null;
/**
* Font options
* @var array
* @access private
*/
var $_fontOptions = array();
/**
* Default font options
*
* This option is included for performance reasons. The value is calculated
* before output and reused in default cases to avoid unnecessary recursive
* calls.
*
* @var array
* @access private
*/
var $_defaultFontOptions = false;
/**
* Shadows options of the element
* @var mixed
* @access private
*/
var $_shadow = false;
/**
* The padding displayed on the element
* @var int
* @access private
*/
var $_padding = array('left' => 0, 'top' => 0, 'right' => 0, 'bottom' => 0);
/**
* Sets the background fill style of the element
*
* @param Image_Graph_Fill $background The background
* @see Image_Graph_Fill
*/
function setBackground(& $background)
{
if (!is_a($background, 'Image_Graph_Fill')) {
$this->_error(
'Could not set background for ' . get_class($this) . ': ' .
get_class($background), array('background' => &$background)
);
} else {
$this->_background =& $background;
$this->add($background);
}
}
/**
* Shows shadow on the element
*/
function showShadow($color = 'black@0.2', $size = 5)
{
$this->_shadow = array(
'color' => $color,
'size' => $size
);
}
/**
* Sets the background color of the element.
*
* See colors.txt in the docs/ folder for a list of available named colors.
*
* @param mixed $color The color
*/
function setBackgroundColor($color)
{
$this->_background = $color;
}
/**
* Gets the background fill style of the element
*
* @return int A GD fillstyle representing the background style
* @see Image_Graph_Fill
* @access private
*/
function _getBackground()
{
if (is_object($this->_background)) {
$this->_canvas->setFill($this->_background->_getFillStyle());
} elseif ($this->_background != null) {
$this->_canvas->setFill($this->_background);
} else {
return false;
}
return true;
}
/**
* Sets the border line style of the element
*
* @param Image_Graph_Line $borderStyle The line style of the border
* @see Image_Graph_Line
*/
function setBorderStyle(& $borderStyle)
{
if (!is_a($borderStyle, 'Image_Graph_Line')) {
$this->_error(
'Could not set border style for ' . get_class($this) . ': ' .
get_class($borderStyle), array('borderstyle' => &$borderStyle)
);
} else {
$this->_borderStyle =& $borderStyle;
$this->add($borderStyle);
}
}
/**
* Sets the border color of the element.
*
* See colors.txt in the docs/ folder for a list of available named colors.
* @param mixed $color The color
*/
function setBorderColor($color)
{
$this->_borderStyle = $color;
}
/**
* Gets the border line style of the element
*
* @return int A GD linestyle representing the borders line style
* @see Image_Graph_Line
* @access private
*/
function _getBorderStyle()
{
if (is_object($this->_borderStyle)) {
$result = $this->_borderStyle->_getLineStyle();
$this->_canvas->setLineThickness($result['thickness']);
$this->_canvas->setLineColor($result['color']);
} elseif ($this->_borderStyle != null) {
$this->_canvas->setLineThickness(1);
$this->_canvas->setLineColor($this->_borderStyle);
} else {
return false;
}
return true;
}
/**
* Sets the line style of the element
*
* @param Image_Graph_Line $lineStyle The line style of the element
* @see Image_Graph_Line
*/
function setLineStyle(& $lineStyle)
{
if (!is_object($lineStyle)) {
$this->_error(
'Could not set line style for ' . get_class($this) . ': ' .
get_class($lineStyle), array('linestyle' => &$lineStyle)
);
} else {
$this->_lineStyle =& $lineStyle;
$this->add($lineStyle);
}
}
/**
* Sets the line color of the element.
*
* See colors.txt in the docs/ folder for a list of available named colors.
*
* @param mixed $color The color
*/
function setLineColor($color)
{
$this->_lineStyle = $color;
}
/**
* Gets the line style of the element
*
* @return int A GD linestyle representing the line style
* @see Image_Graph_Line
* @access private
*/
function _getLineStyle($ID = false)
{
if (is_object($this->_lineStyle)) {
$result = $this->_lineStyle->_getLineStyle($ID);
if (is_array($result)) {
$this->_canvas->setLineThickness($result['thickness']);
$this->_canvas->setLineColor($result['color']);
} else {
$this->_canvas->setLineThickness(1);
$this->_canvas->setLineColor($result);
}
} elseif ($this->_lineStyle != null) {
$this->_canvas->setLineThickness(1);
$this->_canvas->setLineColor($this->_lineStyle);
} else {
return false;
}
return true;
}
/**
* Sets the fill style of the element
*
* @param Image_Graph_Fill $fillStyle The fill style of the element
* @see Image_Graph_Fill
*/
function setFillStyle(& $fillStyle)
{
if (!is_a($fillStyle, 'Image_Graph_Fill')) {
$this->_error(
'Could not set fill style for ' . get_class($this) . ': ' .
get_class($fillStyle), array('fillstyle' => &$fillStyle)
);
} else {
$this->_fillStyle =& $fillStyle;
$this->add($fillStyle);
}
}
/**
* Sets the fill color of the element.
*
* See colors.txt in the docs/ folder for a list of available named colors.
*
* @param mixed $color The color
*/
function setFillColor($color)
{
$this->_fillStyle = $color;
}
/**
* Gets the fill style of the element
*
* @return int A GD filestyle representing the fill style
* @see Image_Graph_Fill
* @access private
*/
function _getFillStyle($ID = false)
{
if (is_object($this->_fillStyle)) {
$this->_canvas->setFill($this->_fillStyle->_getFillStyle($ID));
} elseif ($this->_fillStyle != null) {
$this->_canvas->setFill($this->_fillStyle);
} else {
return false;
}
return true;
}
/**
* Gets the font of the element.
*
* If not font has been set, the parent font is propagated through it's
* children.
*
* @return array An associated array used for canvas
* @access private
*/
function _getFont($options = false)
{
if (($options === false) && ($this->_defaultFontOptions !== false)) {
return $this->_defaultFontOptions;
}
if ($options === false) {
$saveDefault = true;
} else {
$saveDefault = false;
}
if ($options === false) {
$options = $this->_fontOptions;
} else {
$options = array_merge($this->_fontOptions, $options);
}
if ($this->_font == null) {
$result = $this->_parent->_getFont($options);
} else {
$result = $this->_font->_getFont($options);
}
if ((isset($result['size'])) && (isset($result['size_rel']))) {
$result['size'] += $result['size_rel'];
unset($result['size_rel']);
}
if ($saveDefault) {
$this->_defaultFontOptions = $result;
}
return $result;
}
/**
* Sets the font of the element
*
* @param Image_Graph_Font $font The font of the element
* @see Image_Graph_Font
*/
function setFont(& $font)
{
if (!is_a($font, 'Image_Graph_Font')) {
$this->_error('Invalid font set on ' . get_class($this));
} else {
$this->_font =& $font;
$this->add($font);
}
}
/**
* Sets the font size
*
* @param int $size The size of the font
*/
function setFontSize($size)
{
$this->_fontOptions['size'] = $size;
}
/**
* Sets the font angle
*
* @param int $angle The angle of the font
*/
function setFontAngle($angle)
{
if ($angle == 'vertical') {
$this->_fontOptions['vertical'] = true;
$this->_fontOptions['angle'] = 90;
} else {
$this->_fontOptions['angle'] = $angle;
}
}
/**
* Sets the font color
*
* @param mixed $color The color of the font
*/
function setFontColor($color)
{
$this->_fontOptions['color'] = $color;
}
/**
* Clip the canvas to the coordinates of the element
*
* @param $enable bool Whether clipping should be enabled or disabled
* @access protected
*/
function _clip($enable)
{
$this->_canvas->setClipping(
($enable ?
array(
'x0' => min($this->_left, $this->_right),
'y0' => min($this->_top, $this->_bottom),
'x1' => max($this->_left, $this->_right),
'y1' => max($this->_top, $this->_bottom)
)
: false
)
);
}
/**
* Sets the coordinates of the element
*
* @param int $left The leftmost pixel of the element on the canvas
* @param int $top The topmost pixel of the element on the canvas
* @param int $right The rightmost pixel of the element on the canvas
* @param int $bottom The bottommost pixel of the element on the canvas
* @access private
*/
function _setCoords($left, $top, $right, $bottom)
{
if ($left === false) {
$left = $this->_left;
}
if ($top === false) {
$top = $this->_top;
}
if ($right === false) {
$right = $this->_right;
}
if ($bottom === false) {
$bottom = $this->_bottom;
}
$this->_left = min($left, $right);
$this->_top = min($top, $bottom);
$this->_right = max($left, $right);
$this->_bottom = max($top, $bottom);
}
/**
* Moves the element
*
* @param int $deltaX Number of pixels to move the element to the right
* (negative values move to the left)
* @param int $deltaY Number of pixels to move the element downwards
* (negative values move upwards)
* @access private
*/
function _move($deltaX, $deltaY)
{
$this->_left += $deltaX;
$this->_right += $deltaX;
$this->_top += $deltaY;
$this->_bottom += $deltaY;
}
/**
* Sets the width of the element relative to the left side
*
* @param int $width Number of pixels the element should be in width
* @access private
*/
function _setWidth($width)
{
$this->_right = $this->_left + $width;
}
/**
* Sets the height of the element relative to the top
*
* @param int $width Number of pixels the element should be in height
* @access private
*/
function _setHeight($height)
{
$this->_bottom = $this->_top + $height;
}
/**
* Sets padding of the element
*
* @param mixed $padding Number of pixels the element should be padded with
* or an array of paddings (left, top, right and bottom as index)
*/
function setPadding($padding)
{
if (is_array($padding)) {
$this->_padding = array();
$this->_padding['left'] = (isset($padding['left']) ? $padding['left'] : 0);
$this->_padding['top'] = (isset($padding['top']) ? $padding['top'] : 0);
$this->_padding['right'] = (isset($padding['right']) ? $padding['right'] : 0);
$this->_padding['bottom'] = (isset($padding['bottom']) ? $padding['bottom'] : 0);
}
else {
$this->_padding = array(
'left' => $padding,
'top' => $padding,
'right' => $padding,
'bottom' => $padding
);
}
}
/**
* The width of the element on the canvas
*
* @return int Number of pixels representing the width of the element
*/
function width()
{
return abs($this->_right - $this->_left) + 1;
}
/**
* The height of the element on the canvas
*
* @return int Number of pixels representing the height of the element
*/
function height()
{
return abs($this->_bottom - $this->_top) + 1;
}
/**
* Left boundary of the background fill area
*
* @return int Leftmost position on the canvas
* @access private
*/
function _fillLeft()
{
return $this->_left + $this->_padding['left'];
}
/**
* Top boundary of the background fill area
*
* @return int Topmost position on the canvas
* @access private
*/
function _fillTop()
{
return $this->_top + $this->_padding['top'];
}
/**
* Right boundary of the background fill area
*
* @return int Rightmost position on the canvas
* @access private
*/
function _fillRight()
{
return $this->_right - $this->_padding['right'];
}
/**
* Bottom boundary of the background fill area
*
* @return int Bottommost position on the canvas
* @access private
*/
function _fillBottom()
{
return $this->_bottom - $this->_padding['bottom'];
}
/**
* Returns the filling width of the element on the canvas
*
* @return int Filling width
* @access private
*/
function _fillWidth()
{
return $this->_fillRight() - $this->_fillLeft() + 1;
}
/**
* Returns the filling height of the element on the canvas
*
* @return int Filling height
* @access private
*/
function _fillHeight()
{
return $this->_fillBottom() - $this->_fillTop() + 1;
}
/**
* Draws a shadow 'around' the element
*
* Not implemented yet.
*
* @access private
*/
function _displayShadow()
{
if (is_array($this->_shadow)) {
$this->_canvas->startGroup(get_class($this) . '_shadow');
$this->_canvas->setFillColor($this->_shadow['color']);
$this->_canvas->addVertex(array('x' => $this->_right + 1, 'y' => $this->_top + $this->_shadow['size']));
$this->_canvas->addVertex(array('x' => $this->_right + $this->_shadow['size'], 'y' => $this->_top + $this->_shadow['size']));
$this->_canvas->addVertex(array('x' => $this->_right + $this->_shadow['size'], 'y' => $this->_bottom + $this->_shadow['size']));
$this->_canvas->addVertex(array('x' => $this->_left + $this->_shadow['size'], 'y' => $this->_bottom + $this->_shadow['size']));
$this->_canvas->addVertex(array('x' => $this->_left + $this->_shadow['size'], 'y' => $this->_bottom + 1));
$this->_canvas->addVertex(array('x' => $this->_right + 1, 'y' => $this->_bottom + 1));
$this->_canvas->polygon(array('connect' => true));
$this->_canvas->endGroup();
}
}
/**
* Writes text to the canvas.
*
* @param int $x The x position relative to alignment
* @param int $y The y position relative to alignment
* @param string $text The text
* @param int $alignmen The text alignment (both vertically and horizontally)
*/
function write($x, $y, $text, $alignment = false, $font = false)
{
if (($font === false) && ($this->_defaultFontOptions !== false)) {
$font = $this->_defaultFontOptions;
} else {
$font = $this->_getFont($font);
}
if ($alignment === false) {
$alignment = IMAGE_GRAPH_ALIGN_LEFT + IMAGE_GRAPH_ALIGN_TOP;
}
$align = array();
if (($alignment & IMAGE_GRAPH_ALIGN_TOP) != 0) {
$align['vertical'] = 'top';
} else if (($alignment & IMAGE_GRAPH_ALIGN_BOTTOM) != 0) {
$align['vertical'] = 'bottom';
} else {
$align['vertical'] = 'center';
}
if (($alignment & IMAGE_GRAPH_ALIGN_LEFT) != 0) {
$align['horizontal'] = 'left';
} else if (($alignment & IMAGE_GRAPH_ALIGN_RIGHT) != 0) {
$align['horizontal'] = 'right';
} else {
$align['horizontal'] = 'center';
}
$this->_canvas->setFont($font);
$this->_canvas->addText(array('x' => $x, 'y' => $y, 'text' => $text, 'alignment' => $align));
}
/**
* Output the element to the canvas
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @see Image_Graph_Common
* @access private
*/
function _done()
{
$background = $this->_getBackground();
$border = $this->_getBorderStyle();
if (($background) || ($border)) {
$this->_canvas->rectangle(array('x0' => $this->_left, 'y0' => $this->_top, 'x1' => $this->_right, 'y1' => $this->_bottom));
}
$result = parent::_done();
if ($this->_shadow !== false) {
$this->_displayShadow();
}
return $result;
}
}
?>

View File

@ -1,64 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Circle.php,v 1.6 2005/08/24 20:36:01 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Figure/Ellipse.php
*/
require_once 'Image/Graph/Figure/Ellipse.php';
/**
* Circle to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Circle extends Image_Graph_Figure_Ellipse
{
/**
* Image_Graph_Circle [Constructor]
*
* @param int $x The center pixel of the circle on the canvas
* @param int $y The center pixel of the circle on the canvas
* @param int $radius The radius in pixels of the circle
*/
function Image_Graph_Figure_Circle($x, $y, $radius)
{
parent::Image_Graph_Ellipse($x, $y, $radius, $radius);
}
}
?>

View File

@ -1,97 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Ellipse.php,v 1.9 2005/08/24 20:36:00 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Ellipse to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Ellipse extends Image_Graph_Element
{
/**
* 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::Image_Graph_Element();
$this->_setCoords($x - $radiusX, $y - $radiusY, $x + $radiusX, $y + $radiusY);
}
/**
* Output the ellipse
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->ellipse(
array(
'x' => ($this->_left + $this->_right) / 2,
'y' => ($this->_top + $this->_bottom) / 2,
'rx' => $this->width(),
'ry' => $this->height()
)
);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,94 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Polygon.php,v 1.8 2005/08/03 21:21:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Polygon to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Polygon extends Image_Graph_Element
{
/**
* Polygon vertices
*
* @var array
* @access private
*/
var $_polygon = array ();
/**
* Add a vertex to the polygon
*
* @param int $x X-coordinate
* @param int $y Y-coordinate
*/
function addVertex($x, $y)
{
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
/**
* Output the polygon
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->polygon(array('connect' => true));
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,96 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Rectangle.php,v 1.9 2005/08/24 20:36:01 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Rectangle to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Rectangle extends Image_Graph_Element
{
/**
* 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::Image_Graph_Element();
$this->_setCoords($x, $y, $x + $width, $y + $height);
}
/**
* Output the box
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_right,
'y1' => $this->_bottom
)
);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,63 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Fill.php,v 1.6 2005/02/21 20:49:46 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Style used for filling elements.
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Fill extends Image_Graph_Common
{
/**
* Resets the fillstyle
*
* @access private
*/
function _reset()
{
}
}
?>

View File

@ -1,137 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Array.php,v 1.8 2005/08/24 20:36:03 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Fill.php
*/
require_once 'Image/Graph/Fill.php';
/**
* A sequential array of fillstyles.
*
* This is used for filling multiple objects within the same element with
* different styles. This is done by adding multiple fillstyles to a FillArrray
* structure. The fillarray will then when requested return the 'next' fillstyle
* in sequential order. It is possible to specify ID tags to each fillstyle,
* which is used to make sure some data uses a specific fillstyle (i.e. in a
* multiple-/stackedbarchart you name the {@link Image_Graph_Dataset}s and uses
* this name as ID tag when adding the dataset's associated fillstyle to the
* fillarray.
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Fill_Array extends Image_Graph_Fill
{
/**
* The fill array
* @var array
* @access private
*/
var $_fillStyles = array ();
/**
* Resets the fillstyle
*
* @access private
*/
function _reset()
{
reset($this->_fillStyles);
}
/**
* Add a fill style to the array
*
* @param Image_Graph_Fill $style The style to add
* @param string $id The id or name of the style
*/
function &add(& $style, $id = '')
{
if ($id == '') {
$this->_fillStyles[] =& $style;
} else {
$this->_fillStyles[$id] =& $style;
}
reset($this->_fillStyles);
return $style;
}
/**
* Add a color to the array
*
* @param int $color The color
* @param string $id The id or name of the color
*/
function addColor($color, $id = false)
{
if ($id !== false) {
$this->_fillStyles[$id] = $color;
} else {
$this->_fillStyles[] = $color;
}
reset($this->_fillStyles);
}
/**
* Return the fillstyle
*
* @return int A GD fillstyle
* @access private
*/
function _getFillStyle($ID = false)
{
if (($ID === false) || (!isset($this->_fillStyles[$ID]))) {
$ID = key($this->_fillStyles);
if (!next($this->_fillStyles)) {
reset($this->_fillStyles);
}
}
$fillStyle =& $this->_fillStyles[$ID];
if (is_object($fillStyle)) {
return $fillStyle->_getFillStyle($ID);
} elseif ($fillStyle !== null) {
return $fillStyle;
} else {
return parent::_getFillStyle($ID);
}
}
}
?>

View File

@ -1,149 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Gradient.php,v 1.15 2005/08/24 20:36:03 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Fill/Image.php
*/
require_once 'Image/Graph/Fill/Image.php';
/**
* Fill using a gradient color.
* This creates a scaled fillstyle with colors flowing gradiently between 2
* specified RGB values. Several directions are supported:
*
* 1 Vertically (IMAGE_GRAPH_GRAD_VERTICAL)
*
* 2 Horizontally (IMAGE_GRAPH_GRAD_HORIZONTAL)
*
* 3 Mirrored vertically (the color grades from a- b-a vertically)
* (IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED)
*
* 4 Mirrored horizontally (the color grades from a-b-a horizontally)
* IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED
*
* 5 Diagonally from top-left to right-bottom
* (IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR)
*
* 6 Diagonally from bottom-left to top-right
* (IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR)
*
* 7 Radially (concentric circles in the center) (IMAGE_GRAPH_GRAD_RADIAL)
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Fill_Gradient extends Image_Graph_Fill //Image_Graph_Fill_Image
{
/**
* The direction of the gradient
* @var int
* @access private
*/
var $_direction;
/**
* The first color to gradient
* @var mixed
* @access private
*/
var $_startColor;
/**
* The last color to gradient
* @var mixed
* @access private
*/
var $_endColor;
/**
* Image_Graph_GradientFill [Constructor]
*
* @param int $direction The direction of the gradient
* @param mixed $startColor The value of the starting color
* @param mixed $endColor The value of the ending color
*/
function Image_Graph_Fill_Gradient($direction, $startColor, $endColor)
{
parent::Image_Graph_Fill();
$this->_direction = $direction;
$this->_startColor = $startColor;
$this->_endColor = $endColor;
}
/**
* Return the fillstyle
*
* @return int A GD fillstyle
* @access private
*/
function _getFillStyle($ID = false)
{
switch ($this->_direction) {
case IMAGE_GRAPH_GRAD_HORIZONTAL:
$direction = 'horizontal';
break;
case IMAGE_GRAPH_GRAD_VERTICAL:
$direction = 'vertical';
break;
case IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED:
$direction = 'horizontal_mirror';
break;
case IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED:
$direction = 'vertical_mirror';
break;
case IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR:
$direction = 'diagonal_tl_br';
break;
case IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR:
$direction = 'diagonal_bl_tr';
break;
case IMAGE_GRAPH_GRAD_RADIAL:
$direction = 'radial';
break;
}
return array(
'type' => 'gradient',
'start' => $this->_startColor,
'end' => $this->_endColor,
'direction' => $direction
);
}
}
?>

View File

@ -1,97 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Image.php,v 1.7 2005/08/24 20:36:03 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Fill.php
*/
require_once 'Image/Graph/Fill.php';
/**
* Fill using an image.
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Fill_Image extends Image_Graph_Fill
{
/**
* The file name
* @var stirng
* @access private
*/
var $_filename;
/**
* The GD Image resource
* @var resource
* @access private
*/
var $_image;
/**
* Resize the image to the bounding box of the area to fill
* @var bool
* @access private
*/
var $_resize = true;
/**
* Image_Graph_ImageFill [Constructor]
*
* @param string $filename The filename and path of the image to use for filling
*/
function Image_Graph_Fill_Image($filename)
{
parent::Image_Graph_Fill();
$this->_filename = $filename;
}
/**
* Return the fillstyle
*
* @param (something) $ID (Add description)
* @return int A GD fillstyle
* @access private
*/
function _getFillStyle($ID = false)
{
return $this->_filename;
}
}
?>

View File

@ -1,158 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Text
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Font.php,v 1.8 2005/08/24 20:35:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Common.php
*/
require_once 'Image/Graph/Common.php';
/**
* A font.
*
* @category Images
* @package Image_Graph
* @subpackage Text
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Font extends Image_Graph_Common
{
/**
* The name of the font
* @var string
* @access private
*/
var $_name = false;
/**
* The angle of the output
* @var int
* @access private
*/
var $_angle = false;
/**
* The size of the font
* @var int
* @access private
*/
var $_size = 11;
/**
* The color of the font
* @var Color
* @access private
*/
var $_color = 'black';
/**
* Image_Graph_Font [Constructor]
*/
function Image_Graph_Font($name = false, $size = false)
{
parent::Image_Graph_Common();
if ($name !== false) {
$this->_name = $name;
}
if ($size !== false) {
$this->_size = $size;
}
}
/**
* Set the color of the font
*
* @param mixed $color The color object of the Font
*/
function setColor($color)
{
$this->_color = $color;
}
/**
* Set the angle slope of the output font.
*
* 0 = normal, 90 = bottom and up, 180 = upside down, 270 = top and down
*
* @param int $angle The angle in degrees to slope the text
*/
function setAngle($angle)
{
$this->_angle = $angle;
}
/**
* Set the size of the font
*
* @param int $size The size in pixels of the font
*/
function setSize($size)
{
$this->_size = $size;
}
/**
* Get the font 'array'
*
* @return array The font 'summary' to pass to the canvas
* @access private
*/
function _getFont($options = false)
{
if ($options === false) {
$options = array();
}
if ($this->_name !== false) {
$options['name'] = $this->_name;
}
if (!isset($options['color'])) {
$options['color'] = $this->_color;
}
if (!isset($options['size'])) {
$options['size'] = $this->_size;
}
if ((!isset($options['angle'])) && ($this->_angle !== false)) {
$options['angle'] = $this->_angle;
}
return $options;
}
}
?>

View File

@ -1,175 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Grid.php,v 1.8 2005/02/21 20:49:47 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* A grid displayed on the plotarea.
*
* A grid is associated with a primary and a secondary axis. The grid is
* displayed in context of the primary axis' label interval - meaning that a
* grid for an Y-axis displays a grid for every label on the y-axis (fx. a {@link
* Image_Graph_Grid_Lines}, which displays horizontal lines for every label on
* the y-axis from the x-axis minimum to the x-axis maximum). You should always
* add the grid as one of the first elements to the plotarea. This is due to the
* fact that elements are 'outputted' in the order they are added, i.e. if an
* grid is added *after* a chart, the grid will be displayed on top of the chart
* which is (probably) not desired.
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Grid extends Image_Graph_Plotarea_Element
{
/**
* The primary axis: the grid 'refers' to
* @var Axis
* @access private
*/
var $_primaryAxis = null;
/**
* The secondary axis
* @var Axis
* @access private
*/
var $_secondaryAxis = null;
/**
* Set the primary axis: the grid should 'refer' to
*
* @param Image_Graph_Axis $axis The axis
* @access private
*/
function _setPrimaryAxis(& $axis)
{
$this->_primaryAxis =& $axis;
}
/**
* Set the secondary axis
*
* @param Image_Graph_Axis $axis The axis
* @access private
*/
function _setSecondaryAxis(& $axis)
{
$this->_secondaryAxis =& $axis;
}
/**
* Get the points on the secondary axis that the grid should 'connect'
*
* @return array The secondary data values that should mark the grid 'end points'
* @access private
*/
function _getSecondaryAxisPoints()
{
if (is_a($this->_secondaryAxis, 'Image_Graph_Axis_Radar')) {
$secondaryValue = false;
$firstValue = $secondaryValue;
while (($secondaryValue = $this->_secondaryAxis->_getNextLabel($secondaryValue)) !== false) {
$secondaryAxisPoints[] = $secondaryValue;
}
$secondaryAxisPoints[] = $firstValue;
} else {
$secondaryAxisPoints = array ('#min#', '#max#');
}
return $secondaryAxisPoints;
}
/**
* Get the X pixel position represented by a value
*
* @param double $point the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointX($point)
{
if (($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_Y) ||
($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_Y_SECONDARY))
{
$point['AXIS_Y'] = $this->_primaryAxis->_type;
} else {
$point['AXIS_Y'] = $this->_secondaryAxis->_type;
}
return parent::_pointX($point);
}
/**
* Get the Y pixel position represented by a value
*
* @param double $point the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointY($point)
{
if (($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_Y) ||
($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_Y_SECONDARY))
{
$point['AXIS_Y'] = $this->_primaryAxis->_type;
} else {
$point['AXIS_Y'] = $this->_secondaryAxis->_type;
}
return parent::_pointY($point);
}
/**
* Causes the object to update all sub elements coordinates.
*
* @access private
*/
function _updateCoords()
{
$this->_setCoords(
$this->_parent->_plotLeft,
$this->_parent->_plotTop,
$this->_parent->_plotRight,
$this->_parent->_plotBottom
);
parent::_updateCoords();
}
}
?>

View File

@ -1,117 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Bars.php,v 1.10 2005/09/14 20:27:25 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display alternating bars on the plotarea.
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Grid_Bars extends Image_Graph_Grid
{
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$i = 0;
$value = false;
$previousValue = 0;
$secondaryPoints = $this->_getSecondaryAxisPoints();
while (($value = $this->_primaryAxis->_getNextLabel($value)) !== false) {
if ($i == 1) {
reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('Y' => $secondaryValue, 'X' => $value);
$p2 = array ('Y' => $previousSecondaryValue, 'X' => $value);
$p3 = array ('Y' => $previousSecondaryValue, 'X' => $previousValue);
$p4 = array ('Y' => $secondaryValue, 'X' => $previousValue);
} else {
$p1 = array ('X' => $secondaryValue, 'Y' => $value);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $value);
$p3 = array ('X' => $previousSecondaryValue, 'Y' => $previousValue);
$p4 = array ('X' => $secondaryValue, 'Y' => $previousValue);
}
$this->_canvas->addVertex(array('x' => $this->_pointX($p1), 'y' => $this->_pointY($p1)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p2), 'y' => $this->_pointY($p2)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p3), 'y' => $this->_pointY($p3)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p4), 'y' => $this->_pointY($p4)));
$this->_getFillStyle();
$this->_canvas->polygon(array('connect' => true));
$previousSecondaryValue = $secondaryValue;
}
}
$i = 1 - $i;
$previousValue = $value;
}
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,114 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Lines.php,v 1.10 2005/08/24 20:36:04 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display a line grid on the plotarea.
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Grid_Lines extends Image_Graph_Grid
{
/**
* GridLines [Constructor]
*/
function Image_Graph_Grid_Lines()
{
parent::Image_Graph_Grid();
$this->_lineStyle = 'lightgrey';
}
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$value = false;
$secondaryPoints = $this->_getSecondaryAxisPoints();
while (($value = $this->_primaryAxis->_getNextLabel($value)) !== false) {
reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_Y) {
$p1 = array ('X' => $secondaryValue, 'Y' => $value);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $value);
} else {
$p1 = array ('X' => $value, 'Y' => $secondaryValue);
$p2 = array ('X' => $value, 'Y' => $previousSecondaryValue);
}
$x1 = $this->_pointX($p1);
$y1 = $this->_pointY($p1);
$x2 = $this->_pointX($p2);
$y2 = $this->_pointY($p2);
$previousSecondaryValue = $secondaryValue;
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x1, 'y0' => $y1, 'x1' => $x2, 'y1' => $y2));
}
}
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,111 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Polar.php,v 1.10 2005/08/24 20:36:04 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display a line grid on the plotarea.
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @since Class available since Release 0.3.0dev2
*/
class Image_Graph_Grid_Polar extends Image_Graph_Grid
{
/**
* GridLines [Constructor]
*/
function Image_Graph_Grid_Polar()
{
parent::Image_Graph_Grid();
$this->_lineStyle = 'lightgrey';
}
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$value = false;
$p0 = array ('X' => '#min#', 'Y' => '#min#');
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_Y) {
$p1 = array ('X' => '#min#', 'Y' => '#max#');
$r0 = abs($this->_pointY($p1) - $this->_pointY($p0));
} else {
$p1 = array ('X' => '#max#', 'Y' => '#min#');
$r0 = abs($this->_pointX($p1) - $this->_pointX($p0));
}
$cx = $this->_pointX($p0);
$cy = $this->_pointY($p0);
$span = $this->_primaryAxis->_axisSpan;
while (($value = $this->_primaryAxis->_getNextLabel($value)) !== false) {
$r = $r0 * ($value - $this->_primaryAxis->_getMinimum()) / $span;
$this->_getLineStyle();
$this->_canvas->ellipse(array('x' => $cx, 'y' => $cy, 'rx' => $r, 'ry' => $r));
}
$this->_canvas->endGroup();
return true;
}
}
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 B

View File

@ -1,17 +0,0 @@
In this folder the files for the Image_Graph_Plot_Map are located. They should be the
following format:
[map name].png
[map name].txt
The [map name].png (fx. europe.png) is the actual image presenting the map. The
[map name].txt file is the location -> (x,y) conversion table. In this file the
named locations is written on every line with the x and y coordinates after the
name (with a TAB), i.e.:
Denmark 10 30
England 4 30
Where Denmark will be 'located' on (10, 30) on the map, and England at (4, 30).
No maps are released by default due to we want to avoid possible copyright issues.

View File

@ -1,219 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Layout
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Layout.php,v 1.12 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plotarea/Element.php
*/
require_once 'Image/Graph/Plotarea/Element.php';
/**
* Defines an area of the graph that can be layout'ed.
*
* Any class that extends this abstract class can be used within a layout on the canvas.
*
* @category Images
* @package Image_Graph
* @subpackage Layout
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Layout extends Image_Graph_Plotarea_Element
{
/**
* Has the coordinates already been updated?
* @var bool
* @access private
*/
var $_updated = false;
/**
* Alignment of the area for each vertice (left, top, right, bottom)
* @var array
* @access private
*/
var $_alignSize = array ('left' => 0, 'top' => 0, 'right' => 0, 'bottom' => 0);
/**
* Image_Graph_Layout [Constructor]
*/
function Image_Graph_Layout()
{
parent::Image_Graph_Element();
$this->_padding = array('left' => 2, 'top' => 2, 'right' => 2, 'bottom' => 2);
}
/**
* Resets the elements
*
* @access private
*/
function _reset()
{
parent::_reset();
$this->_updated = false;
}
/**
* Calculate the edge offset for a specific edge
* @param array $alignSize The alignment of the edge
* @param int $offset The offset/posision of the at 0% edge
* @param int $total The total size (width or height) of the element
* @param int $multiplier +/- 1 if the edge should pushed either toward more
* negative or positive values
* @since 0.3.0dev2
* @access private
*/
function _calcEdgeOffset($alignSize, $offset, $total, $multiplier)
{
if ($alignSize['unit'] == 'percentage') {
return $offset + $multiplier * ($total * $alignSize['value'] / 100);
} elseif ($alignSize['unit'] == 'pixels') {
if (($alignSize['value'] == 'auto_part1') || ($alignSize['value'] == 'auto_part2')) {
$alignSize['value'] = $multiplier * $this->_parent->_getAbsolute($alignSize['value']);
}
if ($alignSize['value'] < 0) {
return $offset + $multiplier * ($total + $alignSize['value']);
} else {
return $offset + $multiplier * $alignSize['value'];
}
}
return $offset;
}
/**
* Calculate the edges
*
* @access private
*/
function _calcEdges()
{
if ((is_array($this->_alignSize)) && (!$this->_updated)) {
$left = $this->_calcEdgeOffset(
$this->_alignSize['left'],
$this->_parent->_fillLeft(),
$this->_parent->_fillWidth(),
+1
);
$top = $this->_calcEdgeOffset(
$this->_alignSize['top'],
$this->_parent->_fillTop(),
$this->_parent->_fillHeight(),
+1
);
$right = $this->_calcEdgeOffset(
$this->_alignSize['right'],
$this->_parent->_fillRight(),
$this->_parent->_fillWidth(),
-1
);
$bottom = $this->_calcEdgeOffset(
$this->_alignSize['bottom'],
$this->_parent->_fillBottom(),
$this->_parent->_fillHeight(),
-1
);
$this->_setCoords(
$left + $this->_padding['left'],
$top + $this->_padding['top'],
$right - $this->_padding['right'],
$bottom - $this->_padding['bottom']
);
}
}
/**
* Update coordinates
*
* @access private
*/
function _updateCoords()
{
$this->_calcEdges();
parent::_updateCoords();
}
/**
* Pushes an edge of area a specific distance 'into' the canvas
*
* @param int $edge The edge of the canvas to align relative to
* @param int $size The number of pixels or the percentage of the canvas total size to occupy relative to the selected alignment edge
* @access private
*/
function _push($edge, $size = '100%')
{
$result = array();
if (ereg("([0-9]*)\%", $size, $result)) {
$this->_alignSize[$edge] = array(
'value' => min(100, max(0, $result[1])),
'unit' => 'percentage'
);
} else {
$this->_alignSize[$edge] = array(
'value' => $size,
'unit' => 'pixels'
);
}
}
/**
* Sets the coordinates of the element
*
* @param int $left The leftmost pixel of the element on the canvas
* @param int $top The topmost pixel of the element on the canvas
* @param int $right The rightmost pixel of the element on the canvas
* @param int $bottom The bottommost pixel of the element on the canvas
* @access private
*/
function _setCoords($left, $top, $right, $bottom)
{
parent::_setCoords($left, $top, $right, $bottom);
$this->_updated = true;
}
/**
* Returns the calculated "auto" size
*
* @return int The calculated auto size
* @access private
*/
function _getAutoSize()
{
return false;
}
}
?>

View File

@ -1,186 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Layout
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Horizontal.php,v 1.11 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Layout.php
*/
require_once 'Image/Graph/Layout.php';
/**
* Layout for displaying two elements side by side.
*
* This splits the area contained by this element in two, side by side by
* a specified percentage (relative to the left side). A layout can be nested.
* Fx. a HorizontalLayout can layout two {@link Image_Graph_Layout_Vertical}s to
* make a 2 by 2 matrix of 'element-areas'.
*
* @category Images
* @package Image_Graph
* @subpackage Layout
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Layout_Horizontal extends Image_Graph_Layout
{
/**
* Part1 of the layout
* @var GraPHPElemnt
* @access private
*/
var $_part1 = false;
/**
* Part2 of the layout
* @var GraPHPElemnt
* @access private
*/
var $_part2 = false;
/**
* The percentage of the graph where the split occurs
* @var int
* @access private
*/
var $_percentage;
/**
* An absolute position where the split occurs
* @var int
* @access private
*/
var $_absolute;
/**
* HorizontalLayout [Constructor]
*
* @param Image_Graph_Element $part1 The 1st part of the layout
* @param Image_Graph_Element $part2 The 2nd part of the layout
* @param int $percentage The percentage of the layout to split at
*/
function Image_Graph_Layout_Horizontal(& $part1, & $part2, $percentage = 50)
{
parent::Image_Graph_Layout();
if (!is_a($part1, 'Image_Graph_Layout')) {
$this->_error(
'Cannot create layout on non-layouable parts: ' . get_class($part1),
array('part1' => &$part1, 'part2' => &$part2)
);
} elseif (!is_a($part2, 'Image_Graph_Layout')) {
$this->_error(
'Cannot create layout on non-layouable parts: ' . get_class($part2),
array('part1' => &$part1, 'part2' => &$part2)
);
} else {
$this->_part1 =& $part1;
$this->_part2 =& $part2;
$this->add($this->_part1);
$this->add($this->_part2);
};
if ($percentage === 'auto') {
$this->_percentage = false;
$this->_absolute = 'runtime';
} else {
$this->_absolute = false;
$this->_percentage = max(0, min(100, $percentage));
}
$this->_split();
$this->_padding = array('left' => 0, 'top' => 0, 'right' => 0, 'bottom' => 0);
}
/**
* Gets the absolute size of one of the parts.
*
* @param string $part The name of the part - auto_part(1|2)
* @return int The number of pixels the edge should be pushed
* @since 0.3.0dev2
* @access private
*/
function _getAbsolute(&$part)
{
$part1Size = $this->_part1->_getAutoSize();
$part2Size = $this->_part2->_getAutoSize();
$this->_percentage = false;
if (($part1Size !== false) and ($part2Size !== false)) {
$width = $this->_fillWidth() * $part1Size / ($part1Size + $part2Size);
} elseif ($part1Size !== false) {
$width = $part1Size;
} elseif ($part2Size !== false) {
$width = -$part2Size;
} else {
$width = $this->_fillWidth() / 2;
}
if ($part == 'auto_part2') {
$width = -$width;
}
return $width;
}
/**
* Splits the layout between the parts, by the specified percentage
*
* @access private
*/
function _split()
{
if (($this->_part1) && ($this->_part2)) {
if ($this->_percentage !== false) {
$split1 = 100 - $this->_percentage;
$split2 = $this->_percentage;
$this->_part1->_push('right', "$split1%");
$this->_part2->_push('left', "$split2%");
} else {
$this->_part1->_push('right', 'auto_part1');
$this->_part2->_push('left', 'auto_part2');
}
}
}
/**
* Output the layout to the canvas
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (($this->_part1) && ($this->_part2)) {
return (($this->_part1->_done()) && ($this->_part2->_done()));
}
return true;
}
}
?>

View File

@ -1,201 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Layout
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Matrix.php,v 1.8 2005/08/24 20:35:58 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Layout.php
*/
require_once 'Image/Graph/Layout.php';
/**
* Layout for displaying elements in a matix.
*
* @category Images
* @package Image_Graph
* @subpackage Layout
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Layout_Matrix extends Image_Graph_Layout
{
/**
* Layout matrix
* @var array
* @access private
*/
var $_matrix = false;
/**
* The number of rows
* @var int
* @access private
*/
var $_rows = false;
/**
* The number of columns
* @var int
* @access private
*/
var $_cols = false;
/**
* Image_Graph_Layout_Matrix [Constructor]
*
* @param int $rows The number of rows
* @param int $cols The number of cols
* @param bool $autoCreate Specifies whether the matrix should automatically
* be filled with newly created Image_Graph_Plotares objects, or they will
* be added manually
*/
function Image_Graph_Layout_Matrix($rows, $cols, $autoCreate = true)
{
parent::Image_Graph_Layout();
$this->_rows = $rows;
$this->_cols = $cols;
if (($this->_rows > 0) && ($this->_cols > 0)) {
$this->_matrix = array(array());
for ($i = 0; $i < $this->_rows; $i++) {
for ($j = 0; $j < $this->_cols; $j++) {
if ($autoCreate) {
$this->_matrix[$i][$j] =& $this->addNew('plotarea');
$this->_pushEdges($i, $j);
} else {
$this->_matrix[$i][$j] = false;
}
}
}
}
}
/**
* Pushes the edges on the specified position in the matrix
*
* @param int $row The row
* @param int $col The column
* @access private
*/
function _pushEdges($row, $col)
{
if ((isset($this->_matrix[$row])) && (isset($this->_matrix[$row][$col]))) {
$height = 100/$this->_rows;
$width = 100/$this->_cols;
if ($col > 0) {
$this->_matrix[$row][$col]->_push('left', round($col*$width) . '%');
}
if ($col+1 < $this->_cols) {
$this->_matrix[$row][$col]->_push('right', round(100-($col+1)*$width) . '%');
}
if ($row > 0) {
$this->_matrix[$row][$col]->_push('top', round($row*$height) . '%');
}
if ($row+1 < $this->_rows) {
$this->_matrix[$row][$col]->_push('bottom', round(100-($row+1)*$height) . '%');
}
}
}
/**
* Get the area on the specified position in the matrix
*
* @param int $row The row
* @param int $col The column
* @return Image_Graph_Layout The element of position ($row, $col) in the
* matrix
*/
function &getEntry($row, $col)
{
if ((isset($this->_matrix[$row])) && (isset($this->_matrix[$row][$col]))) {
return $this->_matrix[$row][$col];
} else {
$result = null;
return $result;
}
}
/**
* Get the area on the specified position in the matrix
*
* @param int $row The row
* @param int $col The column
* @param Image_Graph_Layout $element The element to set in the position
* ($row, $col) in the matrix
*/
function setEntry($row, $col, &$element)
{
$this->_matrix[$row][$col] =& $element;
$this->_pushEdges($row, $col);
}
/**
* Update coordinates
*
* @access private
*/
function _updateCoords()
{
for ($i = 0; $i < $this->_rows; $i++) {
for ($j = 0; $j < $this->_cols; $j++) {
$element =& $this->getEntry($i, $j);
$this->add($element);
}
}
parent::_updateCoords();
}
/**
* Output the layout to the canvas
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$result = true;
for ($i = 0; $i < $this->_rows; $i++) {
for ($j = 0; $j < $this->_cols; $j++) {
$element =& $this->getEntry($i, $j);
if ($element) {
if (!$element->_done()) {
$result = false;
}
}
}
}
return $result;
}
}
?>

View File

@ -1,108 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Layout
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Vertical.php,v 1.6 2005/02/21 20:49:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Layout/Horizontal.php
*/
require_once 'Image/Graph/Layout/Horizontal.php';
/**
* Layout for displaying two elements on top of each other.
*
* This splits the area contained by this element in two on top of each other
* by a specified percentage (relative to the top). A layout can be nested.
* Fx. a {@link Image_Graph_Layout_Horizontal} can layout two VerticalLayout's to
* make a 2 by 2 matrix of 'element-areas'.
*
* @category Images
* @package Image_Graph
* @subpackage Layout
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Layout_Vertical extends Image_Graph_Layout_Horizontal
{
/**
* Gets the absolute size of one of the parts.
*
* @param string $part The name of the part - auto_part(1|2)
* @return int The number of pixels the edge should be pushed
* @since 0.3.0dev2
* @access private
*/
function _getAbsolute(&$part)
{
$part1Size = $this->_part1->_getAutoSize();
$part2Size = $this->_part2->_getAutoSize();
$this->_percentage = false;
if (($part1Size !== false) and ($part2Size !== false)) {
$height = $this->_fillHeight() * $part1Size / ($part1Size + $part2Size);
} elseif ($part1Size !== false) {
$height = $part1Size;
} elseif ($part2Size !== false) {
$height = -$part2Size;
} else {
$height = $this->_fillHeight() / 2;
}
if ($part == 'auto_part2') {
// $height = $this->_fillHeight() - $height;
}
return $height;
}
/**
* Splits the layout between the parts, by the specified percentage
*
* @access private
*/
function _split()
{
if (($this->_part1) && ($this->_part2)) {
if ($this->_percentage !== false) {
$split1 = 100 - $this->_percentage;
$split2 = $this->_percentage;
$this->_part1->_push('bottom', "$split1%");
$this->_part2->_push('top', "$split2%");
} else {
$this->_part1->_push('bottom', 'auto_part1');
$this->_part2->_push('top', 'auto_part2');
}
}
}
}
?>

View File

@ -1,385 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Legend
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Legend.php,v 1.16 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Layout.php
*/
require_once 'Image/Graph/Layout.php';
/**
* Displays a legend for a plotarea.
*
* A legend can be displayed in two ways:
*
* 1 As an overlayed box within the plotarea
*
* 2 Layout'ed on the canvas smewhere next to the plotarea.
*
* @category Images
* @package Image_Graph
* @subpackage Legend
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Legend extends Image_Graph_Layout
{
/**
* Alignment of the text
* @var int
* @access private
*/
var $_alignment = false;
/**
* The plotarea(s) to show the legend for
* @var array
* @access private
*/
var $_plotareas = array();
/**
* Should markers be shown or not on this legend
* @var bool
* @access private
*/
var $_showMarker = false;
/**
* Image_Graph_Legend [Constructor]
*/
function Image_Graph_Legend()
{
parent::Image_Graph_Layout();
$this->_padding = array('left' => 5, 'top' => 5, 'right' => 5, 'bottom' => 5);
}
/**
* The number of actual plots in the plot area
*
* @return int The number of plotes
* @access private
*/
function _plotCount()
{
$count = 0;
$keys = array_keys($this->_plotareas);
foreach($keys as $key) {
$plotarea =& $this->_plotareas[$key];
if (is_a($plotarea, 'Image_Graph_Plotarea')) {
$keys2 = array_keys($plotarea->_elements);
foreach ($keys2 as $key) {
$element =& $plotarea->_elements[$key];
if (is_a($element, 'Image_Graph_Plot')) {
$count ++;
}
}
unset($keys2);
}
}
unset($keys);
return $count;
}
/**
* Get a default parameter array for legendSamples
* @param bool $simulate Whether the array should be used for simulation or
* not
* @return array Default parameter array
* @access private
*/
function _parameterArray($simulate = false)
{
$param['left'] = $this->_left + $this->_padding['left'];
$param['top'] = $this->_top + $this->_padding['top'];
$param['right'] = $this->_right - $this->_padding['right'];
$param['bottom'] = $this->_bottom - $this->_padding['bottom'];
$param['align'] = $this->_alignment;
$param['x'] = $this->_left + $this->_padding['left'];
$param['y'] = $this->_top + $this->_padding['top'];
$param['width'] = 16;
$param['height'] = 16;
$param['show_marker'] = $this->_showMarker;
$param['maxwidth'] = 0;
$param['font'] = $this->_getFont();
if ($simulate) {
$param['simulate'] = true;
}
return $param;
}
/**
* The height of the element on the canvas
*
* @return int Number of pixels representing the height of the element
* @access private
*/
function _height()
{
$parent = (is_object($this->_parent) ? get_class($this->_parent) : $this->_parent);
if (strtolower($parent) == 'image_graph_plotarea') {
$param = $this->_parameterArray(true);
$param['align'] = IMAGE_GRAPH_ALIGN_VERTICAL;
$param0 = $param;
$keys = array_keys($this->_plotareas);
foreach($keys as $key) {
$plotarea =& $this->_plotareas[$key];
$keys2 = array_keys($plotarea->_elements);
foreach($keys2 as $key) {
$element =& $plotarea->_elements[$key];
if (is_a($element, 'Image_Graph_Plot')) {
$element->_legendSample($param);
}
}
unset($keys2);
}
unset($keys);
return abs($param['y'] - $param0['y']) + $this->_padding['top'] + $this->_padding['bottom'];
} else {
return parent::height();
}
}
/**
* The width of the element on the canvas
*
* @return int Number of pixels representing the width of the element
* @access private
*/
function _width()
{
$parent = (is_object($this->_parent) ? get_class($this->_parent) : $this->_parent);
if (strtolower($parent) == 'image_graph_plotarea') {
$param = $this->_parameterArray(true);
$param['align'] = IMAGE_GRAPH_ALIGN_VERTICAL;
$keys = array_keys($this->_plotareas);
foreach($keys as $key) {
$plotarea =& $this->_plotareas[$key];
$keys2 = array_keys($plotarea->_elements);
foreach($keys2 as $key) {
$element =& $plotarea->_elements[$key];
if (is_a($element, 'Image_Graph_Plot')) {
$element->_legendSample($param);
}
}
unset($keys2);
}
unset($keys);
return $param['maxwidth'];
} else {
return parent::width();
}
}
/**
* Set the alignment of the legend
*
* @param int $alignment The alignment
*/
function setAlignment($alignment)
{
$this->_alignment = $alignment;
}
/**
* Update coordinates
*
* @access private
*/
function _updateCoords()
{
parent::_updateCoords();
$parent = (is_object($this->_parent) ? get_class($this->_parent) : $this->_parent);
if (strtolower($parent) == 'image_graph_plotarea') {
$w = $this->_width();
$h = $this->_height();
if ($this->_alignment === false) {
$this->_alignment = IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_RIGHT;
}
if (($this->_alignment & IMAGE_GRAPH_ALIGN_BOTTOM) != 0) {
$y = $this->_parent->_fillBottom() - $h - $this->_padding['bottom'];
} else {
$y = $this->_parent->_fillTop() + $this->_padding['top'];
}
if (($this->_alignment & IMAGE_GRAPH_ALIGN_LEFT) != 0) {
$x = $this->_parent->_fillLeft() + $this->_padding['left'];
} else {
$x = $this->_parent->_fillRight() - $w - $this->_padding['right'];
}
$this->_setCoords($x, $y, $x + $w, $y + $h);
}
}
/**
* Sets Plotarea
*
* @param Image_Graph_Plotarea $plotarea The plotarea
*/
function setPlotarea(& $plotarea)
{
if (is_a($plotarea, 'Image_Graph_Plotarea')) {
$this->_plotareas[] =& $plotarea;
}
}
/**
* Sets the parent. The parent chain should ultimately be a GraPHP object
*
* @see Image_Graph
* @param Image_Graph_Common $parent The parent
* @access private
*/
function _setParent(& $parent)
{
parent::_setParent($parent);
if (count($this->_plotareas) == 0) {
$this->setPlotarea($parent);
}
}
/**
* Set if this legends should show markers
*
* @param bool $showMarker True if markers are to be shown, false is not
*/
function setShowMarker($showMarker)
{
$this->_showMarker = $showMarker;
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (Image_Graph_Element::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$param = $this->_parameterArray();
$parent = (is_object($this->_parent) ?
get_class($this->_parent) :
$this->_parent
);
if (strtolower($parent) == 'image_graph_plotarea') {
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_right,
'y1' => $this->_bottom
)
);
$param = $this->_parameterArray();
$keys = array_keys($this->_plotareas);
foreach($keys as $key) {
$plotarea =& $this->_plotareas[$key];
$keys2 = array_keys($plotarea->_elements);
foreach($keys2 as $key) {
$element =& $plotarea->_elements[$key];
if (is_a($element, 'Image_Graph_Plot')) {
$element->_legendSample($param);
}
}
unset($keys2);
}
unset($keys);
} else {
$param0 = $param;
$param0['simulate'] = true;
$keys = array_keys($this->_plotareas);
foreach($keys as $key) {
$plotarea =& $this->_plotareas[$key];
$keys2 = array_keys($plotarea->_elements);
foreach($keys2 as $key) {
$element =& $plotarea->_elements[$key];
if (is_a($element, 'Image_Graph_Plot')) {
$element->_legendSample($param0);
}
}
unset($keys2);
}
unset($keys);
if (($this->_alignment & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) {
if ($param0['x'] == $param['x']) {
$param['y'] = $param['y'] + ($this->_height() - ($param0['y'] - $param['y']))/2;
}
} else {
if ($param0['y'] == $param['y']) {
$param['x'] = $param['x'] + ($this->_width() - ($param0['x'] - $param['x']))/2;
}
}
$keys = array_keys($this->_plotareas);
foreach($keys as $key) {
$plotarea =& $this->_plotareas[$key];
$keys2 = array_keys($plotarea->_elements);
foreach($keys2 as $key) {
$element =& $plotarea->_elements[$key];
if (is_a($element, 'Image_Graph_Plot')) {
$element->_legendSample($param);
}
}
unset($keys2);
}
unset($keys);
}
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,129 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Array.php,v 1.7 2005/02/21 20:49:42 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Common.php
*/
require_once 'Image/Graph/Common.php';
/**
* A sequential array of linestyles.
*
* This is used for multiple objects within the same element with different line
* styles. This is done by adding multiple line styles to a LineArrray
* structure. The linearray will then when requested return the 'next' linestyle
* in sequential order. It is possible to specify ID tags to each linestyle,
* which is used to make sure some data uses a specific linestyle (i.e. in a
* multiple-/stackedbarchart you name the {@link Image_Graph_Dataset}s and uses
* this name as ID tag when adding the dataset's associated linestyle to the
* linearray.
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Line_Array extends Image_Graph_Common
{
/**
* The fill array
* @var array
* @access private
*/
var $_lineStyles = array ();
/**
* Add a line style to the array
*
* @param Image_Graph_Line $style The style to add
*/
function add(& $style, $id = false)
{
if (is_a($style, 'Image_Graph_Element')) {
parent::add($style);
}
if ($id === false) {
$this->_lineStyles[] =& $style;
} else {
$this->_lineStyles[$id] =& $style;
}
reset($this->_lineStyles);
}
/**
* Add a color to the array
*
* @param int $color The color
* @param string $id The id or name of the color
*/
function addColor($color, $id = false)
{
if ($id !== false) {
$this->_lineStyles[$id] = $color;
} else {
$this->_lineStyles[] = $color;
}
reset($this->_lineStyles);
}
/**
* Return the linestyle
*
* @return int A GD Linestyle
* @access private
*/
function _getLineStyle($ID = false)
{
if (($ID === false) || (!isset($this->_lineStyles[$ID]))) {
$ID = key($this->_lineStyles);
if (!next($this->_lineStyles)) {
reset($this->_lineStyles);
}
}
$lineStyle =& $this->_lineStyles[$ID];
if (is_object($lineStyle)) {
return $lineStyle->_getLineStyle($ID);
} elseif ($lineStyle !== null) {
return $lineStyle;
} else {
return parent::_getLineStyle($ID);
}
}
}
?>

View File

@ -1,76 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Dashed.php,v 1.6 2005/08/24 20:35:52 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Line/Formatted.php
*/
require_once 'Image/Graph/Line/Formatted.php';
/**
* Dashed line style.
*
* This style displays as a short line with a shorter space afterwards, i.e
* 4px color1, 2px color2, 4px color1, etc.
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Line_Dashed extends Image_Graph_Line_Formatted
{
/**
* Image_Graph_DashedLine [Constructor]
*
* @param mixed $color1 The color for the 'dashes'
* @param mixed $color2 The color for the 'spaces'
*/
function Image_Graph_Line_Dashed($color1, $color2)
{
parent::Image_Graph_Line_Formatted(
array(
$color1,
$color1,
$color1,
$color1,
$color2,
$color2
)
);
}
}
?>

View File

@ -1,67 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Dotted.php,v 1.6 2005/08/24 20:35:52 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Line/Formatted.php
*/
require_once 'Image/Graph/Line/Formatted.php';
/**
* Dotted line style.
*
* This style displays as a short line with a shorter space afterwards, i.e
* 1px color1, 1px color2, 1px color1, etc.
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Line_Dotted extends Image_Graph_Line_Formatted
{
/**
* DottedLine [Constructor]
*
* @param mixed $color1 The color representing the dots
* @param mixed $color2 The color representing the spaces
*/
function Image_Graph_Line_Dotted($color1, $color2)
{
parent::Image_Graph_Line_Formatted(array ($color1, $color2));
}
}
?>

View File

@ -1,90 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Formatted.php,v 1.6 2005/08/24 20:35:51 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Line/Solid.php
*/
require_once 'Image/Graph/Line/Solid.php';
/**
* Formatted user defined line style.
*
* Use this to create a user defined line style. Specify an array of colors that are to
* be used for displaying the line.
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Line_Formatted extends Image_Graph_Line_Solid
{
/**
* The style of the line
*
* @var array
* @access private
*/
var $_style;
/**
* Image_Graph_FormattedLine [Constructor]
*
* @param array $style The style of the line
*/
function Image_Graph_Line_Formatted($style)
{
parent::Image_Graph_Line_Solid(reset($style));
$this->_style = $style;
}
/**
* Gets the line style of the element
*
* @return int A GD linestyle representing the line style
* @see Image_Graph_Line
* @access private
*/
function _getLineStyle()
{
return array(
'color' => $this->_style,
'thickness' => $this->_thickness
);
}
}
?>

View File

@ -1,105 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Solid.php,v 1.6 2005/08/24 20:35:51 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Common.php
*/
require_once 'Image/Graph/Common.php';
/**
* Simple colored line style.
*
* Use a color for line style.
*
* @category Images
* @package Image_Graph
* @subpackage Line
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Line_Solid extends Image_Graph_Common
{
/**
* The thickness of the line (requires GD 2)
* @var int
* @access private
*/
var $_thickness = 1;
/**
* The color of the line
* @var mixed
* @access private
*/
var $_color;
/**
* Image_Graph_SolidLine [Constructor]
*
* @param mixed $color The color of the line
*/
function Image_Graph_Line_Solid($color)
{
parent::Image_Graph_Common();
$this->_color = $color;
}
/**
* Set the thickness of the linestyle
*
* @param int $thickness The line width in pixels
*/
function setThickness($thickness)
{
$this->_thickness = $thickness;
}
/**
* Gets the line style of the element
*
* @return int A GD linestyle representing the line style
* @see Image_Graph_Line
* @access private
*/
function _getLineStyle()
{
return array(
'color' => $this->_color,
'thickness' => $this->_thickness
);
}
}
?>

View File

@ -1,153 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Logo
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Logo.php,v 1.9 2005/08/24 20:35:56 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Displays a logo on the canvas.
*
* By default the logo is displayed in the top-right corner of the canvas.
*
* @category Images
* @package Image_Graph
* @subpackage Logo
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Logo extends Image_Graph_Element
{
/**
* The file name
* @var stirng
* @access private
*/
var $_filename;
/**
* The GD Image resource
* @var resource
* @access private
*/
var $_image;
/**
* Alignment of the logo
* @var int
* @access private
*/
var $_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::Image_Graph_Element();
$this->_filename = $filename;
$this->_alignment = $alignment;
}
/**
* Sets the parent. The parent chain should ultimately be a GraPHP object
*
* @see Image_Graph
* @param Image_Graph_Common $parent The parent
* @access private
*/
function _setParent(& $parent)
{
parent::_setParent($parent);
$this->_setCoords(
$this->_parent->_left,
$this->_parent->_top,
$this->_parent->_right,
$this->_parent->_bottom
);
}
/**
* Output the logo
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$align = array();
if ($this->_alignment & IMAGE_GRAPH_ALIGN_LEFT) {
$x = $this->_parent->_left + 2;
$align['horizontal'] = 'left';
} elseif ($this->_alignment & IMAGE_GRAPH_ALIGN_RIGHT) {
$x = $this->_parent->_right - 2;
$align['horizontal'] = 'right';
} else {
$x = ($this->_parent->_left + $this->_parent->_right) / 2;
$align['horizontal'] = 'center';
}
if ($this->_alignment & IMAGE_GRAPH_ALIGN_TOP) {
$y = $this->_parent->_top + 2;
$align['vertical'] = 'top';
} elseif ($this->_alignment & IMAGE_GRAPH_ALIGN_BOTTOM) {
$y = $this->_parent->_bottom - 2;
$align['vertical'] = 'bottom';
} else {
$y = ($this->_parent->_top + $this->_parent->_bottom) / 2;
$align['vertical'] = 'center';
}
$this->_canvas->image(
array(
'x' => $x,
'y' => $y,
'filename' => $this->_filename,
'alignment' => $align
)
);
return true;
}
}
?>

View File

@ -1,123 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Marker.php,v 1.8 2005/02/21 20:49:47 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plotarea/Element.php
*/
require_once 'Image/Graph/Plotarea/Element.php';
/**
* Data point marker.
*
* The data point marker is used for marking the datapoints on a graph with some
* visual label, fx. a cross, a text box with the value or an icon.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Marker extends Image_Graph_Plotarea_Element
{
/**
* Secondary marker
* @var Marker
* @access private
*/
var $_secondaryMarker = false;
/**
* The 'size' of the marker, the meaning depends on the specific Marker
* implementation
* @var int
* @access private
*/
var $_size = 6;
/**
* Set the 'size' of the marker
*
* @param int $size The 'size' of the marker, the meaning depends on the
* specific Marker implementation
*/
function setSize($size)
{
$this->_size = $size;
}
/**
* Set the secondary marker
*
* @param Marker $secondaryMarker The secondary marker
*/
function setSecondaryMarker(& $secondaryMarker)
{
$this->_secondaryMarker =& $secondaryMarker;
$this->_secondaryMarker->_setParent($this);
}
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
if (is_a($this->_secondaryMarker, 'Image_Graph_Marker')) {
$this->_secondaryMarker->_drawMarker($x, $y, $values);
}
}
/**
* Output to the canvas
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
return true;
}
}
?>

View File

@ -1,105 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Array.php,v 1.6 2005/02/21 20:49:50 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* A sequential array of markers.
*
* This is used for displaying different markers for datapoints on a chart.
* This is done by adding multiple markers to a MarkerArrray structure.
* The marker array will then when requested return the 'next' marker in
* sequential order. It is possible to specify ID tags to each marker, which is
* used to make sure some data uses a specific marker.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Array extends Image_Graph_Marker
{
/**
* The marker array
* @var array
* @access private
*/
var $_markers = array ();
/**
* Add a marker style to the array
*
* @param Marker $marker The marker to add
*/
function add(& $marker)
{
if (is_a($marker, 'Image_Graph_Element')) {
parent::add($marker);
}
$this->_markers[] =& $marker;
reset($this->_markers);
}
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$ID = key($this->_markers);
if (!next($this->_markers)) {
reset($this->_markers);
}
$marker =& $this->_markers[$ID];
if ($marker != null) {
$marker->_drawMarker($x, $y, $values);
}
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,109 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Asterisk.php,v 1.6 2005/08/03 21:21:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as an asterisk (*)
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Asterisk extends Image_Graph_Marker
{
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$this->_getLineStyle();
$this->_canvas->line(
array(
'x0' => $x - $this->_size,
'y0' => $y - $this->_size,
'x1' => $x + $this->_size,
'y1' => $y + $this->_size
)
);
$this->_getLineStyle();
$this->_canvas->line(
array(
'x0' => $x + $this->_size,
'y0' => $y - $this->_size,
'x1' => $x - $this->_size,
'y1' => $y + $this->_size
)
);
$this->_getLineStyle();
$this->_canvas->line(
array(
'x0' => $x - $this->_size,
'y0' => $y,
'x1' => $x + $this->_size,
'y1' => $y
)
);
$this->_getLineStyle();
$this->_canvas->line(
array(
'x0' => $x,
'y0' => $y - $this->_size,
'x1' => $x,
'y1' => $y + $this->_size
)
);
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,91 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Average.php,v 1.6 2005/08/03 21:21:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* A marker displaying the 'distance' to the datasets average value.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Average extends Image_Graph_Marker
{
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
if ((isset($values['AVERAGE_Y'])) &&
(is_a($this->_parent, 'Image_Graph_Plot')))
{
$point = $this->_pointXY(
array(
'X' => $values['APX'],
'Y' => $values['AVERAGE_Y']
)
);
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x, 'y0' => $y, 'x1' => $point['X'], 'y1' => $point['Y']));
$this->_getLineStyle();
$this->_canvas->line(
array(
'x0' => $point['X'] - 2,
'y0' => $point['Y'],
'x1' => $point['X'] + 2,
'y1' => $point['Y']
)
);
}
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,76 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Box.php,v 1.6 2005/08/03 21:21:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as a box
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Box extends Image_Graph_Marker
{
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the canvas
* @param array $values The values representing the data the marker 'points' to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->rectangle(
array(
'x0' => $x - $this->_size,
'y0' => $y - $this->_size,
'x1' => $x + $this->_size,
'y1' => $y + $this->_size
)
);
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,91 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Bubble.php,v 1.5 2005/02/21 20:49:50 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker/Circle.php
*/
require_once 'Image/Graph/Marker/Circle.php';
/**
* Display a circle with y-value percentage as radius (require GD2).
*
* This will display a circle centered on the datapoint with a radius calculated
* as a percentage of the maximum value. I.e. the radius depends on the y-value
* of the datapoint
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Bubble extends Image_Graph_Marker_Circle
{
/**
* The radius of the marker when 100%
* @var int
* @access private
*/
var $_size100Pct = 40;
/**
* Sets the maximum radius the marker can occupy
*
* @param int $radius The new Image_Graph_max radius
*/
function setMaxRadius($radius)
{
$this->_size100Pct = $radius;
}
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$this->_size = $this->_size100Pct*$values['PCT_MAX_Y']/100;
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,96 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Circle.php,v 1.6 2005/08/03 21:21:54 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as circle (require GD2)
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Circle extends Image_Graph_Marker
{
/**
* The 'size' of the marker, the meaning depends on the specific Marker
* implementation
* @var int
* @access private
*/
var $_size = 10;
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points' to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$this->_getFillStyle();
$this->_getLineStyle();
$dA = 2*pi()/($this->_size*2);
$angle = 0;
while ($angle < 2*pi()) {
$this->_canvas->addVertex(array('x' =>
$x + $this->_size*cos($angle), 'y' =>
$y - $this->_size*sin($angle)
));
$angle += $dA;
}
$this->_canvas->addVertex(array('x' =>
$x + $this->_size*cos(0), 'y' =>
$y - $this->_size*sin(0)
));
$this->_canvas->polygon(array('connect' => true));
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,114 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Cross.php,v 1.7 2005/08/03 21:21:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as a cross.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Cross extends Image_Graph_Marker
{
/**
* The thickness of the plus in pixels (thickness is actually double this)
* @var int
* @access private
*/
var $_thickness = 2;
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the canvas
* @param array $values The values representing the data the marker 'points' to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
if ($this->_thickness > 0) {
$this->_getLineStyle();
$this->_getFillStyle();
$d1 = round(0.7071067 * $this->_size); // cos/sin(45 de>)
$d2 = round(0.7071067 * $this->_thickness); // cos/sin(45 deg)
$this->_canvas->addVertex(array('x' => $x - $d1 - $d2, 'y' => $y - $d1 + $d2));
$this->_canvas->addVertex(array('x' => $x - $d1 + $d2, 'y' => $y - $d1 - $d2));
$this->_canvas->addVertex(array('x' => $x, 'y' => $y - 2 * $d2));
$this->_canvas->addVertex(array('x' => $x + $d1 - $d2, 'y' => $y - $d1 - $d2));
$this->_canvas->addVertex(array('x' => $x + $d1 + $d2, 'y' => $y - $d1 + $d2));
$this->_canvas->addVertex(array('x' => $x + 2 * $d2, 'y' => $y));
$this->_canvas->addVertex(array('x' => $x + $d1 + $d2, 'y' => $y + $d1 - $d2));
$this->_canvas->addVertex(array('x' => $x + $d1 - $d2, 'y' => $y + $d1 + $d2));
$this->_canvas->addVertex(array('x' => $x, 'y' => $y + 2 * $d2));
$this->_canvas->addVertex(array('x' => $x - $d1 + $d2, 'y' => $y + $d1 + $d2));
$this->_canvas->addVertex(array('x' => $x - $d1 - $d2, 'y' => $y + $d1 - $d2));
$this->_canvas->addVertex(array('x' => $x - 2 * $d2, 'y' => $y));
$this->_canvas->polygon(array('connect' => true));
} else {
$this->_getLineStyle();
$this->_canvas->line(
array(
'x0' => $x - $this->_size,
'y0' => $y - $this->_size,
'x1' => $x + $this->_size,
'y1' => $y + $this->_size
)
);
$this->_getLineStyle();
$this->_canvas->line(
array(
'x0' => $x + $this->_size,
'y0' => $y - $this->_size,
'x1' => $x - $this->_size,
'y1' => $y + $this->_size
)
);
}
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,73 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Diamond.php,v 1.6 2005/08/03 21:21:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as a diamond.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Diamond extends Image_Graph_Marker
{
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the canvas
* @param array $values The values representing the data the marker 'points' to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->addVertex(array('x' => $x - $this->_size, 'y' => $y));
$this->_canvas->addVertex(array('x' => $x, 'y' => $y - $this->_size));
$this->_canvas->addVertex(array('x' => $x + $this->_size, 'y' => $y));
$this->_canvas->addVertex(array('x' => $x, 'y' => $y + $this->_size));
$this->_canvas->polygon(array('connect' => true));
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,133 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Icon.php,v 1.8 2005/08/24 20:35:53 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker using an image as icon.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Icon extends Image_Graph_Marker
{
/**
* Filename of the image icon
* @var string
* @access private
*/
var $_filename;
/**
* X Point of the icon to use as data 'center'
* @var int
* @access private
*/
var $_pointX = 0;
/**
* Y Point of the icon to use as data 'center'
* @var int
* @access private
*/
var $_pointY = 0;
/**
* Create an icon marker
*
* @param string $filename The filename of the icon
* @param int $width The 'new' width of the icon if it is to be resized
* @param int $height The 'new' height of the icon if it is to be resized
*/
function Image_Graph_Marker_Icon($filename, $width = 0, $height = 0)
{
parent::Image_Graph_Marker();
$this->_filename = $filename;
}
/**
* Set the X 'center' point of the marker
*
* @param int $x The X 'center' point of the marker
*/
function setPointX($x)
{
$this->_pointX = $x;
}
/**
* Set the Y 'center' point of the marker
*
* @param int $y The Y 'center' point of the marker
*/
function setPointY($y)
{
$this->_pointY = $y;
}
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
parent::_drawMarker($x, $y, $values);
if ($this->_filename) {
$this->_canvas->image(
array(
'x' => $x,
'y' => $y,
'filename' => $this->_filename,
'alignment' => array('horizontal' => 'center', 'vertical' => 'center')
)
);
}
}
}
?>

View File

@ -1,65 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Pinpoint.php,v 1.5 2005/08/24 20:35:53 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker/Icon.php
*/
require_once 'Image/Graph/Marker/Icon.php';
/**
* Data marker using a pinpoint as marker.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Pinpoint extends Image_Graph_Marker_Icon
{
/**
* Create the marker as a pin point
*/
function Image_Graph_Marker_Pinpoint()
{
parent::Image_Graph_Marker_Icon(
dirname(__FILE__).'/../Images/Icons/pinpoint.png'
);
$this->setPointX(0);
$this->setPointY(13);
}
}
?>

View File

@ -1,98 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Plus.php,v 1.7 2005/08/03 21:21:54 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as a plus.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Plus extends Image_Graph_Marker
{
/**
* The thickness of the plus in pixels (thickness is actually double this)
* @var int
* @access private
*/
var $_thickness = 2;
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
if ($this->_thickness > 0) {
$this->_getLineStyle();
$this->_getFillStyle();
$this->_canvas->addVertex(array('x' => $x - $this->_size, 'y' => $y - $this->_thickness));
$this->_canvas->addVertex(array('x' => $x - $this->_thickness, 'y' => $y - $this->_thickness));
$this->_canvas->addVertex(array('x' => $x - $this->_thickness, 'y' => $y - $this->_size));
$this->_canvas->addVertex(array('x' => $x + $this->_thickness, 'y' => $y - $this->_size));
$this->_canvas->addVertex(array('x' => $x + $this->_thickness, 'y' => $y - $this->_thickness));
$this->_canvas->addVertex(array('x' => $x + $this->_size, 'y' => $y - $this->_thickness));
$this->_canvas->addVertex(array('x' => $x + $this->_size, 'y' => $y + $this->_thickness));
$this->_canvas->addVertex(array('x' => $x + $this->_thickness, 'y' => $y + $this->_thickness));
$this->_canvas->addVertex(array('x' => $x + $this->_thickness, 'y' => $y + $this->_size));
$this->_canvas->addVertex(array('x' => $x - $this->_thickness, 'y' => $y + $this->_size));
$this->_canvas->addVertex(array('x' => $x - $this->_thickness, 'y' => $y + $this->_thickness));
$this->_canvas->addVertex(array('x' => $x - $this->_size, 'y' => $y + $this->_thickness));
$this->_canvas->polygon(array('connect' => true));
} else {
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x - $this->_size, 'y0' => $y, 'x1' => $x + $this->_size, 'y1' => $y));
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x, 'y0' => $y - $this->_size, 'x1' => $x, 'y1' => $y + $this->_size));
}
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,140 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Pointing.php,v 1.8 2005/08/24 20:35:54 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as a 'pointing marker'.
*
* Points to the data using another marker (as start and/or end)
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Pointing extends Image_Graph_Marker
{
/**
* The starting marker
* @var Marker
* @access private
*/
var $_markerStart;
/**
* The ending marker
* @var Marker
* @access private
*/
var $_markerEnd;
/**
* The X offset from the 'data'
* @var int
* @access private
*/
var $_deltaX = -1;
/**
* The Y offset from the 'data'
* @var int
* @access private
*/
var $_deltaY = -1;
/**
* Create an pointing marker, ie a pin on a board
*
* @param int $deltaX The the X offset from the real 'data' point
* @param int $deltaY The the Y offset from the real 'data' point
* @param Marker $markerEnd The ending marker that represents 'the head of
* the pin'
*/
function Image_Graph_Marker_Pointing($deltaX, $deltaY, & $markerEnd)
{
parent::Image_Graph_Marker();
$this->_deltaX = $deltaX;
$this->_deltaY = $deltaY;
$this->_markerStart = null;
$this->_markerEnd =& $markerEnd;
}
/**
* Sets the starting marker, ie the tip of the pin on a board
*
* @param Marker $markerStart The starting marker that represents 'the tip
* of the pin'
*/
function setMarkerStart(& $markerStart)
{
$this->_markerStart =& $markerStart;
$this->_markerStart->_setParent($this);
}
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
parent::_drawMarker($x, $y, $values);
if ($this->_markerStart) {
$this->_markerStart->_setParent($this);
$this->_markerStart->_drawMarker($x, $y, $values);
}
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x, 'y0' => $y, 'x1' => $x + $this->_deltaX, 'y1' => $y + $this->_deltaY));
$this->_markerEnd->_setParent($this);
$this->_markerEnd->_drawMarker(
$x + $this->_deltaX,
$y + $this->_deltaY,
$values
);
}
}
?>

View File

@ -1,105 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Angular.php,v 1.5 2005/08/24 20:36:03 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker/Pointing.php
*/
require_once 'Image/Graph/Marker/Pointing.php';
/**
* Marker that points 'away' from the graph.
*
* Use this as a marker for displaying another marker pointing to the original
* point on the graph - where the 'pointer' is calculated as line orthogonal to
* a line drawn between the points neighbours to both sides (an approximate
* tangent). This should make an the pointer appear to point 'straight' out from
* the graph. The 'head' of the pointer is then another marker of any choice.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Pointing_Angular extends Image_Graph_Marker_Pointing
{
/**
* The length of the angular marker
* @var int
* @access private
*/
var $_radius;
/**
* Image_Graph_AngularPointingMarker [Constructor]
* @param int $radius The 'length' of the pointer
* @param Marker $markerEnd The ending marker that represents 'the head of
* the pin'
*/
function Image_Graph_Marker_Pointing_Angular($radius, & $markerEnd)
{
parent::Image_Graph_Marker_Pointing(0, 0, $markerEnd);
$this->_radius = $radius;
}
/**
* Draw the marker on the canvas
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
if ((isset($values['LENGTH'])) && ($values['LENGTH'] != 0)) {
$this->_deltaX = - $values['AX'] * $this->_radius / $values['LENGTH'];
$this->_deltaY = - $values['AY'] * $this->_radius / $values['LENGTH'];
}
if ((isset($values['NPY'])) && (isset($values['APY'])) &&
(isset($values['PPY'])) && ($values['NPY'] > $values['APY']) &&
($values['PPY'] > $values['APY']))
{
$this->_deltaX = - $this->_deltaX;
$this->_deltaY = - $this->_deltaY;
}
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,91 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radial.php,v 1.5 2005/08/24 20:36:03 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker/Pointing.php
*/
require_once 'Image/Graph/Marker/Pointing.php';
/**
* A pointing marker in a random angle from the data
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Pointing_Radial extends Image_Graph_Marker_Pointing
{
/**
* The radius of the radial marker
* @var int
* @access private
*/
var $_radius;
/**
* Create an radial pointing marker, ie a marker on a defined distance from
* the data
* @param int $radius The 'length' of the pointer
* @param Marker $markerEnd The ending marker that represents 'the head of
* the pin'
*/
function Image_Graph_Marker_Pointing_Radial($radius, & $markerEnd)
{
parent::Image_Graph_Marker_Pointing(0, 0, $markerEnd);
$this->_radius = $radius;
}
/**
* Draw the marker on the canvas
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$angle = pi() * rand(0, 360) / 180;
$this->_deltaX = $this->_radius * cos($angle);
$this->_deltaY = $this->_radius * sin($angle);
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,65 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: ReversePinpoint.php,v 1.5 2005/08/24 20:35:53 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker/Icon.php
*/
require_once 'Image/Graph/Marker/Icon.php';
/**
* Data marker using a (reverse) pinpoint as marker.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_ReversePinpoint extends Image_Graph_Marker_Icon
{
/**
* Create the marker as a reverse pin point
*/
function Image_Graph_Marker_ReversePinpoint()
{
parent::Image_Graph_Marker_Icon(
dirname(__FILE__).'/../Images/Icons/pinpointr.png'
);
$this->setPointX(10);
$this->setPointY(13);
}
}
?>

View File

@ -1,88 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Star.php,v 1.2 2005/08/03 21:21:54 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as a triangle.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Star extends Image_Graph_Marker
{
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$this->_getFillStyle();
$this->_getLineStyle();
$d = $this->_size / 5;
$x = round($x);
$y = round($y);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y - $this->_size));
$this->_canvas->addVertex(array('x' => $x + round($d), 'y' => $y - round($d)));
$this->_canvas->addVertex(array('x' => $x + $this->_size, 'y' => $y - round($d)));
$this->_canvas->addVertex(array('x' => $x + round(2 * $d), 'y' => $y + round($d)));
$this->_canvas->addVertex(array('x' => $x + round(3 * $d), 'y' => $y + $this->_size));
$this->_canvas->addVertex(array('x' => $x, 'y' => $y + round(3 * $d)));
$this->_canvas->addVertex(array('x' => $x - round(3 * $d), 'y' => $y + $this->_size));
$this->_canvas->addVertex(array('x' => $x - round(2 * $d), 'y' => $y + round($d)));
$this->_canvas->addVertex(array('x' => $x - $this->_size, 'y' => $y - round($d)));
$this->_canvas->addVertex(array('x' => $x - round($d), 'y' => $y - round($d)));
$this->_canvas->polygon(array('connect' => true));
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,75 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Triangle.php,v 1.6 2005/08/03 21:21:54 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* Data marker as a triangle.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Triangle extends Image_Graph_Marker
{
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->addVertex(array('x' => $x - $this->_size, 'y' => $y + $this->_size));
$this->_canvas->addVertex(array('x' => $x, 'y' => $y - $this->_size));
$this->_canvas->addVertex(array('x' => $x + $this->_size, 'y' => $y + $this->_size));
$this->_canvas->polygon(array('connect' => true));
parent::_drawMarker($x, $y, $values);
}
}
?>

View File

@ -1,214 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Value.php,v 1.10 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Marker.php
*/
require_once 'Image/Graph/Marker.php';
/**
* A marker showing the data value.
*
* @category Images
* @package Image_Graph
* @subpackage Marker
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Marker_Value extends Image_Graph_Marker
{
/**
* Datapreproccesor to format the value
* @var DataPreprocessor
* @access private
*/
var $_dataPreprocessor = null;
/**
* Which value to use from the data set, ie the X or Y value
* @var int
* @access private
*/
var $_useValue;
/**
* Create a value marker, ie a box containing the value of the 'pointing
* data'
*
* @param int $useValue Defines which value to use from the dataset, i.e. the
* X or Y value
*/
function Image_Graph_Marker_Value($useValue = IMAGE_GRAPH_VALUE_X)
{
parent::Image_Graph_Marker();
$this->_padding = array('left' => 2, 'top' => 2, 'right' => 2, 'bottom' => 2);
$this->_useValue = $useValue;
$this->_fillStyle = 'white';
$this->_borderStyle = 'black';
}
/**
* Sets the background fill style of the element
*
* @param Image_Graph_Fill $background The background
* @see Image_Graph_Fill
*/
function setBackground(& $background)
{
$this->setFillStyle($background);
}
/**
* Sets the background color of the element
*
* @param mixed $color The color
*/
function setBackgroundColor($color)
{
$this->setFillColor($color);
}
/**
* Sets a data preprocessor for formatting the values
*
* @param DataPreprocessor $dataPreprocessor The data preprocessor
* @return Image_Graph_DataPreprocessor The data preprocessor
*/
function &setDataPreprocessor(& $dataPreprocessor)
{
$this->_dataPreprocessor =& $dataPreprocessor;
return $dataPreprocessor;
}
/**
* Get the value to display
*
* @param array $values The values representing the data the marker 'points'
* to
* @return string The display value, this is the pre-preprocessor value, to
* support for customized with multiple values. i.e show 'x = y' or '(x, y)'
* @access private
*/
function _getDisplayValue($values)
{
switch ($this->_useValue) {
case IMAGE_GRAPH_VALUE_X:
$value = $values['X'];
break;
case IMAGE_GRAPH_PCT_X_MIN:
$value = $values['PCT_MIN_X'];
break;
case IMAGE_GRAPH_PCT_X_MAX:
$value = $values['PCT_MAX_X'];
break;
case IMAGE_GRAPH_PCT_Y_MIN:
$value = $values['PCT_MIN_Y'];
break;
case IMAGE_GRAPH_PCT_Y_MAX:
$value = $values['PCT_MAX_Y'];
break;
case IMAGE_GRAPH_PCT_Y_TOTAL:
if (isset($values['SUM_Y'])) {
$value = 100 * $values['Y'] / $values['SUM_Y'];
}
else {
$value = 0;
}
break;
case IMAGE_GRAPH_POINT_ID:
$value = $values['ID'];
break;
default:
$value = $values['Y'];
break;
}
return $value;
}
/**
* Draw the marker on the canvas
*
* @param int $x The X (horizontal) position (in pixels) of the marker on
* the canvas
* @param int $y The Y (vertical) position (in pixels) of the marker on the
* canvas
* @param array $values The values representing the data the marker 'points'
* to
* @access private
*/
function _drawMarker($x, $y, $values = false)
{
parent::_drawMarker($x, $y, $values);
$value = $this->_getDisplayValue($values);
if ($this->_dataPreprocessor) {
$value = $this->_dataPreprocessor->_process($value);
}
if ($this->_defaultFontOptions !== false) {
$this->_canvas->setFont($this->_defaultFontOptions);
} else {
$this->_canvas->setFont($this->_getFont());
}
$width = $this->_canvas->textWidth($value);
$height = $this->_canvas->textHeight($value);
$offsetX = $width/2 + $this->_padding['left'];
$offsetY = $height/2 + $this->_padding['top'];
$this->_getFillStyle();
$this->_getBorderStyle();
$this->_canvas->rectangle(
array(
'x0' => $x - $offsetX,
'y0' => $y - $offsetY,
'x1' => $x + $offsetX,
'y1' => $y + $offsetY
)
);
$this->write($x, $y, $value, IMAGE_GRAPH_ALIGN_CENTER);
}
}
?>

View File

@ -1,824 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Plot.php,v 1.20 2006/02/28 22:33:00 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plotarea/Element.php
*/
require_once 'Image/Graph/Plotarea/Element.php';
/**
* Framework for a chart
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Plot extends Image_Graph_Plotarea_Element
{
/**
* The dataset to plot
* @var Dataset
* @access private
*/
var $_dataset;
/**
* The marker to plot the data set as
* @var Marker
* @access private
*/
var $_marker = null;
/**
* The dataselector to use for data marking
* @var DataSelector
* @access private
*/
var $_dataSelector = null;
/**
* The Y axis to associate the plot with
* @var int
* @access private
*/
var $_axisY = IMAGE_GRAPH_AXIS_Y;
/**
* The type of the plot if multiple datasets are used
* @var string
* @access private
*/
var $_multiType = 'normal';
/**
* The title of the plot, used for legending in case of simple plots
* @var string
* @access private
*/
var $_title = 'plot';
/**
* PlotType [Constructor]
*
* Valid values for multiType are:
*
* 'normal' Plot is normal, multiple datasets are displayes next to one
* another
*
* 'stacked' Datasets are stacked on top of each other
*
* 'stacked100pct' Datasets are stacked and displayed as percentages of the
* total sum
*
* I no title is specified a default is used, which is basically the plot
* type (fx. for a 'Image_Graph_Plot_Smoothed_Area' default title is
* 'Smoothed Area')
*
* @param Image_Graph_Dataset $dataset The data set (value containter) to
* plot or an array of datasets
* @param string $multiType The type of the plot
* @param string $title The title of the plot (used for legends,
* {@link Image_Graph_Legend})
*/
function Image_Graph_Plot(& $dataset, $multiType = 'normal', $title = '')
{
if (!is_a($dataset, 'Image_Graph_Dataset')) {
if (is_array($dataset)) {
$keys = array_keys($dataset);
foreach ($keys as $key) {
if (!is_a($dataset[$key], 'Image_Graph_Dataset')) {
$this->_error('Invalid dataset passed to ' . get_class($this));
}
}
unset($keys);
} else {
$this->_error('Invalid dataset passed to ' . get_class($this));
}
}
parent::Image_Graph_Common();
if ($dataset) {
if (is_array($dataset)) {
$this->_dataset =& $dataset;
} else {
$this->_dataset = array(&$dataset);
}
}
if ($title) {
$this->_title = $title;
} else {
$this->_title = str_replace('_', ' ', substr(get_class($this), 17));
}
$multiType = strtolower($multiType);
if (($multiType == 'normal') ||
($multiType == 'stacked') ||
($multiType == 'stacked100pct'))
{
$this->_multiType = $multiType;
} else {
$this->_error(
'Invalid multitype: ' . $multiType .
' expected (normal|stacked|stacked100pct)'
);
$this->_multiType = 'normal';
}
}
/**
* Sets the title of the plot, used for legend
*
* @param string $title The title of the plot
*/
function setTitle($title)
{
$this->_title = $title;
}
/**
* Parses the URL mapping data in the point and adds it to the parameter array used by
* Image_Canvas
*
* @param array $point The data point (from the dataset)
* @param array $canvasData The The for the canvas method
* @return array The union of the canvas data points and the appropriate points for the dataset
* @access private
*/
function _mergeData($point, $canvasData)
{
if (isset($point['data'])) {
if (isset($point['data']['url'])) {
$canvasData['url'] = $point['data']['url'];
}
if (isset($point['data']['target'])) {
$canvasData['target'] = $point['data']['target'];
}
if (isset($point['data']['alt'])) {
$canvasData['alt'] = $point['data']['alt'];
}
if (isset($point['data']['htmltags'])) {
$canvasData['htmltags'] = $point['data']['htmltags'];
}
}
return $canvasData;
}
/**
* Sets the Y axis to plot the data
*
* @param int $axisY The Y axis (either IMAGE_GRAPH_AXIS_Y / 'y' or
* IMAGE_GRAPH_AXIS_Y_SECONDARY / 'ysec' (defaults to IMAGE_GRAPH_AXIS_Y))
* @access private
*/
function _setAxisY($axisY)
{
if ($axisY == 'y') {
$this->_axisY = IMAGE_GRAPH_AXIS_Y;
} elseif ($axisY == 'ysec') {
$this->_axisY = IMAGE_GRAPH_AXIS_Y_SECONDARY;
} else {
$this->_axisY = $axisY;
}
}
/**
* Sets the marker to 'display' data points on the graph
*
* @param Marker $marker The marker
*/
function &setMarker(& $marker)
{
$this->add($marker);
$this->_marker =& $marker;
return $marker;
}
/**
* Sets the dataselector to specify which data should be displayed on the
* plot as markers and which are not
*
* @param DataSelector $dataSelector The dataselector
*/
function setDataSelector(& $dataSelector)
{
$this->_dataSelector =& $dataSelector;
}
/**
* Calculate marker point data
*
* @param array Point The point to calculate data for
* @param array NextPoint The next point
* @param array PrevPoint The previous point
* @param array Totals The pre-calculated totals, if needed
* @return array An array containing marker point data
* @access private
*/
function _getMarkerData($point, $nextPoint, $prevPoint, & $totals)
{
if (is_array($this->_dataset)) {
if ($this->_multiType == 'stacked') {
if (!isset($totals['SUM_Y'])) {
$totals['SUM_Y'] = array();
}
$x = $point['X'];
if (!isset($totals['SUM_Y'][$x])) {
$totals['SUM_Y'][$x] = 0;
}
} elseif ($this->_multiType == 'stacked100pct') {
$x = $point['X'];
if ($totals['TOTAL_Y'][$x] != 0) {
if (!isset($totals['SUM_Y'])) {
$totals['SUM_Y'] = array();
}
if (!isset($totals['SUM_Y'][$x])) {
$totals['SUM_Y'][$x] = 0;
}
}
}
if (isset($totals['ALL_SUM_Y'])) {
$point['SUM_Y'] = $totals['ALL_SUM_Y'];
}
if (!$prevPoint) {
$point['AX'] = -5;
$point['AY'] = 5;
$point['PPX'] = 0;
$point['PPY'] = 0;
$point['NPX'] = $nextPoint['X'];
$point['NPY'] = $nextPoint['Y'];
} elseif (!$nextPoint) {
$point['AX'] = 5;
$point['AY'] = 5;
$point['PPX'] = $prevPoint['X'];
$point['PPY'] = $prevPoint['Y'];
$point['NPX'] = 0;
$point['NPY'] = 0;
} else {
$point['AX'] = $this->_pointY($prevPoint) - $this->_pointY($nextPoint);
$point['AY'] = $this->_pointX($nextPoint) - $this->_pointX($prevPoint);
$point['PPX'] = $prevPoint['X'];
$point['PPY'] = $prevPoint['Y'];
$point['NPX'] = $nextPoint['X'];
$point['NPY'] = $nextPoint['Y'];
}
$point['APX'] = $point['X'];
$point['APY'] = $point['Y'];
if ((isset($totals['MINIMUM_X'])) && ($totals['MINIMUM_X'] != 0)) {
$point['PCT_MIN_X'] = 100 * $point['X'] / $totals['MINIMUM_X'];
}
if ((isset($totals['MAXIMUM_X'])) && ($totals['MAXIMUM_X'] != 0)) {
$point['PCT_MAX_X'] = 100 * $point['X'] / $totals['MAXIMUM_X'];
}
if ((isset($totals['MINIMUM_Y'])) && ($totals['MINIMUM_Y'] != 0)) {
$point['PCT_MIN_Y'] = 100 * $point['Y'] / $totals['MINIMUM_Y'];
}
if ((isset($totals['MAXIMUM_Y'])) && ($totals['MAXIMUM_Y'] != 0)) {
$point['PCT_MAX_Y'] = 100 * $point['Y'] / $totals['MAXIMUM_Y'];
}
$point['LENGTH'] = sqrt($point['AX'] * $point['AX'] +
$point['AY'] * $point['AY']);
if ((isset($point['LENGTH'])) && ($point['LENGTH'] != 0)) {
$point['ANGLE'] = asin($point['AY'] / $point['LENGTH']);
}
if ((isset($point['AX'])) && ($point['AX'] > 0)) {
$point['ANGLE'] = pi() - $point['ANGLE'];
}
if ($this->_parent->_horizontal) {
$point['MARKER_Y1'] = $this->_pointY($point) -
(isset($totals['WIDTH']) ? $totals['WIDTH'] : 0);
$point['MARKER_Y2'] = $this->_pointY($point) +
(isset($totals['WIDTH']) ? $totals['WIDTH'] : 0);
$point['COLUMN_WIDTH'] = abs($point['MARKER_Y2'] -
$point['MARKER_Y1']) / count($this->_dataset);
$point['MARKER_Y'] = $point['MARKER_Y1'] +
((isset($totals['NUMBER']) ? $totals['NUMBER'] : 0) + 0.5) *
$point['COLUMN_WIDTH'];
$point['MARKER_X'] = $this->_pointX($point);
if ($this->_multiType == 'stacked') {
$point['MARKER_Y'] =
($point['MARKER_Y1'] + $point['MARKER_Y2']) / 2;
$P1 = array('Y' => $totals['SUM_Y'][$x]);
$P2 = array('Y' => $totals['SUM_Y'][$x] + $point['Y']);
$point['MARKER_X'] =
($this->_pointX($P1) + $this->_pointX($P2)) / 2;
} elseif ($this->_multiType == 'stacked100pct') {
$x = $point['X'];
if ($totals['TOTAL_Y'][$x] != 0) {
$point['MARKER_Y'] =
($point['MARKER_Y1'] + $point['MARKER_Y2']) / 2;
$P1 = array(
'Y' => 100 * $totals['SUM_Y'][$x] / $totals['TOTAL_Y'][$x]
);
$P2 = array(
'Y' => 100 * ($totals['SUM_Y'][$x] + $point['Y']) / $totals['TOTAL_Y'][$x]
);
$point['MARKER_X'] =
($this->_pointX($P1) + $this->_pointX($P2)) / 2;
} else {
$point = false;
}
}
}
else {
$point['MARKER_X1'] = $this->_pointX($point) -
(isset($totals['WIDTH']) ? $totals['WIDTH'] : 0);
$point['MARKER_X2'] = $this->_pointX($point) +
(isset($totals['WIDTH']) ? $totals['WIDTH'] : 0);
$point['COLUMN_WIDTH'] = abs($point['MARKER_X2'] -
$point['MARKER_X1']) / count($this->_dataset);
$point['MARKER_X'] = $point['MARKER_X1'] +
((isset($totals['NUMBER']) ? $totals['NUMBER'] : 0) + 0.5) *
$point['COLUMN_WIDTH'];
$point['MARKER_Y'] = $this->_pointY($point);
if ($this->_multiType == 'stacked') {
$point['MARKER_X'] =
($point['MARKER_X1'] + $point['MARKER_X2']) / 2;
$P1 = array('Y' => $totals['SUM_Y'][$x]);
$P2 = array('Y' => $totals['SUM_Y'][$x] + $point['Y']);
$point['MARKER_Y'] =
($this->_pointY($P1) + $this->_pointY($P2)) / 2;
} elseif ($this->_multiType == 'stacked100pct') {
$x = $point['X'];
if ($totals['TOTAL_Y'][$x] != 0) {
$point['MARKER_X'] =
($point['MARKER_X1'] + $point['MARKER_X2']) / 2;
$P1 = array(
'Y' => 100 * $totals['SUM_Y'][$x] / $totals['TOTAL_Y'][$x]
);
$P2 = array(
'Y' => 100 * ($totals['SUM_Y'][$x] + $point['Y']) / $totals['TOTAL_Y'][$x]
);
$point['MARKER_Y'] =
($this->_pointY($P1) + $this->_pointY($P2)) / 2;
} else {
$point = false;
}
}
}
return $point;
}
}
/**
* Draws markers on the canvas
*
* @access private
*/
function _drawMarker()
{
if (($this->_marker) && (is_array($this->_dataset))) {
$this->_canvas->startGroup(get_class($this) . '_marker');
$totals = $this->_getTotals();
$totals['WIDTH'] = $this->width() / ($this->_maximumX() + 2) / 2;
$number = 0;
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$totals['MINIMUM_X'] = $dataset->minimumX();
$totals['MAXIMUM_X'] = $dataset->maximumX();
$totals['MINIMUM_Y'] = $dataset->minimumY();
$totals['MAXIMUM_Y'] = $dataset->maximumY();
$totals['NUMBER'] = $number ++;
$dataset->_reset();
while ($point = $dataset->_next()) {
$prevPoint = $dataset->_nearby(-2);
$nextPoint = $dataset->_nearby();
$x = $point['X'];
$y = $point['Y'];
if (((!is_object($this->_dataSelector)) ||
($this->_dataSelector->_select($point))) && ($point['Y'] !== null))
{
$point = $this->_getMarkerData(
$point,
$nextPoint,
$prevPoint,
$totals
);
if (is_array($point)) {
$this->_marker->_drawMarker(
$point['MARKER_X'],
$point['MARKER_Y'],
$point
);
}
}
if (!isset($totals['SUM_Y'])) {
$totals['SUM_Y'] = array();
}
if (isset($totals['SUM_Y'][$x])) {
$totals['SUM_Y'][$x] += $y;
} else {
$totals['SUM_Y'][$x] = $y;
}
}
}
unset($keys);
$this->_canvas->endGroup();
}
}
/**
* Get the minimum X value from the dataset
*
* @return double The minimum X value
* @access private
*/
function _minimumX()
{
if (!is_array($this->_dataset)) {
return 0;
}
$min = false;
if (is_array($this->_dataset)) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
if ($min === false) {
$min = $this->_dataset[$key]->minimumX();
} else {
$min = min($min, $this->_dataset[$key]->minimumX());
}
}
unset($keys);
}
return $min;
}
/**
* Get the maximum X value from the dataset
*
* @return double The maximum X value
* @access private
*/
function _maximumX()
{
if (!is_array($this->_dataset)) {
return 0;
}
$max = 0;
if (is_array($this->_dataset)) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$max = max($max, $this->_dataset[$key]->maximumX());
}
unset($keys);
}
return $max;
}
/**
* Get the minimum Y value from the dataset
*
* @return double The minimum Y value
* @access private
*/
function _minimumY()
{
if (!is_array($this->_dataset)) {
return 0;
}
$min = false;
if (is_array($this->_dataset)) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
if ($this->_multiType == 'normal') {
if ($min === false) {
$min = $this->_dataset[$key]->minimumY();
} else {
$min = min($min, $this->_dataset[$key]->minimumY());
}
} else {
if ($min === false) {
$min = 0;
}
$dataset =& $this->_dataset[$key];
$dataset->_reset();
while ($point = $dataset->_next()) {
if ($point['Y'] < 0) {
$x = $point['X'];
if ((!isset($total)) || (!isset($total[$x]))) {
$total[$x] = $point['Y'];
} else {
$total[$x] += $point['Y'];
}
if (isset($min)) {
$min = min($min, $total[$x]);
} else {
$min = $total[$x];
}
}
}
}
}
unset($keys);
}
return $min;
}
/**
* Get the maximum Y value from the dataset
*
* @return double The maximum Y value
* @access private
*/
function _maximumY()
{
if ($this->_multiType == 'stacked100pct') {
return 100;
}
$maxY = 0;
if (is_array($this->_dataset)) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
if ($this->_multiType == 'normal') {
if (isset($maxY)) {
$maxY = max($maxY, $dataset->maximumY());
} else {
$maxY = $dataset->maximumY();
}
} else {
$dataset->_reset();
while ($point = $dataset->_next()) {
if ($point['Y'] > 0) {
$x = $point['X'];
if ((!isset($total)) || (!isset($total[$x]))) {
$total[$x] = $point['Y'];
} else {
$total[$x] += $point['Y'];
}
if (isset($maxY)) {
$maxY = max($maxY, $total[$x]);
} else {
$maxY = $total[$x];
}
}
}
}
}
unset($keys);
}
return $maxY;
}
/**
* Get the X pixel position represented by a value
*
* @param double $point The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointX($point)
{
$point['AXIS_Y'] = $this->_axisY;
return parent::_pointX($point);
}
/**
* Get the Y pixel position represented by a value
*
* @param double $point the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointY($point)
{
$point['AXIS_Y'] = $this->_axisY;
return parent::_pointY($point);
}
/**
* Update coordinates
*
* @access private
*/
function _updateCoords()
{
$this->_setCoords($this->_parent->_plotLeft, $this->_parent->_plotTop, $this->_parent->_plotRight, $this->_parent->_plotBottom);
parent::_updateCoords();
}
/**
* Get the dataset
*
* @return Image_Graph_Dataset The dataset(s)
*/
function &dataset()
{
return $this->_dataset;
}
/**
* Calulate totals
*
* @return array An associated array with the totals
* @access private
*/
function _getTotals()
{
$total = array(
'MINIMUM_X' => $this->_minimumX(),
'MAXIMUM_X' => $this->_maximumX(),
'MINIMUM_Y' => $this->_minimumY(),
'MAXIMUM_Y' => $this->_maximumY()
);
$total['ALL_SUM_Y'] = 0;
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
while ($point = $dataset->_next()) {
$x = $point['X'];
if (is_numeric($point['Y'])) {
$total['ALL_SUM_Y'] += $point['Y'];
if (isset($total['TOTAL_Y'][$x])) {
$total['TOTAL_Y'][$x] += $point['Y'];
} else {
$total['TOTAL_Y'][$x] = $point['Y'];
}
}
if (is_numeric($point['X'])) {
if (isset($total['TOTAL_X'][$x])) {
$total['TOTAL_X'][$x] += $point['X'];
} else {
$total['TOTAL_X'][$x] = $point['X'];
}
}
}
}
unset($keys);
return $total;
}
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$this->_canvas->rectangle(array('x0' => $x0, 'y0' => $y0, 'x1' => $x1, 'y1' => $y1));
}
/**
* Draw a sample for use with legend
*
* @param array $param The parameters for the legend
* @access private
*/
function _legendSample(&$param)
{
if (!is_array($this->_dataset)) {
return false;
}
if (is_a($this->_fillStyle, 'Image_Graph_Fill')) {
$this->_fillStyle->_reset();
}
$count = 0;
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$count++;
$caption = ($dataset->_name ? $dataset->_name : $this->_title);
$this->_canvas->setFont($param['font']);
$width = 20 + $param['width'] + $this->_canvas->textWidth($caption);
$param['maxwidth'] = max($param['maxwidth'], $width);
$x2 = $param['x'] + $width;
$y2 = $param['y'] + $param['height'] + 5;
if ((($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) && ($y2 > $param['bottom'])) {
$param['y'] = $param['top'];
$param['x'] = $x2;
$y2 = $param['y'] + $param['height'];
} elseif ((($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) == 0) && ($x2 > $param['right'])) {
$param['x'] = $param['left'];
$param['y'] = $y2;
$x2 = $param['x'] + 20 + $param['width'] + $this->_canvas->textWidth($caption);
}
$x = $x0 = $param['x'];
$y = $param['y'];
$y0 = $param['y'];
$x1 = $param['x'] + $param['width'];
$y1 = $param['y'] + $param['height'];
if (!isset($param['simulate'])) {
$this->_getFillStyle($key);
$this->_getLineStyle();
$this->_drawLegendSample($x0, $y0, $x1, $y1);
if (($this->_marker) && ($dataset) && ($param['show_marker'])) {
$dataset->_reset();
$point = $dataset->_next();
$prevPoint = $dataset->_nearby(-2);
$nextPoint = $dataset->_nearby();
$tmp = array();
$point = $this->_getMarkerData($point, $nextPoint, $prevPoint, $tmp);
if (is_array($point)) {
$point['MARKER_X'] = $x+$param['width']/2;
$point['MARKER_Y'] = $y;
unset ($point['AVERAGE_Y']);
$this->_marker->_drawMarker($point['MARKER_X'], $point['MARKER_Y'], $point);
}
}
$this->write($x + $param['width'] + 10, $y + $param['height'] / 2, $caption, IMAGE_GRAPH_ALIGN_CENTER_Y | IMAGE_GRAPH_ALIGN_LEFT, $param['font']);
}
if (($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) {
$param['y'] = $y2;
} else {
$param['x'] = $x2;
}
}
unset($keys);
}
}
?>

View File

@ -1,194 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Area.php,v 1.13 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Area Chart plot.
*
* An area chart plots all data points similar to a {@link
* Image_Graph_Plot_Line}, but the area beneath the line is filled and the whole
* area 'the-line', 'the right edge', 'the x-axis' and 'the left edge' is
* bounded. Smoothed charts are only supported with non-stacked types
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Area extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$dx = abs($x1 - $x0) / 3;
$dy = abs($y1 - $y0) / 3;
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y1));
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y0 + $dy));
$this->_canvas->addVertex(array('x' => $x0 + $dx, 'y' => $y0));
$this->_canvas->addVertex(array('x' => $x0 + 2*$dx, 'y' => $y0 + 2*$dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y0 + $dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y1));
$this->_canvas->polygon(array('connect' => true));
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$base = array();
if ($this->_multiType == 'stacked') {
reset($this->_dataset);
$key = key($this->_dataset);
$dataset =& $this->_dataset[$key];
$first = $dataset->first();
$point = array ('X' => $first['X'], 'Y' => '#min_pos#');
$base[] = array();
$base[] = $this->_pointY($point);
$first = $this->_pointX($point);
$base[] = $first;
$last = $dataset->last();
$point = array ('X' => $last['X'], 'Y' => '#min_pos#');
$base[] = array();
$base[] = $this->_pointY($point);
$base[] = $this->_pointX($point);
$current = array();
}
$minYaxis = $this->_parent->_getMinimum($this->_axisY);
$maxYaxis = $this->_parent->_getMaximum($this->_axisY);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
if ($this->_multiType == 'stacked') {
$plotarea = array_reverse($base);
$base = array();
while ($point = $dataset->_next()) {
$x = $point['X'];
$p = $point;
if (isset($current[$x])) {
$p['Y'] += $current[$x];
} else {
$current[$x] = 0;
}
$x1 = $this->_pointX($p);
$y1 = $this->_pointY($p);
$plotarea[] = $x1;
$plotarea[] = $y1;
$plotarea[] = $point;
$base[] = array();
$base[] = $y1;
$base[] = $x1;
$current[$x] += $point['Y'];
}
} else {
$first = true;
$plotarea = array();
while ($point = $dataset->_next()) {
if ($first) {
$firstPoint = array ('X' => $point['X'], 'Y' => '#min_pos#');
$plotarea[] = $this->_pointX($firstPoint);
$plotarea[] = $this->_pointY($firstPoint);
$plotarea[] = array();
}
$plotarea[] = $this->_pointX($point);
$plotarea[] = $this->_pointY($point);
$plotarea[] = $point;
$lastPoint = $point;
$first = false;
}
$endPoint['X'] = $lastPoint['X'];
$endPoint['Y'] = '#min_pos#';
$plotarea[] = $this->_pointX($endPoint);
$plotarea[] = $this->_pointY($endPoint);
$plotarea[] = array();
}
reset($plotarea);
while (list(, $x) = each($plotarea)) {
list(, $y) = each($plotarea);
list(, $data) = each($plotarea);
$this->_canvas->addVertex(
$this->_mergeData(
$data,
array('x' => $x, 'y' => $y)
)
);
}
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true, 'map_vertices' => true));
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,205 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Band.php,v 1.12 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* "Band" (area chart with min AND max) chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @since Class available since Release 0.3.0dev2
*/
class Image_Graph_Plot_Band extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$h = abs($y1 - $y0) / 6;
$w = round(abs($x1 - $x0) / 5);
$y = ($y0 + $y1) / 2;
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y - $h * 3));
$this->_canvas->addVertex(array('x' => $x0 + $w, 'y' => $y - 4 * $h));
$this->_canvas->addVertex(array('x' => $x0 + 2 * $w, 'y' => $y - $h * 2));
$this->_canvas->addVertex(array('x' => $x0 + 3 * $w, 'y' => $y - $h * 4));
$this->_canvas->addVertex(array('x' => $x0 + 4 * $w, 'y' => $y - $h * 3));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y - $h * 2));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y + $h * 3));
$this->_canvas->addVertex(array('x' => $x0 + 4 * $w, 'y' => $y + $h));
$this->_canvas->addVertex(array('x' => $x0 + 3 * $w, 'y' => $y + 2 * $h));
$this->_canvas->addVertex(array('x' => $x0 + 2 * $w, 'y' => $y + 1 * $h));
$this->_canvas->addVertex(array('x' => $x0 + 1 * $w, 'y' => $y));
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y + $h));
$this->_getLineStyle();
$this->_getFillStyle();
$this->_canvas->polygon(array('connect' => true));
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!is_array($this->_dataset)) {
return false;
}
$current = array();
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$upperBand = array();
$lowerBand = array();
while ($data = $dataset->_next()) {
if ($this->_parent->_horizontal) {
$point['X'] = $data['X'];
$point['Y'] = $data['Y']['high'];
$y = $this->_pointY($point);
$x_high = $this->_pointX($point);
$point['Y'] = $data['Y']['low'];
$x_low = $this->_pointX($point);
$data = array('X' => $x_high, 'Y' => $y);
if (isset($point['data'])) {
$data['data'] = $point['data'];
} else {
$data['data'] = array();
}
$upperBand[] = $data;
$data = array('X' => $x_low, 'Y' => $y);
if (isset($point['data'])) {
$data['data'] = $point['data'];
} else {
$data['data'] = array();
}
$lowerBand[] = $data;
}
else {
$point['X'] = $data['X'];
$y = $data['Y'];
$point['Y'] = $data['Y']['high'];
$x = $this->_pointX($point);
$y_high = $this->_pointY($point);
$point['Y'] = $data['Y']['low'];
$y_low = $this->_pointY($point);
$data = array('X' => $x, 'Y' => $y_high);
if (isset($point['data'])) {
$data['data'] = $point['data'];
} else {
$data['data'] = array();
}
$upperBand[] = $data;
$data = array('X' => $x, 'Y' => $y_low);
if (isset($point['data'])) {
$data['data'] = $point['data'];
} else {
$data['data'] = array();
}
$lowerBand[] = $data;
}
}
$lowerBand = array_reverse($lowerBand);
foreach ($lowerBand as $point) {
$this->_canvas->addVertex(
$this->_mergeData(
$point['data'],
array('x' => $point['X'], 'y' => $point['Y'])
)
);
}
foreach ($upperBand as $point) {
$this->_canvas->addVertex(
$this->_mergeData(
$point['data'],
array('x' => $point['X'], 'y' => $point['Y'])
)
);
}
unset($upperBand);
unset($lowerBand);
$this->_getLineStyle($key);
$this->_getFillStyle($key);
$this->_canvas->polygon(array('connect' => true, 'map_vertices' => true));
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,307 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Bar.php,v 1.14 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* A bar chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Bar extends Image_Graph_Plot
{
/**
* The space between 2 bars (should be a multipla of 2)
* @var int
* @access private
*/
var $_space = 4;
/**
* The width of the bars
* @var array
* @access private
*/
var $_width = 'auto';
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$dx = abs($x1 - $x0) / 7;
$this->_canvas->rectangle(array('x0' => $x0 + $dx, 'y0' => $y0, 'x1' => $x1 - $dx, 'y1' => $y1));
}
/**
* Set the spacing between 2 neighbouring bars
*
* @param int $space The number of pixels between 2 bars, should be a
* multipla of 2 (ie an even number)
*/
function setSpacing($space)
{
$this->_space = (int) ($space / 2);
}
/**
* Set the width of a bars.
*
* Specify 'auto' to auto calculate the width based on the positions on the
* x-axis.
*
* Supported units are:
*
* '%' The width is specified in percentage of the total plot width
*
* 'px' The width specified in pixels
*
* @param string $width The width of any bar
* @param string $unit The unit of the width
*/
function setBarWidth($width, $unit = false)
{
if ($width == 'auto') {
$this->_width = $width;
} else {
$this->_width = array(
'width' => $width,
'unit' => $unit
);
}
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!is_array($this->_dataset)) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_width == 'auto') {
$width = $this->_parent->_labelDistance(IMAGE_GRAPH_AXIS_X) / 2;
} elseif ($this->_width['unit'] == '%') {
$width = $this->_width['width'] * $this->width() / 200;
} elseif ($this->_width['unit'] == 'px') {
$width = $this->_width['width'] / 2;
}
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
$minYaxis = $this->_parent->_getMinimum($this->_axisY);
$maxYaxis = $this->_parent->_getMaximum($this->_axisY);
$number = 0;
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
while ($point = $dataset->_next()) {
if ($this->_parent->_horizontal) {
$y1 = $this->_pointY($point) - $width;
$y2 = $this->_pointY($point) + $width;
if ($y2 - $this->_space > $y1 + $this->_space) {
/*
* Take bar spacing into account _only_ if the space doesn't
* turn the bar "inside-out", i.e. if the actual bar width
* is smaller than the space between the bars
*/
$y2 -= $this->_space;
$y1 += $this->_space;
}
}
else {
$x1 = $this->_pointX($point) - $width;
$x2 = $this->_pointX($point) + $width;
if ($x2 - $this->_space > $x1 + $this->_space) {
/*
* Take bar spacing into account _only_ if the space doesn't
* turn the bar "inside-out", i.e. if the actual bar width
* is smaller than the space between the bars
*/
$x2 -= $this->_space;
$x1 += $this->_space;
}
}
if (($this->_multiType == 'stacked') ||
($this->_multiType == 'stacked100pct'))
{
$x = $point['X'];
if ($point['Y'] >= 0) {
if (!isset($current[$x])) {
$current[$x] = 0;
}
if ($this->_multiType == 'stacked') {
$p0 = array(
'X' => $point['X'],
'Y' => $current[$x]
);
$p1 = array(
'X' => $point['X'],
'Y' => $current[$x] + $point['Y']
);
} else {
$p0 = array(
'X' => $point['X'],
'Y' => 100 * $current[$x] / $total['TOTAL_Y'][$x]
);
$p1 = array(
'X' => $point['X'],
'Y' => 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x]
);
}
$current[$x] += $point['Y'];
} else {
if (!isset($currentNegative[$x])) {
$currentNegative[$x] = 0;
}
$p0 = array(
'X' => $point['X'],
'Y' => $currentNegative[$x]
);
$p1 = array(
'X' => $point['X'],
'Y' => $currentNegative[$x] + $point['Y']
);
$currentNegative[$x] += $point['Y'];
}
} else {
if (count($this->_dataset) > 1) {
$w = 2 * ($width - $this->_space) / count($this->_dataset);
if ($this->_parent->_horizontal) {
$y2 = ($y1 = ($y1 + $y2) / 2 - ($width - $this->_space) + $number * $w) + $w;
}
else {
$x2 = ($x1 = ($x1 + $x2) / 2 - ($width - $this->_space) + $number * $w) + $w;
}
}
$p0 = array('X' => $point['X'], 'Y' => 0);
$p1 = $point;
}
if ((($minY = min($p0['Y'], $p1['Y'])) < $maxYaxis) &&
(($maxY = max($p0['Y'], $p1['Y'])) > $minYaxis)
) {
$p0['Y'] = $minY;
$p1['Y'] = $maxY;
if ($p0['Y'] < $minYaxis) {
$p0['Y'] = '#min_pos#';
}
if ($p1['Y'] > $maxYaxis) {
$p1['Y'] = '#max_neg#';
}
if ($this->_parent->_horizontal) {
$x1 = $this->_pointX($p0);
$x2 = $this->_pointX($p1);
}
else {
$y1 = $this->_pointY($p0);
$y2 = $this->_pointY($p1);
}
$ID = $point['ID'];
if (($ID === false) && (count($this->_dataset) > 1)) {
$ID = $key;
}
$this->_getFillStyle($ID);
$this->_getLineStyle($ID);
if (($y1 != $y2) && ($x1 != $x2)) {
$this->_canvas->rectangle(
$this->_mergeData(
$point,
array(
'x0' => min($x1, $x2),
'y0' => min($y1, $y2),
'x1' => max($x1, $x2),
'y1' => max($y1, $y2)
)
)
);
}
}
}
$number ++;
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,298 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: BoxWhisker.php,v 1.14 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Box & Whisker chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @since Class available since Release 0.3.0dev2
*/
class Image_Graph_Plot_BoxWhisker extends Image_Graph_Plot
{
/**
* Whisker circle size
* @var int
* @access private
*/
var $_whiskerSize = false;
/**
* Draws a box & whisker
*
* @param int $x The x position
* @param int $w The width of the box
* @param int $r The radius of the circle markers
* @param int $y_min The Y position of the minimum value
* @param int $y_q1 The Y position of the median of the first quartile
* @param int $y_med The Y position of the median
* @param int $y_q3 The Y position of the median of the third quartile
* @param int $y_max The Y position of the maximum value
* @param int $key The ID tag
* @access private
*/
function _drawBoxWhiskerV($x, $w, $r, $y_min, $y_q1, $y_med, $y_q3, $y_max, $key = false)
{
// draw circles
$this->_getLineStyle();
$this->_getFillStyle('min');
$this->_canvas->ellipse(array('x' => $x, 'y' => $y_min, 'rx' => $r, 'ry' => $r));
$this->_getLineStyle();
$this->_getFillStyle('quartile1');
$this->_canvas->ellipse(array('x' => $x, 'y' => $y_q1, 'rx' => $r, 'ry' => $r));
$this->_getLineStyle();
$this->_getFillStyle('median');
$this->_canvas->ellipse(array('x' => $x, 'y' => $y_med, 'rx' => $r, 'ry' => $r));
$this->_getLineStyle();
$this->_getFillStyle('quartile3');
$this->_canvas->ellipse(array('x' => $x, 'y' => $y_q3, $r, 'rx' => $r, 'ry' => $r));
$this->_getLineStyle();
$this->_getFillStyle('max');
$this->_canvas->ellipse(array('x' => $x, 'y' => $y_max, $r, 'rx' => $r, 'ry' => $r));
// draw box and lines
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x, 'y0' => $y_min, 'x1' => $x, 'y1' => $y_q1));
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x, 'y0' => $y_q3, 'x1' => $x, 'y1' => $y_max));
$this->_getLineStyle();
$this->_getFillStyle('box');
$this->_canvas->rectangle(array('x0' => $x - $w, 'y0' => $y_q1, 'x1' => $x + $w, 'y1' => $y_q3));
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x - $w, 'y0' => $y_med, 'x1' => $x + $w, 'y1' => $y_med));
}
/**
* Draws a box & whisker
*
* @param int $y The x position
* @param int $h The width of the box
* @param int $r The radius of the circle markers
* @param int $x_min The Y position of the minimum value
* @param int $x_q1 The Y position of the median of the first quartile
* @param int $x_med The Y position of the median
* @param int $x_q3 The Y position of the median of the third quartile
* @param int $x_max The Y position of the maximum value
* @param int $key The ID tag
* @access private
*/
function _drawBoxWhiskerH($y, $h, $r, $x_min, $x_q1, $x_med, $x_q3, $x_max, $key = false)
{
// draw circles
$this->_getLineStyle();
$this->_getFillStyle('min');
$this->_canvas->ellipse(array('x' => $x_min, 'y' => $y, 'rx' => $r, 'ry' => $r));
$this->_getLineStyle();
$this->_getFillStyle('quartile1');
$this->_canvas->ellipse(array('x' => $x_q1, 'y' => $y, 'rx' => $r, 'ry' => $r));
$this->_getLineStyle();
$this->_getFillStyle('median');
$this->_canvas->ellipse(array('x' => $x_med, 'y' => $y, 'rx' => $r, 'ry' => $r));
$this->_getLineStyle();
$this->_getFillStyle('quartile3');
$this->_canvas->ellipse(array('x' => $x_q3, 'y' => $y, $r, 'rx' => $r, 'ry' => $r));
$this->_getLineStyle();
$this->_getFillStyle('max');
$this->_canvas->ellipse(array('x' => $x_max, 'y' => $y, $r, 'rx' => $r, 'ry' => $r));
// draw box and lines
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x_min, 'y0' => $y, 'x1' => $x_q1, 'y1' => $y));
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x_q3, 'y0' => $y, 'x1' => $x_max, 'y1' => $y));
$this->_getLineStyle();
$this->_getFillStyle('box');
$this->_canvas->rectangle(array('x0' => $x_q1, 'y0' => $y - $h, 'x1' => $x_q3, 'y1' => $y + $h));
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x_med, 'y0' => $y - $h, 'x1' => $x_med, 'y1' => $y + $h));
}
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$x = round(($x0 + $x1) / 2);
$h = abs($y1 - $y0) / 9;
$w = round(abs($x1 - $x0) / 5);
$r = 2;//round(abs($x1 - $x0) / 13);
$this->_drawBoxWhiskerV($x, $w, $r, $y1, $y1 - 2 * $h, $y1 - 4 * $h, $y0 + 3 * $h, $y0);
}
/**
* Sets the whisker circle size
*
* @param int $size Size (radius) of the whisker circle/dot
*/
function setWhiskerSize($size = false)
{
$this->_whiskerSize = $size;
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!is_array($this->_dataset)) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
$current = array();
$number = 0;
$width = floor(0.5 * $this->_parent->_labelDistance(IMAGE_GRAPH_AXIS_X) / 2);
if ($this->_whiskerSize !== false) {
$r = $this->_whiskerSize;
} else {
$r = min(5, $width / 10);
}
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
while ($data = $dataset->_next()) {
if ($this->_parent->_horizontal) {
$point['X'] = $data['X'];
$y = $data['Y'];
$min = min($y);
$max = max($y);
$q1 = $dataset->_median($y, 'first');
$med = $dataset->_median($y, 'second');
$q3 = $dataset->_median($y, 'third');
$point['Y'] = $min;
$y = $this->_pointY($point);
$x_min = $this->_pointX($point);
$point['Y'] = $max;
$x_max = $this->_pointX($point);
$point['Y'] = $q1;
$x_q1 = $this->_pointX($point);
$point['Y'] = $med;
$x_med = $this->_pointX($point);
$point['Y'] = $q3;
$x_q3 = $this->_pointX($point);
$this->_drawBoxWhiskerH($y, $width, $r, $x_min, $x_q1, $x_med, $x_q3, $x_max, $key);
}
else {
$point['X'] = $data['X'];
$y = $data['Y'];
$min = min($y);
$max = max($y);
$q1 = $dataset->_median($y, 'first');
$med = $dataset->_median($y, 'second');
$q3 = $dataset->_median($y, 'third');
$point['Y'] = $min;
$x = $this->_pointX($point);
$y_min = $this->_pointY($point);
$point['Y'] = $max;
$y_max = $this->_pointY($point);
$point['Y'] = $q1;
$y_q1 = $this->_pointY($point);
$point['Y'] = $med;
$y_med = $this->_pointY($point);
$point['Y'] = $q3;
$y_q3 = $this->_pointY($point);
$this->_drawBoxWhiskerV($x, $width, $r, $y_min, $y_q1, $y_med, $y_q3, $y_max, $key);
}
}
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,317 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Area.php,v 1.13 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Bubble Chart plot.
*
* An area chart plots all data points similar to a {@link
* Image_Graph_Plot_Line}, but the area beneath the line is filled and the whole
* area 'the-line', 'the right edge', 'the x-axis' and 'the left edge' is
* bounded. Smoothed charts are only supported with non-stacked types
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Eric Ross <eric.ross.c@gmail.com>
* @copyright Copyright (C) 2007 Eric Ross
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Bubble extends Image_Graph_Plot
{
var $_only_minmax = true;
function Image_Graph_Plot_Bubble(&$dataset, $only_minmax = false)
{
$this->_only_minmax = $only_minmax;
parent::Image_Graph_Plot($dataset);
}
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
if ($this->_only_minmax)
return;
$x = ($x0 + $x1) / 2;
$y = ($y0 + $y1) / 2;
$rx = abs($x0 - $x1) / 2.0;
$ry = abs($y0 - $y1) / 2.0;
$fill = $this->_fillStyle->_getFillStyle(-1);
$this->_canvas->ellipse(array(
'x' => $x,
'y' => $y,
'rx' => $rx,
'ry' => $ry,
'fill' => $fill,
'line' => 'black'
)
);
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if ($this->_only_minmax)
return $this->_drawMinMax();
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$index = 0;
$canvas_width = $this->_canvas->getWidth();
$graph_width = $this->_right - $this->_left;
$graph_height = $this->_bottom - $this->_top;
$num_datasets = count($this->_dataset);
$y_step = $graph_height / ($num_datasets + 1);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$fill = $this->_fillStyle->_getFillStyle(-1);
while ($point = $dataset->_next()) {
//$pivot = $point['X'];
$y = $point['Y'];
$size = $point['data']['size'];
$x = $point['data']['x'];
// x is the % from the left border (0% = full left; 100% = full right)
$x = $this->_left + $x * $graph_width / 100.0;
// y is the number of steps (the number of the dataset) zero based
$y = $this->_bottom - ($y + 1) * $y_step;
$this->_canvas->ellipse(array(
'x' => $x,
'y' => $y,
'rx' => $size,
'ry' => $size,
'fill' => $fill,
'line' => 'black'
)
);
/*
if (isset($this->_callback)) {
call_user_func($this->_callback, array( 'event' => 'bubble',
'x' => $x,
'y' => $y,
'rx' => $size,
'ry' => $size,
'value' => $point['data']['value']
)
);
}
*/
}
$index++;
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
function getTextWidth($str)
{
return $this->_canvas->textWidth($str);
}
function _drawMinMax()
{
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$index = 0;
$canvas_width = $this->_canvas->getWidth();
$graph_width = $this->_right - $this->_left;
$graph_height = $this->_bottom - $this->_top;
$num_datasets = count($this->_dataset);
$y_step = $graph_height / ($num_datasets + 1);
$keys = array_keys($this->_dataset);
$max_value = -1;
$max_size = -1;
$min_value = 999999;
$min_size = 100;
$avg_value = 0;
$avg_size = 1;
$count = 0;
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
while ($point = $dataset->_next()) {
//$pivot = $point['X'];
//$y = $point['Y'];
$value = $point['data']['value'];
$size = $point['data']['size'];
//$x = $point['data']['x'];
if ($value > $max_value) {
$max_value = $value;
$max_size = $size;
}
if ($value < $min_value) {
$min_value = $value;
$min_size = $size;
}
$avg_value += $value;
$avg_size += $size;
$count++;
}
}
$avg_value /= $count == 0 ? 1 : $count;
$avg_size /= $count == 0 ? 1 : $count;
unset($keys);
$xs = array(0, 0, 0);
$y = 0;
$fills = array("gray", "gray", "gray");
$sizes = array($min_size, $avg_size, $max_size);
$values = array($min_value, $avg_value, $max_value);
$titles = array("Min", "Prom", "Max");
for($i=0;$i<3;$i++) {
$x = $this->_left + $xs[$i];
$this->_canvas->setFont($this->_getFont());
$this->_canvas->addText(array(
"x" => $x,
"y" => $this->_top + $y,
"text" => $titles[$i],
"color" => "black",
)
);
$textHeight = $this->_canvas->textWidth($titles[$i]);
$x += $textHeight + $sizes[$i] + 6;
$ye = $y + $this->_canvas->textHeight($titles[$i]) / 2.0;
$this->_canvas->ellipse(array(
'x' => $x,
'y' => $this->_top + $ye,
'rx' => $sizes[$i],
'ry' => $sizes[$i],
'fill' => $fills[$i],
'line' => 'black'
)
);
$x += $sizes[$i] + 6;
$this->_canvas->setFont($this->_getFont());
$txt = "" . round($values[$i]);
$this->_canvas->addText(array(
"x" => $x,
"y" => $this->_top + $y,
"text" => $txt,
"color" => "black",
)
);
$yOld = $y;
$y += $textHeight / 2.0;
$y += $sizes[$i];
$y += ($i < 2 ? $sizes[$i + 1] : 0);
$y -= ($i < 2 ? $this->_canvas->textHeight($titles[$i+1]) : 0);
if ($y < $yOld + $textHeight)
$y = $yOld + $textHeight;
}
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,251 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: CandleStick.php,v 1.12 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Candlestick chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
* @since Class available since Release 0.3.0dev2
*/
class Image_Graph_Plot_CandleStick extends Image_Graph_Plot
{
/**
* (Add basic description here)
*
* @access private
*/
function _drawCandleStickH($y, $h, $x_min, $x_open, $x_close, $x_max, $ID)
{
$this->_getLineStyle($ID);
$this->_canvas->line(
array(
'x0' => min($x_open, $x_close),
'y0' => $y,
'x1' => $x_min,
'y1' => $y
)
);
$this->_getLineStyle($ID);
$this->_canvas->line(
array(
'x0' => max($x_open, $x_close),
'y0' => $y,
'x1' => $x_max,
'y1' => $y
)
);
$this->_getLineStyle($ID);
$this->_getFillStyle($ID);
$this->_canvas->rectangle(
array(
'x0' => min($x_open, $x_close),
'y0' => $y - $h,
'x1' => max($x_open, $x_close),
'y1' => $y + $h
)
);
}
/**
* (Add basic description here)
*
* @access private
*/
function _drawCandleStickV($x, $w, $y_min, $y_open, $y_close, $y_max, $ID)
{
$this->_getLineStyle($ID);
$this->_canvas->line(
array(
'x0' => $x,
'y0' => min($y_open, $y_close),
'x1' => $x,
'y1' => $y_max
)
);
$this->_getLineStyle($ID);
$this->_canvas->line(
array(
'x0' => $x,
'y0' => max($y_open, $y_close),
'x1' => $x,
'y1' => $y_min
)
);
$this->_getLineStyle($ID);
$this->_getFillStyle($ID);
$this->_canvas->rectangle(
array(
'x0' => $x - $w,
'y0' => min($y_open, $y_close),
'x1' => $x + $w,
'y1' => max($y_open, $y_close)
)
);
}
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$x = round(($x0 + $x1) / 2);
$h = abs($y1 - $y0) / 4;
$w = round(abs($x1 - $x0) / 5);
$this->_drawCandleStickV($x, $w, $y1, $y1 - $h, $y0 + $h, $y0, 'green');
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!is_array($this->_dataset)) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
$current = array();
$number = 0;
$width = floor(0.8 * $this->_parent->_labelDistance(IMAGE_GRAPH_AXIS_X) / 2);
$lastClosed = false;
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
while ($data = $dataset->_next()) {
if ($this->_parent->_horizontal) {
$point['X'] = $data['X'];
//$y = $data['Y'];
if (isset($data['Y']['open'])) {
$point['Y'] = $data['Y']['open'];
} else {
$point['Y'] = $lastClosed;
}
$y = $this->_pointY($point);
$x_open = $this->_pointX($point);
$lastClosed = $point['Y'] = $data['Y']['close'];
$x_close = $this->_pointX($point);
$point['Y'] = $data['Y']['min'];
$x_min = $this->_pointX($point);
$point['Y'] = $data['Y']['max'];
$x_max = $this->_pointX($point);
if ($data['Y']['close'] < $data['Y']['open']) {
$ID = 'red';
} else {
$ID = 'green';
}
$this->_drawCandleStickH($y, $width, $x_min, $x_open, $x_close, $x_max, $ID);
}
else {
$point['X'] = $data['X'];
//$y = $data['Y'];
if (isset($data['Y']['open'])) {
$point['Y'] = $data['Y']['open'];
} else {
$point['Y'] = $lastClosed;
}
$x = $this->_pointX($point);
$y_open = $this->_pointY($point);
$lastClosed = $point['Y'] = $data['Y']['close'];
$y_close = $this->_pointY($point);
$point['Y'] = $data['Y']['min'];
$y_min = $this->_pointY($point);
$point['Y'] = $data['Y']['max'];
$y_max = $this->_pointY($point);
if ($data['Y']['close'] < $data['Y']['open']) {
$ID = 'red';
} else {
$ID = 'green';
}
$this->_drawCandleStickV($x, $width, $y_min, $y_open, $y_close, $y_max, $ID);
}
}
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup($this->_title);
return true;
}
}
?>

View File

@ -1,99 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Dot.php,v 1.11 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Dot / scatter chart (only marker).
*
* This plot type only displays a {@link Image_Graph_Marker} for the datapoints.
* The marker must explicitly be defined using {@link Image_Graph_Plot::
* setMarker()}.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Dot extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
if (isset($this->_marker)) {
$key = key($this->_dataset);
$samplePoint = $this->_dataset[$key]->_nearby();
$this->_marker->_drawMarker(($x0 + $x1) / 2, ($y0 + $y1) / 2, $samplePoint);
}
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (Image_Graph_Plot::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,118 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Line.php,v 1.2 2005/11/27 22:21:18 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Include file Image/Graph/Tool.php
*/
require_once 'Image/Graph/Tool.php';
/**
* Fit the graph (to a line using linear regression).
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Fit_Line extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$y = ($y0 + $y1) / 2;
$dy = abs($y1 - $y0) / 6;
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y + $dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y - $dy));
$this->_canvas->polygon(array('connect' => false));
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (Image_Graph_Plot::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$data = array();
while ($point = $dataset->_next()) {
$data[] = array(
'X' => $this->_pointX($point),
'Y' => $this->_pointY($point)
);
}
$regression = Image_Graph_Tool::calculateLinearRegression($data);
$this->_getLineStyle($key);
$this->_canvas->line(
array(
'x0' => $this->_left,
'y0' => $this->_left * $regression['slope'] + $regression['intersection'],
'x1' => $this->_right,
'y1' => $this->_right * $regression['slope'] + $regression['intersection']
)
);
}
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,204 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Impulse.php,v 1.13 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Impulse chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: 0.7.2
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Impulse extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$x = ($x0 + $x1) / 2;
$this->_canvas->line(array('x0' => $x, 'y0' => $y0, 'x1' => $x, 'y1' => $y1));
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!is_array($this->_dataset)) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
$current = array();
$number = 0;
$minYaxis = $this->_parent->_getMinimum($this->_axisY);
$maxYaxis = $this->_parent->_getMaximum($this->_axisY);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
while ($point = $dataset->_next()) {
$x0 = $this->_pointX($point);
if (($this->_multiType == 'stacked') ||
($this->_multiType == 'stacked100pct'))
{
$x = $point['X'];
if ($point['Y'] >= 0) {
if (!isset($current[$x])) {
$current[$x] = 0;
}
if ($this->_multiType == 'stacked') {
$p0 = array(
'X' => $point['X'],
'Y' => $current[$x]
);
$p1 = array(
'X' => $point['X'],
'Y' => $current[$x] + $point['Y']
);
} else {
$p0 = array(
'X' => $point['X'],
'Y' => 100 * $current[$x] / $total['TOTAL_Y'][$x]
);
$p1 = array(
'X' => $point['X'],
'Y' => 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x]
);
}
$current[$x] += $point['Y'];
} else {
if (!isset($currentNegative[$x])) {
$currentNegative[$x] = 0;
}
$p0 = array(
'X' => $point['X'],
'Y' => $currentNegative[$x]
);
$p1 = array(
'X' => $point['X'],
'Y' => $currentNegative[$x] + $point['Y']
);
$currentNegative[$x] += $point['Y'];
}
} else {
$p0 = array('X' => $point['X'], 'Y' => 0);
$p1 = $point;
}
if ((($minY = min($p0['Y'], $p1['Y'])) < $maxYaxis) &&
(($maxY = max($p0['Y'], $p1['Y'])) > $minYaxis)
) {
$p0['Y'] = $minY;
$p1['Y'] = $maxY;
if ($p0['Y'] < $minYaxis) {
$p0['Y'] = '#min_pos#';
}
if ($p1['Y'] > $maxYaxis) {
$p1['Y'] = '#max_neg#';
}
$x1 = $this->_pointX($p0);
$y1 = $this->_pointY($p0);
$x2 = $this->_pointX($p1);
$y2 = $this->_pointY($p1);
if ($this->_multiType == 'normal') {
$offset = 5*$number;
$x1 += $offset;
$x2 += $offset;
}
$ID = $point['ID'];
if (($ID === false) && (count($this->_dataset) > 1)) {
$ID = $key;
}
$this->_getLineStyle($key);
$this->_canvas->line(
$this->_mergeData(
$point,
array(
'x0' => $x1,
'y0' => $y1,
'x1' => $x2,
'y1' => $y2
)
)
);
}
}
$number++;
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

Some files were not shown because too many files have changed in this diff Show More