diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 49cb9e8a74..194ee81e77 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -433,6 +433,7 @@ var vm_actions = { monitor_resources : "NET_TX", humanize_figures : true, convert_from_bytes : true, + y_sufix : "B/s", derivative : true, div_graph : $("#dash_vm_net_tx_graph", $dashboard), div_legend : $("#dash_vm_net_tx_legend", $dashboard) @@ -441,6 +442,7 @@ var vm_actions = { monitor_resources : "NET_RX", humanize_figures : true, convert_from_bytes : true, + y_sufix : "B/s", derivative : true, div_graph : $("#dash_vm_net_rx_graph", $dashboard), div_legend : $("#dash_vm_net_rx_legend", $dashboard) diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index 6620a5e405..aa668c74ac 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -83,14 +83,14 @@ function pretty_time_runtime(time){ //returns a human readable size in Kilo, Mega, Giga or Tera bytes //if no from_bytes, assumes value comes in Ks -function humanize_size(value,from_bytes) { +function humanize_size(value,from_bytes,sufix) { if (typeof(value) === "undefined") { value = 0; } - var binarySufix = from_bytes ? - ["", "K", "M", "G", "T" ] : ["K", "M", "G", "T" ]; - var i=0; - while (value > 1024 && i < 3){ + var binarySufix = ["", "K", "M", "G", "T" ]; + + var i = from_bytes ? 0 : 1; + while (value >= 1024 && i < 4){ value = value / 1024; i++; } @@ -100,7 +100,11 @@ function humanize_size(value,from_bytes) { value = Math.round(value); } - var st = value + binarySufix[i]; + if(sufix == undefined) { + sufix = "B"; + } + + var st = value + binarySufix[i] + sufix; return st; } @@ -110,7 +114,7 @@ function humanize_size_from_mb(value) { } var binarySufix = ["MB", "GB", "TB" ]; var i=0; - while (value > 1024 && i < 3){ + while (value >= 1024 && i < 2){ value = value / 1024; i++; } @@ -883,7 +887,7 @@ function plot_totals(response, info) { }, yaxis : { labelWidth: 40, tickFormatter: function(val, axis) { - return humanize(val, info.convert_from_bytes); + return humanize(val, info.convert_from_bytes, info.y_sufix); }, min: 0 }