summaryrefslogtreecommitdiffstats
path: root/src/renderer
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2008-06-18 10:50:57 +0000
committerKore Nordmann <github@kore-nordmann.de>2008-06-18 10:50:57 +0000
commit5632023751fcbd0c8fecd0d665ebf918b3a798b6 (patch)
treea9d0c25a51955e8b35da5df8a44b4d4c536fbdb0 /src/renderer
parent3c878c9db2814028445e85b3f8204151d4e1e1fd (diff)
downloadzetacomponents-graph-5632023751fcbd0c8fecd0d665ebf918b3a798b6.zip
zetacomponents-graph-5632023751fcbd0c8fecd0d665ebf918b3a798b6.tar.gz
- Implemented feature #13102: Axes not extending beyond zero in line charts
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/2d.php37
-rw-r--r--src/renderer/3d.php39
2 files changed, 69 insertions, 7 deletions
diff --git a/src/renderer/2d.php b/src/renderer/2d.php
index 1a5db3d..1ca9369 100644
--- a/src/renderer/2d.php
+++ b/src/renderer/2d.php
@@ -1304,6 +1304,37 @@ class ezcGraphRenderer2d
$end->x += $boundings->x0;
$end->y += $boundings->y0;
+ // Shorten drawn axis, if requested.
+ if ( ( $this->options->shortAxis === true ) &&
+ ( ( $axis->position === ezcGraph::TOP ) ||
+ ( $axis->position === ezcGraph::BOTTOM ) ) )
+ {
+ $axisStart = clone $start;
+ $axisEnd = clone $end;
+
+ $axisStart->y += $boundings->height * $axis->axisSpace *
+ ( $axis->position === ezcGraph::TOP ? 1 : -1 );
+ $axisEnd->y -= $boundings->height * $axis->axisSpace *
+ ( $axis->position === ezcGraph::TOP ? 1 : -1 );
+ }
+ elseif ( ( $this->options->shortAxis === true ) &&
+ ( ( $axis->position === ezcGraph::LEFT ) ||
+ ( $axis->position === ezcGraph::RIGHT ) ) )
+ {
+ $axisStart = clone $start;
+ $axisEnd = clone $end;
+
+ $axisStart->x += $boundings->width * $axis->axisSpace *
+ ( $axis->position === ezcGraph::LEFT ? 1 : -1 );
+ $axisEnd->x -= $boundings->width * $axis->axisSpace *
+ ( $axis->position === ezcGraph::LEFT ? 1 : -1 );
+ }
+ else
+ {
+ $axisStart = $start;
+ $axisEnd = $end;
+ }
+
// Determine normalized direction
$direction = new ezcGraphVector(
$start->x - $end->x,
@@ -1313,15 +1344,15 @@ class ezcGraphRenderer2d
// Draw axis
$this->driver->drawLine(
- $start,
- $end,
+ $axisStart,
+ $axisEnd,
$axis->border,
1
);
// Draw small arrowhead
$this->drawAxisArrowHead(
- $end,
+ $axisEnd,
$direction,
max(
$axis->minArrowHeadSize,
diff --git a/src/renderer/3d.php b/src/renderer/3d.php
index b860a1b..d3fe9de 100644
--- a/src/renderer/3d.php
+++ b/src/renderer/3d.php
@@ -2062,11 +2062,42 @@ class ezcGraphRenderer3d
$end->x += $boundings->x0;
$end->y += $boundings->y0;
+ // Shorten drawn axis, if requested.
+ if ( ( $this->options->shortAxis === true ) &&
+ ( ( $axis->position === ezcGraph::TOP ) ||
+ ( $axis->position === ezcGraph::BOTTOM ) ) )
+ {
+ $axisStart = clone $start;
+ $axisEnd = clone $end;
+
+ $axisStart->y += $boundings->height * $axis->axisSpace *
+ ( $axis->position === ezcGraph::TOP ? 1 : -1 );
+ $axisEnd->y -= $boundings->height * $axis->axisSpace *
+ ( $axis->position === ezcGraph::TOP ? 1 : -1 );
+ }
+ elseif ( ( $this->options->shortAxis === true ) &&
+ ( ( $axis->position === ezcGraph::LEFT ) ||
+ ( $axis->position === ezcGraph::RIGHT ) ) )
+ {
+ $axisStart = clone $start;
+ $axisEnd = clone $end;
+
+ $axisStart->x += $boundings->width * $axis->axisSpace *
+ ( $axis->position === ezcGraph::LEFT ? 1 : -1 );
+ $axisEnd->x -= $boundings->width * $axis->axisSpace *
+ ( $axis->position === ezcGraph::LEFT ? 1 : -1 );
+ }
+ else
+ {
+ $axisStart = $start;
+ $axisEnd = $end;
+ }
+
$axisPolygonCoordinates = array(
- $this->get3dCoordinate( $start, true ),
- $this->get3dCoordinate( $end, true ),
- $this->get3dCoordinate( $end, false ),
- $this->get3dCoordinate( $start, false ),
+ $this->get3dCoordinate( $axisStart, true ),
+ $this->get3dCoordinate( $axisEnd, true ),
+ $this->get3dCoordinate( $axisEnd, false ),
+ $this->get3dCoordinate( $axisStart, false ),
);
// Draw axis
OpenPOWER on IntegriCloud