diff options
Diffstat (limited to 'library/Graphite/Web/Widget/Graphs.php')
-rw-r--r-- | library/Graphite/Web/Widget/Graphs.php | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/library/Graphite/Web/Widget/Graphs.php b/library/Graphite/Web/Widget/Graphs.php index e18b8da..e49a0eb 100644 --- a/library/Graphite/Web/Widget/Graphs.php +++ b/library/Graphite/Web/Widget/Graphs.php @@ -134,7 +134,7 @@ abstract class Graphs extends AbstractWidget * * @param MonitoredObject $object * - * @return static + * @return ?static */ public static function forMonitoredObject(MonitoredObject $object) { @@ -304,17 +304,17 @@ abstract class Graphs extends AbstractWidget $actheight = $this->height; } $actwidth = $this->width; - $actwidthfix = ""; + $explicitWidth = false; if (array_key_exists("width", $urlParams)) { $actwidth = $urlParams["width"]->resolve(['width']); - $actwidthfix = "width: {$actwidth}px; "; + $explicitWidth = $actwidth; } if ($this->renderInline) { $chart->setFrom($this->start) ->setUntil($this->end) - ->setWidth($actwidth) - ->setHeight($actheight) + ->setWidth((int) $actwidth) + ->setHeight((int) $actheight) ->setBackgroundColor('white') ->setForegroundColor('black') ->setMajorGridLineColor('grey') @@ -331,7 +331,7 @@ abstract class Graphs extends AbstractWidget ->setParam('height', $actheight); if (! $this->compact) { - $imageUrl->setParam('legend', 1); + $imageUrl->setParam('legend', '1'); } if ($this->preloadDummy) { @@ -344,8 +344,12 @@ abstract class Graphs extends AbstractWidget $img = '<img id="graphiteImg-' . md5((string) $imageUrl) . '"' . " src=\"$src\" data-actualimageurl=\"$imageUrl\" class=\"detach graphiteImg\"" - . " alt=\"\" width=\"$actwidth\" height=\"$actheight\"" - . " style=\"min-width: {$actwidth}px; $actwidthfix min-height: {$actheight}px;\">"; + . " alt=\"\" width=\"$actwidth\" height=\"$actheight\""; + if ($explicitWidth !== false) { + $img .= " data-width=\"$explicitWidth\""; + } + + $img .= '>'; } $currentGraphs[] = [$img, $metricVariables, $bestPos]; |