cvs: pear /Image_Graph/Graph Axis.php Plotarea.php

From: Date: Wed, 16 Nov 2005 20:44:49 +0000
Subject: cvs: pear /Image_Graph/Graph Axis.php Plotarea.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36332@lists.php.net to get a copy of this message
nosey Wed Nov 16 15:44:49 2005 EDT Modified files: /pear/Image_Graph/Graph Plotarea.php Axis.php Log: * Added possibility to set color of axis ticks (thanks to bdondo from forum) * Modified axis arrows, so that an axis with all negative values, the arrow will be shown at the minimum value instead of maximum

http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Plotarea.php?r1=1.21&r2=1.22&ty=u Index: pear/Image_Graph/Graph/Plotarea.php diff -u pear/Image_Graph/Graph/Plotarea.php:1.21 pear/Image_Graph/Graph/Plotarea.php:1.22 --- pear/Image_Graph/Graph/Plotarea.php:1.21 Wed Oct 5 16:51:21 2005 +++ pear/Image_Graph/Graph/Plotarea.php Wed Nov 16 15:44:48 2005 @@ -24,7 +24,7 @@ * @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: Plotarea.php,v 1.21 2005/10/05 20:51:21 nosey Exp $ + * @version CVS: $Id: Plotarea.php,v 1.22 2005/11/16 20:44:48 nosey Exp $ * @link http://pear.php.net/package/Image_Graph */ @@ -616,19 +616,21 @@ * @access private */ function _updateCoords() - { + { if (is_array($this->_elements)) { $keys = array_keys($this->_elements); foreach ($keys as $key) { $element =& $this->_elements[$key]; - if (is_a($element, 'Image_Graph_Plot')) { + if (is_a($element, 'Image_Graph_Plot')) { if (((is_a($element, 'Image_Graph_Plot_Bar')) || (is_a($element, 'Image_Graph_Plot_Step')) || (is_a($element, 'Image_Graph_Plot_Dot')) || (is_a($element, 'Image_Graph_Plot_CandleStick')) || (is_a($element, 'Image_Graph_Plot_BoxWhisker')) || (is_a($element, 'Image_Graph_Plot_Impulse'))) && - ($this->_axisX != null)) + ($this->_axisX != null) && + (strtolower(get_class($this->_axisX)) != 'image_graph_axis') // do not push plot if x-axis is linear + ) { $this->_axisX->_pushValues(); } http://cvs.php.net/diff.php/pear/Image_Graph/Graph/Axis.php?r1=1.33&r2=1.34&ty=u Index: pear/Image_Graph/Graph/Axis.php diff -u pear/Image_Graph/Graph/Axis.php:1.33 pear/Image_Graph/Graph/Axis.php:1.34 --- pear/Image_Graph/Graph/Axis.php:1.33 Wed Oct 5 16:51:22 2005 +++ pear/Image_Graph/Graph/Axis.php Wed Nov 16 15:44:48 2005 @@ -24,7 +24,7 @@ * @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: Axis.php,v 1.33 2005/10/05 20:51:22 nosey Exp $ + * @version CVS: $Id: Axis.php,v 1.34 2005/11/16 20:44:48 nosey Exp $ * @link http://pear.php.net/package/Image_Graph */ @@ -182,12 +182,16 @@ 1 => array( 'interval' => 1, 'type' => 'auto', - 'tick' => array('start' => -2, 'end' => 2), + 'tick' => array( + 'start' => -2, + 'end' => 2, + 'color' => false // default color + ), 'showtext' => true, 'showoffset' => false, 'font' => array(), 'offset' => 0, - 'position' => 'outside' + 'position' => 'outside', ) ); @@ -628,7 +632,7 @@ if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) || (($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose))) { - if ($this->_invert) { + if ($this->_invert) { return max($this->_left, $this->_right - $this->_axisPadding['high'] - $this->_delta * $this->_value($value)); } else { return min($this->_right, $this->_left + $this->_axisPadding['low'] + $this->_delta * $this->_value($value)); @@ -702,9 +706,9 @@ if ($this->_axisValueSpan == 0) { $this->_delta = false; } elseif ($this->_type == IMAGE_GRAPH_AXIS_X) { - $this->_delta = (($this->_transpose ? $this->height() : $this->width()) - ($this->_axisPadding['low'] + $this->_axisPadding['high'])) / $this->_axisValueSpan; + $this->_delta = (($this->_transpose ? $this->height() : $this->width()) - ($this->_axisPadding['low'] + $this->_axisPadding['high'])) / ($this->_axisValueSpan + ($this->_pushValues ? 1 : 0)); } else { - $this->_delta = (($this->_transpose ? $this->width() : $this->height()) - ($this->_axisPadding['low'] + $this->_axisPadding['high'])) / $this->_axisValueSpan; + $this->_delta = (($this->_transpose ? $this->width() : $this->height()) - ($this->_axisPadding['low'] + $this->_axisPadding['high'])) / ($this->_axisValueSpan + ($this->_pushValues ? 1 : 0)); } } @@ -1276,15 +1280,40 @@ } } + $tickColor = false; if (isset($this->_labelOptions[$level]['tick'])) { - $tickStart = $this->_labelOptions[$level]['tick']['start']; - $tickEnd = $this->_labelOptions[$level]['tick']['end']; - } else { + if (isset($this->_labelOptions[$level]['tick']['start'])) { + $tickStart = $this->_labelOptions[$level]['tick']['start']; + } else { + $tickStart = false; + } + + if (isset($this->_labelOptions[$level]['tick']['end'])) { + $tickEnd = $this->_labelOptions[$level]['tick']['end']; + } else { + $tickEnd = false; + } + + if ((isset($this->_labelOptions[$level]['tick']['color'])) && ($this->_labelOptions[$level]['tick']['color'] !== false)) { + $tickColor = $this->_labelOptions[$level]['tick']['color']; + } + } + + if ($tickStart === false) { $tickStart = -2; + } + + if ($tickEnd === false) { $tickEnd = 2; } - $this->_getLineStyle(); + if ($tickColor !== false) { + $this->_canvas->setLineColor($tickColor); + } + else { + $this->_getLineStyle(); + } + if ($this->_type == IMAGE_GRAPH_AXIS_Y) { if ($tickStart === 'auto') { $tickStart = -$offset; @@ -1389,8 +1418,14 @@ } if ($this->_showArrow) { - $data['end1'] = 'arrow2'; - $data['size1'] = 7; + if ($this->_getMaximum() <= 0) { + $data['end0'] = 'arrow2'; + $data['size0'] = 7; + } + else { + $data['end1'] = 'arrow2'; + $data['size1'] = 7; + } } $this->_canvas->line($data); @@ -1427,8 +1462,14 @@ ); } if ($this->_showArrow) { - $data['end1'] = 'arrow2'; - $data['size1'] = 7; + if ($this->_getMaximum() <= 0) { + $data['end0'] = 'arrow2'; + $data['size0'] = 7; + } + else { + $data['end1'] = 'arrow2'; + $data['size1'] = 7; + } } $this->_canvas->line($data); @@ -1464,8 +1505,14 @@ ); } if ($this->_showArrow) { - $data['end1'] = 'arrow2'; - $data['size1'] = 7; + if ($this->_getMaximum() <= 0) { + $data['end0'] = 'arrow2'; + $data['size0'] = 7; + } + else { + $data['end1'] = 'arrow2'; + $data['size1'] = 7; + } } $this->_canvas->line($data);
« previous php.pear.cvs (#36332) next »