From fecd4151d1c4284b0861ddf06818f65819517bed Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 19 Jan 2015 13:35:41 +0100 Subject: [PATCH] Move axis labels to the top of the chart --- library/Icinga/Chart/Axis.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/library/Icinga/Chart/Axis.php b/library/Icinga/Chart/Axis.php index 88718f976..c12d9a904 100644 --- a/library/Icinga/Chart/Axis.php +++ b/library/Icinga/Chart/Axis.php @@ -228,15 +228,6 @@ class Axis implements Drawable } $i++; } - - // render the label for this axis - if ($this->xLabel) { - $axisLabel = new Text(50, 104, $this->xLabel); - $axisLabel->setFontSize('2em') - ->setFontWeight('bold') - ->setAlignment(Text::ALIGN_MIDDLE); - $group->appendChild($axisLabel->toSvg($ctx)); - } } /** @@ -287,12 +278,19 @@ class Axis implements Drawable $i++; } - if ($this->yLabel) { - $axisLabel = new Text(-8, 50, $this->yLabel); + if ($this->yLabel || $this->xLabel) { + if ($this->yLabel && $this->xLabel) { + $txt = $this->yLabel . ' / ' . $this->xLabel; + } else if ($this->xLabel) { + $txt = $this->xLabel; + } else { + $txt = $this->yLabel; + } + + $axisLabel = new Text(50, -3, $txt); $axisLabel->setFontSize('2em') ->setFontWeight('bold') ->setAlignment(Text::ALIGN_MIDDLE); - $axisLabel = new Rotator($axisLabel, 90); $group->appendChild($axisLabel->toSvg($ctx)); }