Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/element/axis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) )
Expand Down
25 changes: 25 additions & 0 deletions src/renderer/axis_label_exact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) ||
Expand Down