1
This commit is contained in:
parent
42a07e2bf8
commit
1f315a40da
15
src/App.tsx
15
src/App.tsx
@ -330,6 +330,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;
|
||||
@ -633,7 +642,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[] {
|
||||
@ -1093,10 +1102,10 @@ function App() {
|
||||
);
|
||||
const pivotGridColumnDefs = useMemo<(ColDef<PivotGridRow> | ColGroupDef<PivotGridRow>)[]>(
|
||||
() => {
|
||||
const valueUnit = requestMetricKey === 'cost' ? '万元' : '万元/m²';
|
||||
const valueUnit = requestMetricKey === 'cost' ? '万元' : '元/m²';
|
||||
const valueColumnMinWidth = requestMetricKey === 'cost' ? 112 : 142;
|
||||
const valueFormatter = ({ value }: ValueFormatterParams<PivotGridRow, number | null>) => (
|
||||
value == null ? '' : formatGridWanValue(Number(value))
|
||||
value == null ? '' : formatGridMetricValue(Number(value), requestMetricKey)
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user