Merge branch 'ent-5395-Pelayo-Fallo-en-el-eje-de-titulos-de-los-custom-graphs-de-barra' into 'develop'

fix format function for X axis of custom graphs

See merge request artica/pandorafms!3138
This commit is contained in:
Daniel Rodriguez 2020-04-03 13:55:59 +02:00
commit 846e6100b8
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:' +