Merge branch 'ent-2556-realtime-graphs-with-shorter-y-axis-numbers' into 'develop'

Now the integer numbers of the Y axis of the realtime graphs are shorter

See merge request artica/pandorafms!1770
This commit is contained in:
vgilc 2018-09-28 11:20:31 +02:00
commit 06d71a905f
1 changed files with 21 additions and 0 deletions

View File

@ -28,6 +28,11 @@
return formattedTime;
}
},
yaxis: {
tickFormatter: function (value, axis) {
return shortNumber(value);
}
},
series: {
lines: {
lineWidth: 2,
@ -158,6 +163,22 @@
});
}
function shortNumber (number) {
if (Math.round(number) != number) return number;
number = Number.parseInt(number);
if (Number.isNaN(number)) return number;
var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
var pos = 0;
while (number >= 1000 || number <= -1000) {
pos++;
number = number / 1000;
}
return number + " " + shorts[pos];
}
$('#graph').change(function() {
$('form#realgraph').submit();
});