1
This commit is contained in:
parent
f0dd3b830c
commit
3a4e7d73bc
15
src/App.tsx
15
src/App.tsx
@ -308,6 +308,15 @@ function formatGridWanValue(value: number) {
|
|||||||
return formatNumber(wanValue, fractionDigits);
|
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 {
|
function normalizeStat(row: ApiBuildingFunctionStat): ChartDatum {
|
||||||
const avgValue = row.avg_value ?? null;
|
const avgValue = row.avg_value ?? null;
|
||||||
const medianValue = row.median_value ?? null;
|
const medianValue = row.median_value ?? null;
|
||||||
@ -611,7 +620,7 @@ function isRangeFilterKey(filterKey: FilterKey): filterKey is RangeFilterKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isSingleSelectFilterKey(filterKey: FilterKey) {
|
function isSingleSelectFilterKey(filterKey: FilterKey) {
|
||||||
return isTemplateFilterKey(filterKey) || isIndicatorTreeFilterKey(filterKey) || isBuildingNatureFilterKey(filterKey);
|
return isTemplateFilterKey(filterKey) || isIndicatorTreeFilterKey(filterKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultTemplateFilterNodes(): SelectedFilterNode[] {
|
function getDefaultTemplateFilterNodes(): SelectedFilterNode[] {
|
||||||
@ -1061,10 +1070,10 @@ function App() {
|
|||||||
);
|
);
|
||||||
const pivotGridColumnDefs = useMemo<(ColDef<PivotGridRow> | ColGroupDef<PivotGridRow>)[]>(
|
const pivotGridColumnDefs = useMemo<(ColDef<PivotGridRow> | ColGroupDef<PivotGridRow>)[]>(
|
||||||
() => {
|
() => {
|
||||||
const valueUnit = requestMetricKey === 'cost' ? '万元' : '万元/m²';
|
const valueUnit = requestMetricKey === 'cost' ? '万元' : '元/m²';
|
||||||
const valueColumnMinWidth = requestMetricKey === 'cost' ? 112 : 142;
|
const valueColumnMinWidth = requestMetricKey === 'cost' ? 112 : 142;
|
||||||
const valueFormatter = ({ value }: ValueFormatterParams<PivotGridRow, number | null>) => (
|
const valueFormatter = ({ value }: ValueFormatterParams<PivotGridRow, number | null>) => (
|
||||||
value == null ? '' : formatGridWanValue(Number(value))
|
value == null ? '' : formatGridMetricValue(Number(value), requestMetricKey)
|
||||||
);
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user