Visual Console Refactor: fixed the module graph element

Former-commit-id: baee256acdbc28c3b2d0364b97f301f776121e36
This commit is contained in:
Alejandro Gallardo Escobar 2019-04-25 16:59:24 +02:00
parent af69804708
commit f3f5bcecd8
1 changed files with 14 additions and 2 deletions

View File

@ -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. // Custom graph.
if (empty($customGraphId) === false) { if (empty($customGraphId) === false) {
$customGraph = \db_get_row_filter( $customGraph = \db_get_row_filter(
@ -204,7 +216,7 @@ final class ModuleGraph extends Item
$params = [ $params = [
'period' => $period, 'period' => $period,
'width' => $data['width'], 'width' => $data['width'],
'height' => $data['height'], 'height' => ($data['height'] - 30),
'title' => '', 'title' => '',
'unit_name' => null, 'unit_name' => null,
'show_alerts' => false, 'show_alerts' => false,
@ -237,7 +249,7 @@ final class ModuleGraph extends Item
'period' => $period, 'period' => $period,
'show_events' => false, 'show_events' => false,
'width' => $data['width'], 'width' => $data['width'],
'height' => $data['height'], 'height' => ($data['height'] - 30),
'title' => \modules_get_agentmodule_name($moduleId), 'title' => \modules_get_agentmodule_name($moduleId),
'unit' => \modules_get_unit($moduleId), 'unit' => \modules_get_unit($moduleId),
'only_image' => $imageOnly, 'only_image' => $imageOnly,