Update to PEAR 1.7.2, Image_Canvas 0.3.1, Image_Color 1.0.3, Image_Graph 0.7.2, XML_Parser 1.3.1.

Removed PHP_Compat, and references to it.
Removed ionCube/Zend/mmCache compatibility checks in test.php script.
Changed minimum PHP requirement to 5.0 in test.php script.
This commit is contained in:
anubis
2009-01-04 19:22:54 -05:00
parent 60b674c776
commit fae6352bf2
384 changed files with 34150 additions and 44524 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,164 +1,171 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Line.php,v 1.12 2005/08/08 19:09:18 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Linechart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Line extends Image_Graph_Plot
{
/**
* Gets the fill style of the element
*
* @return int A GD filestyle representing the fill style
* @see Image_Graph_Fill
* @access private
*/
function _getFillStyle($ID = false)
{
return IMG_COLOR_TRANSPARENT;
}
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$y = ($y0 + $y1) / 2;
$dx = abs($x1 - $x0) / 3;
$dy = abs($y1 - $y0) / 5;
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y));
$this->_canvas->addVertex(array('x' => $x0 + $dx, 'y' => $y - $dy * 2));
$this->_canvas->addVertex(array('x' => $x1 - $dx, 'y' => $y + $dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y - $dy));
$this->_canvas->polygon(array('connect' => false));
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!is_array($this->_dataset)) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
reset($this->_dataset);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
$p1 = false;
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$numPoints = 0;
while ($point = $dataset->_next()) {
if (($this->_multiType == 'stacked') ||
($this->_multiType == 'stacked100pct'))
{
$x = $point['X'];
if (!isset($current[$x])) {
$current[$x] = 0;
}
if ($this->_multiType == 'stacked') {
$py = $current[$x] + $point['Y'];
} else {
$py = 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x];
}
$current[$x] += $point['Y'];
$point['Y'] = $py;
}
if ($point['Y'] === null) {
if ($numPoints > 1) {
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
$numPoints = 0;
} else {
$p2['X'] = $this->_pointX($point);
$p2['Y'] = $this->_pointY($point);
$this->_canvas->addVertex(
$this->_mergeData(
$point,
array('x' => $p2['X'], 'y' => $p2['Y'])
)
);
$numPoints++;
}
}
if ($numPoints > 1) {
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
}
unset($keys);
$this->_drawMarker();
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Line.php,v 1.15 2006/03/02 12:37:37 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Linechart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Line extends Image_Graph_Plot
{
/**
* Gets the fill style of the element
*
* @return int A GD filestyle representing the fill style
* @see Image_Graph_Fill
* @access private
*/
function _getFillStyle($ID = false)
{
return IMG_COLOR_TRANSPARENT;
}
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$y = ($y0 + $y1) / 2;
$dx = abs($x1 - $x0) / 3;
$dy = abs($y1 - $y0) / 5;
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y));
$this->_canvas->addVertex(array('x' => $x0 + $dx, 'y' => $y - $dy * 2));
$this->_canvas->addVertex(array('x' => $x1 - $dx, 'y' => $y + $dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y - $dy));
$this->_canvas->polygon(array('connect' => false));
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!is_array($this->_dataset)) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
reset($this->_dataset);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
$p1 = false;
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$numPoints = 0;
while ($point = $dataset->_next()) {
if (($this->_multiType == 'stacked') ||
($this->_multiType == 'stacked100pct'))
{
$x = $point['X'];
if (!isset($current[$x])) {
$current[$x] = 0;
}
if ($this->_multiType == 'stacked') {
$py = $current[$x] + $point['Y'];
} else {
$py = 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x];
}
$current[$x] += $point['Y'];
$point['Y'] = $py;
}
if ($point['Y'] === null) {
if ($numPoints > 1) {
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
else {
$this->_canvas->reset();
}
$numPoints = 0;
} else {
$p2['X'] = $this->_pointX($point);
$p2['Y'] = $this->_pointY($point);
$this->_canvas->addVertex(
$this->_mergeData(
$point,
array('x' => $p2['X'], 'y' => $p2['Y'])
)
);
$numPoints++;
}
}
if ($numPoints > 1) {
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
else {
$this->_canvas->reset();
}
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,116 +1,118 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radar.php,v 1.10 2005/08/03 21:21:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Radar chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Radar extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$p = 10;
$rx = abs($x1 - $x0) / 2;
$ry = abs($x1 - $x0) / 2;
$r = min($rx, $ry);
$cx = ($x0 + $x1) / 2;
$cy = ($y0 + $y1) / 2;
$max = 5;
for ($i = 0; $i < $p; $i++) {
$v = 2 * pi() * $i / $p;
$t = $r * rand(3, $max) / $max;
$x = $cx + $t * cos($v);
$y = $cy + $t * sin($v);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
$this->_canvas->polygon(array('connect' => true));
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$maxY = $dataset->maximumY();
$count = $dataset->count();
$dataset->_reset();
while ($point = $dataset->_next()) {
$this->_canvas->addVertex(array('x' =>
$this->_pointX($point), 'y' =>
$this->_pointY($point)
));
}
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true));
}
unset($keys);
}
$this->_drawMarker();
$this->_canvas->endGroup();
return parent::_done();
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radar.php,v 1.11 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Radar chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Radar extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$p = 10;
$rx = abs($x1 - $x0) / 2;
$ry = abs($x1 - $x0) / 2;
$r = min($rx, $ry);
$cx = ($x0 + $x1) / 2;
$cy = ($y0 + $y1) / 2;
$max = 5;
for ($i = 0; $i < $p; $i++) {
$v = 2 * pi() * $i / $p;
$t = $r * rand(3, $max) / $max;
$x = $cx + $t * cos($v);
$y = $cy + $t * sin($v);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
$this->_canvas->polygon(array('connect' => true));
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$maxY = $dataset->maximumY();
$count = $dataset->count();
$dataset->_reset();
while ($point = $dataset->_next()) {
$this->_canvas->addVertex(array('x' =>
$this->_pointX($point), 'y' =>
$this->_pointY($point)
));
}
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true));
}
unset($keys);
}
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return parent::_done();
}
}
?>

View File

@@ -1,142 +1,145 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Area.php,v 1.10 2005/08/03 21:21:52 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot/Smoothed/Bezier.php
*/
require_once 'Image/Graph/Plot/Smoothed/Bezier.php';
/**
* Bezier smoothed area chart
*
* Similar to an {@link Image_Graph_Plot_Area}, but the interconnecting lines
* between two datapoints are smoothed using a Bezier curve, which enables the
* chart to appear as a nice curved plot instead of the sharp edges of a
* conventional {@link Image_Graph_Plot_Area}. Smoothed charts are only supported
* with non-stacked types
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Smoothed_Area extends Image_Graph_Plot_Smoothed_Bezier
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y1));
$this->_addSamplePoints($x0, $y0, $x1, $y1);
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y1));
$this->_canvas->polygon(array('connect' => true));
}
/**
* Output the Bezier smoothed plot as an Area Chart
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$first = true;
while ($p1 = $dataset->_next()) {
$p0 = $dataset->_nearby(-2);
$p2 = $dataset->_nearby(0);
$p3 = $dataset->_nearby(1);
if ($first) {
$p = $p1;
$p['Y'] = '#min_pos#';
$x = $this->_pointX($p);
$y = $this->_pointY($p);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
if ($p2) {
$cp = $this->_getControlPoints($p1, $p0, $p2, $p3);
$this->_canvas->addSpline(
array(
'x' => $cp['X'],
'y' => $cp['Y'],
'p1x' => $cp['P1X'],
'p1y' => $cp['P1Y'],
'p2x' => $cp['P2X'],
'p2y' => $cp['P2Y']
)
);
} else {
$x = $this->_pointX($p1);
$y = $this->_pointY($p1);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
$lastPoint = $p1;
$first = false;
}
$lastPoint['Y'] = '#min_pos#';
$x = $this->_pointX($lastPoint);
$y = $this->_pointY($lastPoint);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true));
}
unset($keys);
$this->_drawMarker();
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Area.php,v 1.11 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot/Smoothed/Bezier.php
*/
require_once 'Image/Graph/Plot/Smoothed/Bezier.php';
/**
* Bezier smoothed area chart
*
* Similar to an {@link Image_Graph_Plot_Area}, but the interconnecting lines
* between two datapoints are smoothed using a Bezier curve, which enables the
* chart to appear as a nice curved plot instead of the sharp edges of a
* conventional {@link Image_Graph_Plot_Area}. Smoothed charts are only supported
* with non-stacked types
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Smoothed_Area extends Image_Graph_Plot_Smoothed_Bezier
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y1));
$this->_addSamplePoints($x0, $y0, $x1, $y1);
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y1));
$this->_canvas->polygon(array('connect' => true));
}
/**
* Output the Bezier smoothed plot as an Area Chart
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$first = true;
while ($p1 = $dataset->_next()) {
$p0 = $dataset->_nearby(-2);
$p2 = $dataset->_nearby(0);
$p3 = $dataset->_nearby(1);
if ($first) {
$p = $p1;
$p['Y'] = '#min_pos#';
$x = $this->_pointX($p);
$y = $this->_pointY($p);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
if ($p2) {
$cp = $this->_getControlPoints($p1, $p0, $p2, $p3);
$this->_canvas->addSpline(
array(
'x' => $cp['X'],
'y' => $cp['Y'],
'p1x' => $cp['P1X'],
'p1y' => $cp['P1Y'],
'p2x' => $cp['P2X'],
'p2y' => $cp['P2Y']
)
);
} else {
$x = $this->_pointX($p1);
$y = $this->_pointY($p1);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
$lastPoint = $p1;
$first = false;
}
$lastPoint['Y'] = '#min_pos#';
$x = $this->_pointX($lastPoint);
$y = $this->_pointY($lastPoint);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true));
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@@ -1,173 +1,173 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Bezier.php,v 1.8 2005/08/24 20:36:02 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Include file Image/Graph/Tool.php
*/
require_once 'Image/Graph/Tool.php';
/**
* Bezier smoothed plottype.
*
* The framework for calculating the Bezier smoothed curve from the dataset.
* Used in {@link Image_Graph_Plot_Smoothed_Line} and {@link
* Image_Graph_Plot_Smoothed_Area}. Smoothed charts are only supported with non-
* stacked types
* @link http://homepages.borland.com/efg2lab/Graphics/Jean-
* YvesQueinecBezierCurves.htm efg computer lab - description of bezier curves
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Plot_Smoothed_Bezier extends Image_Graph_Plot
{
/**
* Image_Graph_Plot_Smoothed_Bezier [Constructor]
*
* Only 'normal' multitype supported
*
* @param Dataset $dataset The data set (value containter) to plot
* @param string $title The title of the plot (used for legends, {@link
* Image_Graph_Legend})
*/
function Image_Graph_Plot_Smoothed_Bezier(& $dataset, $title = '')
{
parent::Image_Graph_Plot($dataset, 'normal', $title);
}
/**
* Return the minimum Y point
*
* @return double The minumum Y point
* @access private
*/
function _minimumY()
{
return 1.05 * parent::_minimumY();
}
/**
* Return the maximum Y point
*
* @return double The maximum Y point
* @access private
*/
function _maximumY()
{
return 1.05 * parent::_maximumY();
}
/**
* Calculates all Bezier points, for the curve
*
* @param array $p1 The actual point to calculate control points for
* @param array $p0 The point "just before" $p1
* @param array $p2 The point "just after" $p1
* @param array $p3 The point "just after" $p2
* @return array Array of Bezier points
* @access private
*/
function _getControlPoints($p1, $p0, $p2, $p3)
{
$p1 = $this->_pointXY($p1);
if ($p2) {
$p2 = $this->_pointXY($p2);
}
if (!$p0) {
$p0['X'] = $p1['X'] - abs($p2['X'] - $p1['X']);
$p0['Y'] = $p1['Y']; //-($p2['Y']-$p1['Y']);
} else {
$p0 = $this->_pointXY($p0);
}
if (!$p3) {
$p3['X'] = $p1['X'] + 2*abs($p1['X'] - $p0['X']);
$p3['Y'] = $p1['Y'];
} else {
$p3 = $this->_pointXY($p3);
}
if (!$p2) {
$p2['X'] = $p1['X'] + abs($p1['X'] - $p0['X']);
$p2['Y'] = $p1['Y'];
}
$pC1['X'] = Image_Graph_Tool::controlPoint($p0['X'], $p1['X'], $p2['X']);
$pC1['Y'] = Image_Graph_Tool::controlPoint($p0['Y'], $p1['Y'], $p2['Y']);
$pC2['X'] = Image_Graph_Tool::controlPoint($p3['X'], $p2['X'], $p1['X']);
$pC2['Y'] = Image_Graph_Tool::controlPoint($p3['Y'], $p2['Y'], $p1['Y']);
return array(
'X' => $p1['X'],
'Y' => $p1['Y'],
'P1X' => $pC1['X'],
'P1Y' => $pC1['Y'],
'P2X' => $pC2['X'],
'P2Y' => $pC2['Y']
);
}
/**
* Create legend sample data for the canvas.
*
* Common for all smoothed plots
*
* @access private
*/
function _addSamplePoints($x0, $y0, $x1, $y1)
{
$p = abs($x1 - $x0);
$cy = ($y0 + $y1) / 2;
$h = abs($y1 - $y0);
$dy = $h / 4;
$dw = abs($x1 - $x0) / $p;
for ($i = 0; $i < $p; $i++) {
$v = 2 * pi() * $i / $p;
$x = $x0 + $i * $dw;
$y = $cy + 2 * $v * sin($v);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Bezier.php,v 1.8 2005/08/24 20:36:02 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot.php
*/
require_once 'Image/Graph/Plot.php';
/**
* Include file Image/Graph/Tool.php
*/
require_once 'Image/Graph/Tool.php';
/**
* Bezier smoothed plottype.
*
* The framework for calculating the Bezier smoothed curve from the dataset.
* Used in {@link Image_Graph_Plot_Smoothed_Line} and {@link
* Image_Graph_Plot_Smoothed_Area}. Smoothed charts are only supported with non-
* stacked types
* @link http://homepages.borland.com/efg2lab/Graphics/Jean-
* YvesQueinecBezierCurves.htm efg computer lab - description of bezier curves
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Plot_Smoothed_Bezier extends Image_Graph_Plot
{
/**
* Image_Graph_Plot_Smoothed_Bezier [Constructor]
*
* Only 'normal' multitype supported
*
* @param Dataset $dataset The data set (value containter) to plot
* @param string $title The title of the plot (used for legends, {@link
* Image_Graph_Legend})
*/
function Image_Graph_Plot_Smoothed_Bezier(& $dataset, $title = '')
{
parent::Image_Graph_Plot($dataset, 'normal', $title);
}
/**
* Return the minimum Y point
*
* @return double The minumum Y point
* @access private
*/
function _minimumY()
{
return 1.05 * parent::_minimumY();
}
/**
* Return the maximum Y point
*
* @return double The maximum Y point
* @access private
*/
function _maximumY()
{
return 1.05 * parent::_maximumY();
}
/**
* Calculates all Bezier points, for the curve
*
* @param array $p1 The actual point to calculate control points for
* @param array $p0 The point "just before" $p1
* @param array $p2 The point "just after" $p1
* @param array $p3 The point "just after" $p2
* @return array Array of Bezier points
* @access private
*/
function _getControlPoints($p1, $p0, $p2, $p3)
{
$p1 = $this->_pointXY($p1);
if ($p2) {
$p2 = $this->_pointXY($p2);
}
if (!$p0) {
$p0['X'] = $p1['X'] - abs($p2['X'] - $p1['X']);
$p0['Y'] = $p1['Y']; //-($p2['Y']-$p1['Y']);
} else {
$p0 = $this->_pointXY($p0);
}
if (!$p3) {
$p3['X'] = $p1['X'] + 2*abs($p1['X'] - $p0['X']);
$p3['Y'] = $p1['Y'];
} else {
$p3 = $this->_pointXY($p3);
}
if (!$p2) {
$p2['X'] = $p1['X'] + abs($p1['X'] - $p0['X']);
$p2['Y'] = $p1['Y'];
}
$pC1['X'] = Image_Graph_Tool::controlPoint($p0['X'], $p1['X'], $p2['X']);
$pC1['Y'] = Image_Graph_Tool::controlPoint($p0['Y'], $p1['Y'], $p2['Y']);
$pC2['X'] = Image_Graph_Tool::controlPoint($p3['X'], $p2['X'], $p1['X']);
$pC2['Y'] = Image_Graph_Tool::controlPoint($p3['Y'], $p2['Y'], $p1['Y']);
return array(
'X' => $p1['X'],
'Y' => $p1['Y'],
'P1X' => $pC1['X'],
'P1Y' => $pC1['Y'],
'P2X' => $pC2['X'],
'P2Y' => $pC2['Y']
);
}
/**
* Create legend sample data for the canvas.
*
* Common for all smoothed plots
*
* @access private
*/
function _addSamplePoints($x0, $y0, $x1, $y1)
{
$p = abs($x1 - $x0);
$cy = ($y0 + $y1) / 2;
$h = abs($y1 - $y0);
$dy = $h / 4;
$dw = abs($x1 - $x0) / $p;
for ($i = 0; $i < $p; $i++) {
$v = 2 * pi() * $i / $p;
$x = $x0 + $i * $dw;
$y = $cy + 2 * $v * sin($v);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
}
}
?>

View File

@@ -1,164 +1,172 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Line.php,v 1.11 2005/08/08 19:09:19 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot/Smoothed/Bezier.php
*/
require_once 'Image/Graph/Plot/Smoothed/Bezier.php';
/**
* Bezier smoothed line chart.
*
* Similar to a {@link Image_Graph_Plot_Line}, but the interconnecting lines
* between two datapoints are smoothed using a Bezier curve, which enables the
* chart to appear as a nice curved plot instead of the sharp edges of a
* conventional {@link Image_Graph_Plot_Line}. Smoothed charts are only supported
* with non-stacked types
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Smoothed_Line extends Image_Graph_Plot_Smoothed_Bezier
{
/**
* Gets the fill style of the element
*
* @return int A GD filestyle representing the fill style
* @see Image_Graph_Fill
* @access private
*/
function _getFillStyle($ID = false)
{
return IMG_COLOR_TRANSPARENT;
}
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$this->_addSamplePoints($x0, $y0, $x1, $y1);
$this->_canvas->polygon(array('connect' => false));
}
/**
* Output the Bezier smoothed plot as an Line Chart
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$numPoints = 0;
while ($p1 = $dataset->_next()) {
if ($p1['Y'] === null) {
if ($numPoints > 1) {
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
$numPoints = 0;
} else {
$p0 = $dataset->_nearby(-2);
$p2 = $dataset->_nearby(0);
$p3 = $dataset->_nearby(1);
if (($p0) && ($p0['Y'] === null)) {
$p0 = false;
}
if (($p2) && ($p2['Y'] === null)) {
$p2 = false;
}
if (($p3) && ($p3['Y'] === null)) {
$p3 = false;
}
if ($p2) {
$cp = $this->_getControlPoints($p1, $p0, $p2, $p3);
$this->_canvas->addSpline(
$this->_mergeData(
$p1,
array(
'x' => $cp['X'],
'y' => $cp['Y'],
'p1x' => $cp['P1X'],
'p1y' => $cp['P1Y'],
'p2x' => $cp['P2X'],
'p2y' => $cp['P2Y']
)
)
);
} else {
$x = $this->_pointX($p1);
$y = $this->_pointY($p1);
$this->_canvas->addVertex(
$this->_mergeData(
$p1,
array('x' => $x, 'y' => $y)
)
);
}
$numPoints++;
}
}
if ($numPoints > 1) {
$this->_getLineStyle();
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
}
unset($keys);
$this->_drawMarker();
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Line.php,v 1.14 2006/03/02 12:37:37 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot/Smoothed/Bezier.php
*/
require_once 'Image/Graph/Plot/Smoothed/Bezier.php';
/**
* Bezier smoothed line chart.
*
* Similar to a {@link Image_Graph_Plot_Line}, but the interconnecting lines
* between two datapoints are smoothed using a Bezier curve, which enables the
* chart to appear as a nice curved plot instead of the sharp edges of a
* conventional {@link Image_Graph_Plot_Line}. Smoothed charts are only supported
* with non-stacked types
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Smoothed_Line extends Image_Graph_Plot_Smoothed_Bezier
{
/**
* Gets the fill style of the element
*
* @return int A GD filestyle representing the fill style
* @see Image_Graph_Fill
* @access private
*/
function _getFillStyle($ID = false)
{
return IMG_COLOR_TRANSPARENT;
}
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$this->_addSamplePoints($x0, $y0, $x1, $y1);
$this->_canvas->polygon(array('connect' => false));
}
/**
* Output the Bezier smoothed plot as an Line Chart
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$numPoints = 0;
while ($p1 = $dataset->_next()) {
if ($p1['Y'] === null) {
if ($numPoints > 1) {
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
else {
$this->_canvas->reset();
}
$numPoints = 0;
} else {
$p0 = $dataset->_nearby(-2);
$p2 = $dataset->_nearby(0);
$p3 = $dataset->_nearby(1);
if (($p0) && ($p0['Y'] === null)) {
$p0 = false;
}
if (($p2) && ($p2['Y'] === null)) {
$p2 = false;
}
if (($p3) && ($p3['Y'] === null)) {
$p3 = false;
}
if ($p2) {
$cp = $this->_getControlPoints($p1, $p0, $p2, $p3);
$this->_canvas->addSpline(
$this->_mergeData(
$p1,
array(
'x' => $cp['X'],
'y' => $cp['Y'],
'p1x' => $cp['P1X'],
'p1y' => $cp['P1Y'],
'p2x' => $cp['P2X'],
'p2y' => $cp['P2Y']
)
)
);
} else {
$x = $this->_pointX($p1);
$y = $this->_pointY($p1);
$this->_canvas->addVertex(
$this->_mergeData(
$p1,
array('x' => $x, 'y' => $y)
)
);
}
$numPoints++;
}
}
if ($numPoints > 1) {
$this->_getLineStyle();
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
else {
$this->_canvas->reset();
}
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@@ -1,140 +1,142 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radar.php,v 1.9 2005/08/03 21:21:52 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
/**
* Include file Image/Graph/Plot/Smoothed/Bezier.php
*/
require_once 'Image/Graph/Plot/Smoothed/Bezier.php';
/**
* Smoothed radar chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @since Class available since Release 0.3.0dev2
*/
class Image_Graph_Plot_Smoothed_Radar extends Image_Graph_Plot_Smoothed_Bezier
{
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
if ($dataset->count() >= 3) {
$dataset->_reset();
$p1_ = $dataset->_next();
$p2_ = $dataset->_next();
$p3_ = $dataset->_next();
$plast_ = false;
if ($p3_) {
while ($p = $dataset->_next()) {
$plast_ = $p;
}
}
if ($plast_ === false) {
$plast_ = $p3_;
}
$dataset->_reset();
while ($p1 = $dataset->_next()) {
$p0 = $dataset->_nearby(-2);
$p2 = $dataset->_nearby(0);
$p3 = $dataset->_nearby(1);
if ($p0 === false) {
$p0 = $plast_;
}
if ($p2 === false) {
$p2 = $p1_;
$p3 = $p2_;
} elseif ($p3 === false) {
$p3 = $p1_;
}
$cp = $this->_getControlPoints($p1, $p0, $p2, $p3);
$this->_canvas->addSpline(
array(
'x' => $cp['X'],
'y' => $cp['Y'],
'p1x' => $cp['P1X'],
'p1y' => $cp['P1Y'],
'p2x' => $cp['P2X'],
'p2y' => $cp['P2Y']
)
);
$next2last = $p0;
$last = $p1;
}
$cp = $this->_getControlPoints($p1_, $plast_, $p2_, $p3_);
$this->_canvas->addSpline(
array(
'x' => $cp['X'],
'y' => $cp['Y'],
'p1x' => $cp['P1X'],
'p1y' => $cp['P1Y'],
'p2x' => $cp['P2X'],
'p2y' => $cp['P2Y']
)
);
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true));
}
}
unset($keys);
}
$this->_drawMarker();
$this->_canvas->endGroup($this->_title);
return parent::_done();
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radar.php,v 1.10 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
/**
* Include file Image/Graph/Plot/Smoothed/Bezier.php
*/
require_once 'Image/Graph/Plot/Smoothed/Bezier.php';
/**
* Smoothed radar chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @since Class available since Release 0.3.0dev2
*/
class Image_Graph_Plot_Smoothed_Radar extends Image_Graph_Plot_Smoothed_Bezier
{
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
if ($dataset->count() >= 3) {
$dataset->_reset();
$p1_ = $dataset->_next();
$p2_ = $dataset->_next();
$p3_ = $dataset->_next();
$plast_ = false;
if ($p3_) {
while ($p = $dataset->_next()) {
$plast_ = $p;
}
}
if ($plast_ === false) {
$plast_ = $p3_;
}
$dataset->_reset();
while ($p1 = $dataset->_next()) {
$p0 = $dataset->_nearby(-2);
$p2 = $dataset->_nearby(0);
$p3 = $dataset->_nearby(1);
if ($p0 === false) {
$p0 = $plast_;
}
if ($p2 === false) {
$p2 = $p1_;
$p3 = $p2_;
} elseif ($p3 === false) {
$p3 = $p1_;
}
$cp = $this->_getControlPoints($p1, $p0, $p2, $p3);
$this->_canvas->addSpline(
array(
'x' => $cp['X'],
'y' => $cp['Y'],
'p1x' => $cp['P1X'],
'p1y' => $cp['P1Y'],
'p2x' => $cp['P2X'],
'p2y' => $cp['P2Y']
)
);
$next2last = $p0;
$last = $p1;
}
$cp = $this->_getControlPoints($p1_, $plast_, $p2_, $p3_);
$this->_canvas->addSpline(
array(
'x' => $cp['X'],
'y' => $cp['Y'],
'p1x' => $cp['P1X'],
'p1y' => $cp['P1Y'],
'p2x' => $cp['P2X'],
'p2y' => $cp['P2Y']
)
);
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true));
}
}
unset($keys);
}
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup($this->_title);
return parent::_done();
}
}
?>

View File

@@ -1,198 +1,200 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Step.php,v 1.14 2005/10/05 20:51:21 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot/Bar.php
*/
require_once 'Image/Graph/Plot/Bar.php';
/**
* Step chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Step extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$dx = abs($x1 - $x0) / 3;
$dy = abs($y1 - $y0) / 3;
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y1));
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y0 + $dy));
$this->_canvas->addVertex(array('x' => $x0 + $dx, 'y' => $y0 + $dy));
$this->_canvas->addVertex(array('x' => $x0 + $dx, 'y' => $y0));
$this->_canvas->addVertex(array('x' => $x0 + 2*$dx, 'y' => $y0));
$this->_canvas->addVertex(array('x' => $x0 + 2*$dx, 'y' => $y0 + 2*$dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y0 + 2*$dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y1));
$this->_canvas->polygon(array('connect' => true));
}
/**
* PlotType [Constructor]
*
* A 'normal' step chart is 'stacked'
*
* @param Dataset $dataset The data set (value containter) to plot
* @param string $multiType The type of the plot
* @param string $title The title of the plot (used for legends,
* {@link Image_Graph_Legend})
*/
function Image_Graph_Plot_Step(& $dataset, $multiType = 'stacked', $title = '')
{
$multiType = strtolower($multiType);
if (($multiType != 'stacked') && ($multiType != 'stacked100pct')) {
$multiType = 'stacked';
}
parent::Image_Graph_Plot($dataset, $multiType, $title);
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (Image_Graph_Plot::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
if ($this->_parent->_horizontal) {
$width = $this->height() / ($this->_maximumX() + 2) / 2;
}
else {
$width = $this->width() / ($this->_maximumX() + 2) / 2;
}
reset($this->_dataset);
$key = key($this->_dataset);
$dataset =& $this->_dataset[$key];
$first = $dataset->first();
$last = $dataset->last();
$point = array ('X' => $first['X'], 'Y' => '#min_pos#');
$firstY = $this->_pointY($point) + ($this->_parent->_horizontal ? $width : 0);
$base[] = $firstY;
$firstX = $this->_pointX($point) - ($this->_parent->_horizontal ? 0 : $width);
$base[] = $firstX;
$point = array ('X' => $last['X'], 'Y' => '#min_pos#');
$base[] = $this->_pointY($point) - ($this->_parent->_horizontal ? $width : 0);
$base[] = $this->_pointX($point) + ($this->_parent->_horizontal ? 0 : $width);
$first = ($this->_parent->_horizontal ? $firstY : $firstX);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$polygon = array_reverse($base);
unset ($base);
$last = $first;
while ($point = $dataset->_next()) {
$x = $point['X'];
$p = $point;
if (!isset($current[$x])) {
$current[$x] = 0;
}
if ($this->_multiType == 'stacked100pct') {
$p['Y'] = 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x];
} else {
$p['Y'] += $current[$x];
}
$current[$x] += $point['Y'];
$point = $p;
if ($this->_parent->_horizontal) {
$x0 = $this->_pointX($point);
$y0 = $last;
$x1 = $this->_pointX($point);
$last = $y1 = $this->_pointY($point) - $width;
}
else {
$x0 = $last;
$y0 = $this->_pointY($point);
$last = $x1 = $this->_pointX($point) + $width;
$y1 = $this->_pointY($point);
}
$polygon[] = $x0; $base[] = $y0;
$polygon[] = $y0; $base[] = $x0;
$polygon[] = $x1; $base[] = $y1;
$polygon[] = $y1; $base[] = $x1;
}
while (list(, $x) = each($polygon)) {
list(, $y) = each($polygon);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true));
}
unset($keys);
$this->_drawMarker();
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Step.php,v 1.15 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plot/Bar.php
*/
require_once 'Image/Graph/Plot/Bar.php';
/**
* Step chart.
*
* @category Images
* @package Image_Graph
* @subpackage Plot
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plot_Step extends Image_Graph_Plot
{
/**
* Perform the actual drawing on the legend.
*
* @param int $x0 The top-left x-coordinate
* @param int $y0 The top-left y-coordinate
* @param int $x1 The bottom-right x-coordinate
* @param int $y1 The bottom-right y-coordinate
* @access private
*/
function _drawLegendSample($x0, $y0, $x1, $y1)
{
$dx = abs($x1 - $x0) / 3;
$dy = abs($y1 - $y0) / 3;
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y1));
$this->_canvas->addVertex(array('x' => $x0, 'y' => $y0 + $dy));
$this->_canvas->addVertex(array('x' => $x0 + $dx, 'y' => $y0 + $dy));
$this->_canvas->addVertex(array('x' => $x0 + $dx, 'y' => $y0));
$this->_canvas->addVertex(array('x' => $x0 + 2*$dx, 'y' => $y0));
$this->_canvas->addVertex(array('x' => $x0 + 2*$dx, 'y' => $y0 + 2*$dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y0 + 2*$dy));
$this->_canvas->addVertex(array('x' => $x1, 'y' => $y1));
$this->_canvas->polygon(array('connect' => true));
}
/**
* PlotType [Constructor]
*
* A 'normal' step chart is 'stacked'
*
* @param Dataset $dataset The data set (value containter) to plot
* @param string $multiType The type of the plot
* @param string $title The title of the plot (used for legends,
* {@link Image_Graph_Legend})
*/
function Image_Graph_Plot_Step(& $dataset, $multiType = 'stacked', $title = '')
{
$multiType = strtolower($multiType);
if (($multiType != 'stacked') && ($multiType != 'stacked100pct')) {
$multiType = 'stacked';
}
parent::Image_Graph_Plot($dataset, $multiType, $title);
}
/**
* Output the plot
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (Image_Graph_Plot::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
if ($this->_parent->_horizontal) {
$width = $this->height() / ($this->_maximumX() + 2) / 2;
}
else {
$width = $this->width() / ($this->_maximumX() + 2) / 2;
}
reset($this->_dataset);
$key = key($this->_dataset);
$dataset =& $this->_dataset[$key];
$first = $dataset->first();
$last = $dataset->last();
$point = array ('X' => $first['X'], 'Y' => '#min_pos#');
$firstY = $this->_pointY($point) + ($this->_parent->_horizontal ? $width : 0);
$base[] = $firstY;
$firstX = $this->_pointX($point) - ($this->_parent->_horizontal ? 0 : $width);
$base[] = $firstX;
$point = array ('X' => $last['X'], 'Y' => '#min_pos#');
$base[] = $this->_pointY($point) - ($this->_parent->_horizontal ? $width : 0);
$base[] = $this->_pointX($point) + ($this->_parent->_horizontal ? 0 : $width);
$first = ($this->_parent->_horizontal ? $firstY : $firstX);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
$dataset->_reset();
$polygon = array_reverse($base);
unset ($base);
$last = $first;
while ($point = $dataset->_next()) {
$x = $point['X'];
$p = $point;
if (!isset($current[$x])) {
$current[$x] = 0;
}
if ($this->_multiType == 'stacked100pct') {
$p['Y'] = 100 * ($current[$x] + $point['Y']) / $total['TOTAL_Y'][$x];
} else {
$p['Y'] += $current[$x];
}
$current[$x] += $point['Y'];
$point = $p;
if ($this->_parent->_horizontal) {
$x0 = $this->_pointX($point);
$y0 = $last;
$x1 = $this->_pointX($point);
$last = $y1 = $this->_pointY($point) - $width;
}
else {
$x0 = $last;
$y0 = $this->_pointY($point);
$last = $x1 = $this->_pointX($point) + $width;
$y1 = $this->_pointY($point);
}
$polygon[] = $x0; $base[] = $y0;
$polygon[] = $y0; $base[] = $x0;
$polygon[] = $x1; $base[] = $y1;
$polygon[] = $y1; $base[] = $x1;
}
while (list(, $x) = each($polygon)) {
list(, $y) = each($polygon);
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
$this->_getFillStyle($key);
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => true));
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}
?>