API module graph width

This commit is contained in:
fbsanchez 2021-03-05 10:30:14 +01:00
parent b2d1369717
commit 1534fd9c40
2 changed files with 13 additions and 6 deletions

View File

@ -178,14 +178,19 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
$params_combined = json_decode($data_combined, true);
$module_list = json_decode($data_module_list, true);
$type_graph_pdf = $type_graph_pdf;
if (isset($params['vconsole']) === false || $params['vconsole'] === false) {
if ((int) $viewport_width > 0) {
$params['width'] = (int) $viewport_width;
}
if ((isset($params['width']) === false
|| ($params['width'] <= 0))
) {
if ((int) $params['width'] <= 0) {
$params['width'] = 650;
}
if ((int) $params['landscape'] === 1) {
$params['width'] = 850;
}

View File

@ -13767,16 +13767,18 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4)
}
if (is_array($other['data']) === true) {
// Parameters received by user call.
$graph_seconds = (!empty($other) && isset($other['data'][0])) ? $other['data'][0] : SECONDS_1HOUR;
// 1 hour by default.
$graph_threshold = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 0;
$graph_threshold = (!empty($other) && isset($other['data'][1]) && $other['data'][1]) ? $other['data'][1] : 0;
// Graph height when send email by alert
$height = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : 225;
$height = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 225;
// Graph width (optional).
$width = (!empty($other) && isset($other['data'][4]) && $other['data'][4]) ? $other['data'][4] : 225;
$width = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : '';
} else {
// Fixed parameters for _modulegraph_nh_.
$graph_seconds = $other['data'];
$graph_threshold = 0;
$other['data'][1] = 0;