From f3f5bcecd8a244f34255b47cb8631d0144aa631b Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 25 Apr 2019 16:59:24 +0200 Subject: [PATCH] Visual Console Refactor: fixed the module graph element Former-commit-id: baee256acdbc28c3b2d0364b97f301f776121e36 --- .../models/VisualConsole/Items/ModuleGraph.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php index d4669cb7cc..a7430e76d3 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php @@ -193,6 +193,18 @@ final class ModuleGraph extends Item } } + /* + * About the 30 substraction to the graph height: + * The function which generates the graph doesn't respect the + * required height. It uses it for the canvas (the graph itself and + * their axes), but then it adds the legend. One item of the legend + * (one dataset) is about 30px, so we need to substract that height + * from the canvas to try to fit the element's height. + * + * PD: The custom graphs can have more datasets, but we only substract + * the height of one of it to replicate the legacy functionality. + */ + // Custom graph. if (empty($customGraphId) === false) { $customGraph = \db_get_row_filter( @@ -204,7 +216,7 @@ final class ModuleGraph extends Item $params = [ 'period' => $period, 'width' => $data['width'], - 'height' => $data['height'], + 'height' => ($data['height'] - 30), 'title' => '', 'unit_name' => null, 'show_alerts' => false, @@ -237,7 +249,7 @@ final class ModuleGraph extends Item 'period' => $period, 'show_events' => false, 'width' => $data['width'], - 'height' => $data['height'], + 'height' => ($data['height'] - 30), 'title' => \modules_get_agentmodule_name($moduleId), 'unit' => \modules_get_unit($moduleId), 'only_image' => $imageOnly,