]> git.proxmox.com Git - proxmox-widget-toolkit.git/blobdiff - panel/RRDChart.js
rrd charts: render 3 decimal points for small values
[proxmox-widget-toolkit.git] / panel / RRDChart.js
index 27b35b0e37c1b453cf9a600f38f94c6a62a2cc25..6b878d03848c2dd276fe0fbaeb06f2cff31e79b7 100644 (file)
@@ -10,6 +10,8 @@ Ext.define('Proxmox.widget.RRDChart', {
        convertToUnits: function(value) {
            var units = ['', 'k','M','G','T', 'P'];
            var si = 0;
+           let format = '0.##';
+           if (value < 0.1) format += '#';
            while(value >= 1000  && si < (units.length -1)){
                value = value / 1000;
                si++;
@@ -18,15 +20,14 @@ Ext.define('Proxmox.widget.RRDChart', {
            // javascript floating point weirdness
            value = Ext.Number.correctFloat(value);
 
-           // limit to 2 decimal points
-           value = Ext.util.Format.number(value, "0.##");
+           // limit decimal points
+           value = Ext.util.Format.number(value, format);
 
            return value.toString() + " " + units[si];
        },
 
        leftAxisRenderer: function(axis, label, layoutContext) {
            var me = this;
-
            return me.convertToUnits(label);
        },