diff options
Diffstat (limited to 'src/renderer')
-rw-r--r-- | src/renderer/2d.php | 37 | ||||
-rw-r--r-- | src/renderer/3d.php | 39 |
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 |