From f2f1eaf58e35e0dff8e36470ba35a5d3f881ad9a Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Tue, 26 May 2020 14:44:52 +0200 Subject: [PATCH] Fixed values legend charts sparse --- pandora_console/include/functions.php | 8 ++++++++ pandora_console/include/graphs/flot/pandora.flot.js | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index eaea211d2a..d409096b06 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3718,6 +3718,14 @@ function series_type_graph_array($data, $show_elements_graph) } } + if ((int) $value['min'] === PHP_INT_MAX) { + $value['min'] = 0; + } + + if ((int) $value['max'] === (-PHP_INT_MAX)) { + $value['max'] = 0; + } + $data_return['legend'][$key] .= __('Min:').remove_right_zeros( number_format( $value['min'], diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 175173160c..48aaa94ee5 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -3009,7 +3009,7 @@ function number_format(number, force_integer, unit, short_data, divisor) { var decimals = 2; if (unit == "KB") { - return number + unit; + return Math.round(number * decimals) + unit; } // Set maximum decimal precision to 99 in case short_data is not set. @@ -3038,6 +3038,12 @@ function number_format(number, force_integer, unit, short_data, divisor) { if (divisor) { number = Math.round(number * decimals) / decimals; + } else { + number = Math.round(number * decimals); + } + + if (isNaN(number)) { + number = 0; } return number + " " + shorts[pos] + unit;