添加到 trunk
+YUCHENG HU+ git-svn-id: https://svn.code.sf.net/p/hawebs/svn@154 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,152 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,156 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,124 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,204 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,103 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,92 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,97 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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) );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,147 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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 ++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,114 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,260 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,185 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,97 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,137 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,97 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,114 @@
|
||||
<?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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user