From b91a269ddba415b6ff23974ba8058b0f097136ac Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Sun, 7 Jan 2024 20:48:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E9=A5=BC=E5=9B=BE=E6=98=BE=E7=A4=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Detail/index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/web/src/pages/Detail/index.js b/web/src/pages/Detail/index.js index ad3ce51b..84808e37 100644 --- a/web/src/pages/Detail/index.js +++ b/web/src/pages/Detail/index.js @@ -68,6 +68,7 @@ const Detail = (props) => { id: 'id0', values: [ { type: 'null', value: '0' }, + { type: 'null', value: '0' }, ] } ], @@ -181,14 +182,14 @@ const Detail = (props) => { // 合并created_at和model_name 为 lineData, created_at 数据类型是小时的时间戳 // 转换日期格式 let createTime = timestamp2string1(item.created_at); - let lineItem = lineData.find(item => item.Time === item.createTime && item.Model === model_name); + let lineItem = lineData.find(item => item.Time === createTime && item.Model === model_name); if (lineItem) { - lineItem.Usage += getQuotaWithUnit(quota); + lineItem.Usage += parseFloat(getQuotaWithUnit(quota)); } else { lineData.push({ "Time": createTime, "Model": model_name, - "Usage": getQuotaWithUnit(quota) + "Usage": parseFloat(getQuotaWithUnit(quota)) }); } @@ -197,15 +198,16 @@ const Detail = (props) => { pieData.sort((a, b) => b.value - a.value); pieChart.updateData('id0', pieData); lineChart.updateData('barData', lineData); - + pieChart.reLayout(); + lineChart.reLayout(); } - useEffectOnce(() => { + useEffect(() => { if (!initialized.current) { initialized.current = true; initChart(); } - }); + }, []); return ( <> @@ -240,10 +242,10 @@ const Detail = (props) => { >