From 0c3a7166e061e87ed656830f80092a5545b29db6 Mon Sep 17 00:00:00 2001 From: alejandro-campos <alejandro.campos@artica.es> Date: Fri, 3 Apr 2020 10:34:54 +0200 Subject: [PATCH 1/2] fix format function for X axis of custom graphs --- .../include/graphs/flot/pandora.flot.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index cb2a6fc4cc..3d3b48b18e 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -458,10 +458,19 @@ function pandoraFlotHBars( // v, axis; function xFormatter(v) { var label = parseFloat(v); + + const unit_prefixes = ["K", "M", "G"]; + var unit_prefix; + var i = 0; + + while (label >= 1000 && i < 3) { + label = label / 1000; + unit_prefix = unit_prefixes[i]; + i++; + } var text = label.toLocaleString(); - if (label >= 1000000) text = text.substring(0, 4) + "M"; - else if (label >= 100000) text = text.substring(0, 3) + "K"; - else if (label >= 1000) text = text.substring(0, 2) + "K"; + + text = text + unit_prefix; return ( '<div style="font-size:' + From 80ce89e650355d602a3d16e7d0aad2a6aa10cec0 Mon Sep 17 00:00:00 2001 From: alejandro-campos <alejandro.campos@artica.es> Date: Fri, 3 Apr 2020 10:41:24 +0200 Subject: [PATCH 2/2] fix format function for X axis of custom graphs --- pandora_console/include/graphs/flot/pandora.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 3d3b48b18e..175173160c 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -460,7 +460,7 @@ function pandoraFlotHBars( var label = parseFloat(v); const unit_prefixes = ["K", "M", "G"]; - var unit_prefix; + var unit_prefix = ""; var i = 0; while (label >= 1000 && i < 3) {