From 6a23c0c2148cfb5c9c1056ec395d84b5d93dba97 Mon Sep 17 00:00:00 2001 From: PhoenixFnX Date: Wed, 6 Aug 2014 01:31:13 +0200 Subject: [PATCH 1/2] Adding a position feature to the axes labels I just commit the minimum code to allow labels on the right of a vertical secondary axis --- src/element/axis.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/element/axis.php b/src/element/axis.php index e9a65387..2dcb7dc7 100644 --- a/src/element/axis.php +++ b/src/element/axis.php @@ -119,6 +119,8 @@ * Size of axis label * @property int $labelMargin * Distance between label an axis + * @property int $labelPosition + * Integer defining the labels position regarding the axe. * @property int $minArrowHeadSize * Minimum Size used to draw arrow heads. * @property int $maxArrowHeadSize @@ -179,6 +181,7 @@ public function __construct( array $options = array() ) $this->properties['label'] = false; $this->properties['labelSize'] = 14; $this->properties['labelMargin'] = 2; + $this->properties['labelPosition'] = ezcGraph::LEFT; $this->properties['minArrowHeadSize'] = 4; $this->properties['maxArrowHeadSize'] = 8; $this->properties['labelCallback'] = null; @@ -296,6 +299,23 @@ public function __set( $propertyName, $propertyValue ) $this->properties['labelMargin'] = (int) $propertyValue; break; + case 'labelPosition': + $positions = array( + ezcGraph::TOP, + ezcGraph::BOTTOM, + ezcGraph::LEFT, + ezcGraph::RIGHT, + ); + + if ( in_array( $propertyValue, $positions, true ) ) + { + $this->properties['labelPosition'] = $propertyValue; + } + else + { + throw new ezcBaseValueException( 'labelPosition', $propertyValue, 'integer' ); + } + break; case 'maxArrowHeadSize': if ( !is_numeric( $propertyValue ) || ( $propertyValue <= 0 ) ) From faedfb17584e6f09034df4c87ca7809da7e2e74b Mon Sep 17 00:00:00 2001 From: PhoenixFnX Date: Wed, 6 Aug 2014 01:32:36 +0200 Subject: [PATCH 2/2] Adding a position feature to the axes labels only $axis->labelPosition === ezcGraph::RIGHT is supported --- src/renderer/axis_label_exact.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/renderer/axis_label_exact.php b/src/renderer/axis_label_exact.php index a158756e..d0027116 100644 --- a/src/renderer/axis_label_exact.php +++ b/src/renderer/axis_label_exact.php @@ -207,6 +207,31 @@ public function renderLabels( // Skip last step if showLastValue is false $showLabel = false; break; + // NTH : Draw label at top right of step on vertical axis + case ( ( $axis->labelPosition === ezcGraph::RIGHT ) && + ( !$step->isLast ) ) || + ( ( $axis->labelPosition === ezcGraph::RIGHT ) && + ( $step->isLast ) && + ( $this->renderLastOutside ) ) : + $labelBoundings = new ezcGraphBoundings( + $position->x + $this->labelPadding, + $position->y - $labelHeight + $this->labelPadding, + $position->x + $labelWidth - $this->labelPadding, + $position->y - $this->labelPadding + ); + $alignement = ezcGraph::LEFT | ezcGraph::BOTTOM; + break; + case ( ( $axis->labelPosition === ezcGraph::RIGHT ) && + ( $step->isLast ) && + ( !$this->renderLastOutside ) ) : + $labelBoundings = new ezcGraphBoundings( + $position->x + $this->labelPadding, + $position->y + $this->labelPadding, + $position->x + $labelWidth - $this->labelPadding, + $position->y + $labelHeight - $this->labelPadding + ); + $alignement = ezcGraph::TOP | ezcGraph::LEFT; + break; // Draw label at top left of step case ( ( $axis->position === ezcGraph::BOTTOM ) && ( !$step->isLast ) ) ||