cvs: pear /Image_Graph/Graph Axis.php Dataset.php Driver.php Element.php Legend.php Plot.php Plotarea.php /Image_Graph/Graph/Axis Category.php
/Image_Graph/Graph/Axis/Marker Area.php Line.php /Image_Graph/Graph/Dataset Sequential.php Trivial.php /Image_Graph/Graph/Driver SVG.php
/Image_Graph/Graph/Figure Ellipse.php Polygon.php Rectangle.php /Image_Graph/Graph/Grid Bars.php Lines.php Polar.php /Image_Graph/Graph/Images
logo.png /Image_Graph/Graph/Images/Shadows b.png bl.png br.png r.png tr.png /Image_Graph/Graph/Layout Plotarea.php /Image_Graph/Graph/Plot Area.php
Band.php Bar.php BoxWhisker.php CandleStick.php Dot.php Impulse.php Line.php Pie.php Radar.php Step.php /Image_Graph/Graph/Plot/Smoothed Area.php
Line.php Radar.php /Image_Graph/docs ChangeLog

From: Date: Sun, 06 Feb 2005 22:14:51 +0000
Subject: cvs: pear /Image_Graph/Graph Axis.php Dataset.php Driver.php Element.php Legend.php Plot.php Plotarea.php /Image_Graph/Graph/Axis Category.php
/Image_Graph/Graph/Axis/Marker Area.php Line.php /Image_Graph/Graph/Dataset Sequential.php Trivial.php /Image_Graph/Graph/Driver SVG.php
/Image_Graph/Graph/Figure Ellipse.php Polygon.php Rectangle.php /Image_Graph/Graph/Grid Bars.php Lines.php Polar.php /Image_Graph/Graph/Images
logo.png /Image_Graph/Graph/Images/Shadows b.png bl.png br.png r.png tr.png /Image_Graph/Graph/Layout Plotarea.php /Image_Graph/Graph/Plot Area.php
Band.php Bar.php BoxWhisker.php CandleStick.php Dot.php Impulse.php Line.php Pie.php Radar.php Step.php /Image_Graph/Graph/Plot/Smoothed Area.php
Line.php Radar.php /Image_Graph/docs ChangeLog
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-29160@lists.php.net to get a copy of this message
nosey Sun Feb 6 17:14:51 2005 EDT Removed files: /pear/Image_Graph/Graph/Images/Shadows br.png r.png b.png bl.png tr.png /pear/Image_Graph/Graph/Images logo.png /pear/Image_Graph/Graph/Layout Plotarea.php Modified files: /pear/Image_Graph/Graph/Plot Dot.php CandleStick.php Area.php Step.php Pie.php Band.php Bar.php Line.php BoxWhisker.php Impulse.php Radar.php /pear/Image_Graph/Graph/Driver SVG.php /pear/Image_Graph/Graph Plotarea.php Driver.php Dataset.php Axis.php Element.php Plot.php Legend.php /pear/Image_Graph/Graph/Plot/Smoothed Radar.php Line.php Area.php /pear/Image_Graph/Graph/Grid Bars.php Lines.php Polar.php /pear/Image_Graph/Graph/Axis Category.php /pear/Image_Graph/Graph/Dataset Sequential.php Trivial.php /pear/Image_Graph/docs ChangeLog /pear/Image_Graph/Graph/Figure Polygon.php Rectangle.php Ellipse.php /pear/Image_Graph/Graph/Axis/Marker Line.php Area.php Log: Added possibility to use arrays of the type $data[$id] = array('x' => $x, 'y' => $y) for easy data addition to a dataset Added use of 'null' y-values in line plots (normal and smoothed) causing a break in the line (instead of dropping to zero) Added possibility to make one legend use multiple plotareas Added grouping to drivers (currently only fully supported by SVG driver) Implemented simple shadows (and removed shadow images from distribution) Fixed bug #3346 "double as data" Fixed a problem with normal multi-data bar charts not displaying expected bar width Fixed problem with legends when overlayed Fixed axis not displaying labels after resetting driver Fixed problem in SVG driver with vertical texts Changes which changes API causing minor BC breaks - Renamed Image_Graph_Plot_Bar::barWidth() to Image_Graph_Plot_Bar::setBarWidth() - Renamed Image_Graph_Plot_Bar::spacing() to Image_Graph_Plot_Bar::setSpacing() - Removed Image_Graph_Layout_Plotarea, it being completely obsolete with introduction of Image_Graph_Axis::setTitle() Performance optimizations

http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Dot.php?r1=1.6&r2=1.7&ty=u Index: pear/Image_Graph/Graph/Plot/Dot.php diff -u pear/Image_Graph/Graph/Plot/Dot.php:1.6 pear/Image_Graph/Graph/Plot/Dot.php:1.7 --- pear/Image_Graph/Graph/Plot/Dot.php:1.6 Sun Jan 2 08:00:45 2005 +++ pear/Image_Graph/Graph/Plot/Dot.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Dot.php,v 1.6 2005/01/02 13:00:45 nosey Exp $ + * @version $Id: Dot.php,v 1.7 2005/02/06 22:14:48 nosey Exp $ */ /** @@ -77,7 +77,13 @@ if (Image_Graph_Plot::_done() === false) { return false; } + + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); + $this->_drawMarker(); + + $this->_driver->endGroup(); + return true; } } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/CandleStick.php?r1=1.6&r2=1.7&ty=u Index: pear/Image_Graph/Graph/Plot/CandleStick.php diff -u pear/Image_Graph/Graph/Plot/CandleStick.php:1.6 pear/Image_Graph/Graph/Plot/CandleStick.php:1.7 --- pear/Image_Graph/Graph/Plot/CandleStick.php:1.6 Wed Jan 26 17:58:07 2005 +++ pear/Image_Graph/Graph/Plot/CandleStick.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: CandleStick.php,v 1.6 2005/01/26 22:58:07 nosey Exp $ + * @version $Id: CandleStick.php,v 1.7 2005/02/06 22:14:48 nosey Exp $ * @since 0.3.0dev2 */ @@ -101,6 +101,8 @@ return false; } + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); + if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } @@ -140,6 +142,9 @@ } unset($keys); $this->_drawMarker(); + + $this->_driver->endGroup($this->_title); + return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Area.php?r1=1.8&r2=1.9&ty=u Index: pear/Image_Graph/Graph/Plot/Area.php diff -u pear/Image_Graph/Graph/Plot/Area.php:1.8 pear/Image_Graph/Graph/Plot/Area.php:1.9 --- pear/Image_Graph/Graph/Plot/Area.php:1.8 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Area.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Area.php,v 1.8 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Area.php,v 1.9 2005/02/06 22:14:48 nosey Exp $ */ /** @@ -88,6 +88,7 @@ return false; } + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); if ($this->_multiType == 'stacked') { reset($this->_dataset); $key = key($this->_dataset); @@ -165,6 +166,7 @@ } unset($keys); $this->_drawMarker(); + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Step.php?r1=1.8&r2=1.9&ty=u Index: pear/Image_Graph/Graph/Plot/Step.php diff -u pear/Image_Graph/Graph/Plot/Step.php:1.8 pear/Image_Graph/Graph/Plot/Step.php:1.9 --- pear/Image_Graph/Graph/Plot/Step.php:1.8 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Step.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Step.php,v 1.8 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Step.php,v 1.9 2005/02/06 22:14:48 nosey Exp $ */ /** @@ -107,6 +107,8 @@ return false; } + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); + if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } @@ -172,6 +174,7 @@ } unset($keys); $this->_drawMarker(); + $this->_driver->endGroup(); return true; } } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Pie.php?r1=1.8&r2=1.9&ty=u Index: pear/Image_Graph/Graph/Plot/Pie.php diff -u pear/Image_Graph/Graph/Plot/Pie.php:1.8 pear/Image_Graph/Graph/Plot/Pie.php:1.9 --- pear/Image_Graph/Graph/Plot/Pie.php:1.8 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Pie.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Pie.php,v 1.8 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Pie.php,v 1.9 2005/02/06 22:14:48 nosey Exp $ */ /** @@ -287,6 +287,9 @@ function _legendSample(&$param) { if (is_array($this->_dataset)) { + + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); + $totals = $this->_getTotals(); $totals['CENTER_X'] = (int) (($this->_left + $this->_right) / 2); $totals['CENTER_Y'] = (int) (($this->_top + $this->_bottom) / 2); @@ -304,9 +307,11 @@ $caption = $point['X']; $this->_driver->setFont($param['font']); - $x2 = $param['x'] + 20 + $param['width'] + $this->_driver->textWidth($caption); + $width = 20 + $param['width'] + $this->_driver->textWidth($caption); + $param['maxwidth'] = max($param['maxwidth'], $width); + $x2 = $param['x'] + $width; $y2 = $param['y'] + $param['height']+5; - + if ((($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) && ($y2 > $param['bottom'])) { $param['y'] = $param['top']; $param['x'] = $x2; @@ -351,6 +356,7 @@ } } unset($keys); + $this->_driver->endGroup(); } } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Band.php?r1=1.6&r2=1.7&ty=u Index: pear/Image_Graph/Graph/Plot/Band.php diff -u pear/Image_Graph/Graph/Plot/Band.php:1.6 pear/Image_Graph/Graph/Plot/Band.php:1.7 --- pear/Image_Graph/Graph/Plot/Band.php:1.6 Wed Jan 26 17:58:07 2005 +++ pear/Image_Graph/Graph/Plot/Band.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Band.php,v 1.6 2005/01/26 22:58:07 nosey Exp $ + * @version $Id: Band.php,v 1.7 2005/02/06 22:14:48 nosey Exp $ * @since 0.3.0dev2 */ @@ -102,6 +102,7 @@ $current = array(); + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; @@ -138,6 +139,7 @@ } unset($keys); $this->_drawMarker(); + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Bar.php?r1=1.7&r2=1.8&ty=u Index: pear/Image_Graph/Graph/Plot/Bar.php diff -u pear/Image_Graph/Graph/Plot/Bar.php:1.7 pear/Image_Graph/Graph/Plot/Bar.php:1.8 --- pear/Image_Graph/Graph/Plot/Bar.php:1.7 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Bar.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Bar.php,v 1.7 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Bar.php,v 1.8 2005/02/06 22:14:48 nosey Exp $ */ /** @@ -84,7 +84,7 @@ * @param int $space The number of pixels between 2 bars, should be a * multipla of 2 (ie an even number) */ - function spacing($space) + function setSpacing($space) { $this->_space = (int) ($space / 2); } @@ -104,7 +104,7 @@ * @param string $width The width of any bar * @param string $unit The unit of the width */ - function barWidth($width, $unit = false) + function setBarWidth($width, $unit = false) { if ($width == 'auto') { $this->_width = $width; @@ -132,14 +132,16 @@ return false; } + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); + if ($this->_width == 'auto') { - $width = $this->_parent->_labelDistance(IMAGE_GRAPH_AXIS_X) / 2; + $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(); } @@ -154,8 +156,19 @@ $dataset->_reset(); while ($point = $dataset->_next()) { - $x1 = $this->_pointX($point) - $width + $this->_space; - $x2 = $this->_pointX($point) + $width - $this->_space; + $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')) @@ -204,8 +217,8 @@ } } else { if (count($this->_dataset) > 1) { - $w = $width / count($this->_dataset); - $x2 = ($x1 = ($x1 + $x2 - $width) / 2 + $number * $w) + $w; + $w = 2 * ($width - $this->_space) / count($this->_dataset); + $x2 = ($x1 = ($x1 + $x2) / 2 - ($width - $this->_space) + $number * $w) + $w; } $p0 = array('X' => $point['X'], 'Y' => 0); $p1 = $point; @@ -248,6 +261,8 @@ unset($keys); $this->_drawMarker(); + + $this->_driver->endGroup(); return true; } } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Line.php?r1=1.7&r2=1.8&ty=u Index: pear/Image_Graph/Graph/Plot/Line.php diff -u pear/Image_Graph/Graph/Plot/Line.php:1.7 pear/Image_Graph/Graph/Plot/Line.php:1.8 --- pear/Image_Graph/Graph/Plot/Line.php:1.7 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Line.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Line.php,v 1.7 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Line.php,v 1.8 2005/02/06 22:14:48 nosey Exp $ */ /** @@ -98,6 +98,8 @@ if (!is_array($this->_dataset)) { return false; } + + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); reset($this->_dataset); @@ -111,6 +113,7 @@ foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; $dataset->_reset(); + $numPoints = 0; while ($point = $dataset->_next()) { if (($this->_multiType == 'stacked') || ($this->_multiType == 'stacked100pct')) @@ -128,16 +131,28 @@ $point['Y'] = $py; } - $p2['X'] = $this->_pointX($point); - $p2['Y'] = $this->_pointY($point); - - $this->_driver->polygonAdd($p2['X'], $p2['Y']); + if ($point['Y'] === null) { + if ($numPoints > 1) { + $this->_getLineStyle($key); + $this->_driver->polygonEnd(false); + } + $numPoints = 0; + } else { + $p2['X'] = $this->_pointX($point); + $p2['Y'] = $this->_pointY($point); + + $this->_driver->polygonAdd($p2['X'], $p2['Y']); + $numPoints++; + } + } + if ($numPoints > 1) { + $this->_getLineStyle($key); + $this->_driver->polygonEnd(false); } - $this->_getLineStyle($key); - $this->_driver->polygonEnd(false); } unset($keys); $this->_drawMarker(); + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/BoxWhisker.php?r1=1.5&r2=1.6&ty=u Index: pear/Image_Graph/Graph/Plot/BoxWhisker.php diff -u pear/Image_Graph/Graph/Plot/BoxWhisker.php:1.5 pear/Image_Graph/Graph/Plot/BoxWhisker.php:1.6 --- pear/Image_Graph/Graph/Plot/BoxWhisker.php:1.5 Sun Jan 2 08:00:45 2005 +++ pear/Image_Graph/Graph/Plot/BoxWhisker.php Sun Feb 6 17:14:48 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: BoxWhisker.php,v 1.5 2005/01/02 13:00:45 nosey Exp $ + * @version $Id: BoxWhisker.php,v 1.6 2005/02/06 22:14:48 nosey Exp $ * @since 0.3.0dev2 */ @@ -137,6 +137,8 @@ return false; } + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); + if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); } @@ -180,6 +182,8 @@ } unset($keys); $this->_drawMarker(); + + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Impulse.php?r1=1.8&r2=1.9&ty=u Index: pear/Image_Graph/Graph/Plot/Impulse.php diff -u pear/Image_Graph/Graph/Plot/Impulse.php:1.8 pear/Image_Graph/Graph/Plot/Impulse.php:1.9 --- pear/Image_Graph/Graph/Plot/Impulse.php:1.8 Thu Jan 27 16:25:17 2005 +++ pear/Image_Graph/Graph/Plot/Impulse.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Impulse.php,v 1.8 2005/01/27 21:25:17 nosey Exp $ + * @version $Id: Impulse.php,v 1.9 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -79,6 +79,9 @@ if (!is_array($this->_dataset)) { return false; } + + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); + if ($this->_multiType == 'stacked100pct') { $total = $this->_getTotals(); @@ -182,6 +185,7 @@ } unset($keys); $this->_drawMarker(); + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Radar.php?r1=1.7&r2=1.8&ty=u Index: pear/Image_Graph/Graph/Plot/Radar.php diff -u pear/Image_Graph/Graph/Plot/Radar.php:1.7 pear/Image_Graph/Graph/Plot/Radar.php:1.8 --- pear/Image_Graph/Graph/Plot/Radar.php:1.7 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Radar.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Radar.php,v 1.7 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Radar.php,v 1.8 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -85,6 +85,7 @@ */ function _done() { + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) { $keys = array_keys($this->_dataset); foreach ($keys as $key) { @@ -107,6 +108,7 @@ } $this->_drawMarker(); + $this->_driver->endGroup(); return parent::_done(); } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Driver/SVG.php?r1=1.4&r2=1.5&ty=u Index: pear/Image_Graph/Graph/Driver/SVG.php diff -u pear/Image_Graph/Graph/Driver/SVG.php:1.4 pear/Image_Graph/Graph/Driver/SVG.php:1.5 --- pear/Image_Graph/Graph/Driver/SVG.php:1.4 Thu Jan 13 07:45:52 2005 +++ pear/Image_Graph/Graph/Driver/SVG.php Sun Feb 6 17:14:49 2005 @@ -32,7 +32,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: SVG.php,v 1.4 2005/01/13 12:45:52 nosey Exp $ + * @version $Id: SVG.php,v 1.5 2005/02/06 22:14:49 nosey Exp $ * @since 0.3.0dev2 */ @@ -76,6 +76,27 @@ var $_defs = ''; /** + * The current indention level + * @var string + * @access private + */ + var $_indent = ' '; + + /** + * A unieuq id counter + * @var int + * @access private + */ + var $_id = 1; + + /** + * The current group ids + * @var array + * @access private + */ + var $_groupIDs = array(); + + /** * Create the SVG driver. * * Parameters available: @@ -93,6 +114,26 @@ } /** + * Add a SVG "element" to the output + * + * @param string $element The element + * @access private + */ + function _addElement($element) { + $this->_elements .= $this->_indent . $element . "\n"; + } + + /** + * Add a SVG "define" to the output + * + * @param string $def The define + * @access private + */ + function _addDefine($def) { + $this->_defs .= ' ' . $def . "\n"; + } + + /** * Get the color index for the RGB color * * @param int $color The color @@ -145,6 +186,8 @@ $lineStyle = $this->_lineStyle; } + // TODO Linestyles (i.e. fx. dotted) does not work + if (($lineStyle != 'transparent') && ($lineStyle !== false)) { $result = 'stroke-width:' . $this->_thickness . ';'; $result .= 'stroke:' .$this->_color($lineStyle) . ';'; @@ -172,7 +215,7 @@ if (is_array($fillStyle)) { if ($fillStyle['type'] == 'gradient') { - $id = 'gradient_' . rand(0, 10000); + $id = 'gradient_' . ($this->_id++); $startColor = $this->_color($fillStyle['start']); $endColor = $this->_color($fillStyle['end']); $startOpacity = $this->_opacity($fillStyle['start']); @@ -190,9 +233,9 @@ case IMAGE_GRAPH_GRAD_VERTICAL: case IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED: $x1 = '0%'; - $y1 = '0%'; + $y1 = '100%'; $x2 = '0%'; - $y2 = '100%'; + $y2 = '0%'; break; case IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR: @@ -203,10 +246,10 @@ break; case IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR: - $x1 = '100%'; - $y1 = '0%'; - $x2 = '0%'; - $y2 = '100%'; + $x1 = '0%'; + $y1 = '100%'; + $x2 = '100%'; + $y2 = '0%'; break; case IMAGE_GRAPH_GRAD_RADIAL: @@ -220,46 +263,69 @@ } if ($fillStyle['direction'] == IMAGE_GRAPH_GRAD_RADIAL) { - $this->_defs .= - "\t" . '<radialGradient id="' . $id . '" cx="' . + $this->_addDefine( + '<radialGradient id="' . $id . '" cx="' . $cx .'" cy="' . $cy .'" r="' . $r .'" fx="' . - $fx .'" fy="' . $fy .'">' . "\n" . - "\t\t" . '<stop offset="0%" style="stop-color:' . + $fx .'" fy="' . $fy .'">' + ); + $this->_addDefine( + ' <stop offset="0%" style="stop-color:' . $startColor. ';' . ($startOpacity ? 'stop-opacity:' . - $startOpacity . ';' : ''). '"/>' . "\n" . - "\t\t" . '<stop offset="100%" style="stop-color:' . + $startOpacity . ';' : ''). '"/>' + ); + $this->_addDefine( + ' <stop offset="100%" style="stop-color:' . $endColor. ';' . ($endOpacity ? 'stop-opacity:' . - $endOpacity . ';' : ''). '"/>' . "\n" . - "\t" . '</radialGradient>' . "\n"; + $endOpacity . ';' : ''). '"/>' + ); + $this->_addDefine( + '</radialGradient>' + ); } elseif (($fillStyle['direction'] == IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED) || ($fillStyle['direction'] == IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED)) { - $this->_defs .= - "\t" . '<linearGradient id="' . $id . '" x1="' . + $this->_addDefine( + '<linearGradient id="' . $id . '" x1="' . $x1 .'" y1="' . $y1 .'" x2="' . $x2 .'" y2="' . - $y2 .'">' . "\n" . - "\t\t" . '<stop offset="0%" style="stop-color:' . + $y2 .'">' + ); + $this->_addDefine( + ' <stop offset="0%" style="stop-color:' . $startColor. ';' . ($startOpacity ? 'stop-opacity:' . - $startOpacity . ';' : ''). '"/>' . "\n" . - "\t\t" . '<stop offset="50%" style="stop-color:' . + $startOpacity . ';' : ''). '"/>' + ); + $this->_addDefine( + ' <stop offset="50%" style="stop-color:' . $endColor. ';' . ($endOpacity ? 'stop-opacity:' . - $endOpacity . ';' : ''). '"/>' . "\n" . - "\t\t" . '<stop offset="100%" style="stop-color:' . + $endOpacity . ';' : ''). '"/>' + ); + $this->_addDefine( + ' <stop offset="100%" style="stop-color:' . $startColor. ';' . ($startOpacity ? 'stop-opacity:' . - $startOpacity . ';' : ''). '"/>' . "\n" . - "\t" . '</linearGradient>' . "\n"; + $startOpacity . ';' : ''). '"/>' + ); + $this->_addDefine( + '</linearGradient>' + ); } else { - $this->_defs .= - "\t" . '<linearGradient id="' . $id . '" x1="' . + $this->_addDefine( + '<linearGradient id="' . $id . '" x1="' . $x1 .'" y1="' . $y1 .'" x2="' . $x2 .'" y2="' . - $y2 .'">' . "\n" . - "\t\t" . '<stop offset="0%" style="stop-color:' . + $y2 .'">' + ); + $this->_addDefine( + ' <stop offset="0%" style="stop-color:' . $startColor. ';' . ($startOpacity ? 'stop-opacity:' . - $startOpacity . ';' : ''). '"/>' . "\n" . - "\t\t" . '<stop offset="100%" style="stop-color:' . + $startOpacity . ';' : ''). '"/>' + ); + $this->_addDefine( + ' <stop offset="100%" style="stop-color:' . $endColor. ';' . ($endOpacity ? 'stop-opacity:' . - $endOpacity . ';' : ''). '"/>' . "\n" . - "\t" . '</linearGradient>' . "\n"; + $endOpacity . ';' : ''). '"/>' + ); + $this->_addDefine( + '</linearGradient>' + ); } return 'fill:url(#' . $id . ');'; @@ -328,14 +394,15 @@ { $style = $this->_getLineStyle($color) . $this->_getFillStyle('transparent'); if ($style != '') { - $this->_elements .= - '<line ' . - 'x1="' . round($x0) . '" ' . - 'y1="' . round($y0) . '" ' . - 'x2="' . round($x1) . '" ' . - 'y2="' . round($y1) . '" ' . - 'style="' . $style . '"' . - '/>' . "\n"; + $this->_addElement( + '<line ' . + 'x1="' . round($x0) . '" ' . + 'y1="' . round($y0) . '" ' . + 'x2="' . round($x1) . '" ' . + 'y2="' . round($y1) . '" ' . + 'style="' . $style . '"' . + '/>' + ); } parent::line($x0, $y0, $x1, $y1, $color); } @@ -363,13 +430,14 @@ $points .= round($point['X']) . ',' . round($point['Y']); } if ($connectEnds) { - $point .= ' Z'; + $points .= ' Z'; } - $this->_elements .= + $this->_addElement( '<path ' . 'd="' . $points . '" ' . 'style="' . $style . '"' . - '/>' . "\n"; + '/>' + ); parent::polygonEnd($connectEnds); } @@ -417,11 +485,12 @@ if ($connectEnds) { $point .= ' Z'; } - $this->_elements .= + $this->_addElement( '<path ' . 'd="' . $points . '" ' . 'style="' . $style . '"' . - '/>' . "\n"; + '/>' + ); parent::splineEnd($connectEnds); } @@ -440,14 +509,15 @@ { $style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor); if ($style != '') { - $this->_elements .= + $this->_addElement( '<rect ' . 'x="' . round($x0) . '" ' . 'y="' . round($y0) . '" ' . 'width="' . round(abs($x1 - $x0)) . '" ' . 'height="' . round(abs($y1 - $y0)) . '" ' . 'style="' . $style . '"' . - '/>' . "\n"; + '/>' + ); } parent::rectangle($x0, $y0, $x1, $y1, $fillColor, $lineColor); } @@ -466,14 +536,15 @@ { $style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor); if ($style != '') { - $this->_elements .= + $this->_addElement( '<ellipse ' . 'cx="' . round($x) . '" ' . 'cy="' . round($y) . '" ' . 'rx="' . round($rx) . '" ' . 'ry="' . round($ry) . '" ' . 'style="' . $style . '"' . - '/>' . "\n"; + '/>' + ); } parent::ellipse($x, $y, $rx, $ry, $fillColor, $lineColor); } @@ -501,7 +572,7 @@ $y1 = ($y + $ry * sin(deg2rad(min($v1, $v2) % 360))); $x2 = ($x + $rx * cos(deg2rad(max($v1, $v2) % 360))); $y2 = ($y + $ry * sin(deg2rad(max($v1, $v2) % 360))); - $this->_elements .= + $this->_addElement( '<path d="' . 'M' . round($x) . ',' . round($y) . ' ' . 'L' . round($x1) . ',' . round($y1) . ' ' . @@ -509,7 +580,8 @@ round($x2) . ',' . round($y2) . ' ' . 'z" ' . 'style="' . $style . '"' . - '/>' . "\n"; + '/>' + ); } } @@ -554,7 +626,6 @@ */ function write($x, $y, $text, $alignment, $color = false) { - // TODO Consider using text path all together for this $textHeight = $this->textHeight($text); $align = ''; @@ -590,14 +661,14 @@ $textColor = $this->_color($color); $textOpacity = $this->_opacity($color); - $this->_elements .= + $this->_addElement( '<text ' . 'x="' . round($x) . '" ' . 'y="' . round($y) . '" ' . - (isset($this->_font['angle']) && ($this->_font['angle'] > 0) ? +/* (isset($this->_font['angle']) && ($this->_font['angle'] > 0) ? 'rotate="' . $this->_font['angle'] . '" ' : '' - ) . + ) .*/ 'style="' . (isset($this->_font['file']) ? 'font-family:' . $this->_font['file'] . ';' : '') . @@ -607,7 +678,8 @@ '' ) . ';' . $align . '">' . str_replace('&', '&amp;', $text) . - '</text>' . "\n"; + '</text>' + ); parent::write($x, $y, $text, $alignment); } @@ -625,15 +697,46 @@ { // TODO Make images work in SVG $filename = 'file:///' . str_replace('\\', '/', $filename); - $this->_elements .= + $this->_addElement( '<image xlink:href="' . $filename . '" x="' . $x . '" y="' . $y . ($width ? '" width="' . $width : '') . ($height ? '" height="' . $height : '') . - '"/>'; + '"/>' + ); parent::overlayImage($x, $y, $filename, $width, $height); } /** + * Start a group. + * + * What this does, depends on the driver/format. + * + * @param string $name The name of the group + */ + function startGroup($name = false) + { + $name = strtolower(str_replace(' ', '_', $name)); + if (in_array($name, $this->_groupIDs)) { + $name .= $this->_id; + $this->_id++; + } + $this->_groupIDs[] = $name; + $this->_addElement('<g id="' . $name . '">'); + $this->_indent .= ' '; + } + + /** + * End the "current" group. + * + * What this does, depends on the driver/format. + */ + function endGroup() + { + $this->_indent = substr($this->_indent, 0, -4); + $this->_addElement('</g>'); + } + + /** * Output the result of the driver * * @param array $param Parameter array @@ -648,9 +751,9 @@ '<svg width="' . $this->_width . '" height="' . $this->_height . '" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' . "\n" . ($this->_defs ? - '<defs>' . "\n" . + ' <defs>' . "\n" . $this->_defs . - '</defs>' . "\n" : + ' </defs>' . "\n" : '' ) . $this->_elements . http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plotarea.php?r1=1.11&r2=1.12&ty=u Index: pear/Image_Graph/Graph/Plotarea.php diff -u pear/Image_Graph/Graph/Plotarea.php:1.11 pear/Image_Graph/Graph/Plotarea.php:1.12 --- pear/Image_Graph/Graph/Plotarea.php:1.11 Wed Feb 2 17:17:35 2005 +++ pear/Image_Graph/Graph/Plotarea.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Plotarea.php,v 1.11 2005/02/02 22:17:35 nosey Exp $ + * @version $Id: Plotarea.php,v 1.12 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -169,13 +169,23 @@ * * @param Image_Graph_Element $element The element to add * @param int $axis The axis to associate the element with, either - * IMAGE_GRAPH_AXIS_X, IMAGE_GRAPH_AXIS_Y or IMAGE_GRAPH_AXIS_Y_SECONDARY - * (defaults to IMAGE_GRAPH_AXIS_Y) + * IMAGE_GRAPH_AXIS_X, IMAGE_GRAPH_AXIS_Y, IMAGE_GRAPH_AXIS_Y_SECONDARY + * or the shorter string notations 'x', 'y' or 'ysec' (defaults to + * IMAGE_GRAPH_AXIS_Y) * @return Image_Graph_Element The added element * @see Image_Graph_Common::add() */ - function &add(& $element, $axis = IMAGE_GRAPH_AXIS_Y) + function &add(& $element, $axis = IMAGE_GRAPH_AXIS_Y) { + if ($axis == 'x') { + $axis = IMAGE_GRAPH_AXIS_X; + } + if ($axis == 'y') { + $axis = IMAGE_GRAPH_AXIS_Y; + } + if ($axis == 'ysec') { + $axis = IMAGE_GRAPH_AXIS_Y_SECONDARY; + } if (($axis == IMAGE_GRAPH_AXIS_Y_SECONDARY) && ($this->_axisYSecondary == null)) { @@ -433,7 +443,8 @@ /** * Return the minimum value of the specified axis * - * @param int $axis The axis to return the minimum value of + * @param int $axis The axis to return the minimum value of (see {$link + * Image_Graph_Plotarea::getAxis()}) * @return double The minimum value of the axis * @access private */ @@ -450,7 +461,8 @@ /** * Return the maximum value of the specified axis * - * @param int $axis The axis to return the maximum value of + * @param int $axis The axis to return the maximum value of(see {$link + * Image_Graph_Plotarea::getAxis()}) * @return double The maximum value of the axis * @access private */ @@ -473,15 +485,11 @@ */ function _labelDistance($axis) { - if (($axis == IMAGE_GRAPH_AXIS_Y_SECONDARY) && - ($this->_axisYSecondary != null)) - { - return $this->_axisYSecondary->_labelDistance(); - } elseif (($axis == IMAGE_GRAPH_AXIS_Y) && ($this->_axisY != null)) { - return $this->_axisY->_labelDistance(); - } elseif (($axis == IMAGE_GRAPH_AXIS_X) && ($this->_axisX != null)) { - return $this->_axisX->_labelDistance(); + $axis =& $this->getAxis($axis); + if ($axis !== null) { + return $axis->_labelDistance(); } + return false; } @@ -494,27 +502,35 @@ } /** - * Get axis - * - * @param int $Axis The axis to return + * Get axis. + * + * Possible values are IMAGE_GRAPH_AXIS_X, IMAGE_GRAPH_AXIS_Y, + * IMAGE_GRAPH_AXIS_Y_SECONDARY or a short hand notation using + * string identifiers: 'x', 'y', 'ysec' + * + * @param int $axis The axis to return * @return Image_Graph_Axis The axis */ - function &getAxis($Axis = IMAGE_GRAPH_AXIS_X) + function &getAxis($axis = IMAGE_GRAPH_AXIS_X) { - switch ($Axis) { + switch ($axis) { case IMAGE_GRAPH_AXIS_X: + case 'x': return $this->_axisX; break; case IMAGE_GRAPH_AXIS_Y: + case 'y': return $this->_axisY; break; case IMAGE_GRAPH_AXIS_Y_SECONDARY: + case 'ysec': return $this->_axisYSecondary; break; } + return null; } /** @@ -565,18 +581,21 @@ $intersectX = $this->_axisX->_getAxisIntersection(); $sizeX = $this->_axisX->_size(); $this->_axisX->_setCoords($left, $top, $right, $bottom); + $this->_axisX->_updateCoords(); } if ($this->_axisY !== null) { $intersectY = $this->_axisY->_getAxisIntersection(); $sizeY = $this->_axisY->_size(); $this->_axisY->_setCoords($left, $top, $right, $bottom); + $this->_axisY->_updateCoords(); } if ($this->_axisYSecondary !== null) { $intersectYsec = $this->_axisYSecondary->_getAxisIntersection(); $sizeYsec = $this->_axisYSecondary->_size(); $this->_axisYSecondary->_setCoords($left, $top, $right, $bottom); + $this->_axisYSecondary->_updateCoords(); } $axisCoordAdd = array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0); @@ -601,6 +620,7 @@ $pos, $bottom ); + $this->_axisY->_updateCoords(); } } @@ -622,6 +642,7 @@ $pos + $sizeY, $bottom ); + $this->_axisYSecondary->_updateCoords(); } } @@ -653,6 +674,7 @@ $right - $axisCoordAdd['right'], $pos + $sizeX ); + $this->_axisX->_updateCoords(); } if (($this->_axisX !== null) && @@ -668,6 +690,7 @@ $pos, false ); + $this->_axisY->_updateCoords(); } if ($this->_axisYSecondary !== null) { @@ -678,6 +701,7 @@ $pos + $sizeYsec, false ); + $this->_axisYSecondary->_updateCoords(); } } @@ -689,6 +713,7 @@ false, $bottom - $axisCoordAdd['bottom'] ); + $this->_axisY->_updateCoords(); } // adjust top and bottom of y-axis @@ -699,6 +724,7 @@ false, $bottom - $axisCoordAdd['bottom'] ); + $this->_axisYSecondary->_updateCoords(); } if ($this->_axisX !== null) { @@ -721,7 +747,7 @@ } Image_Graph_Element::_updateCoords(); - +/* if ($this->_axisX != null) { $this->_axisX->_updateCoords(); } @@ -730,7 +756,7 @@ } if ($this->_axisYSecondary != null) { $this->_axisYSecondary->_updateCoords(); - } + }*/ } /** @@ -741,6 +767,7 @@ */ function _done() { + $this->_driver->startGroup(get_class($this)); if ($this->_axisX != null) { $this->add($this->_axisX); } @@ -758,8 +785,9 @@ $this->_plotRight, $this->_plotBottom ); - - return parent::_done(); + $result = parent::_done(); + $this->_driver->endGroup(); + return $result; } } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Driver.php?r1=1.5&r2=1.6&ty=u Index: pear/Image_Graph/Graph/Driver.php diff -u pear/Image_Graph/Graph/Driver.php:1.5 pear/Image_Graph/Graph/Driver.php:1.6 --- pear/Image_Graph/Graph/Driver.php:1.5 Wed Feb 2 17:17:35 2005 +++ pear/Image_Graph/Graph/Driver.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Driver.php,v 1.5 2005/02/02 22:17:35 nosey Exp $ + * @version $Id: Driver.php,v 1.6 2005/02/06 22:14:49 nosey Exp $ * @since 0.3.0dev2 */ @@ -493,6 +493,26 @@ } /** + * Start a group. + * + * What this does, depends on the driver/format. + * + * @param string $name The name of the group + */ + function startGroup($name = false) + { + } + + /** + * End the "current" group. + * + * What this does, depends on the driver/format. + */ + function endGroup() + { + } + + /** * Output the result of the driver * * @param array $param Parameter array http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Dataset.php?r1=1.6&r2=1.7&ty=u Index: pear/Image_Graph/Graph/Dataset.php diff -u pear/Image_Graph/Graph/Dataset.php:1.6 pear/Image_Graph/Graph/Dataset.php:1.7 --- pear/Image_Graph/Graph/Dataset.php:1.6 Thu Jan 13 07:45:55 2005 +++ pear/Image_Graph/Graph/Dataset.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Dataset.php,v 1.6 2005/01/13 12:45:55 nosey Exp $ + * @version $Id: Dataset.php,v 1.7 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -120,24 +120,30 @@ */ function addPoint($x, $y = false, $ID = false) { - if (is_array($y)) { - $maxY = max($y); - $minY = min($y); - } else { - $maxY = $y; - $minY = $y; + if ($y !== null) { + if (is_array($y)) { + $maxY = max($y); + $minY = min($y); + } else { + $maxY = $y; + $minY = $y; + } } if ($this->_count) { $this->_minimumX = min($x, $this->_minimumX); $this->_maximumX = max($x, $this->_maximumX); - $this->_minimumY = min($minY, $this->_minimumY); - $this->_maximumY = max($maxY, $this->_maximumY); + if ($y !== null) { + $this->_minimumY = min($minY, $this->_minimumY); + $this->_maximumY = max($maxY, $this->_maximumY); + } } else { $this->_minimumX = $x; $this->_maximumX = $x; - $this->_minimumY = $minY; - $this->_maximumY = $maxY; + if ($y !== null) { + $this->_minimumY = $minY; + $this->_maximumY = $maxY; + } } $this->_count++; @@ -176,7 +182,7 @@ */ function _getPointY($x) { - return $y; + return $x; } /** http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Axis.php?r1=1.17&r2=1.18&ty=u Index: pear/Image_Graph/Graph/Axis.php diff -u pear/Image_Graph/Graph/Axis.php:1.17 pear/Image_Graph/Graph/Axis.php:1.18 --- pear/Image_Graph/Graph/Axis.php:1.17 Wed Feb 2 17:17:35 2005 +++ pear/Image_Graph/Graph/Axis.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Axis.php,v 1.17 2005/02/02 22:17:35 nosey Exp $ + * @version $Id: Axis.php,v 1.18 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -48,12 +48,15 @@ */ class Image_Graph_Axis extends Image_Graph_Plotarea_Element { + + // TODO There seems to be a problem with axis labels not printing after setting new driver (i.e. a reset) /** * The type of the axis, possible values are: * <ul> * <li>IMAGE_GRAPH_AXIS_X / IMAGE_GRAPH_AXIS_HORIZONTAL - * <li>IMAGE_GRAPH_AXIS_Y / IMAGE_GRAPH_AXIS_VERTICAL / IMAGE_GRAPH_AXIS_Y_SECONDARY + * <li>IMAGE_GRAPH_AXIS_Y / IMAGE_GRAPH_AXIS_VERTICAL / + * IMAGE_GRAPH_AXIS_Y_SECONDARY * </ul> * @var int * @access private @@ -235,6 +238,7 @@ */ function &Image_Graph_Axis($type = IMAGE_GRAPH_AXIS_X) { + parent::Image_Graph_Element(); $this->_type = $type; } @@ -417,7 +421,7 @@ function _labelDistance($level = 1) { $l1 = $this->_getNextLabel(false, $level); - $l2 = $this->_getNextLabel($l1, $level); + $l2 = $this->_getNextLabel($l1, $level);; return abs($this->_point($l2) - $this->_point($l1)); } @@ -962,6 +966,13 @@ */ function setAxisIntersection($intersection, $axis = 'default') { + if ($axis == 'x') { + $axis = IMAGE_GRAPH_AXIS_X; + } elseif ($axis = 'y') { + $axis = IMAGE_GRAPH_AXIS_Y; + } elseif ($axis = 'ysec') { + $axis = IMAGE_GRAPH_AXIS_Y_SECONDARY; + } $this->_intersect = array( 'value' => $intersection, 'axis' => $axis @@ -1005,6 +1016,17 @@ } /** + * Resets the elements + * + * @access private + */ + function _reset() + { + parent::_reset(); + $this->_labelText = array(); + } + + /** * Output an axis tick mark. * * @param int $value The value to output @@ -1257,12 +1279,15 @@ */ function _done() { + $this->_driver->startGroup(get_class($this)); + if (parent::_done() === false) { return false; } $this->_drawAxisLines(); + $this->_driver->startGroup(get_class($this) . '_ticks'); ksort($this->_labelOptions); foreach ($this->_labelOptions as $level => $labelOption) { $value = false; @@ -1276,6 +1301,7 @@ } } } + $this->_driver->endGroup(); $tickStart = -3; $tickEnd = 2; @@ -1323,6 +1349,7 @@ $this->_driver->polygonEnd(); } } + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Element.php?r1=1.12&r2=1.13&ty=u Index: pear/Image_Graph/Graph/Element.php diff -u pear/Image_Graph/Graph/Element.php:1.12 pear/Image_Graph/Graph/Element.php:1.13 --- pear/Image_Graph/Graph/Element.php:1.12 Wed Feb 2 17:17:35 2005 +++ pear/Image_Graph/Graph/Element.php Sun Feb 6 17:14:49 2005 @@ -30,7 +30,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Element.php,v 1.12 2005/02/02 22:17:35 nosey Exp $ + * @version $Id: Element.php,v 1.13 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -136,8 +136,8 @@ var $_defaultFontOptions = false; /** - * Enable shadows on the element - * @var bool + * Shadows options of the element + * @var mixed * @access private */ var $_shadow = false; @@ -150,16 +150,6 @@ var $_padding = 0; /** - * Resets the elements - * - * @access private - */ - function _reset() - { - parent::_reset(); - } - - /** * Sets the background fill style of the element * * @param Image_Graph_Fill $background The background @@ -181,9 +171,12 @@ /** * Shows shadow on the element */ - function showShadow() + function showShadow($color = 'black@0.2', $size = 5) { - $this->_shadow = true; + $this->_shadow = array( + 'color' => $color, + 'size' => $size + ); } /** @@ -505,7 +498,7 @@ $this->_left = min($left, $right); $this->_top = min($top, $bottom); $this->_right = max($left, $right); - $this->_bottom = max($top, $bottom); + $this->_bottom = max($top, $bottom); } /** @@ -652,7 +645,18 @@ */ function _displayShadow() { - // TODO Implement shadows + if (is_array($this->_shadow)) { + $this->_driver->startGroup(get_class($this) . '_shadow'); + $this->_driver->setFillColor($this->_shadow['color']); + $this->_driver->polygonAdd($this->_right + 1, $this->_top + $this->_shadow['size']); + $this->_driver->polygonAdd($this->_right + $this->_shadow['size'], $this->_top + $this->_shadow['size']); + $this->_driver->polygonAdd($this->_right + $this->_shadow['size'], $this->_bottom + $this->_shadow['size']); + $this->_driver->polygonAdd($this->_left + $this->_shadow['size'], $this->_bottom + $this->_shadow['size']); + $this->_driver->polygonAdd($this->_left + $this->_shadow['size'], $this->_bottom + 1); + $this->_driver->polygonAdd($this->_right + 1, $this->_bottom + 1); + $this->_driver->polygonEnd(); + $this->_driver->endGroup(); + } } /** @@ -695,6 +699,10 @@ } $result = parent::_done(); + + if ($this->_shadow !== false) { + $this->_displayShadow(); + } return $result; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot.php?r1=1.8&r2=1.9&ty=u Index: pear/Image_Graph/Graph/Plot.php diff -u pear/Image_Graph/Graph/Plot.php:1.8 pear/Image_Graph/Graph/Plot.php:1.9 --- pear/Image_Graph/Graph/Plot.php:1.8 Wed Feb 2 17:17:35 2005 +++ pear/Image_Graph/Graph/Plot.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Plot.php,v 1.8 2005/02/02 22:17:35 nosey Exp $ + * @version $Id: Plot.php,v 1.9 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -173,13 +173,19 @@ /** * Sets the Y axis to plot the data * - * @param int $axisY The Y axis (either IMAGE_GRAPH_AXIS_Y or - * IMAGE_GRAPH_AXIS_Y_SECONDARY (defaults to IMAGE_GRAPH_AXIS_Y)) + * @param int $axisY The Y axis (either IMAGE_GRAPH_AXIS_Y / 'y' or + * IMAGE_GRAPH_AXIS_Y_SECONDARY / 'ysec' (defaults to IMAGE_GRAPH_AXIS_Y)) * @access private */ function _setAxisY($axisY) { - $this->_axisY = $axisY; + if ($axisY == 'y') { + $this->_axisY = IMAGE_GRAPH_AXIS_Y; + } elseif ($axisY == 'ysec') { + $this->_axisY = IMAGE_GRAPH_AXIS_Y_SECONDARY; + } else { + $this->_axisY = $axisY; + } } /** @@ -347,8 +353,10 @@ * @access private */ function _drawMarker() - { + { if (($this->_marker) && (is_array($this->_dataset))) { + $this->_driver->startGroup(get_class($this) . '_marker'); + $totals = $this->_getTotals(); $totals['WIDTH'] = $this->width() / ($this->_maximumX() + 2) / 2; @@ -398,7 +406,8 @@ } } unset($keys); - } + $this->_driver->endGroup(); + } } /** @@ -676,7 +685,9 @@ $caption = ($dataset->_name ? $dataset->_name : $this->_title); $this->_driver->setFont($param['font']); - $x2 = $param['x'] + 20 + $param['width'] + $this->_driver->textWidth($caption); + $width = 20 + $param['width'] + $this->_driver->textWidth($caption); + $param['maxwidth'] = max($param['maxwidth'], $width); + $x2 = $param['x'] + $width; $y2 = $param['y'] + $param['height']+5; if ((($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) && ($y2 > $param['bottom'])) { @@ -725,7 +736,7 @@ } unset($keys); } - + } ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Legend.php?r1=1.7&r2=1.8&ty=u Index: pear/Image_Graph/Graph/Legend.php diff -u pear/Image_Graph/Graph/Legend.php:1.7 pear/Image_Graph/Graph/Legend.php:1.8 --- pear/Image_Graph/Graph/Legend.php:1.7 Wed Feb 2 17:17:35 2005 +++ pear/Image_Graph/Graph/Legend.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Legend.php,v 1.7 2005/02/02 22:17:35 nosey Exp $ + * @version $Id: Legend.php,v 1.8 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -63,11 +63,11 @@ var $_alignment = false; /** - * The plotarea to show the legend for - * @var Plotarea + * The plotarea(s) to show the legend for + * @var array * @access private */ - var $_plotarea = false; + var $_plotareas = array(); /** * Should markers be shown or not on this legend @@ -93,21 +93,50 @@ */ function _plotCount() { - if (is_a($this->_plotarea, 'Image_Graph_Plotarea')) { - $elements = $this->_plotarea->_elements; - - $maxSize = 0; - $count = 0; - $keys = array_keys($elements); - foreach ($keys as $key) { - $element =& $elements[$key]; - if (is_a($element, 'Image_Graph_Plot')) { - $count ++; + $count = 0; + $keys = array_keys($this->_plotareas); + foreach($keys as $key) { + $plotarea =& $this->_plotareas[$key]; + if (is_a($plotarea, 'Image_Graph_Plotarea')) { + $keys2 = array_keys($plotarea->_elements); + foreach ($keys2 as $key) { + $element =& $plotarea->_elements[$key]; + if (is_a($element, 'Image_Graph_Plot')) { + $count ++; + } } + unset($keys2); } - unset($keys); - return $count; } + unset($keys); + return $count; + } + + /** + * Get a default parameter array for legendSamples + * @param bool $simulate Whether the array should be used for simulation or + * not + * @return array Default parameter array + * @access private + */ + function _parameterArray($simulate = false) { + $param['left'] = $this->_left + $this->_padding; + $param['top'] = $this->_top + $this->_padding; + $param['right'] = $this->_right - $this->_padding; + $param['bottom'] = $this->_bottom - $this->_padding; + $param['align'] = $this->_alignment; + $param['x'] = $this->_left + $this->_padding; + $param['y'] = $this->_top + $this->_padding; + $param['width'] = 16; + $param['height'] = 16; + $param['show_marker'] = $this->_showMarker; + $param['maxwidth'] = 0; + $param['font'] = $this->_getFont(); + if ($simulate) { + $param['simulate'] = true; + } + + return $param; } /** @@ -120,11 +149,24 @@ { $parent = (is_object($this->_parent) ? get_class($this->_parent) : $this->_parent); - if (strtolower($parent) == 'Image_Graph_plotarea') { - $count = $this->_plotCount(); - return $count * 10 + // The height of 'plot'-legends - ($count -1) * $this->_padding + // The space between plots - 2 * $this->_padding; // Top and bottom padding + if (strtolower($parent) == 'image_graph_plotarea') { + $param = $this->_parameterArray(true); + $param['align'] = IMAGE_GRAPH_ALIGN_VERTICAL; + $param0 = $param; + $keys = array_keys($this->_plotareas); + foreach($keys as $key) { + $plotarea =& $this->_plotareas[$key]; + $keys2 = array_keys($plotarea->_elements); + foreach($keys2 as $key) { + $element =& $plotarea->_elements[$key]; + if (is_a($element, 'Image_Graph_Plot')) { + $element->_legendSample($param); + } + } + unset($keys2); + } + unset($keys); + return abs($param['y'] - $param0['y']) + 2*$this->_padding; } else { return parent::height(); } @@ -140,24 +182,23 @@ { $parent = (is_object($this->_parent) ? get_class($this->_parent) : $this->_parent); - if (strtolower($parent) == 'Image_Graph_plotarea') { - $elements = $this->_plotarea->_elements; - - $this->_driver->setFont($this->_getFont()); - - $maxSize = 0; - $keys = array_keys($elements); - foreach ($keys as $key) { - $element =& $elements[$key]; - if (is_a($element, 'Image_Graph_Plot')) { - $maxSize = max($maxSize, $this->_driver->textWidth($element->Title)); + if (strtolower($parent) == 'image_graph_plotarea') { + $param = $this->_parameterArray(true); + $param['align'] = IMAGE_GRAPH_ALIGN_VERTICAL; + $keys = array_keys($this->_plotareas); + foreach($keys as $key) { + $plotarea =& $this->_plotareas[$key]; + $keys2 = array_keys($plotarea->_elements); + foreach($keys2 as $key) { + $element =& $plotarea->_elements[$key]; + if (is_a($element, 'Image_Graph_Plot')) { + $element->_legendSample($param); + } } + unset($keys2); } unset($keys); - return $maxSize + // The width of the text - 10 + // Spacing between legend and text - 10 + // The width of the legend - 2 * $this->_padding; // Left and right padding + return $param['maxwidth']; } else { return parent::width(); } @@ -185,23 +226,26 @@ $parent = (is_object($this->_parent) ? get_class($this->_parent) : $this->_parent); if (strtolower($parent) == 'image_graph_plotarea') { + $w = $this->_width(); + $h = $this->_height(); + if ($this->_alignment === false) { $this->_alignment = IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_RIGHT; } if (($this->_alignment & IMAGE_GRAPH_ALIGN_BOTTOM) != 0) { - $y = $this->_parent->_fillBottom() - $this->_height() - 5 - 10; + $y = $this->_parent->_fillBottom() - $h; } else { $y = $this->_parent->_fillTop(); } if (($this->_alignment & IMAGE_GRAPH_ALIGN_LEFT) != 0) { - $x = $this->_parent->_fillLeft() + $this->_width() + 10; + $x = $this->_parent->_fillLeft(); } else { - $x = $this->_parent->_fillRight() - 5; + $x = $this->_parent->_fillRight() - $w; } - $this->_setCoords($x, $y, $x + $this->_width(), $y + $this->_height()); + $this->_setCoords($x, $y, $x + $w, $y + $h); } } @@ -212,7 +256,9 @@ */ function setPlotarea(& $plotarea) { - $this->_plotarea =& $plotarea; + if (is_a($plotarea, 'Image_Graph_Plotarea')) { + $this->_plotareas[] =& $plotarea; + } } /** @@ -225,8 +271,8 @@ function _setParent(& $parent) { parent::_setParent($parent); - if ($this->_plotarea === false) { - $this->_plotarea =& $parent; + if (count($this->_plotareas) == 0) { + $this->setPlotarea($parent); } } @@ -250,97 +296,87 @@ function _done() { - $shadow = $this->_shadow; - $this->_shadow = false; - if (Image_Graph_Element::_done() === false) { return false; } + + $this->_driver->startGroup(get_class($this)); - $param['left'] = $this->_left + $this->_padding; - $param['top'] = $this->_top + $this->_padding; - $param['right'] = $this->_right - $this->_padding; - $param['bottom'] = $this->_bottom - $this->_padding; - $param['align'] = $this->_alignment; - $param['x'] = $this->_left + $this->_padding; - $param['y'] = $this->_top + $this->_padding; - $param['width'] = 16; - $param['height'] = 16; - $param['show_marker'] = $this->_showMarker; + $param = $this->_parameterArray(); - $legend = 0; - if (is_a($this->_plotarea, 'Image_Graph_Plotarea')) { - $elements = $this->_plotarea->_elements; - - if (is_array($elements)) { - $param['font'] = $this->_getFont(); - - $parent = (is_object($this->_parent) ? - get_class($this->_parent) : - $this->_parent - ); - - if (strtolower($parent) == 'image_graph_plotarea') { - $this->_setCoords( - $this->_right - $this->_width(), - $this->_top, - $this->_right, - $this->_top + $this->_height() - ); - - $this->_getFillStyle(); - $this->_getLineStyle(); - $this->_driver->rectangle( - $this->_left, - $this->_top, - $this->_right, - $this->_bottom - ); - - $y = 0; - $keys = array_keys($elements); - foreach($keys as $key) { - $element =& $elements[$key]; - if (is_a($element, 'Image_Graph_Plot')) { - $element->_legendSample($param); - } - } - unset($keys); - } else { - $param0 = $param; - $param0['simulate'] = true; - $keys = array_keys($elements); - foreach($keys as $key) { - $element =& $elements[$key]; - if (is_a($element, 'Image_Graph_Plot')) { - $element->_legendSample($param0); - } + $parent = (is_object($this->_parent) ? + get_class($this->_parent) : + $this->_parent + ); + + if (strtolower($parent) == 'image_graph_plotarea') { + $this->_getFillStyle(); + $this->_getLineStyle(); + $this->_driver->rectangle( + $this->_left, + $this->_top, + $this->_right, + $this->_bottom + ); + + $param = $this->_parameterArray(); + + $keys = array_keys($this->_plotareas); + foreach($keys as $key) { + $plotarea =& $this->_plotareas[$key]; + $keys2 = array_keys($plotarea->_elements); + foreach($keys2 as $key) { + $element =& $plotarea->_elements[$key]; + if (is_a($element, 'Image_Graph_Plot')) { + $element->_legendSample($param); } - unset($keys); - if (($this->_alignment & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) { - if ($param0['x'] == $param['x']) { - $param['y'] = $param['y'] + ($this->_height() - ($param0['y'] - $param['y']))/2; - } - } else { - if ($param0['y'] == $param['y']) { - $param['x'] = $param['x'] + ($this->_width() - ($param0['x'] - $param['x']))/2; - } + } + unset($keys2); + } + unset($keys); + } else { + $param0 = $param; + $param0['simulate'] = true; + $keys = array_keys($this->_plotareas); + foreach($keys as $key) { + $plotarea =& $this->_plotareas[$key]; + $keys2 = array_keys($plotarea->_elements); + foreach($keys2 as $key) { + $element =& $plotarea->_elements[$key]; + if (is_a($element, 'Image_Graph_Plot')) { + $element->_legendSample($param0); } + } + unset($keys2); + } + unset($keys); + if (($this->_alignment & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) { + if ($param0['x'] == $param['x']) { + $param['y'] = $param['y'] + ($this->_height() - ($param0['y'] - $param['y']))/2; + } + } else { + if ($param0['y'] == $param['y']) { + $param['x'] = $param['x'] + ($this->_width() - ($param0['x'] - $param['x']))/2; + } + } - if ($plotCount = $this->_plotCount()) { - $legendWidth = $this->_width() / $plotCount; - } - $keys = array_keys($elements); - foreach ($keys as $key) { - $element =& $elements[$key]; - if (is_a($element, 'Image_Graph_Plot')) { - $element->_legendSample($param); - } + $keys = array_keys($this->_plotareas); + foreach($keys as $key) { + $plotarea =& $this->_plotareas[$key]; + $keys2 = array_keys($plotarea->_elements); + foreach($keys2 as $key) { + $element =& $plotarea->_elements[$key]; + if (is_a($element, 'Image_Graph_Plot')) { + $element->_legendSample($param); } - unset($keys); } + unset($keys2); } + unset($keys); } + + $this->_driver->endGroup(); + return true; } } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Smoothed/Radar.php?r1=1.5&r2=1.6&ty=u Index: pear/Image_Graph/Graph/Plot/Smoothed/Radar.php diff -u pear/Image_Graph/Graph/Plot/Smoothed/Radar.php:1.5 pear/Image_Graph/Graph/Plot/Smoothed/Radar.php:1.6 --- pear/Image_Graph/Graph/Plot/Smoothed/Radar.php:1.5 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Smoothed/Radar.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Radar.php,v 1.5 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Radar.php,v 1.6 2005/02/06 22:14:49 nosey Exp $ * @since 0.3.0dev2 */ @@ -61,6 +61,7 @@ */ function _done() { + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) { $keys = array_keys($this->_dataset); foreach ($keys as $key) { @@ -129,6 +130,7 @@ unset($keys); } $this->_drawMarker(); + $this->_driver->endGroup($this->_title); return parent::_done(); } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Smoothed/Line.php?r1=1.7&r2=1.8&ty=u Index: pear/Image_Graph/Graph/Plot/Smoothed/Line.php diff -u pear/Image_Graph/Graph/Plot/Smoothed/Line.php:1.7 pear/Image_Graph/Graph/Plot/Smoothed/Line.php:1.8 --- pear/Image_Graph/Graph/Plot/Smoothed/Line.php:1.7 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Smoothed/Line.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Line.php,v 1.7 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Line.php,v 1.8 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -94,35 +94,60 @@ return false; } + $this->_driver->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()) { - $p0 = $dataset->_nearby(-2); - $p2 = $dataset->_nearby(0); - $p3 = $dataset->_nearby(1); - if ($p2) { - $cp = $this->_getControlPoints($p1, $p0, $p2, $p3); - $this->_driver->splineAdd( - $cp['X'], - $cp['Y'], - $cp['P1X'], - $cp['P1Y'], - $cp['P2X'], - $cp['P2Y'] - ); + if ($p1['Y'] === null) { + if ($numPoints > 1) { + $this->_getLineStyle($key); + $this->_driver->splineEnd(false); + } + $numPoints = 0; } else { - $x = $this->_pointX($p1); - $y = $this->_pointY($p1); - $this->_driver->polygonAdd($x, $y); + $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->_driver->splineAdd( + $cp['X'], + $cp['Y'], + $cp['P1X'], + $cp['P1Y'], + $cp['P2X'], + $cp['P2Y'] + ); + } else { + $x = $this->_pointX($p1); + $y = $this->_pointY($p1); + $this->_driver->polygonAdd($x, $y); + } + $numPoints++; } } - $this->_getLineStyle(); - $this->_driver->splineEnd(false); + if ($numPoints > 1) { + $this->_getLineStyle(); + $this->_driver->splineEnd(false); + } } unset($keys); $this->_drawMarker(); + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plot/Smoothed/Area.php?r1=1.7&r2=1.8&ty=u Index: pear/Image_Graph/Graph/Plot/Smoothed/Area.php diff -u pear/Image_Graph/Graph/Plot/Smoothed/Area.php:1.7 pear/Image_Graph/Graph/Plot/Smoothed/Area.php:1.8 --- pear/Image_Graph/Graph/Plot/Smoothed/Area.php:1.7 Wed Feb 2 17:17:36 2005 +++ pear/Image_Graph/Graph/Plot/Smoothed/Area.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Area.php,v 1.7 2005/02/02 22:17:36 nosey Exp $ + * @version $Id: Area.php,v 1.8 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -85,6 +85,7 @@ return false; } + $this->_driver->startGroup(get_class($this) . '_' . $this->_title); $keys = array_keys($this->_dataset); foreach ($keys as $key) { $dataset =& $this->_dataset[$key]; @@ -131,6 +132,7 @@ } unset($keys); $this->_drawMarker(); + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Grid/Bars.php?r1=1.6&r2=1.7&ty=u Index: pear/Image_Graph/Graph/Grid/Bars.php diff -u pear/Image_Graph/Graph/Grid/Bars.php:1.6 pear/Image_Graph/Graph/Grid/Bars.php:1.7 --- pear/Image_Graph/Graph/Grid/Bars.php:1.6 Thu Jan 27 16:25:16 2005 +++ pear/Image_Graph/Graph/Grid/Bars.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Bars.php,v 1.6 2005/01/27 21:25:16 nosey Exp $ + * @version $Id: Bars.php,v 1.7 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -66,6 +66,8 @@ if (!$this->_primaryAxis) { return false; } + + $this->_driver->startGroup(get_class($this)); $i = 0; $value = false; @@ -103,6 +105,9 @@ $i = 1 - $i; $previousValue = $value; } + + $this->_driver->endGroup(); + return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Grid/Lines.php?r1=1.6&r2=1.7&ty=u Index: pear/Image_Graph/Graph/Grid/Lines.php diff -u pear/Image_Graph/Graph/Grid/Lines.php:1.6 pear/Image_Graph/Graph/Grid/Lines.php:1.7 --- pear/Image_Graph/Graph/Grid/Lines.php:1.6 Thu Jan 27 16:25:16 2005 +++ pear/Image_Graph/Graph/Grid/Lines.php Sun Feb 6 17:14:49 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Lines.php,v 1.6 2005/01/27 21:25:16 nosey Exp $ + * @version $Id: Lines.php,v 1.7 2005/02/06 22:14:49 nosey Exp $ */ /** @@ -76,6 +76,8 @@ return false; } + $this->_driver->startGroup(get_class($this)); + $value = false; $secondaryPoints = $this->_getSecondaryAxisPoints(); @@ -103,6 +105,9 @@ $this->_driver->line($x1, $y1, $x2, $y2); } } + + $this->_driver->endGroup(); + return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Grid/Polar.php?r1=1.6&r2=1.7&ty=u Index: pear/Image_Graph/Graph/Grid/Polar.php diff -u pear/Image_Graph/Graph/Grid/Polar.php:1.6 pear/Image_Graph/Graph/Grid/Polar.php:1.7 --- pear/Image_Graph/Graph/Grid/Polar.php:1.6 Thu Jan 27 16:25:16 2005 +++ pear/Image_Graph/Graph/Grid/Polar.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Polar.php,v 1.6 2005/01/27 21:25:16 nosey Exp $ + * @version $Id: Polar.php,v 1.7 2005/02/06 22:14:50 nosey Exp $ * @since 0.3.0dev2 */ @@ -78,6 +78,8 @@ return false; } + $this->_driver->startGroup(get_class($this)); + $value = false; $p0 = array ('X' => '#min#', 'Y' => '#min#'); @@ -100,6 +102,9 @@ $this->_getLineStyle(); $this->_driver->ellipse($cx, $cy, $r, $r); } + + $this->_driver->endGroup(); + return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Axis/Category.php?r1=1.7&r2=1.8&ty=u Index: pear/Image_Graph/Graph/Axis/Category.php diff -u pear/Image_Graph/Graph/Axis/Category.php:1.7 pear/Image_Graph/Graph/Axis/Category.php:1.8 --- pear/Image_Graph/Graph/Axis/Category.php:1.7 Wed Feb 2 17:17:35 2005 +++ pear/Image_Graph/Graph/Axis/Category.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Category.php,v 1.7 2005/02/02 22:17:35 nosey Exp $ + * @version $Id: Category.php,v 1.8 2005/02/06 22:14:50 nosey Exp $ */ /** @@ -378,17 +378,24 @@ */ function _done() { + $result = true; if (Image_Graph_Element::_done() === false) { - return false; + $result = false; } + $this->_driver->startGroup(get_class($this)); + + $this->_drawAxisLines(); + + $this->_driver->startGroup(get_class($this) . '_ticks'); $label = false; while (($label = $this->_getNextLabel($label)) !== false) { $this->_drawTick($label); } + $this->_driver->endGroup(); - $this->_drawAxisLines(); - return true; + $this->_driver->endGroup(); + return $result; } } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Dataset/Sequential.php?r1=1.4&r2=1.5&ty=u Index: pear/Image_Graph/Graph/Dataset/Sequential.php diff -u pear/Image_Graph/Graph/Dataset/Sequential.php:1.4 pear/Image_Graph/Graph/Dataset/Sequential.php:1.5 --- pear/Image_Graph/Graph/Dataset/Sequential.php:1.4 Sun Dec 19 17:17:36 2004 +++ pear/Image_Graph/Graph/Dataset/Sequential.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Sequential.php,v 1.4 2004/12/19 22:17:36 neufeind Exp $ + * @version $Id: Sequential.php,v 1.5 2005/02/06 22:14:50 nosey Exp $ */ /** @@ -42,9 +42,9 @@ /** * Sequential data set, simply add points (y) 1 by 1. * - * This is a single point dataset, all points are of the type (0, y1), (1, y2), - * (2, y3)... Where the X-value is implicitly incremented. This is useful for - * example for barcharts, where you could fx. use an {@link + * This is a single point (1D) dataset, all points are of the type (0, y1), (1, + * y2), (2, y3)... Where the X-value is implicitly incremented. This is useful + * for example for barcharts, where you could fx. use an {@link * Image_Graph_Dataset_Array} datapreprocessor to make sence of the x-values. * * @author Jesper Veggerby <pear.nosey@veggerby.dk> http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Dataset/Trivial.php?r1=1.5&r2=1.6&ty=u Index: pear/Image_Graph/Graph/Dataset/Trivial.php diff -u pear/Image_Graph/Graph/Dataset/Trivial.php:1.5 pear/Image_Graph/Graph/Dataset/Trivial.php:1.6 --- pear/Image_Graph/Graph/Dataset/Trivial.php:1.5 Thu Jan 13 07:45:55 2005 +++ pear/Image_Graph/Graph/Dataset/Trivial.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Trivial.php,v 1.5 2005/01/13 12:45:55 nosey Exp $ + * @version $Id: Trivial.php,v 1.6 2005/02/06 22:14:50 nosey Exp $ */ /** @@ -59,11 +59,15 @@ /** * Image_Graph_Dataset_Trivial [Constructor] * - * Pass an assictaed array ($data[$x] = $y) to the constructor for easy data - * addition. - * - * NB! If passing an array at this point, the x-values will also be used for - * ID tags, i.e. when using {@link Image_Graph_Fill_Array}. + * Pass an associated array ($data[$x] = $y) to the constructor for easy + * data addition. Alternatively (if multiple entries with same x value is + * required) pass an array with (x, y) values: $data[$id] = array('x' => $x, + * 'y' => $y); + * + * NB! If passing the 1st type array at this point, the x-values will also + * be used for ID tags, i.e. when using {@link Image_Graph_Fill_Array}. In + * the 2nd type the key/index of the "outermost" array will be the id tag + * (i.e. $id in the example) * * @param array $dataArray An associated array with values to the dataset */ @@ -75,8 +79,12 @@ reset($dataArray); $keys = array_keys($dataArray); foreach ($keys as $x) { - $y = $dataArray[$x]; - $this->addPoint($x, $y, $x); + $y =& $dataArray[$x]; + if ((is_array($y)) && (isset($y['x'])) && (isset($y['y']))) { + $this->addPoint($y['x'], $y['y'], $x); + } else { + $this->addPoint($x, $y, $x); + } } } } @@ -128,7 +136,7 @@ */ function _getPointX($x) { - if (isset ($this->_data[$x]['X'])) { + if (isset($this->_data[$x])) { return $this->_data[$x]['X']; } else { return false; @@ -145,7 +153,7 @@ */ function _getPointY($x) { - if (isset ($this->_data[$x]['Y'])) { + if (isset($this->_data[$x])) { return $this->_data[$x]['Y']; } else { return false; @@ -162,7 +170,7 @@ */ function _getPointID($x) { - if (isset ($this->_data[$x]['ID'])) { + if (isset($this->_data[$x])) { return $this->_data[$x]['ID']; } else { return false; @@ -207,7 +215,7 @@ $ID = $this->_getPointID($this->_posX); $this->_posX += $this->_stepX(); - return array ('X' => $x, 'Y' => $y, 'ID' => $ID); + return array('X' => $x, 'Y' => $y, 'ID' => $ID); } } http://cvs.php.net/diff.php/pear/Image_Graph/docs/ChangeLog?r1=1.13&r2=1.14&ty=u Index: pear/Image_Graph/docs/ChangeLog diff -u pear/Image_Graph/docs/ChangeLog:1.13 pear/Image_Graph/docs/ChangeLog:1.14 --- pear/Image_Graph/docs/ChangeLog:1.13 Wed Feb 2 17:17:37 2005 +++ pear/Image_Graph/docs/ChangeLog Sun Feb 6 17:14:50 2005 @@ -2,7 +2,20 @@ Image_Graph - Changelog ************************* Version 0.x.y-state [2005-xxx-yy] - Jesper Veggerby <pear.nosey@veggerby.dk> + * Added possibility to use arrays of the type $data[$id] = array('x' => $x, 'y' => $y) for easy data addition to a dataset + * Added use of 'null' y-values in line plots (normal and smoothed) causing a break in the line (instead of dropping to zero) + * Added possibility to make one legend use multiple plotareas + * Added grouping to drivers (currently only fully supported by SVG driver) + * Implemented simple shadows (and removed shadow images from distribution) * Fixed bug #3346 "double as data" + * Fixed a problem with normal multi-data bar charts not displaying expected bar width + * Fixed problem with legends when overlayed + * Fixed axis not displaying labels after resetting driver + * Fixed problem in SVG driver with vertical texts + * Changed which changes API causing minor BC breaks + - Renamed Image_Graph_Plot_Bar::barWidth() to Image_Graph_Plot_Bar::setBarWidth() + - Renamed Image_Graph_Plot_Bar::spacing() to Image_Graph_Plot_Bar::setSpacing() + - Removed Image_Graph_Layout_Plotarea, it being completely obsolete with introduction of Image_Graph_Axis::setTitle() * Performance optimizations Version 0.3.0-dev4 [2005-Jan-28] - Jesper Veggerby <pear.nosey@veggerby.dk> http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Figure/Polygon.php?r1=1.5&r2=1.6&ty=u Index: pear/Image_Graph/Graph/Figure/Polygon.php diff -u pear/Image_Graph/Graph/Figure/Polygon.php:1.5 pear/Image_Graph/Graph/Figure/Polygon.php:1.6 --- pear/Image_Graph/Graph/Figure/Polygon.php:1.5 Sun Jan 2 08:00:48 2005 +++ pear/Image_Graph/Graph/Figure/Polygon.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Polygon.php,v 1.5 2005/01/02 13:00:48 nosey Exp $ + * @version $Id: Polygon.php,v 1.6 2005/02/06 22:14:50 nosey Exp $ */ /** @@ -80,9 +80,13 @@ return false; } + $this->_driver->startGroup(get_class($this)); + $this->_getFillStyle(); $this->_getLineStyle(); $this->_driver->polygonEnd(); + + $this->_driver->endGroup(); return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Figure/Rectangle.php?r1=1.5&r2=1.6&ty=u Index: pear/Image_Graph/Graph/Figure/Rectangle.php diff -u pear/Image_Graph/Graph/Figure/Rectangle.php:1.5 pear/Image_Graph/Graph/Figure/Rectangle.php:1.6 --- pear/Image_Graph/Graph/Figure/Rectangle.php:1.5 Sun Jan 2 08:00:48 2005 +++ pear/Image_Graph/Graph/Figure/Rectangle.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Rectangle.php,v 1.5 2005/01/02 13:00:48 nosey Exp $ + * @version $Id: Rectangle.php,v 1.6 2005/02/06 22:14:50 nosey Exp $ */ /** @@ -75,6 +75,8 @@ return false; } + $this->_driver->startGroup(get_class($this)); + $this->_getFillStyle(); $this->_getLineStyle(); $this->_driver->rectangle( @@ -83,6 +85,9 @@ $this->_right, $this->_bottom ); + + $this->_driver->endGroup(); + return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Figure/Ellipse.php?r1=1.5&r2=1.6&ty=u Index: pear/Image_Graph/Graph/Figure/Ellipse.php diff -u pear/Image_Graph/Graph/Figure/Ellipse.php:1.5 pear/Image_Graph/Graph/Figure/Ellipse.php:1.6 --- pear/Image_Graph/Graph/Figure/Ellipse.php:1.5 Sun Jan 2 08:00:48 2005 +++ pear/Image_Graph/Graph/Figure/Ellipse.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Ellipse.php,v 1.5 2005/01/02 13:00:48 nosey Exp $ + * @version $Id: Ellipse.php,v 1.6 2005/02/06 22:14:50 nosey Exp $ */ /** @@ -74,6 +74,8 @@ if (parent::_done() === false) { return false; } + + $this->_driver->startGroup(get_class($this)); $this->_getFillStyle(); $this->_getLineStyle(); @@ -83,6 +85,9 @@ $this->width(), $this->height() ); + + $this->_driver->endGroup(); + return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Axis/Marker/Line.php?r1=1.5&r2=1.6&ty=u Index: pear/Image_Graph/Graph/Axis/Marker/Line.php diff -u pear/Image_Graph/Graph/Axis/Marker/Line.php:1.5 pear/Image_Graph/Graph/Axis/Marker/Line.php:1.6 --- pear/Image_Graph/Graph/Axis/Marker/Line.php:1.5 Sun Jan 2 08:00:48 2005 +++ pear/Image_Graph/Graph/Axis/Marker/Line.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Line.php,v 1.5 2005/01/02 13:00:48 nosey Exp $ + * @version $Id: Line.php,v 1.6 2005/02/06 22:14:50 nosey Exp $ */ /** @@ -83,6 +83,8 @@ if (!$this->_primaryAxis) { return false; } + + $this->_driver->startGroup(get_class($this)); $i = 0; @@ -111,6 +113,9 @@ $this->_getLineStyle(); $this->_driver->line($x1, $y1, $x2, $y2); } + + $this->_driver->endGroup(); + return true; } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Axis/Marker/Area.php?r1=1.7&r2=1.8&ty=u Index: pear/Image_Graph/Graph/Axis/Marker/Area.php diff -u pear/Image_Graph/Graph/Axis/Marker/Area.php:1.7 pear/Image_Graph/Graph/Axis/Marker/Area.php:1.8 --- pear/Image_Graph/Graph/Axis/Marker/Area.php:1.7 Wed Feb 2 17:17:37 2005 +++ pear/Image_Graph/Graph/Axis/Marker/Area.php Sun Feb 6 17:14:50 2005 @@ -31,7 +31,7 @@ * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License * @author Jesper Veggerby <pear.nosey@veggerby.dk> - * @version $Id: Area.php,v 1.7 2005/02/02 22:17:37 nosey Exp $ + * @version $Id: Area.php,v 1.8 2005/02/06 22:14:50 nosey Exp $ */ /** @@ -110,6 +110,8 @@ return false; } + $this->_driver->startGroup(get_class($this)); + $i = 0; $this->_lower = max($this->_primaryAxis->_getMinimum(), $this->_lower); @@ -143,6 +145,9 @@ $this->_getFillStyle(); $this->_driver->polygonEnd(); } + + $this->_driver->endGroup(); + return true; }
« previous php.pear.cvs (#29160) next »