From 4d7825693722c2d607b66deb42eccdec18cfc729 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 17 Apr 2018 11:54:52 +0200 Subject: [PATCH] Fixed Y-axis label decimals --- pandora_console/include/graphs/flot/pandora.flot.js | 2 ++ pandora_console/include/graphs/pandora.d3.js | 8 -------- pandora_console/include/javascript/pandora.js | 8 ++++++++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index b3ea1d5f8a..c1abf15186 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -1930,6 +1930,8 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, } } + // Get only two decimals + formatted =round_with_decimals(formatted, 100) return '
'+formatted+'
'; } diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index de89872da3..6f4a59cab1 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -1494,14 +1494,6 @@ function print_phases_donut (recipient, phases) { } } -function round_with_decimals (value, multiplier = 1) { - if ((value * multiplier) == 0) return 0; - if ((value * multiplier) >= 1) { - return Math.round(value * multiplier) / multiplier; - } - return round_with_decimals (value, multiplier * 10); -} - function progress_bar_d3 (recipient, percentile, width, height, color, unit, label, label_color) { var startPercent = 0; var endPercent = parseInt(percentile) / 100; diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 336eacecdd..1bc39e31e3 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1551,4 +1551,12 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er } } +} + +function round_with_decimals (value, multiplier = 1) { + if ((value * multiplier) == 0) return 0; + if ((value * multiplier) >= 1) { + return Math.round(value * multiplier) / multiplier; + } + return round_with_decimals (value, multiplier * 10); } \ No newline at end of file