From c58d41009932fe955f7663e41953c780812f8e9f Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 29 May 2020 19:15:08 +0200 Subject: [PATCH] rrd charts: render 3 decimal points for small values Signed-off-by: Thomas Lamprecht --- panel/RRDChart.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/panel/RRDChart.js b/panel/RRDChart.js index 27b35b0..6b878d0 100644 --- a/panel/RRDChart.js +++ b/panel/RRDChart.js @@ -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); },