@visactor/vtable 1.7.8-alpha.4 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/cjs/ListTable.js +12 -8
  2. package/cjs/ListTable.js.map +1 -1
  3. package/cjs/PivotTable.js +3 -3
  4. package/cjs/PivotTable.js.map +1 -1
  5. package/cjs/core/BaseTable.d.ts +7 -0
  6. package/cjs/core/BaseTable.js +26 -9
  7. package/cjs/core/BaseTable.js.map +1 -1
  8. package/cjs/core/record-helper.js +83 -10
  9. package/cjs/core/record-helper.js.map +1 -1
  10. package/cjs/core/tableHelper.d.ts +2 -0
  11. package/cjs/core/tableHelper.js +26 -3
  12. package/cjs/core/tableHelper.js.map +1 -1
  13. package/cjs/data/CachedDataSource.d.ts +3 -3
  14. package/cjs/data/CachedDataSource.js +4 -4
  15. package/cjs/data/CachedDataSource.js.map +1 -1
  16. package/cjs/data/DataSource.d.ts +3 -3
  17. package/cjs/data/DataSource.js +28 -21
  18. package/cjs/data/DataSource.js.map +1 -1
  19. package/cjs/dataset/dataset.d.ts +20 -2
  20. package/cjs/dataset/dataset.js +259 -159
  21. package/cjs/dataset/dataset.js.map +1 -1
  22. package/cjs/dataset/statistics-helper.d.ts +22 -0
  23. package/cjs/dataset/statistics-helper.js +114 -8
  24. package/cjs/dataset/statistics-helper.js.map +1 -1
  25. package/cjs/edit/edit-manager.js +1 -0
  26. package/cjs/edit/edit-manager.js.map +1 -1
  27. package/cjs/event/listener/table-group.js +1 -0
  28. package/cjs/event/listener/table-group.js.map +1 -1
  29. package/cjs/header-helper/header-helper.js +3 -3
  30. package/cjs/header-helper/header-helper.js.map +1 -1
  31. package/cjs/icons.js +2 -2
  32. package/cjs/icons.js.map +1 -1
  33. package/cjs/index.d.ts +1 -1
  34. package/cjs/index.js +1 -1
  35. package/cjs/index.js.map +1 -1
  36. package/cjs/layout/layout-helper.js +2 -2
  37. package/cjs/layout/layout-helper.js.map +1 -1
  38. package/cjs/layout/simple-header-layout.d.ts +3 -4
  39. package/cjs/layout/simple-header-layout.js +15 -25
  40. package/cjs/layout/simple-header-layout.js.map +1 -1
  41. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js +25 -10
  42. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  43. package/cjs/scenegraph/layout/frozen-react.d.ts +5 -0
  44. package/cjs/scenegraph/layout/frozen-react.js +86 -0
  45. package/cjs/scenegraph/layout/frozen-react.js.map +1 -0
  46. package/cjs/scenegraph/layout/frozen.js +6 -5
  47. package/cjs/scenegraph/layout/frozen.js.map +1 -1
  48. package/cjs/scenegraph/scenegraph.js +2 -15
  49. package/cjs/scenegraph/scenegraph.js.map +1 -1
  50. package/cjs/scenegraph/utils/text-measure.js +1 -1
  51. package/cjs/scenegraph/utils/text-measure.js.map +1 -1
  52. package/cjs/ts-types/base-table.d.ts +14 -0
  53. package/cjs/ts-types/base-table.js.map +1 -1
  54. package/cjs/ts-types/table-engine.d.ts +1 -0
  55. package/cjs/ts-types/table-engine.js.map +1 -1
  56. package/cjs/vrender.js.map +1 -1
  57. package/dist/vtable.js +1231 -443
  58. package/dist/vtable.min.js +2 -2
  59. package/es/ListTable.js +10 -10
  60. package/es/ListTable.js.map +1 -1
  61. package/es/PivotTable.js +3 -3
  62. package/es/PivotTable.js.map +1 -1
  63. package/es/core/BaseTable.d.ts +7 -0
  64. package/es/core/BaseTable.js +27 -9
  65. package/es/core/BaseTable.js.map +1 -1
  66. package/es/core/record-helper.js +83 -10
  67. package/es/core/record-helper.js.map +1 -1
  68. package/es/core/tableHelper.d.ts +2 -0
  69. package/es/core/tableHelper.js +23 -1
  70. package/es/core/tableHelper.js.map +1 -1
  71. package/es/data/CachedDataSource.d.ts +3 -3
  72. package/es/data/CachedDataSource.js +4 -4
  73. package/es/data/CachedDataSource.js.map +1 -1
  74. package/es/data/DataSource.d.ts +3 -3
  75. package/es/data/DataSource.js +28 -21
  76. package/es/data/DataSource.js.map +1 -1
  77. package/es/dataset/dataset.d.ts +20 -2
  78. package/es/dataset/dataset.js +258 -159
  79. package/es/dataset/dataset.js.map +1 -1
  80. package/es/dataset/statistics-helper.d.ts +22 -0
  81. package/es/dataset/statistics-helper.js +114 -8
  82. package/es/dataset/statistics-helper.js.map +1 -1
  83. package/es/edit/edit-manager.js +1 -0
  84. package/es/edit/edit-manager.js.map +1 -1
  85. package/es/event/listener/table-group.js +1 -0
  86. package/es/event/listener/table-group.js.map +1 -1
  87. package/es/header-helper/header-helper.js +3 -3
  88. package/es/header-helper/header-helper.js.map +1 -1
  89. package/es/icons.js +2 -2
  90. package/es/icons.js.map +1 -1
  91. package/es/index.d.ts +1 -1
  92. package/es/index.js +1 -1
  93. package/es/index.js.map +1 -1
  94. package/es/layout/layout-helper.js +2 -2
  95. package/es/layout/layout-helper.js.map +1 -1
  96. package/es/layout/simple-header-layout.d.ts +3 -4
  97. package/es/layout/simple-header-layout.js +15 -25
  98. package/es/layout/simple-header-layout.js.map +1 -1
  99. package/es/scenegraph/graphic/contributions/group-contribution-render.js +25 -10
  100. package/es/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  101. package/es/scenegraph/layout/frozen-react.d.ts +5 -0
  102. package/es/scenegraph/layout/frozen-react.js +77 -0
  103. package/es/scenegraph/layout/frozen-react.js.map +1 -0
  104. package/es/scenegraph/layout/frozen.js +6 -4
  105. package/es/scenegraph/layout/frozen.js.map +1 -1
  106. package/es/scenegraph/scenegraph.js +3 -14
  107. package/es/scenegraph/scenegraph.js.map +1 -1
  108. package/es/scenegraph/utils/text-measure.js +2 -2
  109. package/es/scenegraph/utils/text-measure.js.map +1 -1
  110. package/es/ts-types/base-table.d.ts +14 -0
  111. package/es/ts-types/base-table.js.map +1 -1
  112. package/es/ts-types/table-engine.d.ts +1 -0
  113. package/es/ts-types/table-engine.js.map +1 -1
  114. package/es/vrender.js.map +1 -1
  115. package/package.json +5 -5
@@ -9,7 +9,7 @@ import { IndicatorDimensionKeyPlaceholder } from "../tools/global";
9
9
  import { join } from "../tools/join";
10
10
 
11
11
  export class Dataset {
12
- constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
12
+ constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative, hasExtensionRowTree, parseCustomTreeToMatchRecords) {
13
13
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
14
14
  this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
15
15
  this.colKeys = [], this.rowKeys = [], this.colKeys_normal = [], this.rowKeys_normal = [],
@@ -31,7 +31,10 @@ export class Dataset {
31
31
  this.rows = rows, this.columns = columns, this.indicatorKeys = indicatorKeys, this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys = [ ...indicatorKeys ];
32
32
  for (let m = 0; m < this.calculatedFieldDependIndicatorKeys.length; m++) -1 === this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.indexOf(this.calculatedFieldDependIndicatorKeys[m]) && this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.push(this.calculatedFieldDependIndicatorKeys[m]);
33
33
  if (this.indicatorsAsCol = indicatorsAsCol, this.indicators = indicators, this.customColTree = customColTree,
34
- this.customRowTree = customRowTree, this.colGrandTotalLabel = null !== (_p = null === (_o = null === (_m = this.totals) || void 0 === _m ? void 0 : _m.column) || void 0 === _o ? void 0 : _o.grandTotalLabel) && void 0 !== _p ? _p : "总计",
34
+ this.customRowTree = customRowTree, this.hasExtensionRowTree = hasExtensionRowTree,
35
+ this.parseCustomTreeToMatchRecords = parseCustomTreeToMatchRecords, this.parseCustomTreeToMatchRecords && (this.customColTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customColTree, "col"),
36
+ this.hasExtensionRowTree || (this.customRowTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customRowTree, "row"))),
37
+ this.colGrandTotalLabel = null !== (_p = null === (_o = null === (_m = this.totals) || void 0 === _m ? void 0 : _m.column) || void 0 === _o ? void 0 : _o.grandTotalLabel) && void 0 !== _p ? _p : "总计",
35
38
  this.colSubTotalLabel = null !== (_s = null === (_r = null === (_q = this.totals) || void 0 === _q ? void 0 : _q.column) || void 0 === _r ? void 0 : _r.subTotalLabel) && void 0 !== _s ? _s : "小计",
36
39
  this.rowGrandTotalLabel = null !== (_v = null === (_u = null === (_t = this.totals) || void 0 === _t ? void 0 : _t.row) || void 0 === _u ? void 0 : _u.grandTotalLabel) && void 0 !== _v ? _v : "总计",
37
40
  this.rowSubTotalLabel = null !== (_y = null === (_x = null === (_w = this.totals) || void 0 === _w ? void 0 : _w.row) || void 0 === _x ? void 0 : _x.subTotalLabel) && void 0 !== _y ? _y : "小计",
@@ -153,7 +156,7 @@ export class Dataset {
153
156
  return isReserved;
154
157
  }
155
158
  processRecord(record, assignedIndicatorKey) {
156
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36;
159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40;
157
160
  null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
158
161
  derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
159
162
  }));
@@ -179,109 +182,154 @@ export class Dataset {
179
182
  -1 === fieldRange.indexOf(record[field]) && fieldRange.push(record[field]);
180
183
  }
181
184
  }
182
- const colKey = [], rowKey = [];
183
185
  let isToTalRecord = !1;
184
- for (let l = 0, len1 = this.rows.length; l < len1; l++) {
185
- const rowAttr = this.rows[l];
186
- if (rowAttr in record) this.rowsHasValue[l] = !0, rowKey.push(record[rowAttr]); else if (rowAttr !== IndicatorDimensionKeyPlaceholder) {
187
- if ((null === (_d = null === (_c = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) && 0 === l && !this.rows.find((rk => rk in record))) {
188
- rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
189
- break;
190
- }
191
- if ((null === (_g = null === (_f = null === (_e = this.dataConfig) || void 0 === _e ? void 0 : _e.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions) && (null === (_k = null === (_j = null === (_h = this.dataConfig) || void 0 === _h ? void 0 : _h.totals) || void 0 === _j ? void 0 : _j.row) || void 0 === _k ? void 0 : _k.subTotalsDimensions.indexOf(this.rows[l - 1])) >= 0) {
192
- "grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
193
- break;
186
+ const colKeys = [], rowKeys = [];
187
+ if (!this.parseCustomTreeToMatchRecords || (null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.isPivotChart) || !(null === (_c = this.customRowTree) || void 0 === _c ? void 0 : _c.length) || assignedIndicatorKey || this.hasExtensionRowTree) {
188
+ const rowKey = [];
189
+ rowKeys.push({
190
+ rowKey: rowKey,
191
+ indicatorKey: assignedIndicatorKey
192
+ });
193
+ for (let l = 0, len1 = this.rows.length; l < len1; l++) {
194
+ const rowAttr = this.rows[l];
195
+ if (rowAttr in record) this.rowsHasValue[l] = !0, rowKey.push(record[rowAttr]); else if (rowAttr !== IndicatorDimensionKeyPlaceholder) {
196
+ if ((null === (_f = null === (_e = null === (_d = this.dataConfig) || void 0 === _d ? void 0 : _d.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.showGrandTotals) && 0 === l && !this.rows.find((rk => rk in record))) {
197
+ rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
198
+ break;
199
+ }
200
+ if ((null === (_j = null === (_h = null === (_g = this.dataConfig) || void 0 === _g ? void 0 : _g.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.subTotalsDimensions) && (null === (_m = null === (_l = null === (_k = this.dataConfig) || void 0 === _k ? void 0 : _k.totals) || void 0 === _l ? void 0 : _l.row) || void 0 === _m ? void 0 : _m.subTotalsDimensions.indexOf(this.rows[l - 1])) >= 0) {
201
+ "grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
202
+ break;
203
+ }
194
204
  }
195
205
  }
196
- }
197
- for (let n = 0, len2 = this.columns.length; n < len2; n++) {
198
- const colAttr = this.columns[n];
199
- if (colAttr in record) this.columnsHasValue[n] = !0, colKey.push(record[colAttr]); else if (colAttr !== IndicatorDimensionKeyPlaceholder) {
200
- if ((null === (_o = null === (_m = null === (_l = this.dataConfig) || void 0 === _l ? void 0 : _l.totals) || void 0 === _m ? void 0 : _m.column) || void 0 === _o ? void 0 : _o.showGrandTotals) && 0 === n && !this.columns.find((ck => ck in record))) {
201
- colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
202
- break;
203
- }
204
- if ((null === (_r = null === (_q = null === (_p = this.dataConfig) || void 0 === _p ? void 0 : _p.totals) || void 0 === _q ? void 0 : _q.column) || void 0 === _r ? void 0 : _r.subTotalsDimensions) && (null === (_u = null === (_t = null === (_s = this.dataConfig) || void 0 === _s ? void 0 : _s.totals) || void 0 === _t ? void 0 : _t.column) || void 0 === _u ? void 0 : _u.subTotalsDimensions.indexOf(this.columns[n - 1])) >= 0) {
205
- colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
206
- break;
207
- }
206
+ } else {
207
+ const rowTreePath = this.getFieldMatchRowDimensionPaths(record);
208
+ if (rowTreePath.length > 0) for (let i = 0, len = rowTreePath.length; i < len; i++) {
209
+ const rowPath = rowTreePath[i], rowKey = [];
210
+ let indicatorKey;
211
+ for (let j = 0, len1 = rowPath.length; j < len1; j++) isValid(rowPath[j].indicatorKey) ? indicatorKey = rowPath[j].indicatorKey : rowKey.push(rowPath[j].value);
212
+ rowKeys.push({
213
+ rowKey: rowKey,
214
+ indicatorKey: indicatorKey
215
+ });
208
216
  }
209
217
  }
210
- const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
211
- if (isToTalRecord) {
212
- this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
213
- const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
214
- for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
215
- const calculatedFieldRule = null === (_v = this.calculatedFieldRules) || void 0 === _v ? void 0 : _v.find((rule => rule.key === toComputeIndicatorKeys[i]));
216
- (null === (_x = null === (_w = this.totalRecordsTree[flatRowKey]) || void 0 === _w ? void 0 : _w[flatColKey]) || void 0 === _x ? void 0 : _x[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
217
- key: toComputeIndicatorKeys[i],
218
- dimension: toComputeIndicatorKeys[i],
219
- isRecord: !0,
220
- formatFun: null === (_z = null === (_y = this.indicators) || void 0 === _y ? void 0 : _y.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _z ? void 0 : _z.format,
221
- calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
222
- dependAggregators: this.totalRecordsTree[flatRowKey][flatColKey],
223
- dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
224
- })), toComputeIndicatorKeys[i] in record && (null === (_1 = null === (_0 = this.totalRecordsTree[flatRowKey]) || void 0 === _0 ? void 0 : _0[flatColKey]) || void 0 === _1 || _1[i].push(record));
225
- } else {
226
- const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
227
- (null === (_3 = null === (_2 = this.totalRecordsTree[flatRowKey]) || void 0 === _2 ? void 0 : _2[flatColKey]) || void 0 === _3 ? void 0 : _3[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_4 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _4 ? _4 : AggregationType.SUM]({
228
- key: toComputeIndicatorKeys[i],
229
- dimension: null !== (_5 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _5 ? _5 : toComputeIndicatorKeys[i],
230
- formatFun: null !== (_6 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _6 ? _6 : null === (_8 = null === (_7 = this.indicators) || void 0 === _7 ? void 0 : _7.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _8 ? void 0 : _8.format
231
- })), toComputeIndicatorKeys[i] in record && (null === (_10 = null === (_9 = this.totalRecordsTree[flatRowKey]) || void 0 === _9 ? void 0 : _9[flatColKey]) || void 0 === _10 || _10[i].push(record));
218
+ if (!this.parseCustomTreeToMatchRecords || (null === (_o = this.dataConfig) || void 0 === _o ? void 0 : _o.isPivotChart) || !(null === (_p = this.customColTree) || void 0 === _p ? void 0 : _p.length) || assignedIndicatorKey || this.hasExtensionRowTree) {
219
+ const colKey = [];
220
+ colKeys.push({
221
+ colKey: colKey,
222
+ indicatorKey: assignedIndicatorKey
223
+ });
224
+ for (let n = 0, len2 = this.columns.length; n < len2; n++) {
225
+ const colAttr = this.columns[n];
226
+ if (colAttr in record) this.columnsHasValue[n] = !0, colKey.push(record[colAttr]); else if (colAttr !== IndicatorDimensionKeyPlaceholder) {
227
+ if ((null === (_s = null === (_r = null === (_q = this.dataConfig) || void 0 === _q ? void 0 : _q.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showGrandTotals) && 0 === n && !this.columns.find((ck => ck in record))) {
228
+ colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
229
+ break;
230
+ }
231
+ if ((null === (_v = null === (_u = null === (_t = this.dataConfig) || void 0 === _t ? void 0 : _t.totals) || void 0 === _u ? void 0 : _u.column) || void 0 === _v ? void 0 : _v.subTotalsDimensions) && (null === (_y = null === (_x = null === (_w = this.dataConfig) || void 0 === _w ? void 0 : _w.totals) || void 0 === _x ? void 0 : _x.column) || void 0 === _y ? void 0 : _y.subTotalsDimensions.indexOf(this.columns[n - 1])) >= 0) {
232
+ colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
233
+ break;
234
+ }
235
+ }
232
236
  }
233
- return;
234
- }
235
- 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
236
- this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
237
- this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
238
- (null === (_11 = this.tree[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
239
- const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
240
- for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
241
- const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
242
- (null === (_14 = null === (_13 = this.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColKey]) || void 0 === _14 ? void 0 : _14[i]) || (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
243
- key: toComputeIndicatorKeys[i],
244
- dimension: toComputeIndicatorKeys[i],
245
- isRecord: !0,
246
- formatFun: null === (_16 = null === (_15 = this.indicators) || void 0 === _15 ? void 0 : _15.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _16 ? void 0 : _16.format,
247
- calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
248
- dependAggregators: this.tree[flatRowKey][flatColKey],
249
- dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
250
- })), null === (_18 = null === (_17 = this.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 || _18[i].push(record);
251
237
  } else {
252
- const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
253
- let needAddToAggregator = !1;
254
- if (assignedIndicatorKey) toComputeIndicatorKeys[i] === assignedIndicatorKey && (needAddToAggregator = !0); else if (null == aggRule ? void 0 : aggRule.field) if ("string" == typeof (null == aggRule ? void 0 : aggRule.field)) (null == aggRule ? void 0 : aggRule.field) in record && (needAddToAggregator = !0); else {
255
- (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
256
- } else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
257
- !(null === (_20 = null === (_19 = this.tree[flatRowKey]) || void 0 === _19 ? void 0 : _19[flatColKey]) || void 0 === _20 ? void 0 : _20[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_21 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _21 ? _21 : AggregationType.SUM]({
258
- key: toComputeIndicatorKeys[i],
259
- dimension: null !== (_22 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _22 ? _22 : toComputeIndicatorKeys[i],
260
- formatFun: null !== (_23 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _23 ? _23 : null === (_25 = null === (_24 = this.indicators) || void 0 === _24 ? void 0 : _24.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _25 ? void 0 : _25.format
261
- })), needAddToAggregator && (null === (_27 = null === (_26 = this.tree[flatRowKey]) || void 0 === _26 ? void 0 : _26[flatColKey]) || void 0 === _27 || _27[i].push(record));
238
+ const colTreePath = this.getFieldMatchColDimensionPaths(record);
239
+ if (colTreePath.length > 0) for (let i = 0, len = colTreePath.length; i < len; i++) {
240
+ const colPath = colTreePath[i], colKey = [];
241
+ let indicatorKey;
242
+ for (let j = 0, len1 = colPath.length; j < len1; j++) isValid(colPath[j].indicatorKey) ? indicatorKey = colPath[j].indicatorKey : colKey.push(colPath[j].value);
243
+ colKeys.push({
244
+ colKey: colKey,
245
+ indicatorKey: indicatorKey
246
+ });
247
+ }
262
248
  }
263
- if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
264
- if (!this.indicatorStatistics[i]) {
265
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
266
- this.indicatorStatistics[i] = {
267
- max: new this.aggregators[AggregationType.MAX]({
268
- key: this.indicatorKeys[i],
269
- dimension: this.indicatorKeys[i]
270
- }),
271
- min: new this.aggregators[AggregationType.MIN]({
272
- key: this.indicatorKeys[i],
273
- dimension: this.indicatorKeys[i]
274
- }),
275
- total: new this.aggregators[null !== (_28 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _28 ? _28 : AggregationType.SUM]({
276
- key: this.indicatorKeys[i],
277
- dimension: null !== (_29 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _29 ? _29 : this.indicatorKeys[i],
278
- formatFun: null !== (_30 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _30 ? _30 : null === (_32 = null === (_31 = this.indicators) || void 0 === _31 ? void 0 : _31.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _32 ? void 0 : _32.format
279
- })
280
- };
249
+ for (let row_i = 0; row_i < rowKeys.length; row_i++) {
250
+ const rowKey = rowKeys[row_i].rowKey;
251
+ let assignedIndicatorKey_value;
252
+ this.indicatorsAsCol || (assignedIndicatorKey_value = rowKeys[row_i].indicatorKey);
253
+ for (let col_j = 0; col_j < colKeys.length; col_j++) {
254
+ const colKey = colKeys[col_j].colKey;
255
+ this.indicatorsAsCol && (assignedIndicatorKey_value = colKeys[col_j].indicatorKey);
256
+ const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
257
+ if (isToTalRecord) {
258
+ this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
259
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
260
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
261
+ const calculatedFieldRule = null === (_z = this.calculatedFieldRules) || void 0 === _z ? void 0 : _z.find((rule => rule.key === toComputeIndicatorKeys[i]));
262
+ (null === (_1 = null === (_0 = this.totalRecordsTree[flatRowKey]) || void 0 === _0 ? void 0 : _0[flatColKey]) || void 0 === _1 ? void 0 : _1[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
263
+ key: toComputeIndicatorKeys[i],
264
+ dimension: toComputeIndicatorKeys[i],
265
+ isRecord: !0,
266
+ formatFun: null === (_3 = null === (_2 = this.indicators) || void 0 === _2 ? void 0 : _2.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _3 ? void 0 : _3.format,
267
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
268
+ dependAggregators: this.totalRecordsTree[flatRowKey][flatColKey],
269
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
270
+ })), toComputeIndicatorKeys[i] in record && (null === (_5 = null === (_4 = this.totalRecordsTree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || void 0 === _5 || _5[i].push(record));
271
+ } else {
272
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
273
+ (null === (_7 = null === (_6 = this.totalRecordsTree[flatRowKey]) || void 0 === _6 ? void 0 : _6[flatColKey]) || void 0 === _7 ? void 0 : _7[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_8 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _8 ? _8 : AggregationType.SUM]({
274
+ key: toComputeIndicatorKeys[i],
275
+ dimension: null !== (_9 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _9 ? _9 : toComputeIndicatorKeys[i],
276
+ formatFun: null !== (_10 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _10 ? _10 : null === (_12 = null === (_11 = this.indicators) || void 0 === _11 ? void 0 : _11.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _12 ? void 0 : _12.format
277
+ })), toComputeIndicatorKeys[i] in record && (null === (_14 = null === (_13 = this.totalRecordsTree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColKey]) || void 0 === _14 || _14[i].push(record));
278
+ }
279
+ return;
280
+ }
281
+ 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
282
+ this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
283
+ this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
284
+ (null === (_15 = this.tree[flatRowKey]) || void 0 === _15 ? void 0 : _15[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
285
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
286
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
287
+ const calculatedFieldRule = null === (_16 = this.calculatedFieldRules) || void 0 === _16 ? void 0 : _16.find((rule => rule.key === toComputeIndicatorKeys[i]));
288
+ (null === (_18 = null === (_17 = this.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 ? void 0 : _18[i]) || (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
289
+ key: toComputeIndicatorKeys[i],
290
+ dimension: toComputeIndicatorKeys[i],
291
+ isRecord: !0,
292
+ formatFun: null === (_20 = null === (_19 = this.indicators) || void 0 === _19 ? void 0 : _19.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _20 ? void 0 : _20.format,
293
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
294
+ dependAggregators: this.tree[flatRowKey][flatColKey],
295
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
296
+ })), null === (_22 = null === (_21 = this.tree[flatRowKey]) || void 0 === _21 ? void 0 : _21[flatColKey]) || void 0 === _22 || _22[i].push(record);
297
+ } else {
298
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
299
+ let needAddToAggregator = !1;
300
+ if (assignedIndicatorKey_value) assignedIndicatorKey === assignedIndicatorKey_value ? toComputeIndicatorKeys[i] === assignedIndicatorKey_value && (needAddToAggregator = !0) : toComputeIndicatorKeys[i] === assignedIndicatorKey_value && toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0); else if (null == aggRule ? void 0 : aggRule.field) if ("string" == typeof (null == aggRule ? void 0 : aggRule.field)) (null == aggRule ? void 0 : aggRule.field) in record && (needAddToAggregator = !0); else {
301
+ (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
302
+ } else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
303
+ !(null === (_24 = null === (_23 = this.tree[flatRowKey]) || void 0 === _23 ? void 0 : _23[flatColKey]) || void 0 === _24 ? void 0 : _24[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_25 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _25 ? _25 : AggregationType.SUM]({
304
+ key: toComputeIndicatorKeys[i],
305
+ dimension: null !== (_26 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _26 ? _26 : toComputeIndicatorKeys[i],
306
+ formatFun: null !== (_27 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _27 ? _27 : null === (_29 = null === (_28 = this.indicators) || void 0 === _28 ? void 0 : _28.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _29 ? void 0 : _29.format
307
+ })), needAddToAggregator && (null === (_31 = null === (_30 = this.tree[flatRowKey]) || void 0 === _30 ? void 0 : _30[flatColKey]) || void 0 === _31 || _31[i].push(record));
308
+ }
309
+ if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
310
+ if (!this.indicatorStatistics[i]) {
311
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
312
+ this.indicatorStatistics[i] = {
313
+ max: new this.aggregators[AggregationType.MAX]({
314
+ key: this.indicatorKeys[i],
315
+ dimension: this.indicatorKeys[i]
316
+ }),
317
+ min: new this.aggregators[AggregationType.MIN]({
318
+ key: this.indicatorKeys[i],
319
+ dimension: this.indicatorKeys[i]
320
+ }),
321
+ total: new this.aggregators[null !== (_32 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _32 ? _32 : AggregationType.SUM]({
322
+ key: this.indicatorKeys[i],
323
+ dimension: null !== (_33 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _33 ? _33 : this.indicatorKeys[i],
324
+ formatFun: null !== (_34 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _34 ? _34 : null === (_36 = null === (_35 = this.indicators) || void 0 === _35 ? void 0 : _35.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _36 ? void 0 : _36.format
325
+ })
326
+ };
327
+ }
328
+ this.indicatorStatistics[i].max.push(null === (_38 = null === (_37 = this.tree[flatRowKey]) || void 0 === _37 ? void 0 : _37[flatColKey]) || void 0 === _38 ? void 0 : _38[i].value()),
329
+ this.indicatorStatistics[i].min.push(null === (_40 = null === (_39 = this.tree[flatRowKey]) || void 0 === _39 ? void 0 : _39[flatColKey]) || void 0 === _40 ? void 0 : _40[i].value()),
330
+ this.indicatorStatistics[i].total.push(record);
331
+ }
281
332
  }
282
- this.indicatorStatistics[i].max.push(null === (_34 = null === (_33 = this.tree[flatRowKey]) || void 0 === _33 ? void 0 : _33[flatColKey]) || void 0 === _34 ? void 0 : _34[i].value()),
283
- this.indicatorStatistics[i].min.push(null === (_36 = null === (_35 = this.tree[flatRowKey]) || void 0 === _35 ? void 0 : _35[flatColKey]) || void 0 === _36 ? void 0 : _36[i].value()),
284
- this.indicatorStatistics[i].total.push(record);
285
333
  }
286
334
  }
287
335
  updateSortRules(sortRules) {
@@ -290,10 +338,10 @@ export class Dataset {
290
338
  this.customColTree || (this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns.filter(((key, index) => this.columnsHasValue[index])), this.indicatorsAsCol ? this.indicators : void 0, this.colsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotalsOnLeft) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showSubTotalsOnLeft) && void 0 !== _t && _t));
291
339
  }
292
340
  updateFilterRules(filterRules, isResetTree = !1) {
293
- var _a;
294
- if (this.filterRules = filterRules, this.filteredRecords = void 0, isResetTree) this.tree = {}; else for (const treeRowKey in this.tree) for (const treeColKey in this.tree[treeRowKey]) for (let i = 0; i < this.tree[treeRowKey][treeColKey].length; i++) this.tree[treeRowKey][treeColKey][i].reset();
341
+ var _a, _b;
342
+ if (this.filterRules = filterRules, this.filteredRecords = void 0, isResetTree) this.tree = {}; else for (const treeRowKey in this.tree) for (const treeColKey in this.tree[treeRowKey]) for (let i = 0; i < this.tree[treeRowKey][treeColKey].length; i++) null === (_a = this.tree[treeRowKey][treeColKey][i]) || void 0 === _a || _a.reset();
295
343
  this.collectedValues = {}, this.processRecords(), this.processCollectedValuesWithSumBy(),
296
- this.processCollectedValuesWithSortBy(), this.totalStatistics(), (null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.isPivotChart) && this.cacheDeminsionCollectedValues();
344
+ this.processCollectedValuesWithSortBy(), this.totalStatistics(), (null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.isPivotChart) && this.cacheDeminsionCollectedValues();
297
345
  }
298
346
  getAggregatorRule(indicatorKey) {
299
347
  var _a;
@@ -394,74 +442,75 @@ export class Dataset {
394
442
  }
395
443
  totalStatistics() {
396
444
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
397
- const that = this;
398
- if ((null === (_b = null === (_a = null == that ? void 0 : that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = null == that ? void 0 : that.totals) || void 0 === _c ? void 0 : _c.column) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 || (null === (_g = null === (_f = null == that ? void 0 : that.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions) && (null === (_k = null === (_j = null === (_h = null == that ? void 0 : that.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.subTotalsDimensions) || void 0 === _k ? void 0 : _k.length) >= 1 || (null === (_m = null === (_l = null == that ? void 0 : that.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || (null === (_p = null === (_o = null == that ? void 0 : that.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotals)) {
399
- const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
400
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
401
- if (null === (_b = null === (_a = this.totalRecordsTree) || void 0 === _a ? void 0 : _a[flatRowKey]) || void 0 === _b ? void 0 : _b[flatColKey]) return void (this.tree[flatRowKey][flatColKey] = null === (_d = null === (_c = this.totalRecordsTree) || void 0 === _c ? void 0 : _c[flatRowKey]) || void 0 === _d ? void 0 : _d[flatColKey]);
402
- const colKey = flatColKey.split(this.stringJoinChar);
403
- if ((null === (_f = null === (_e = that.totals) || void 0 === _e ? void 0 : _e.column) || void 0 === _f ? void 0 : _f.subTotalsDimensions) && (null === (_j = null === (_h = null === (_g = that.totals) || void 0 === _g ? void 0 : _g.column) || void 0 === _h ? void 0 : _h.subTotalsDimensions) || void 0 === _j ? void 0 : _j.length) > 0 && !1 !== that.totals.column.showSubTotals) for (let i = 0, len = null === (_m = null === (_l = null === (_k = that.totals) || void 0 === _k ? void 0 : _k.column) || void 0 === _l ? void 0 : _l.subTotalsDimensions) || void 0 === _m ? void 0 : _m.length; i < len; i++) {
404
- const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
405
- if (dimensionIndex >= 0) {
406
- const colTotalKey = colKey.slice(0, dimensionIndex + 1);
407
- colTotalKey.push(that.colSubTotalLabel);
408
- const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
409
- if (null === (_p = null === (_o = this.totalRecordsTree) || void 0 === _o ? void 0 : _o[flatRowKey]) || void 0 === _p ? void 0 : _p[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_r = null === (_q = this.totalRecordsTree) || void 0 === _q ? void 0 : _q[flatRowKey]) || void 0 === _r ? void 0 : _r[flatColTotalKey]);
410
- this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
411
- const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
412
- for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
413
- const calculatedFieldRule = null === (_s = this.calculatedFieldRules) || void 0 === _s ? void 0 : _s.find((rule => rule.key === toComputeIndicatorKeys[i]));
414
- (null === (_u = null === (_t = this.tree[flatRowKey]) || void 0 === _t ? void 0 : _t[flatColTotalKey]) || void 0 === _u ? void 0 : _u[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
415
- key: toComputeIndicatorKeys[i],
416
- dimension: toComputeIndicatorKeys[i],
417
- isRecord: !0,
418
- formatFun: null === (_w = null === (_v = this.indicators) || void 0 === _v ? void 0 : _v.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _w ? void 0 : _w.format,
419
- calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
420
- dependAggregators: this.tree[flatRowKey][flatColTotalKey],
421
- dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
422
- })), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_y = null === (_x = that.tree[flatRowKey]) || void 0 === _x ? void 0 : _x[flatColKey]) || void 0 === _y ? void 0 : _y[i]);
423
- } else {
424
- if (!this.tree[flatRowKey][flatColTotalKey][i]) {
425
- const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
426
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_z = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _z ? _z : AggregationType.SUM]({
427
- key: toComputeIndicatorKeys[i],
428
- dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
429
- formatFun: null !== (_1 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _1 ? _1 : null === (_3 = null === (_2 = this.indicators) || void 0 === _2 ? void 0 : _2.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _3 ? void 0 : _3.format
430
- });
431
- }
432
- flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_5 = null === (_4 = that.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || void 0 === _5 ? void 0 : _5[i]);
433
- }
434
- }
435
- }
436
- if ((null === (_7 = null === (_6 = that.totals) || void 0 === _6 ? void 0 : _6.column) || void 0 === _7 ? void 0 : _7.showGrandTotals) || 0 === this.rows.length) {
437
- const flatColTotalKey = that.colGrandTotalLabel;
438
- if (null === (_9 = null === (_8 = this.totalRecordsTree) || void 0 === _8 ? void 0 : _8[flatRowKey]) || void 0 === _9 ? void 0 : _9[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_11 = null === (_10 = this.totalRecordsTree) || void 0 === _10 ? void 0 : _10[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColTotalKey]);
445
+ const that = this, colCompute = (flatRowKey, flatColKey) => {
446
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
447
+ if (null === (_b = null === (_a = this.totalRecordsTree) || void 0 === _a ? void 0 : _a[flatRowKey]) || void 0 === _b ? void 0 : _b[flatColKey]) return this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
448
+ void (this.tree[flatRowKey][flatColKey] = null === (_d = null === (_c = this.totalRecordsTree) || void 0 === _c ? void 0 : _c[flatRowKey]) || void 0 === _d ? void 0 : _d[flatColKey]);
449
+ const colKey = flatColKey.split(this.stringJoinChar);
450
+ if ((null === (_f = null === (_e = that.totals) || void 0 === _e ? void 0 : _e.column) || void 0 === _f ? void 0 : _f.subTotalsDimensions) && (null === (_j = null === (_h = null === (_g = that.totals) || void 0 === _g ? void 0 : _g.column) || void 0 === _h ? void 0 : _h.subTotalsDimensions) || void 0 === _j ? void 0 : _j.length) > 0 && !1 !== that.totals.column.showSubTotals) for (let i = 0, len = null === (_m = null === (_l = null === (_k = that.totals) || void 0 === _k ? void 0 : _k.column) || void 0 === _l ? void 0 : _l.subTotalsDimensions) || void 0 === _m ? void 0 : _m.length; i < len; i++) {
451
+ const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
452
+ if (dimensionIndex >= 0) {
453
+ const colTotalKey = colKey.slice(0, dimensionIndex + 1);
454
+ colTotalKey.push(that.colSubTotalLabel);
455
+ const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
456
+ if (null === (_p = null === (_o = this.totalRecordsTree) || void 0 === _o ? void 0 : _o[flatRowKey]) || void 0 === _p ? void 0 : _p[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_r = null === (_q = this.totalRecordsTree) || void 0 === _q ? void 0 : _q[flatRowKey]) || void 0 === _r ? void 0 : _r[flatColTotalKey]);
439
457
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
440
458
  const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
441
459
  for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
442
- const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
443
- (null === (_14 = null === (_13 = this.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColTotalKey]) || void 0 === _14 ? void 0 : _14[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
460
+ const calculatedFieldRule = null === (_s = this.calculatedFieldRules) || void 0 === _s ? void 0 : _s.find((rule => rule.key === toComputeIndicatorKeys[i]));
461
+ (null === (_u = null === (_t = this.tree[flatRowKey]) || void 0 === _t ? void 0 : _t[flatColTotalKey]) || void 0 === _u ? void 0 : _u[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
444
462
  key: toComputeIndicatorKeys[i],
445
463
  dimension: toComputeIndicatorKeys[i],
446
464
  isRecord: !0,
447
- formatFun: null === (_16 = null === (_15 = this.indicators) || void 0 === _15 ? void 0 : _15.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _16 ? void 0 : _16.format,
465
+ formatFun: null === (_w = null === (_v = this.indicators) || void 0 === _v ? void 0 : _v.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _w ? void 0 : _w.format,
448
466
  calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
449
467
  dependAggregators: this.tree[flatRowKey][flatColTotalKey],
450
468
  dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
451
- })), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_18 = null === (_17 = that.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 ? void 0 : _18[i]);
469
+ })), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_y = null === (_x = that.tree[flatRowKey]) || void 0 === _x ? void 0 : _x[flatColKey]) || void 0 === _y ? void 0 : _y[i]);
452
470
  } else {
453
471
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
454
472
  const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
455
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_19 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _19 ? _19 : AggregationType.SUM]({
473
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_z = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _z ? _z : AggregationType.SUM]({
456
474
  key: toComputeIndicatorKeys[i],
457
- dimension: null !== (_20 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _20 ? _20 : toComputeIndicatorKeys[i],
458
- formatFun: null !== (_21 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _21 ? _21 : null === (_23 = null === (_22 = this.indicators) || void 0 === _22 ? void 0 : _22.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _23 ? void 0 : _23.format
475
+ dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
476
+ formatFun: null !== (_1 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _1 ? _1 : null === (_3 = null === (_2 = this.indicators) || void 0 === _2 ? void 0 : _2.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _3 ? void 0 : _3.format
459
477
  });
460
478
  }
461
- flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_25 = null === (_24 = that.tree[flatRowKey]) || void 0 === _24 ? void 0 : _24[flatColKey]) || void 0 === _25 ? void 0 : _25[i]);
479
+ flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_5 = null === (_4 = that.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || void 0 === _5 ? void 0 : _5[i]);
462
480
  }
463
481
  }
464
- };
482
+ }
483
+ if ((null === (_7 = null === (_6 = that.totals) || void 0 === _6 ? void 0 : _6.column) || void 0 === _7 ? void 0 : _7.showGrandTotals) || 0 === this.rows.length) {
484
+ const flatColTotalKey = that.colGrandTotalLabel;
485
+ if (null === (_9 = null === (_8 = this.totalRecordsTree) || void 0 === _8 ? void 0 : _8[flatRowKey]) || void 0 === _9 ? void 0 : _9[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_11 = null === (_10 = this.totalRecordsTree) || void 0 === _10 ? void 0 : _10[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColTotalKey]);
486
+ this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
487
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
488
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
489
+ const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
490
+ (null === (_14 = null === (_13 = this.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColTotalKey]) || void 0 === _14 ? void 0 : _14[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
491
+ key: toComputeIndicatorKeys[i],
492
+ dimension: toComputeIndicatorKeys[i],
493
+ isRecord: !0,
494
+ formatFun: null === (_16 = null === (_15 = this.indicators) || void 0 === _15 ? void 0 : _15.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _16 ? void 0 : _16.format,
495
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
496
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
497
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
498
+ })), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_18 = null === (_17 = that.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 ? void 0 : _18[i]);
499
+ } else {
500
+ if (!this.tree[flatRowKey][flatColTotalKey][i]) {
501
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
502
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_19 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _19 ? _19 : AggregationType.SUM]({
503
+ key: toComputeIndicatorKeys[i],
504
+ dimension: null !== (_20 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _20 ? _20 : toComputeIndicatorKeys[i],
505
+ formatFun: null !== (_21 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _21 ? _21 : null === (_23 = null === (_22 = this.indicators) || void 0 === _22 ? void 0 : _22.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _23 ? void 0 : _23.format
506
+ });
507
+ }
508
+ flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_25 = null === (_24 = that.tree[flatRowKey]) || void 0 === _24 ? void 0 : _24[flatColKey]) || void 0 === _25 ? void 0 : _25[i]);
509
+ }
510
+ }
511
+ };
512
+ if ((null === (_b = null === (_a = null == that ? void 0 : that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = null == that ? void 0 : that.totals) || void 0 === _c ? void 0 : _c.column) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 || (null === (_g = null === (_f = null == that ? void 0 : that.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions) && (null === (_k = null === (_j = null === (_h = null == that ? void 0 : that.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.subTotalsDimensions) || void 0 === _k ? void 0 : _k.length) >= 1 || (null === (_m = null === (_l = null == that ? void 0 : that.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || (null === (_p = null === (_o = null == that ? void 0 : that.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotals)) {
513
+ const rowTotalKeys = [];
465
514
  Object.keys(that.tree).forEach((flatRowKey => {
466
515
  const rowKey = flatRowKey.split(this.stringJoinChar);
467
516
  Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
@@ -535,6 +584,7 @@ export class Dataset {
535
584
  }));
536
585
  }));
537
586
  }
587
+ for (const flatRowKey in that.totalRecordsTree) for (const flatColKey in that.totalRecordsTree[flatRowKey]) colCompute(flatRowKey, flatColKey);
538
588
  }
539
589
  ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel) {
540
590
  const result = [], concatStr = this.stringJoinChar, map = new Map;
@@ -632,14 +682,6 @@ export class Dataset {
632
682
  }
633
683
  return result;
634
684
  }
635
- TreeToArr(tree) {
636
- const result = [];
637
- function getPath(node, arr) {
638
- var _a;
639
- arr.push(node.id), node.children.length > 0 ? null === (_a = node.children) || void 0 === _a || _a.forEach((childItem => getPath(childItem, [ ...arr ]))) : result.push(arr);
640
- }
641
- return tree.forEach((treeNode => getPath(treeNode, []))), result;
642
- }
643
685
  cacheDeminsionCollectedValues() {
644
686
  for (const key in this.collectValuesBy) "xField" !== this.collectValuesBy[key].type && "yField" !== this.collectValuesBy[key].type || (this.dataConfig.dimensionSortArray ? this.cacheCollectedValues[key] = arraySortByAnotherArray(this.collectedValues[key], this.dataConfig.dimensionSortArray) : this.cacheCollectedValues[key] = this.collectedValues[key]);
645
687
  }
@@ -669,6 +711,9 @@ export class Dataset {
669
711
  this.rowFlatKeys = {}, this.colFlatKeys = {}, this.tree = {}, this.processRecords();
670
712
  }
671
713
  }
714
+ _rowTreeHasChanged() {
715
+ this.hasExtensionRowTree || (this.customRowTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customRowTree, "row"));
716
+ }
672
717
  changeDataConfig(dataConfig) {
673
718
  this.rows = dataConfig.rows, this.columns = dataConfig.columns;
674
719
  }
@@ -679,6 +724,60 @@ export class Dataset {
679
724
  }
680
725
  Array.isArray(this.records) && this.records.push(records);
681
726
  }
727
+ customTreeToDimensionPathArr(tree, type) {
728
+ const result = [], that = this;
729
+ function getPath(node, arr) {
730
+ var _a, _b, _c;
731
+ node.virtual || ((null === (_a = arr[arr.length - 1]) || void 0 === _a ? void 0 : _a.childKeys) && node.dimensionKey && -1 === arr[arr.length - 1].childKeys.indexOf(node.dimensionKey) && node.dimensionKey !== arr[arr.length - 1].dimensionKey && arr[arr.length - 1].childKeys.push(node.dimensionKey),
732
+ arr.push({
733
+ dimensionKey: isValid(node.indicatorKey) ? void 0 : node.dimensionKey,
734
+ value: node.value,
735
+ indicatorKey: node.indicatorKey,
736
+ virtual: node.virtual
737
+ })), (null === (_b = node.children) || void 0 === _b ? void 0 : _b.length) > 0 ? ("tree" === that.rowHierarchyType && "row" === type && (arr[arr.length - 1].childKeys = [],
738
+ result.push([ ...arr ])), null === (_c = node.children) || void 0 === _c || _c.forEach((childItem => getPath(childItem, [ ...arr ])))) : result.push(arr);
739
+ }
740
+ return null == tree || tree.forEach((treeNode => getPath(treeNode, []))), result;
741
+ }
742
+ getFieldMatchColDimensionPaths(record) {
743
+ var _a, _b;
744
+ const fieldMatchDimensionPaths = [];
745
+ for (let i = 0; null !== (_b = i < (null === (_a = this.customColTreeDimensionPaths) || void 0 === _a ? void 0 : _a.length)) && void 0 !== _b && _b; i++) {
746
+ const dimensionPath = this.customColTreeDimensionPaths[i];
747
+ let isMatch = !0;
748
+ for (let j = 0; j < dimensionPath.length; j++) {
749
+ const dimension = dimensionPath[j];
750
+ if (dimension.dimensionKey && record[dimension.dimensionKey] !== dimension.value || dimension.indicatorKey && void 0 === record[dimension.indicatorKey]) {
751
+ isMatch = !1;
752
+ break;
753
+ }
754
+ }
755
+ isMatch && fieldMatchDimensionPaths.push(dimensionPath);
756
+ }
757
+ return fieldMatchDimensionPaths;
758
+ }
759
+ getFieldMatchRowDimensionPaths(record) {
760
+ var _a, _b;
761
+ const fieldMatchDimensionPaths = [];
762
+ for (let i = 0; null !== (_b = i < (null === (_a = this.customRowTreeDimensionPaths) || void 0 === _a ? void 0 : _a.length)) && void 0 !== _b && _b; i++) {
763
+ const dimensionPath = this.customRowTreeDimensionPaths[i];
764
+ let isMatch = !0;
765
+ for (let j = 0; j < dimensionPath.length; j++) {
766
+ const dimension = dimensionPath[j];
767
+ if (dimension.dimensionKey && record[dimension.dimensionKey] !== dimension.value || dimension.indicatorKey && void 0 === record[dimension.indicatorKey]) {
768
+ isMatch = !1;
769
+ break;
770
+ }
771
+ if (dimension.childKeys && j === dimensionPath.length - 1 && dimension.childKeys.length > 0 && dimension.childKeys.find((key => isValid(record[key])))) {
772
+ isMatch = !1;
773
+ break;
774
+ }
775
+ }
776
+ isMatch && (this.indicatorsAsCol || "tree" !== this.rowHierarchyType || dimensionPath.find((path => path.indicatorKey)) || (isMatch = !1)),
777
+ isMatch && fieldMatchDimensionPaths.push(dimensionPath);
778
+ }
779
+ return fieldMatchDimensionPaths;
780
+ }
682
781
  }
683
782
 
684
783
  function arraySortByAnotherArray(array, sortArray) {