From 3a478b0d364216d26b82e992c528afca9114ee47 Mon Sep 17 00:00:00 2001 From: keting lu Date: Thu, 20 Mar 2025 20:10:09 +0800 Subject: [PATCH] fix: change bytes formatMGT --- web/app/components/base/line-chart/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/app/components/base/line-chart/index.tsx b/web/app/components/base/line-chart/index.tsx index 35bd0e1770..2718c79b0f 100644 --- a/web/app/components/base/line-chart/index.tsx +++ b/web/app/components/base/line-chart/index.tsx @@ -3,7 +3,7 @@ import ReactECharts from 'echarts-for-react' import { useTranslation } from 'react-i18next' import dayjs from 'dayjs' const formatMGT = (y) => { - const yy = Math.abs(y) + const yy = Math.abs(y / 1024 / 1024) if (yy >= 1024 * 1024) { return y < 0 ? `${-1 * +(yy / (1024 * 1024)).toFixed(2)}T` @@ -88,9 +88,9 @@ const LineChart = (props: LineChartProps) => { return '< 0.01%' return `${Number.parseFloat((value).toFixed(2))}%` case 'bytes': - if (value > 0 && value < 0.01) - return `< 0.01 ${unit}` - return `${formatMGT(Number.parseFloat((value).toFixed(2)))} ${unit}` + if (value > 0 && value < 1024 * 0.01) + return '< 0.01M' + return `${formatMGT(Number.parseFloat((value).toFixed(2)))}` default: if (value > 0 && value < 0.01) return `< 0.01 ${unit}`