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,