cvs: pear /Image_Graph Graph.php
| From: | Stefan Neufeind | Date: | Wed, 18 Feb 2004 23:34:29 +0000 |
| Subject: | cvs: pear /Image_Graph Graph.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-16658@lists.php.net to get a copy of this message | ||
neufeind Wed Feb 18 18:34:29 2004 EDT
Modified files:
/pear/Image_Graph Graph.php
Log:
some fixes over which I just stumbled playing with test-scripts
http://cvs.php.net/diff.php/pear/Image_Graph/Graph.php?r1=1.30&r2=1.31&ty=u
Index: pear/Image_Graph/Graph.php
diff -u pear/Image_Graph/Graph.php:1.30 pear/Image_Graph/Graph.php:1.31
--- pear/Image_Graph/Graph.php:1.30 Wed Feb 18 17:01:08 2004
+++ pear/Image_Graph/Graph.php Wed Feb 18 18:34:29 2004
@@ -16,7 +16,7 @@
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+
//
-// $Id: Graph.php,v 1.30 2004/02/18 22:01:08 neufeind Exp $
+// $Id: Graph.php,v 1.31 2004/02/18 23:34:29 neufeind Exp $
/**
* Package for drawing graphs (bars, lines, ...)
@@ -430,62 +430,41 @@
{
for ($axisCount=0; $axisCount<=1; $axisCount++) {
$currAxis = "axisY".$axisCount;
- if (isset($this->{$currAxis}->_bounds['min'])) {
- $this->{$currAxis}->_boundsEffective['min'] =
$this->{$currAxis}->_bounds['min'];
- } else {
- foreach ($this->_dataElementsEffective as $currDataElement) {
- if ($currDataElement->_attributes['axisId'] == $axisCount) {
- // workaround - maybe solve this more elegant
- if (!is_array($currDataElement)) {
- $currDataElementTemp = array(& $currDataElement);
- } else {
- $currDataElementTemp = & $currDataElement;
- }
+ $bounds_min_auto = !isset($this->{$currAxis}->_bounds['min']);
+ $bounds_max_auto = !isset($this->{$currAxis}->_bounds['max']);
- if (!isset($this->{$currAxis}->_boundsEffective['min'])) {
- $this->{$currAxis}->_boundsEffective['min'] =
$currDataElementTemp[0]->_data[0];
- }
-
- foreach ($currDataElementTemp as $currDataElementEffective) {
- if (!is_null($currDataElementEffective->_stackingData)) {
- $dataTemp = & $currDataElementEffective->_stackingData[0];
- } else {
- $dataTemp = & $currDataElementEffective->_data;
- }
- foreach ($dataTemp as $currData) {
- if ($this->{$currAxis}->_boundsEffective['min']
> $currData) {
- $this->{$currAxis}->_boundsEffective['min'] =
$currData;
- }
- }
- }
- }
- }
+ if (!$bounds_min_auto) {
+ $this->{$currAxis}->_boundsEffective['min'] =
$this->{$currAxis}->_bounds['min'];
}
-
- if (isset($this->{$currAxis}->_bounds['max'])) {
+ if (!$bounds_max_auto) {
$this->{$currAxis}->_boundsEffective['max'] =
$this->{$currAxis}->_bounds['max'];
- } else {
+ }
+ if (($bounds_min_auto) || ($bounds_max_auto)) {
foreach ($this->_dataElementsEffective as $currDataElement) {
- if ($currDataElement->_attributes['axisId'] == $axisCount) {
- // workaround - maybe solve this more elegant
- if (!is_array($currDataElement)) {
- $currDataElementTemp = array(& $currDataElement);
- } else {
- $currDataElementTemp = & $currDataElement;
+ if (!is_array($currDataElement)) {
+ $currDataElementTemp = array($currDataElement);
+ } else {
+ $currDataElementTemp = $currDataElement;
+ }
+ if ($currDataElementTemp[0]->_attributes['axisId'] == $axisCount)
{
+ if ($bounds_min_auto &&
!isset($this->{$currAxis}->_boundsEffective['min'])) {
+ $this->{$currAxis}->_boundsEffective['min'] =
$currDataElementTemp[0]->_data[0];
}
-
- if (!isset($this->{$currAxis}->_boundsEffective['max'])) {
+ if ($bounds_max_auto &&
!isset($this->{$currAxis}->_boundsEffective['max'])) {
$this->{$currAxis}->_boundsEffective['max'] =
$currDataElementTemp[0]->_data[0];
}
foreach ($currDataElementTemp as $currDataElementEffective) {
if (!is_null($currDataElementEffective->_stackingData)) {
- $dataTemp = & $currDataElementEffective->_stackingData[1];
+ $dataTemp = & $currDataElementEffective->_stackingData[0];
} else {
$dataTemp = & $currDataElementEffective->_data;
}
foreach ($dataTemp as $currData) {
- if ($this->{$currAxis}->_boundsEffective['max']
< $currData) {
+ if ($bounds_min_auto &&
($this->{$currAxis}->_boundsEffective['min'] > $currData)) {
+ $this->{$currAxis}->_boundsEffective['min'] =
$currData;
+ }
+ if ($bounds_max_auto &&
($this->{$currAxis}->_boundsEffective['max'] < $currData)) {
$this->{$currAxis}->_boundsEffective['max'] =
$currData;
}
}
@@ -738,6 +717,8 @@
}
}
$borderspaceSum["bottom"] += $maxHeight;
+ $borderspaceSum["bottom"] +=
$this->axisX->_spacer['top'];
+ $borderspaceSum["bottom"] +=
$this->axisX->_spacer['bottom'];
}
if (($this->axisX->_tickStyle == IMAGE_GRAPH_TICKS_OUTSIDE) ||
@@ -765,11 +746,14 @@
$this->{$currAxis}->_internalTempValues['maxNumWidth'] =
$maxWidth;
if ($maxWidth > 0) {
- $maxWidth += 2; // add a few pixels between text and axis-major-ticks
if ($axisCount == 0) { // axis 0 (left axis)
- $borderspaceSum["left"] += $maxWidth;
+ $borderspaceSum["left"] += $maxWidth;
+ $borderspaceSum["left"] +=
$this->{$currAxis}->_spacer['left'];
+ $borderspaceSum["left"] +=
$this->{$currAxis}->_spacer['right'];
} else { // axis 1 (right axis)
- $borderspaceSum["right"] += $maxWidth;
+ $borderspaceSum["right"] += $maxWidth;
+ $borderspaceSum["right"] +=
$this->{$currAxis}->_spacer['left'];
+ $borderspaceSum["right"] +=
$this->{$currAxis}->_spacer['right'];
}
}
}
@@ -929,6 +913,7 @@
$textY += $this->axisX->_tickSize;
}
$textY += round($this->axisX->_internalTempValues['maxLabelHeight'] /
2);
+ $textY += $this->axisX->_spacer['top'];
$tempText->set('height',
$this->axisX->_internalTempValues['maxLabelHeight']);