summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-07-11 11:38:12 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-07-11 11:38:12 +0000
commit724f713334360344e6c121f76e66a88e5301ea4e (patch)
tree4632925659ebb68d90cf9bdc5ccb80de972b82e4 /src
parent0e0f42c5fec14738ebd62abdb4b641083a580bf7 (diff)
downloadzetacomponents-graph-724f713334360344e6c121f76e66a88e5301ea4e.zip
zetacomponents-graph-724f713334360344e6c121f76e66a88e5301ea4e.tar.gz
- Fixed boundings calculation for axis and data
Diffstat (limited to 'src')
-rw-r--r--src/charts/line.php7
-rw-r--r--src/element/axis.php40
-rw-r--r--src/element/legend.php2
-rw-r--r--src/renderer/2d.php5
4 files changed, 36 insertions, 18 deletions
diff --git a/src/charts/line.php b/src/charts/line.php
index 8983f4a..321508d 100644
--- a/src/charts/line.php
+++ b/src/charts/line.php
@@ -71,6 +71,13 @@ class ezcGraphLineChart extends ezcGraphChart
protected function renderData( $renderer, $boundings )
{
+ // Apply axis space
+ $boundings->x0 += ( $boundings->x1 - $boundings->x0 ) * $this->xAxis->axisSpace;
+ $boundings->x1 -= ( $boundings->x1 - $boundings->x0 ) * $this->xAxis->axisSpace;
+
+ $boundings->y0 += ( $boundings->y1 - $boundings->y0 ) * $this->yAxis->axisSpace;
+ $boundings->y1 -= ( $boundings->y1 - $boundings->y0 ) * $this->yAxis->axisSpace;
+
foreach ( $this->data as $data )
{
// Determine fill color for dataset
diff --git a/src/element/axis.php b/src/element/axis.php
index 4b61bd7..ac867a7 100644
--- a/src/element/axis.php
+++ b/src/element/axis.php
@@ -249,42 +249,50 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
{
case ezcGraph::TOP:
$start = new ezcGraphCoordinate(
- $this->nullPosition,
- $boundings->y0
+ ( $boundings->x1 - $boundings->x0 ) * $this->axisSpace +
+ $this->nullPosition * ( $boundings->x1 - $boundings->x0 ) * ( 1 - 2 * $this->axisSpace ),
+ 0
);
$end = new ezcGraphCoordinate(
- $this->nullPosition,
- $boundings->y1
+ ( $boundings->x1 - $boundings->x0 ) * $this->axisSpace +
+ $this->nullPosition * ( $boundings->x1 - $boundings->x0 ) * ( 1 - 2 * $this->axisSpace ),
+ $boundings->y1 - $boundings->y0
);
break;
case ezcGraph::BOTTOM:
$start = new ezcGraphCoordinate(
- (int) $this->nullPosition,
- (int) $boundings->y1
+ ( $boundings->x1 - $boundings->x0 ) * $this->axisSpace +
+ $this->nullPosition * ( $boundings->x1 - $boundings->x0 ) * ( 1 - 2 * $this->axisSpace ),
+ $boundings->y1 - $boundings->y0
);
$end = new ezcGraphCoordinate(
- (int) $this->nullPosition,
- (int) $boundings->y0
+ ( $boundings->x1 - $boundings->x0 ) * $this->axisSpace +
+ $this->nullPosition * ( $boundings->x1 - $boundings->x0 ) * ( 1 - 2 * $this->axisSpace ),
+ 0
);
break;
case ezcGraph::LEFT:
$start = new ezcGraphCoordinate(
- (int) $boundings->x0,
- (int) $this->nullPosition
+ 0,
+ ( $boundings->y1 - $boundings->y0 ) * $this->axisSpace +
+ $this->nullPosition * ( $boundings->y1 - $boundings->y0 ) * ( 1 - 2 * $this->axisSpace )
);
$end = new ezcGraphCoordinate(
- (int) $boundings->x1,
- (int) $this->nullPosition
+ $boundings->x1 - $boundings->x0,
+ ( $boundings->y1 - $boundings->y0 ) * $this->axisSpace +
+ $this->nullPosition * ( $boundings->y1 - $boundings->y0 ) * ( 1 - 2 * $this->axisSpace )
);
break;
case ezcGraph::RIGHT:
$start = new ezcGraphCoordinate(
- (int) $boundings->x1,
- (int) $this->nullPosition
+ $boundings->x1 - $boundings->x0,
+ ( $boundings->y1 - $boundings->y0 ) * $this->axisSpace +
+ $this->nullPosition * ( $boundings->y1 - $boundings->y0 ) * ( 1 - 2 * $this->axisSpace )
);
$end = new ezcGraphCoordinate(
- (int) $boundings->x0,
- (int) $this->nullPosition
+ 0,
+ ( $boundings->y1 - $boundings->y0 ) * $this->axisSpace +
+ $this->nullPosition * ( $boundings->y1 - $boundings->y0 ) * ( 1 - 2 * $this->axisSpace )
);
break;
}
diff --git a/src/element/legend.php b/src/element/legend.php
index ed110f4..1d8fe9e 100644
--- a/src/element/legend.php
+++ b/src/element/legend.php
@@ -227,8 +227,6 @@ class ezcGraphChartElementLegend extends ezcGraphChartElement
$type
);
- var_dump( $this->boundings, $boundings );
-
return $boundings;
}
}
diff --git a/src/renderer/2d.php b/src/renderer/2d.php
index 0ac0e91..83ed126 100644
--- a/src/renderer/2d.php
+++ b/src/renderer/2d.php
@@ -630,6 +630,11 @@ class ezcGraphRenderer2d extends ezcGraphRenderer
ezcGraphChartElementAxis $axis,
ezcGraphAxisLabelRenderer $labelClass = null )
{
+ $start->x += $boundings->x0;
+ $start->y += $boundings->y0;
+ $end->x += $boundings->x0;
+ $end->y += $boundings->y0;
+
// Determine normalized direction
$direction = new ezcGraphCoordinate(
$start->x - $end->x,
OpenPOWER on IntegriCloud