feat(图表): 透视表总计支持设置为无 #9732

This commit is contained in:
wisonic
2025-02-28 17:47:41 +08:00
committed by wisonic-s
parent 89421cbb25
commit 90bc05bdd1
2 changed files with 5 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ watch(
)
const aggregations = [
{ name: t('chart.none'), value: 'NONE' },
{ name: t('chart.sum'), value: 'SUM' },
{ name: t('chart.avg'), value: 'AVG' },
{ name: t('chart.max'), value: 'MAX' },

View File

@@ -538,7 +538,7 @@ export class TablePivot extends S2ChartView<PivotSheet> {
}
function customCalcFunc(query, data, status, chart, totalCfgMap, axisMap, customCalc) {
if (!data?.length || !query[EXTRA_FIELD]) {
return 0
return '-'
}
const aggregation = totalCfgMap[query[EXTRA_FIELD]]?.aggregation || 'SUM'
switch (aggregation) {
@@ -565,6 +565,9 @@ function customCalcFunc(query, data, status, chart, totalCfgMap, axisMap, custom
})
return result?.[query[EXTRA_FIELD]]
}
case 'NONE': {
return '-'
}
case 'CUSTOM': {
const val = getCustomCalcResult(query, axisMap, chart, status, customCalc || {})
if (val === '') {