forked from github/dataease
fix(视图): 修复透视表计数字段汇总计算错误 #10499
This commit is contained in:
parent
bdf5292cd6
commit
49c3e012d8
@ -344,30 +344,30 @@ function customCalcFunc(query, data, totalCfgMap) {
|
||||
switch (aggregation) {
|
||||
case 'SUM': {
|
||||
return data.reduce((p, n) => {
|
||||
return p + n[query[EXTRA_FIELD]]
|
||||
return p + parseFloat(n[query[EXTRA_FIELD]])
|
||||
}, 0)
|
||||
}
|
||||
case 'AVG': {
|
||||
const sum = data.reduce((p, n) => {
|
||||
return p + n[query[EXTRA_FIELD]]
|
||||
return p + parseFloat(n[query[EXTRA_FIELD]])
|
||||
}, 0)
|
||||
return sum / data.length
|
||||
}
|
||||
case 'MIN': {
|
||||
const result = minBy(data, n => {
|
||||
return n[query[EXTRA_FIELD]]
|
||||
return parseFloat(n[query[EXTRA_FIELD]])
|
||||
})
|
||||
return result?.[query[EXTRA_FIELD]]
|
||||
}
|
||||
case 'MAX': {
|
||||
const result = maxBy(data, n => {
|
||||
return n[query[EXTRA_FIELD]]
|
||||
return parseFloat(n[query[EXTRA_FIELD]])
|
||||
})
|
||||
return result?.[query[EXTRA_FIELD]]
|
||||
}
|
||||
default: {
|
||||
return data.reduce((p, n) => {
|
||||
return p + n[query[EXTRA_FIELD]]
|
||||
return p + parseFloat(n[query[EXTRA_FIELD]])
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ export function mappingColor(value, defaultColor, field, type) {
|
||||
}
|
||||
|
||||
export function handleTableEmptyStrategy(chart: Chart) {
|
||||
let newData = chart.data?.tableRow as Record<string, any>[]
|
||||
let newData = (chart.data?.tableRow || []) as Record<string, any>[]
|
||||
let intersectionArr = []
|
||||
const senior = parseJson(chart.senior)
|
||||
let emptyDataStrategy = senior?.functionCfg?.emptyDataStrategy
|
||||
|
Loading…
Reference in New Issue
Block a user