Skip to content

Commit

Permalink
fix: avoid to show 0 for non cumulative types when cumulative is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Sep 15, 2024
1 parent cbb553a commit b49d64d
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/modules/pivotTable/PivotTableEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,7 @@ export class PivotTableEngine {

const cellValue = this.data[row][column]

if (!cellValue) {
// Empty cell
// The cell still needs to get the valueType to render correctly 0 and cumulative values
return {
valueType: VALUE_TYPE_NUMBER,
totalAggregationType: AGGREGATE_TYPE_SUM,
}
}

if (!Array.isArray(cellValue)) {
if (cellValue && !Array.isArray(cellValue)) {
// This is a total cell
return {
valueType: cellValue.valueType,
Expand Down Expand Up @@ -1092,6 +1083,9 @@ export class PivotTableEngine {
// only accumulate numeric (except for PERCENTAGE and UNIT_INTERVAL) and boolean values
// accumulating other value types like text values does not make sense
if (isCumulativeValueType(valueType)) {
// initialise to 0 for cumulative types
acc ||= 0

if (this.data[row] && this.data[row][column]) {
const dataRow = this.data[row][column]

Expand All @@ -1109,7 +1103,7 @@ export class PivotTableEngine {
}

return acc
}, 0)
}, '')
})
} else {
this.accumulators = { rows: {} }
Expand Down

0 comments on commit b49d64d

Please sign in to comment.