From 3a4e7d73bc1f375c8941e8169e179c93b74f4433 Mon Sep 17 00:00:00 2001 From: wintsa <770775984@qq.com> Date: Tue, 18 Aug 2026 16:37:11 +0800 Subject: [PATCH] 1 --- src/App.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index f0a5d5d..7ca7d94 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -308,6 +308,15 @@ function formatGridWanValue(value: number) { return formatNumber(wanValue, fractionDigits); } +function formatGridMetricValue(value: number, metricKey: MetricKey) { + if (metricKey === 'cost') { + return formatGridWanValue(value); + } + const absValue = Math.abs(value); + const fractionDigits = absValue > 0 && absValue < 1 ? 4 : 2; + return formatNumber(value, fractionDigits); +} + function normalizeStat(row: ApiBuildingFunctionStat): ChartDatum { const avgValue = row.avg_value ?? null; const medianValue = row.median_value ?? null; @@ -611,7 +620,7 @@ function isRangeFilterKey(filterKey: FilterKey): filterKey is RangeFilterKey { } function isSingleSelectFilterKey(filterKey: FilterKey) { - return isTemplateFilterKey(filterKey) || isIndicatorTreeFilterKey(filterKey) || isBuildingNatureFilterKey(filterKey); + return isTemplateFilterKey(filterKey) || isIndicatorTreeFilterKey(filterKey); } function getDefaultTemplateFilterNodes(): SelectedFilterNode[] { @@ -1061,10 +1070,10 @@ function App() { ); const pivotGridColumnDefs = useMemo<(ColDef | ColGroupDef)[]>( () => { - const valueUnit = requestMetricKey === 'cost' ? '万元' : '万元/m²'; + const valueUnit = requestMetricKey === 'cost' ? '万元' : '元/m²'; const valueColumnMinWidth = requestMetricKey === 'cost' ? 112 : 142; const valueFormatter = ({ value }: ValueFormatterParams) => ( - value == null ? '' : formatGridWanValue(Number(value)) + value == null ? '' : formatGridMetricValue(Number(value), requestMetricKey) ); return [