From f7b8cc2569b001eab98f276a7fc7260d9699c13d Mon Sep 17 00:00:00 2001 From: Malte Schirmacher Date: Wed, 23 Jan 2013 18:10:36 +0100 Subject: Patched ezcGraphRenderer3d to render labels correclty in case of additional axes In case there are additional axes ezcGraphRenderer3d renders labels multiple times (once for additional axis) at varying positions. Added a flag to avoid this faulty behavior. --- src/renderer/3d.php | 58 +++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/renderer/3d.php b/src/renderer/3d.php index 9d43c17..8a226c3 100644 --- a/src/renderer/3d.php +++ b/src/renderer/3d.php @@ -2251,40 +2251,46 @@ class ezcGraphRenderer3d 'start' => clone $start, 'end' => clone $end, 'axis' => $axis, + 'positioningDone' => false, ); if ( $this->xAxisSpace && $this->yAxisSpace ) { - foreach ( $this->axisLabels as $axisLabel ) + foreach ( $this->axisLabels as &$axisLabel ) { - // If font should not be synchronized, use font configuration from - // each axis - if ( $this->options->syncAxisFonts === false ) + if ( !$axisLabel['positioningDone'] ) { - $this->driver->options->font = $axisLabel['axis']->font; - } + // If font should not be synchronized, use font configuration from + // each axis + if ( $this->options->syncAxisFonts === false ) + { + $this->driver->options->font = $axisLabel['axis']->font; + } + + switch ( $axisLabel['axis']->position ) + { + case ezcGraph::RIGHT: + case ezcGraph::LEFT: + $axisLabel['start']->x += $this->xAxisSpace * ( $axisLabel['start'] > $axisLabel['end'] ? -1 : 1 ); + $axisLabel['end']->x -= $this->xAxisSpace * ( $axisLabel['start'] > $axisLabel['end'] ? -1 : 1 ); + break; + case ezcGraph::TOP: + case ezcGraph::BOTTOM: + $axisLabel['start']->y += $this->yAxisSpace * ( $axisLabel['start'] > $axisLabel['end'] ? -1 : 1 ); + $axisLabel['end']->y -= $this->yAxisSpace * ( $axisLabel['start'] > $axisLabel['end'] ? -1 : 1 ); + break; + } + + $axisLabel['object']->renderLabels( + $this, + $axisLabel['boundings'], + $axisLabel['start'], + $axisLabel['end'], + $axisLabel['axis'] + ); - switch ( $axisLabel['axis']->position ) - { - case ezcGraph::RIGHT: - case ezcGraph::LEFT: - $axisLabel['start']->x += $this->xAxisSpace * ( $axisLabel['start'] > $axisLabel['end'] ? -1 : 1 ); - $axisLabel['end']->x -= $this->xAxisSpace * ( $axisLabel['start'] > $axisLabel['end'] ? -1 : 1 ); - break; - case ezcGraph::TOP: - case ezcGraph::BOTTOM: - $axisLabel['start']->y += $this->yAxisSpace * ( $axisLabel['start'] > $axisLabel['end'] ? -1 : 1 ); - $axisLabel['end']->y -= $this->yAxisSpace * ( $axisLabel['start'] > $axisLabel['end'] ? -1 : 1 ); - break; + $axisLabel['positioningDone'] = true; } - - $axisLabel['object']->renderLabels( - $this, - $axisLabel['boundings'], - $axisLabel['start'], - $axisLabel['end'], - $axisLabel['axis'] - ); } } } -- cgit v1.1