@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
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  const vutils_1 = require("@visactor/vutils"), ts_types_1 = require("../ts-types"), statistics_helper_1 = require("./statistics-helper"), global_1 = require("../tools/global"), join_1 = require("../tools/join");
8
8
 
9
9
  class Dataset {
10
- constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
10
+ constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative, hasExtensionRowTree, parseCustomTreeToMatchRecords) {
11
11
  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;
12
12
  this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
13
13
  this.colKeys = [], this.rowKeys = [], this.colKeys_normal = [], this.rowKeys_normal = [],
@@ -29,7 +29,10 @@ class Dataset {
29
29
  this.rows = rows, this.columns = columns, this.indicatorKeys = indicatorKeys, this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys = [ ...indicatorKeys ];
30
30
  for (let m = 0; m < this.calculatedFieldDependIndicatorKeys.length; m++) -1 === this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.indexOf(this.calculatedFieldDependIndicatorKeys[m]) && this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.push(this.calculatedFieldDependIndicatorKeys[m]);
31
31
  if (this.indicatorsAsCol = indicatorsAsCol, this.indicators = indicators, this.customColTree = customColTree,
32
- 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 : "总计",
32
+ this.customRowTree = customRowTree, this.hasExtensionRowTree = hasExtensionRowTree,
33
+ this.parseCustomTreeToMatchRecords = parseCustomTreeToMatchRecords, this.parseCustomTreeToMatchRecords && (this.customColTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customColTree, "col"),
34
+ this.hasExtensionRowTree || (this.customRowTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customRowTree, "row"))),
35
+ 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 : "总计",
33
36
  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 : "小计",
34
37
  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 : "总计",
35
38
  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 : "小计",
@@ -155,7 +158,7 @@ class Dataset {
155
158
  return isReserved;
156
159
  }
157
160
  processRecord(record, assignedIndicatorKey) {
158
- 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;
161
+ 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;
159
162
  null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
160
163
  derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
161
164
  }));
@@ -181,109 +184,154 @@ class Dataset {
181
184
  -1 === fieldRange.indexOf(record[field]) && fieldRange.push(record[field]);
182
185
  }
183
186
  }
184
- const colKey = [], rowKey = [];
185
187
  let isToTalRecord = !1;
186
- for (let l = 0, len1 = this.rows.length; l < len1; l++) {
187
- const rowAttr = this.rows[l];
188
- if (rowAttr in record) this.rowsHasValue[l] = !0, rowKey.push(record[rowAttr]); else if (rowAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
189
- 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))) {
190
- rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
191
- break;
192
- }
193
- 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) {
194
- "grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
195
- break;
188
+ const colKeys = [], rowKeys = [];
189
+ 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) {
190
+ const rowKey = [];
191
+ rowKeys.push({
192
+ rowKey: rowKey,
193
+ indicatorKey: assignedIndicatorKey
194
+ });
195
+ for (let l = 0, len1 = this.rows.length; l < len1; l++) {
196
+ const rowAttr = this.rows[l];
197
+ if (rowAttr in record) this.rowsHasValue[l] = !0, rowKey.push(record[rowAttr]); else if (rowAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
198
+ 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))) {
199
+ rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
200
+ break;
201
+ }
202
+ 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) {
203
+ "grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
204
+ break;
205
+ }
196
206
  }
197
207
  }
198
- }
199
- for (let n = 0, len2 = this.columns.length; n < len2; n++) {
200
- const colAttr = this.columns[n];
201
- if (colAttr in record) this.columnsHasValue[n] = !0, colKey.push(record[colAttr]); else if (colAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
202
- 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))) {
203
- colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
204
- break;
205
- }
206
- 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) {
207
- colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
208
- break;
209
- }
208
+ } else {
209
+ const rowTreePath = this.getFieldMatchRowDimensionPaths(record);
210
+ if (rowTreePath.length > 0) for (let i = 0, len = rowTreePath.length; i < len; i++) {
211
+ const rowPath = rowTreePath[i], rowKey = [];
212
+ let indicatorKey;
213
+ for (let j = 0, len1 = rowPath.length; j < len1; j++) (0, vutils_1.isValid)(rowPath[j].indicatorKey) ? indicatorKey = rowPath[j].indicatorKey : rowKey.push(rowPath[j].value);
214
+ rowKeys.push({
215
+ rowKey: rowKey,
216
+ indicatorKey: indicatorKey
217
+ });
210
218
  }
211
219
  }
212
- const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
213
- if (isToTalRecord) {
214
- this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
215
- const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
216
- for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
217
- const calculatedFieldRule = null === (_v = this.calculatedFieldRules) || void 0 === _v ? void 0 : _v.find((rule => rule.key === toComputeIndicatorKeys[i]));
218
- (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[ts_types_1.AggregationType.RECALCULATE]({
219
- key: toComputeIndicatorKeys[i],
220
- dimension: toComputeIndicatorKeys[i],
221
- isRecord: !0,
222
- 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,
223
- calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
224
- dependAggregators: this.totalRecordsTree[flatRowKey][flatColKey],
225
- dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
226
- })), 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));
227
- } else {
228
- const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
229
- (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 : ts_types_1.AggregationType.SUM]({
230
- key: toComputeIndicatorKeys[i],
231
- dimension: null !== (_5 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _5 ? _5 : toComputeIndicatorKeys[i],
232
- 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
233
- })), 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));
220
+ 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) {
221
+ const colKey = [];
222
+ colKeys.push({
223
+ colKey: colKey,
224
+ indicatorKey: assignedIndicatorKey
225
+ });
226
+ for (let n = 0, len2 = this.columns.length; n < len2; n++) {
227
+ const colAttr = this.columns[n];
228
+ if (colAttr in record) this.columnsHasValue[n] = !0, colKey.push(record[colAttr]); else if (colAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
229
+ 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))) {
230
+ colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
231
+ break;
232
+ }
233
+ 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) {
234
+ colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
235
+ break;
236
+ }
237
+ }
234
238
  }
235
- return;
236
- }
237
- 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
238
- this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
239
- this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
240
- (null === (_11 = this.tree[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
241
- const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
242
- for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
243
- const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
244
- (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[ts_types_1.AggregationType.RECALCULATE]({
245
- key: toComputeIndicatorKeys[i],
246
- dimension: toComputeIndicatorKeys[i],
247
- isRecord: !0,
248
- 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,
249
- calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
250
- dependAggregators: this.tree[flatRowKey][flatColKey],
251
- dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
252
- })), null === (_18 = null === (_17 = this.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 || _18[i].push(record);
253
239
  } else {
254
- const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
255
- let needAddToAggregator = !1;
256
- 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 {
257
- (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
258
- } else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
259
- !(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 : ts_types_1.AggregationType.SUM]({
260
- key: toComputeIndicatorKeys[i],
261
- dimension: null !== (_22 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _22 ? _22 : toComputeIndicatorKeys[i],
262
- 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
263
- })), needAddToAggregator && (null === (_27 = null === (_26 = this.tree[flatRowKey]) || void 0 === _26 ? void 0 : _26[flatColKey]) || void 0 === _27 || _27[i].push(record));
240
+ const colTreePath = this.getFieldMatchColDimensionPaths(record);
241
+ if (colTreePath.length > 0) for (let i = 0, len = colTreePath.length; i < len; i++) {
242
+ const colPath = colTreePath[i], colKey = [];
243
+ let indicatorKey;
244
+ for (let j = 0, len1 = colPath.length; j < len1; j++) (0, vutils_1.isValid)(colPath[j].indicatorKey) ? indicatorKey = colPath[j].indicatorKey : colKey.push(colPath[j].value);
245
+ colKeys.push({
246
+ colKey: colKey,
247
+ indicatorKey: indicatorKey
248
+ });
249
+ }
264
250
  }
265
- if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
266
- if (!this.indicatorStatistics[i]) {
267
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
268
- this.indicatorStatistics[i] = {
269
- max: new this.aggregators[ts_types_1.AggregationType.MAX]({
270
- key: this.indicatorKeys[i],
271
- dimension: this.indicatorKeys[i]
272
- }),
273
- min: new this.aggregators[ts_types_1.AggregationType.MIN]({
274
- key: this.indicatorKeys[i],
275
- dimension: this.indicatorKeys[i]
276
- }),
277
- total: new this.aggregators[null !== (_28 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _28 ? _28 : ts_types_1.AggregationType.SUM]({
278
- key: this.indicatorKeys[i],
279
- dimension: null !== (_29 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _29 ? _29 : this.indicatorKeys[i],
280
- 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
281
- })
282
- };
251
+ for (let row_i = 0; row_i < rowKeys.length; row_i++) {
252
+ const rowKey = rowKeys[row_i].rowKey;
253
+ let assignedIndicatorKey_value;
254
+ this.indicatorsAsCol || (assignedIndicatorKey_value = rowKeys[row_i].indicatorKey);
255
+ for (let col_j = 0; col_j < colKeys.length; col_j++) {
256
+ const colKey = colKeys[col_j].colKey;
257
+ this.indicatorsAsCol && (assignedIndicatorKey_value = colKeys[col_j].indicatorKey);
258
+ const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
259
+ if (isToTalRecord) {
260
+ this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
261
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
262
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
263
+ const calculatedFieldRule = null === (_z = this.calculatedFieldRules) || void 0 === _z ? void 0 : _z.find((rule => rule.key === toComputeIndicatorKeys[i]));
264
+ (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[ts_types_1.AggregationType.RECALCULATE]({
265
+ key: toComputeIndicatorKeys[i],
266
+ dimension: toComputeIndicatorKeys[i],
267
+ isRecord: !0,
268
+ 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,
269
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
270
+ dependAggregators: this.totalRecordsTree[flatRowKey][flatColKey],
271
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
272
+ })), 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));
273
+ } else {
274
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
275
+ (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 : ts_types_1.AggregationType.SUM]({
276
+ key: toComputeIndicatorKeys[i],
277
+ dimension: null !== (_9 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _9 ? _9 : toComputeIndicatorKeys[i],
278
+ 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
279
+ })), 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));
280
+ }
281
+ return;
282
+ }
283
+ 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
284
+ this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
285
+ this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
286
+ (null === (_15 = this.tree[flatRowKey]) || void 0 === _15 ? void 0 : _15[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
287
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
288
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
289
+ const calculatedFieldRule = null === (_16 = this.calculatedFieldRules) || void 0 === _16 ? void 0 : _16.find((rule => rule.key === toComputeIndicatorKeys[i]));
290
+ (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[ts_types_1.AggregationType.RECALCULATE]({
291
+ key: toComputeIndicatorKeys[i],
292
+ dimension: toComputeIndicatorKeys[i],
293
+ isRecord: !0,
294
+ 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,
295
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
296
+ dependAggregators: this.tree[flatRowKey][flatColKey],
297
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
298
+ })), null === (_22 = null === (_21 = this.tree[flatRowKey]) || void 0 === _21 ? void 0 : _21[flatColKey]) || void 0 === _22 || _22[i].push(record);
299
+ } else {
300
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
301
+ let needAddToAggregator = !1;
302
+ 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 {
303
+ (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
304
+ } else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
305
+ !(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 : ts_types_1.AggregationType.SUM]({
306
+ key: toComputeIndicatorKeys[i],
307
+ dimension: null !== (_26 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _26 ? _26 : toComputeIndicatorKeys[i],
308
+ 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
309
+ })), needAddToAggregator && (null === (_31 = null === (_30 = this.tree[flatRowKey]) || void 0 === _30 ? void 0 : _30[flatColKey]) || void 0 === _31 || _31[i].push(record));
310
+ }
311
+ if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
312
+ if (!this.indicatorStatistics[i]) {
313
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
314
+ this.indicatorStatistics[i] = {
315
+ max: new this.aggregators[ts_types_1.AggregationType.MAX]({
316
+ key: this.indicatorKeys[i],
317
+ dimension: this.indicatorKeys[i]
318
+ }),
319
+ min: new this.aggregators[ts_types_1.AggregationType.MIN]({
320
+ key: this.indicatorKeys[i],
321
+ dimension: this.indicatorKeys[i]
322
+ }),
323
+ total: new this.aggregators[null !== (_32 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _32 ? _32 : ts_types_1.AggregationType.SUM]({
324
+ key: this.indicatorKeys[i],
325
+ dimension: null !== (_33 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _33 ? _33 : this.indicatorKeys[i],
326
+ 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
327
+ })
328
+ };
329
+ }
330
+ 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()),
331
+ 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()),
332
+ this.indicatorStatistics[i].total.push(record);
333
+ }
283
334
  }
284
- 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()),
285
- 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()),
286
- this.indicatorStatistics[i].total.push(record);
287
335
  }
288
336
  }
289
337
  updateSortRules(sortRules) {
@@ -292,10 +340,10 @@ class Dataset {
292
340
  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));
293
341
  }
294
342
  updateFilterRules(filterRules, isResetTree = !1) {
295
- var _a;
296
- 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();
343
+ var _a, _b;
344
+ 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();
297
345
  this.collectedValues = {}, this.processRecords(), this.processCollectedValuesWithSumBy(),
298
- this.processCollectedValuesWithSortBy(), this.totalStatistics(), (null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.isPivotChart) && this.cacheDeminsionCollectedValues();
346
+ this.processCollectedValuesWithSortBy(), this.totalStatistics(), (null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.isPivotChart) && this.cacheDeminsionCollectedValues();
299
347
  }
300
348
  getAggregatorRule(indicatorKey) {
301
349
  var _a;
@@ -397,74 +445,75 @@ class Dataset {
397
445
  }
398
446
  totalStatistics() {
399
447
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
400
- const that = this;
401
- 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)) {
402
- const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
403
- 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;
404
- 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]);
405
- const colKey = flatColKey.split(this.stringJoinChar);
406
- 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++) {
407
- const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
408
- if (dimensionIndex >= 0) {
409
- const colTotalKey = colKey.slice(0, dimensionIndex + 1);
410
- colTotalKey.push(that.colSubTotalLabel);
411
- const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
412
- 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]);
413
- this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
414
- const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
415
- for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
416
- const calculatedFieldRule = null === (_s = this.calculatedFieldRules) || void 0 === _s ? void 0 : _s.find((rule => rule.key === toComputeIndicatorKeys[i]));
417
- (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[ts_types_1.AggregationType.RECALCULATE]({
418
- key: toComputeIndicatorKeys[i],
419
- dimension: toComputeIndicatorKeys[i],
420
- isRecord: !0,
421
- 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,
422
- calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
423
- dependAggregators: this.tree[flatRowKey][flatColTotalKey],
424
- dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
425
- })), 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]);
426
- } else {
427
- if (!this.tree[flatRowKey][flatColTotalKey][i]) {
428
- const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
429
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_z = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _z ? _z : ts_types_1.AggregationType.SUM]({
430
- key: toComputeIndicatorKeys[i],
431
- dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
432
- 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
433
- });
434
- }
435
- 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]);
436
- }
437
- }
438
- }
439
- 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) {
440
- const flatColTotalKey = that.colGrandTotalLabel;
441
- 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]);
448
+ const that = this, colCompute = (flatRowKey, flatColKey) => {
449
+ 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;
450
+ 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] = {}),
451
+ 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]);
452
+ const colKey = flatColKey.split(this.stringJoinChar);
453
+ 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++) {
454
+ const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
455
+ if (dimensionIndex >= 0) {
456
+ const colTotalKey = colKey.slice(0, dimensionIndex + 1);
457
+ colTotalKey.push(that.colSubTotalLabel);
458
+ const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
459
+ 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]);
442
460
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
443
461
  const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
444
462
  for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
445
- const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
446
- (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[ts_types_1.AggregationType.RECALCULATE]({
463
+ const calculatedFieldRule = null === (_s = this.calculatedFieldRules) || void 0 === _s ? void 0 : _s.find((rule => rule.key === toComputeIndicatorKeys[i]));
464
+ (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[ts_types_1.AggregationType.RECALCULATE]({
447
465
  key: toComputeIndicatorKeys[i],
448
466
  dimension: toComputeIndicatorKeys[i],
449
467
  isRecord: !0,
450
- 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,
468
+ 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,
451
469
  calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
452
470
  dependAggregators: this.tree[flatRowKey][flatColTotalKey],
453
471
  dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
454
- })), 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]);
472
+ })), 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]);
455
473
  } else {
456
474
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
457
475
  const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
458
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_19 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _19 ? _19 : ts_types_1.AggregationType.SUM]({
476
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_z = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _z ? _z : ts_types_1.AggregationType.SUM]({
459
477
  key: toComputeIndicatorKeys[i],
460
- dimension: null !== (_20 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _20 ? _20 : toComputeIndicatorKeys[i],
461
- 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
478
+ dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
479
+ 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
462
480
  });
463
481
  }
464
- 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]);
482
+ 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]);
465
483
  }
466
484
  }
467
- };
485
+ }
486
+ 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) {
487
+ const flatColTotalKey = that.colGrandTotalLabel;
488
+ 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]);
489
+ this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
490
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
491
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
492
+ const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
493
+ (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[ts_types_1.AggregationType.RECALCULATE]({
494
+ key: toComputeIndicatorKeys[i],
495
+ dimension: toComputeIndicatorKeys[i],
496
+ isRecord: !0,
497
+ 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,
498
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
499
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
500
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
501
+ })), 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]);
502
+ } else {
503
+ if (!this.tree[flatRowKey][flatColTotalKey][i]) {
504
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
505
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_19 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _19 ? _19 : ts_types_1.AggregationType.SUM]({
506
+ key: toComputeIndicatorKeys[i],
507
+ dimension: null !== (_20 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _20 ? _20 : toComputeIndicatorKeys[i],
508
+ 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
509
+ });
510
+ }
511
+ 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]);
512
+ }
513
+ }
514
+ };
515
+ 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)) {
516
+ const rowTotalKeys = [];
468
517
  Object.keys(that.tree).forEach((flatRowKey => {
469
518
  const rowKey = flatRowKey.split(this.stringJoinChar);
470
519
  Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
@@ -538,6 +587,7 @@ class Dataset {
538
587
  }));
539
588
  }));
540
589
  }
590
+ for (const flatRowKey in that.totalRecordsTree) for (const flatColKey in that.totalRecordsTree[flatRowKey]) colCompute(flatRowKey, flatColKey);
541
591
  }
542
592
  ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel) {
543
593
  const result = [], concatStr = this.stringJoinChar, map = new Map;
@@ -635,14 +685,6 @@ class Dataset {
635
685
  }
636
686
  return result;
637
687
  }
638
- TreeToArr(tree) {
639
- const result = [];
640
- function getPath(node, arr) {
641
- var _a;
642
- arr.push(node.id), node.children.length > 0 ? null === (_a = node.children) || void 0 === _a || _a.forEach((childItem => getPath(childItem, [ ...arr ]))) : result.push(arr);
643
- }
644
- return tree.forEach((treeNode => getPath(treeNode, []))), result;
645
- }
646
688
  cacheDeminsionCollectedValues() {
647
689
  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]);
648
690
  }
@@ -672,6 +714,9 @@ class Dataset {
672
714
  this.rowFlatKeys = {}, this.colFlatKeys = {}, this.tree = {}, this.processRecords();
673
715
  }
674
716
  }
717
+ _rowTreeHasChanged() {
718
+ this.hasExtensionRowTree || (this.customRowTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customRowTree, "row"));
719
+ }
675
720
  changeDataConfig(dataConfig) {
676
721
  this.rows = dataConfig.rows, this.columns = dataConfig.columns;
677
722
  }
@@ -682,6 +727,61 @@ class Dataset {
682
727
  }
683
728
  Array.isArray(this.records) && this.records.push(records);
684
729
  }
730
+ customTreeToDimensionPathArr(tree, type) {
731
+ const result = [], that = this;
732
+ function getPath(node, arr) {
733
+ var _a, _b, _c;
734
+ 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),
735
+ arr.push({
736
+ dimensionKey: (0, vutils_1.isValid)(node.indicatorKey) ? void 0 : node.dimensionKey,
737
+ value: node.value,
738
+ indicatorKey: node.indicatorKey,
739
+ virtual: node.virtual
740
+ })), (null === (_b = node.children) || void 0 === _b ? void 0 : _b.length) > 0 ? ("tree" === that.rowHierarchyType && "row" === type && (arr[arr.length - 1].childKeys = [],
741
+ result.push([ ...arr ])), null === (_c = node.children) || void 0 === _c || _c.forEach((childItem => getPath(childItem, [ ...arr ])))) : result.push(arr);
742
+ }
743
+ return null == tree || tree.forEach((treeNode => getPath(treeNode, []))), result;
744
+ }
745
+ getFieldMatchColDimensionPaths(record) {
746
+ var _a, _b;
747
+ const fieldMatchDimensionPaths = [];
748
+ for (let i = 0; null !== (_b = i < (null === (_a = this.customColTreeDimensionPaths) || void 0 === _a ? void 0 : _a.length)) && void 0 !== _b && _b; i++) {
749
+ const dimensionPath = this.customColTreeDimensionPaths[i];
750
+ let isMatch = !0;
751
+ for (let j = 0; j < dimensionPath.length; j++) {
752
+ const dimension = dimensionPath[j];
753
+ if (dimension.dimensionKey && record[dimension.dimensionKey] !== dimension.value || dimension.indicatorKey && void 0 === record[dimension.indicatorKey]) {
754
+ isMatch = !1;
755
+ break;
756
+ }
757
+ }
758
+ isMatch && fieldMatchDimensionPaths.push(dimensionPath);
759
+ }
760
+ return fieldMatchDimensionPaths;
761
+ }
762
+ getFieldMatchRowDimensionPaths(record) {
763
+ var _a, _b;
764
+ const fieldMatchDimensionPaths = [];
765
+ for (let i = 0; null !== (_b = i < (null === (_a = this.customRowTreeDimensionPaths) || void 0 === _a ? void 0 : _a.length)) && void 0 !== _b && _b; i++) {
766
+ const dimensionPath = this.customRowTreeDimensionPaths[i];
767
+ let isMatch = !0;
768
+ for (let j = 0; j < dimensionPath.length; j++) {
769
+ const dimension = dimensionPath[j];
770
+ if (dimension.dimensionKey && record[dimension.dimensionKey] !== dimension.value || dimension.indicatorKey && void 0 === record[dimension.indicatorKey]) {
771
+ isMatch = !1;
772
+ break;
773
+ }
774
+ if (dimension.childKeys && j === dimensionPath.length - 1 && dimension.childKeys.length > 0 && dimension.childKeys.find((key => (0,
775
+ vutils_1.isValid)(record[key])))) {
776
+ isMatch = !1;
777
+ break;
778
+ }
779
+ }
780
+ isMatch && (this.indicatorsAsCol || "tree" !== this.rowHierarchyType || dimensionPath.find((path => path.indicatorKey)) || (isMatch = !1)),
781
+ isMatch && fieldMatchDimensionPaths.push(dimensionPath);
782
+ }
783
+ return fieldMatchDimensionPaths;
784
+ }
685
785
  }
686
786
 
687
787
  function arraySortByAnotherArray(array, sortArray) {