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

This commit is contained in:
Alejandro Gallardo Escobar 2018-09-17 13:13:10 +02:00
parent 921a025262
commit 5f732d035b
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();
});