From 2360f21b094a466975f3128249e96bdd22460454 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Wed, 26 Mar 2014 17:06:21 +0100 Subject: [PATCH] Fix InlinePie boundaries and use floats for the PieSlice path coordinates Use floats as path coordinates in PieSlices, to avoid that the start and ending position of the arc are at the exact same position. This would cause buggy behavior, when displaying values like "99,999%". refs #5863 --- library/Icinga/Chart/Inline/Inline.php | 4 ++-- library/Icinga/Chart/PieChart.php | 4 +++- library/Icinga/Chart/Primitive/PieSlice.php | 8 ++++---- library/Icinga/Web/Widget/Chart/InlinePie.php | 8 ++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/library/Icinga/Chart/Inline/Inline.php b/library/Icinga/Chart/Inline/Inline.php index b31693b66..1040c30a8 100644 --- a/library/Icinga/Chart/Inline/Inline.php +++ b/library/Icinga/Chart/Inline/Inline.php @@ -74,14 +74,14 @@ class Inline { * * @var int */ - protected $height = 20; + protected $height = 100; /** * The width in percent * * @var int */ - protected $width = 20; + protected $width = 100; protected function sanitizeStringArray(array $arr) { diff --git a/library/Icinga/Chart/PieChart.php b/library/Icinga/Chart/PieChart.php index 9a6e89375..f20cd6820 100644 --- a/library/Icinga/Chart/PieChart.php +++ b/library/Icinga/Chart/PieChart.php @@ -193,7 +193,9 @@ class PieChart extends Chart $outerBox = new Canvas('outerGraph', new LayoutBox(0, 0, 100, 100)); $innerBox = new Canvas('graph', new LayoutBox(0, 0, 100, 100)); $labelBox = $ctx->getDocument()->createElement('g'); - $innerBox->getLayout()->setPadding(10, 10, 10, 10); + if (!$this->noCaption) { + $innerBox->getLayout()->setPadding(10, 10, 10, 10); + } $this->createContentClipBox($innerBox); $this->renderPies($innerBox, $labelBox); $innerBox->addElement(new RawElement($labelBox)); diff --git a/library/Icinga/Chart/Primitive/PieSlice.php b/library/Icinga/Chart/Primitive/PieSlice.php index 6cd03ed17..272145edb 100644 --- a/library/Icinga/Chart/Primitive/PieSlice.php +++ b/library/Icinga/Chart/Primitive/PieSlice.php @@ -132,10 +132,10 @@ class PieSlice extends Animatable implements Drawable $pathString = 'M ' . $x . ' ' . $y . ' '; // The coordinate system is mirrored on the Y axis, so we have to flip cos and sin - $xStart = $x + intval($r * sin($this->startRadian)); - $yStart = $y - intval($r * cos($this->startRadian)); - $xEnd = $x + intval($r * sin($this->endRadian)); - $yEnd = $y - intval($r * cos($this->endRadian)); + $xStart = $x + ($r * sin($this->startRadian)); + $yStart = $y - ($r * cos($this->startRadian)); + $xEnd = $x + ($r * sin($this->endRadian)); + $yEnd = $y - ($r * cos($this->endRadian)); // Draw a straight line to the upper part of the arc $pathString .= 'L ' . $xStart . ' ' . $yStart; diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index 61405e0a0..7434126d9 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -71,16 +71,16 @@ EOD; /** * The width of the rendered chart * - * @var int The value in percent + * @var int The value in px */ - private $width = 30; + private $width = 31; /** * The height of the rendered chart * - * @var int The value in perecent + * @var int The value in px */ - private $height = 30; + private $height = 31; /** * The title of the chart