Commit ceb5c9bf authored by Jerome Mariette's avatar Jerome Mariette
Browse files

No commit message

No commit message
parent 11625f47
......@@ -62,15 +62,17 @@ $(function () {
}
}
function get_octet_string_representation (size) {
function get_octet_string_representation (size, round) {
var octets_link = new Array("bytes", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb"),
p = parseInt(Math.ceil(parseFloat(size.toString().length)/parseFloat(3) - parseFloat(1))),
pow_needed = p * 10;
pow_needed = Math.pow(2, pow_needed);
value = parseFloat(size)/parseFloat(pow_needed);
var tmp = value.toString().split(".");
if (tmp.length > 1) {
value = tmp[0] + "." + tmp[1].slice(0, 2);
if (tmp.length > 1 && round > 0) {
value = tmp[0] + "." + tmp[1].slice(0, round);
} else if (tmp.length > 1 && round == 0) {
value = tmp[0];
}
value = value + " " + octets_link[p];
return value;
......@@ -114,7 +116,7 @@ $(function () {
yAxis: {
labels: {
formatter: function() {
return get_octet_string_representation(this.value);
return get_octet_string_representation(this.value, 0);
}
},
plotLines: [{
......@@ -128,7 +130,7 @@ $(function () {
formatter: function() {
var s = Highcharts.dateFormat('%B %Y', this.x) + ":";
$.each(this.points, function(i, point) {
s += '<strong>'+ get_octet_string_representation(point.y) +'</strong>';
s += '<strong>'+ get_octet_string_representation(point.y, 2) +'</strong>';
});
return s;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment