From 194a594254c82d9366cfc6bd8f48837b2fafe9ef Mon Sep 17 00:00:00 2001 From: zhangyu Date: Wed, 23 Sep 2020 10:03:00 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=A4=84=E7=90=86=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E7=B2=BE=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/charts/chartDataFormat.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nezha-fronted/src/components/charts/chartDataFormat.js b/nezha-fronted/src/components/charts/chartDataFormat.js index 1fbef042e..2d183d1fa 100644 --- a/nezha-fronted/src/components/charts/chartDataFormat.js +++ b/nezha-fronted/src/components/charts/chartDataFormat.js @@ -26,11 +26,12 @@ function percent01(value,index){ return `${len} %`; } function percent02(value,index){ + value=value*100; let len=JSON.stringify(value); - if(len.length>5){ + if(len.length>5&&value<100){ len=len.slice(0,5); } - return `${len * 100 } %`; + return `${len} %`; } function localFormat(value,index){ let num = (value || 0).toString(); @@ -644,6 +645,14 @@ export default { }, formatDatas:function(value,type,flow='ceil',ascii){ let pow=0; + if(value<1&&value!=0){ + while(value<1){ + pow++; + value=value*10; + console.log(value); + } + return Math.floor(value+1)/Math.pow(10,pow); + } if(type ==='Time'){ return value }