From 0b09b6d2c1f71e2a8c866b5cafbdb5085d3eccee Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Mon, 13 Jan 2025 17:41:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(statistic):=20decimalPlaces=3D0?= =?UTF-8?q?=E6=97=B6=E6=95=B0=E5=80=BC=E5=8A=A8=E7=94=BB=E6=9C=9F=E9=97=B4?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/statistic/Statistic.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/statistic/Statistic.tsx b/src/statistic/Statistic.tsx index 9961b26d05..c54cc13e41 100644 --- a/src/statistic/Statistic.tsx +++ b/src/statistic/Statistic.tsx @@ -86,8 +86,8 @@ const Statistic = forwardRef((props, ref) => { return format(formatInnerValue); } const options = { - minimumFractionDigits: decimalPlaces || 0, - maximumFractionDigits: decimalPlaces || 20, + minimumFractionDigits: decimalPlaces ?? 0, + maximumFractionDigits: decimalPlaces ?? 20, useGrouping: !!separator, }; // replace的替换的方案仅能应对大部分地区 From cb19aaf1eb4fb010a8a7d9dea2a7f0958931a25a Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Tue, 14 Jan 2025 15:17:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(statistic):=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8getFormatValue=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/statistic/Statistic.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/statistic/Statistic.tsx b/src/statistic/Statistic.tsx index c54cc13e41..f78a22cdd0 100644 --- a/src/statistic/Statistic.tsx +++ b/src/statistic/Statistic.tsx @@ -16,7 +16,7 @@ import useIsFirstRender from '../hooks/useIsFirstRender'; import Skeleton from '../skeleton'; import Tween from '../_common/js/statistic/tween'; -import { COLOR_MAP } from '../_common/js/statistic/utils'; +import { COLOR_MAP, getFormatValue } from '../_common/js/statistic/utils'; export interface StatisticProps extends TdStatisticProps, StyledProps {} @@ -85,13 +85,9 @@ const Statistic = forwardRef((props, ref) => { if (isFunction(format)) { return format(formatInnerValue); } - const options = { - minimumFractionDigits: decimalPlaces ?? 0, - maximumFractionDigits: decimalPlaces ?? 20, - useGrouping: !!separator, - }; + // replace的替换的方案仅能应对大部分地区 - formatInnerValue = formatInnerValue.toLocaleString(undefined, options).replace(/,|,/g, separator); + formatInnerValue = getFormatValue(formatInnerValue, decimalPlaces, separator); return formatInnerValue; }, [innerValue, decimalPlaces, separator, format]);