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) {
|
switch (aggregation) {
|
||||||
case 'SUM': {
|
case 'SUM': {
|
||||||
return data.reduce((p, n) => {
|
return data.reduce((p, n) => {
|
||||||
return p + n[query[EXTRA_FIELD]]
|
return p + parseFloat(n[query[EXTRA_FIELD]])
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
case 'AVG': {
|
case 'AVG': {
|
||||||
const sum = data.reduce((p, n) => {
|
const sum = data.reduce((p, n) => {
|
||||||
return p + n[query[EXTRA_FIELD]]
|
return p + parseFloat(n[query[EXTRA_FIELD]])
|
||||||
}, 0)
|
}, 0)
|
||||||
return sum / data.length
|
return sum / data.length
|
||||||
}
|
}
|
||||||
case 'MIN': {
|
case 'MIN': {
|
||||||
const result = minBy(data, n => {
|
const result = minBy(data, n => {
|
||||||
return n[query[EXTRA_FIELD]]
|
return parseFloat(n[query[EXTRA_FIELD]])
|
||||||
})
|
})
|
||||||
return result?.[query[EXTRA_FIELD]]
|
return result?.[query[EXTRA_FIELD]]
|
||||||
}
|
}
|
||||||
case 'MAX': {
|
case 'MAX': {
|
||||||
const result = maxBy(data, n => {
|
const result = maxBy(data, n => {
|
||||||
return n[query[EXTRA_FIELD]]
|
return parseFloat(n[query[EXTRA_FIELD]])
|
||||||
})
|
})
|
||||||
return result?.[query[EXTRA_FIELD]]
|
return result?.[query[EXTRA_FIELD]]
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return data.reduce((p, n) => {
|
return data.reduce((p, n) => {
|
||||||
return p + n[query[EXTRA_FIELD]]
|
return p + parseFloat(n[query[EXTRA_FIELD]])
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ export function mappingColor(value, defaultColor, field, type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function handleTableEmptyStrategy(chart: Chart) {
|
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 = []
|
let intersectionArr = []
|
||||||
const senior = parseJson(chart.senior)
|
const senior = parseJson(chart.senior)
|
||||||
let emptyDataStrategy = senior?.functionCfg?.emptyDataStrategy
|
let emptyDataStrategy = senior?.functionCfg?.emptyDataStrategy
|
||||||
|
Loading…
Reference in New Issue
Block a user