fix format function for X axis of custom graphs

This commit is contained in:
alejandro-campos 2020-04-03 10:34:54 +02:00
parent e30b9a32d8
commit 0c3a7166e0
1 changed files with 12 additions and 3 deletions

View File

@ -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:' +