@visactor/vtable 1.3.3-alpha.1 → 1.3.3-alpha.2

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 (39) hide show
  1. package/cjs/core/BaseTable.js +1 -1
  2. package/cjs/core/BaseTable.js.map +1 -1
  3. package/cjs/data/DataSource.d.ts +6 -1
  4. package/cjs/data/DataSource.js +12 -2
  5. package/cjs/data/DataSource.js.map +1 -1
  6. package/cjs/dataset/dataset.d.ts +15 -2
  7. package/cjs/dataset/dataset.js +170 -67
  8. package/cjs/dataset/dataset.js.map +1 -1
  9. package/cjs/dataset/statistics-helper.d.ts +43 -3
  10. package/cjs/dataset/statistics-helper.js +61 -26
  11. package/cjs/dataset/statistics-helper.js.map +1 -1
  12. package/cjs/index.d.ts +1 -1
  13. package/cjs/index.js +1 -1
  14. package/cjs/index.js.map +1 -1
  15. package/cjs/ts-types/new-data-set.d.ts +9 -1
  16. package/cjs/ts-types/new-data-set.js +1 -1
  17. package/cjs/ts-types/new-data-set.js.map +1 -1
  18. package/cjs/vrender.js.map +1 -1
  19. package/dist/vtable.js +424 -188
  20. package/dist/vtable.min.js +2 -2
  21. package/es/core/BaseTable.js +1 -1
  22. package/es/core/BaseTable.js.map +1 -1
  23. package/es/data/DataSource.d.ts +6 -1
  24. package/es/data/DataSource.js +12 -2
  25. package/es/data/DataSource.js.map +1 -1
  26. package/es/dataset/dataset.d.ts +15 -2
  27. package/es/dataset/dataset.js +170 -68
  28. package/es/dataset/dataset.js.map +1 -1
  29. package/es/dataset/statistics-helper.d.ts +43 -3
  30. package/es/dataset/statistics-helper.js +55 -23
  31. package/es/dataset/statistics-helper.js.map +1 -1
  32. package/es/index.d.ts +1 -1
  33. package/es/index.js +1 -1
  34. package/es/index.js.map +1 -1
  35. package/es/ts-types/new-data-set.d.ts +9 -1
  36. package/es/ts-types/new-data-set.js +1 -1
  37. package/es/ts-types/new-data-set.js.map +1 -1
  38. package/es/vrender.js.map +1 -1
  39. package/package.json +8 -8
@@ -8,8 +8,8 @@ const vutils_1 = require("@visactor/vutils"), ts_types_1 = require("../ts-types"
8
8
 
9
9
  class Dataset {
10
10
  constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
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;
12
- if (this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
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;
12
+ this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
13
13
  this.colKeys = [], this.rowKeys = [], this.rowOrder = "key_a_to_z", this.colOrder = "key_a_to_z",
14
14
  this.sorted = !1, this.indicatorStatistics = [], this.aggregators = {}, this.stringJoinChar = String.fromCharCode(0),
15
15
  this.rowsIsTotal = [], this.colsIsTotal = [], this.collectedValues = {}, this.cacheCollectedValues = {},
@@ -18,22 +18,28 @@ class Dataset {
18
18
  this.aggregationRules = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.aggregationRules,
19
19
  this.derivedFieldRules = null === (_c = this.dataConfig) || void 0 === _c ? void 0 : _c.derivedFieldRules,
20
20
  this.mappingRules = null === (_d = this.dataConfig) || void 0 === _d ? void 0 : _d.mappingRules,
21
- this.totals = null === (_e = this.dataConfig) || void 0 === _e ? void 0 : _e.totals,
22
- this.rows = rows, this.columns = columns, this.indicatorKeys = indicatorKeys, this.indicatorsAsCol = indicatorsAsCol,
23
- this.indicators = indicators, this.customColTree = customColTree, this.customRowTree = customRowTree,
24
- this.colGrandTotalLabel = null !== (_h = null === (_g = null === (_f = this.totals) || void 0 === _f ? void 0 : _f.column) || void 0 === _g ? void 0 : _g.grandTotalLabel) && void 0 !== _h ? _h : "总计",
25
- this.colSubTotalLabel = null !== (_l = null === (_k = null === (_j = this.totals) || void 0 === _j ? void 0 : _j.column) || void 0 === _k ? void 0 : _k.subTotalLabel) && void 0 !== _l ? _l : "小计",
26
- this.rowGrandTotalLabel = null !== (_p = null === (_o = null === (_m = this.totals) || void 0 === _m ? void 0 : _m.row) || void 0 === _o ? void 0 : _o.grandTotalLabel) && void 0 !== _p ? _p : "总计",
27
- this.rowSubTotalLabel = null !== (_s = null === (_r = null === (_q = this.totals) || void 0 === _q ? void 0 : _q.row) || void 0 === _r ? void 0 : _r.subTotalLabel) && void 0 !== _s ? _s : "小计",
28
- this.collectValuesBy = null === (_t = this.dataConfig) || void 0 === _t ? void 0 : _t.collectValuesBy,
21
+ this.calculatedFieldRules = null === (_e = this.dataConfig) || void 0 === _e ? void 0 : _e.calculatedFieldRules,
22
+ this.calculatedFiledKeys = null !== (_g = null === (_f = this.calculatedFieldRules) || void 0 === _f ? void 0 : _f.map((rule => rule.key))) && void 0 !== _g ? _g : [],
23
+ this.calculatedFieldDependIndicatorKeys = null !== (_j = null === (_h = this.calculatedFieldRules) || void 0 === _h ? void 0 : _h.reduce(((arr, rule) => {
24
+ for (let i = 0; i < rule.dependIndicatorKeys.length; i++) -1 === arr.indexOf(rule.dependIndicatorKeys[i]) && arr.push(rule.dependIndicatorKeys[i]);
25
+ return arr;
26
+ }), [])) && void 0 !== _j ? _j : [], this.totals = null === (_k = this.dataConfig) || void 0 === _k ? void 0 : _k.totals,
27
+ this.rows = rows, this.columns = columns, this.indicatorKeys = indicatorKeys, this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys = [ ...indicatorKeys ];
28
+ for (let m = 0; m < this.calculatedFieldDependIndicatorKeys.length; m++) -1 === this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.indexOf(this.calculatedFieldDependIndicatorKeys[m]) && this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.push(this.calculatedFieldDependIndicatorKeys[m]);
29
+ if (this.indicatorsAsCol = indicatorsAsCol, this.indicators = indicators, this.customColTree = customColTree,
30
+ this.customRowTree = customRowTree, this.colGrandTotalLabel = null !== (_o = null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.grandTotalLabel) && void 0 !== _o ? _o : "总计",
31
+ this.colSubTotalLabel = null !== (_r = null === (_q = null === (_p = this.totals) || void 0 === _p ? void 0 : _p.column) || void 0 === _q ? void 0 : _q.subTotalLabel) && void 0 !== _r ? _r : "小计",
32
+ this.rowGrandTotalLabel = null !== (_u = null === (_t = null === (_s = this.totals) || void 0 === _s ? void 0 : _s.row) || void 0 === _t ? void 0 : _t.grandTotalLabel) && void 0 !== _u ? _u : "总计",
33
+ this.rowSubTotalLabel = null !== (_x = null === (_w = null === (_v = this.totals) || void 0 === _v ? void 0 : _v.row) || void 0 === _w ? void 0 : _w.subTotalLabel) && void 0 !== _x ? _x : "小计",
34
+ this.collectValuesBy = null === (_y = this.dataConfig) || void 0 === _y ? void 0 : _y.collectValuesBy,
29
35
  this.needSplitPositiveAndNegative = null != needSplitPositiveAndNegative && needSplitPositiveAndNegative,
30
- this.rowsIsTotal = new Array(null !== (_v = null === (_u = this.rows) || void 0 === _u ? void 0 : _u.length) && void 0 !== _v ? _v : 0).fill(!1),
31
- this.colsIsTotal = new Array(null !== (_x = null === (_w = this.columns) || void 0 === _w ? void 0 : _w.length) && void 0 !== _x ? _x : 0).fill(!1),
32
- (null === (_y = this.totals) || void 0 === _y ? void 0 : _y.row) && !1 !== this.totals.row.showSubTotals && this.totals.row.subTotalsDimensions) for (let i = 0, len = null !== (_2 = null === (_1 = null === (_0 = null === (_z = this.totals) || void 0 === _z ? void 0 : _z.row) || void 0 === _0 ? void 0 : _0.subTotalsDimensions) || void 0 === _1 ? void 0 : _1.length) && void 0 !== _2 ? _2 : 0; i < len; i++) {
36
+ this.rowsIsTotal = new Array(null !== (_0 = null === (_z = this.rows) || void 0 === _z ? void 0 : _z.length) && void 0 !== _0 ? _0 : 0).fill(!1),
37
+ this.colsIsTotal = new Array(null !== (_2 = null === (_1 = this.columns) || void 0 === _1 ? void 0 : _1.length) && void 0 !== _2 ? _2 : 0).fill(!1),
38
+ (null === (_3 = this.totals) || void 0 === _3 ? void 0 : _3.row) && !1 !== this.totals.row.showSubTotals && this.totals.row.subTotalsDimensions) for (let i = 0, len = null !== (_7 = null === (_6 = null === (_5 = null === (_4 = this.totals) || void 0 === _4 ? void 0 : _4.row) || void 0 === _5 ? void 0 : _5.subTotalsDimensions) || void 0 === _6 ? void 0 : _6.length) && void 0 !== _7 ? _7 : 0; i < len; i++) {
33
39
  const dimension = this.totals.row.subTotalsDimensions[i], dimensionIndex = this.rows.indexOf(dimension);
34
40
  this.rowsIsTotal[dimensionIndex] = !0;
35
41
  }
36
- if ((null === (_3 = this.totals) || void 0 === _3 ? void 0 : _3.column) && !1 !== this.totals.column.showSubTotals && this.totals.column.subTotalsDimensions) for (let i = 0, len = null !== (_7 = null === (_6 = null === (_5 = null === (_4 = this.totals) || void 0 === _4 ? void 0 : _4.column) || void 0 === _5 ? void 0 : _5.subTotalsDimensions) || void 0 === _6 ? void 0 : _6.length) && void 0 !== _7 ? _7 : 0; i < len; i++) {
42
+ if ((null === (_8 = this.totals) || void 0 === _8 ? void 0 : _8.column) && !1 !== this.totals.column.showSubTotals && this.totals.column.subTotalsDimensions) for (let i = 0, len = null !== (_12 = null === (_11 = null === (_10 = null === (_9 = this.totals) || void 0 === _9 ? void 0 : _9.column) || void 0 === _10 ? void 0 : _10.subTotalsDimensions) || void 0 === _11 ? void 0 : _11.length) && void 0 !== _12 ? _12 : 0; i < len; i++) {
37
43
  const dimension = this.totals.column.subTotalsDimensions[i], dimensionIndex = this.columns.indexOf(dimension);
38
44
  this.colsIsTotal[dimensionIndex] = !0;
39
45
  }
@@ -70,7 +76,8 @@ class Dataset {
70
76
  this.registerAggregator(ts_types_1.AggregationType.MAX, statistics_helper_1.MaxAggregator),
71
77
  this.registerAggregator(ts_types_1.AggregationType.MIN, statistics_helper_1.MinAggregator),
72
78
  this.registerAggregator(ts_types_1.AggregationType.AVG, statistics_helper_1.AvgAggregator),
73
- this.registerAggregator(ts_types_1.AggregationType.NONE, statistics_helper_1.NoneAggregator);
79
+ this.registerAggregator(ts_types_1.AggregationType.NONE, statistics_helper_1.NoneAggregator),
80
+ this.registerAggregator(ts_types_1.AggregationType.RECALCULATE, statistics_helper_1.RecalculateAggregator);
74
81
  }
75
82
  processCollectedValuesWithSumBy() {
76
83
  var _a, _b, _c, _d, _e, _f;
@@ -136,7 +143,7 @@ class Dataset {
136
143
  return isReserved;
137
144
  }
138
145
  processRecord(record, assignedIndicatorKey) {
139
- 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;
146
+ 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;
140
147
  null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
141
148
  derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
142
149
  }));
@@ -148,8 +155,12 @@ class Dataset {
148
155
  max: Number.MIN_SAFE_INTEGER
149
156
  } : this.collectedValues[field][collectKeys] = []), this.collectValuesBy[field].sumBy) {
150
157
  const sumByKeys = this.collectValuesBy[field].sumBy.map((byField => record[byField])).join(this.stringJoinChar);
151
- this.collectedValues[field][collectKeys][sumByKeys] || (this.collectedValues[field][collectKeys][sumByKeys] = new this.aggregators[ts_types_1.AggregationType.SUM](field, void 0, void 0, this.needSplitPositiveAndNegative)),
152
- this.collectedValues[field][collectKeys][sumByKeys].push(record);
158
+ this.collectedValues[field][collectKeys][sumByKeys] || (this.collectedValues[field][collectKeys][sumByKeys] = new this.aggregators[ts_types_1.AggregationType.SUM]({
159
+ key: field,
160
+ dimension: field,
161
+ isRecord: void 0,
162
+ needSplitPositiveAndNegative: this.needSplitPositiveAndNegative
163
+ })), this.collectedValues[field][collectKeys][sumByKeys].push(record);
153
164
  } else if (this.collectValuesBy[field].range) {
154
165
  const fieldRange = this.collectedValues[field][collectKeys], max = Math.max(record[field], fieldRange.max), min = Math.min(record[field], fieldRange.min);
155
166
  isNaN(max) || (fieldRange.max = max, fieldRange.min = min);
@@ -191,36 +202,64 @@ class Dataset {
191
202
  this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
192
203
  for (let i = 0; i < this.indicatorKeys.length; i++) {
193
204
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
194
- (null === (_w = null === (_v = this.totalRecordsTree[flatRowKey]) || void 0 === _v ? void 0 : _v[flatColKey]) || void 0 === _w ? void 0 : _w[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_x = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _x ? _x : ts_types_1.AggregationType.SUM](null !== (_y = null == aggRule ? void 0 : aggRule.field) && void 0 !== _y ? _y : this.indicatorKeys[i], null !== (_z = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _z ? _z : null === (_1 = null === (_0 = this.indicators) || void 0 === _0 ? void 0 : _0.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _1 ? void 0 : _1.format)),
195
- this.indicatorKeys[i] in record && (null === (_3 = null === (_2 = this.totalRecordsTree[flatRowKey]) || void 0 === _2 ? void 0 : _2[flatColKey]) || void 0 === _3 || _3[i].push(record));
205
+ (null === (_w = null === (_v = this.totalRecordsTree[flatRowKey]) || void 0 === _v ? void 0 : _v[flatColKey]) || void 0 === _w ? void 0 : _w[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_x = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _x ? _x : ts_types_1.AggregationType.SUM]({
206
+ key: this.indicatorKeys[i],
207
+ dimension: null !== (_y = null == aggRule ? void 0 : aggRule.field) && void 0 !== _y ? _y : this.indicatorKeys[i],
208
+ formatFun: null !== (_z = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _z ? _z : null === (_1 = null === (_0 = this.indicators) || void 0 === _0 ? void 0 : _0.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _1 ? void 0 : _1.format
209
+ })), this.indicatorKeys[i] in record && (null === (_3 = null === (_2 = this.totalRecordsTree[flatRowKey]) || void 0 === _2 ? void 0 : _2[flatColKey]) || void 0 === _3 || _3[i].push(record));
196
210
  }
211
+ return;
212
+ }
213
+ 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
214
+ this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
215
+ this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
216
+ (null === (_4 = this.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
217
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
218
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
219
+ const calculatedFieldRule = null === (_5 = this.calculatedFieldRules) || void 0 === _5 ? void 0 : _5.find((rule => rule.key === toComputeIndicatorKeys[i]));
220
+ (null === (_7 = null === (_6 = this.tree[flatRowKey]) || void 0 === _6 ? void 0 : _6[flatColKey]) || void 0 === _7 ? void 0 : _7[i]) || (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
221
+ key: toComputeIndicatorKeys[i],
222
+ dimension: toComputeIndicatorKeys[i],
223
+ isRecord: !0,
224
+ formatFun: null === (_9 = null === (_8 = this.indicators) || void 0 === _8 ? void 0 : _8.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _9 ? void 0 : _9.format,
225
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
226
+ dependAggregators: this.tree[flatRowKey][flatColKey],
227
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
228
+ })), null === (_11 = null === (_10 = this.tree[flatRowKey]) || void 0 === _10 ? void 0 : _10[flatColKey]) || void 0 === _11 || _11[i].push(record);
197
229
  } else {
198
- 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
199
- this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
200
- this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
201
- (null === (_4 = this.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
202
- for (let i = 0; i < this.indicatorKeys.length; i++) {
230
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
231
+ let needAddToAggregator = !1;
232
+ 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 {
233
+ (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
234
+ } else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
235
+ !(null === (_13 = null === (_12 = this.tree[flatRowKey]) || void 0 === _12 ? void 0 : _12[flatColKey]) || void 0 === _13 ? void 0 : _13[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_14 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _14 ? _14 : ts_types_1.AggregationType.SUM]({
236
+ key: toComputeIndicatorKeys[i],
237
+ dimension: null !== (_15 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _15 ? _15 : toComputeIndicatorKeys[i],
238
+ formatFun: null !== (_16 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _16 ? _16 : null === (_18 = null === (_17 = this.indicators) || void 0 === _17 ? void 0 : _17.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _18 ? void 0 : _18.format
239
+ })), needAddToAggregator && (null === (_20 = null === (_19 = this.tree[flatRowKey]) || void 0 === _19 ? void 0 : _19[flatColKey]) || void 0 === _20 || _20[i].push(record));
240
+ }
241
+ if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
242
+ if (!this.indicatorStatistics[i]) {
203
243
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
204
- let needAddToAggregator = !1;
205
- if (assignedIndicatorKey) this.indicatorKeys[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 {
206
- (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
207
- } else this.indicatorKeys[i] in record && (needAddToAggregator = !0);
208
- !(null === (_6 = null === (_5 = this.tree[flatRowKey]) || void 0 === _5 ? void 0 : _5[flatColKey]) || void 0 === _6 ? void 0 : _6[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_7 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _7 ? _7 : ts_types_1.AggregationType.SUM](null !== (_8 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _8 ? _8 : this.indicatorKeys[i], null !== (_9 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _9 ? _9 : null === (_11 = null === (_10 = this.indicators) || void 0 === _10 ? void 0 : _10.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _11 ? void 0 : _11.format)),
209
- needAddToAggregator && (null === (_13 = null === (_12 = this.tree[flatRowKey]) || void 0 === _12 ? void 0 : _12[flatColKey]) || void 0 === _13 || _13[i].push(record));
210
- }
211
- if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
212
- if (!this.indicatorStatistics[i]) {
213
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
214
- this.indicatorStatistics[i] = {
215
- max: new this.aggregators[ts_types_1.AggregationType.MAX](this.indicatorKeys[i]),
216
- min: new this.aggregators[ts_types_1.AggregationType.MIN](this.indicatorKeys[i]),
217
- total: new this.aggregators[null !== (_14 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _14 ? _14 : ts_types_1.AggregationType.SUM](null !== (_15 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _15 ? _15 : this.indicatorKeys[i], null !== (_16 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _16 ? _16 : null === (_18 = null === (_17 = this.indicators) || void 0 === _17 ? void 0 : _17.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _18 ? void 0 : _18.format)
218
- };
219
- }
220
- this.indicatorStatistics[i].max.push(null === (_20 = null === (_19 = this.tree[flatRowKey]) || void 0 === _19 ? void 0 : _19[flatColKey]) || void 0 === _20 ? void 0 : _20[i].value()),
221
- this.indicatorStatistics[i].min.push(null === (_22 = null === (_21 = this.tree[flatRowKey]) || void 0 === _21 ? void 0 : _21[flatColKey]) || void 0 === _22 ? void 0 : _22[i].value()),
222
- this.indicatorStatistics[i].total.push(record);
244
+ this.indicatorStatistics[i] = {
245
+ max: new this.aggregators[ts_types_1.AggregationType.MAX]({
246
+ key: this.indicatorKeys[i],
247
+ dimension: this.indicatorKeys[i]
248
+ }),
249
+ min: new this.aggregators[ts_types_1.AggregationType.MIN]({
250
+ key: this.indicatorKeys[i],
251
+ dimension: this.indicatorKeys[i]
252
+ }),
253
+ total: new this.aggregators[null !== (_21 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _21 ? _21 : ts_types_1.AggregationType.SUM]({
254
+ key: this.indicatorKeys[i],
255
+ dimension: null !== (_22 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _22 ? _22 : this.indicatorKeys[i],
256
+ 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 === this.indicatorKeys[i]))) || void 0 === _25 ? void 0 : _25.format
257
+ })
258
+ };
223
259
  }
260
+ this.indicatorStatistics[i].max.push(null === (_27 = null === (_26 = this.tree[flatRowKey]) || void 0 === _26 ? void 0 : _26[flatColKey]) || void 0 === _27 ? void 0 : _27[i].value()),
261
+ this.indicatorStatistics[i].min.push(null === (_29 = null === (_28 = this.tree[flatRowKey]) || void 0 === _28 ? void 0 : _28[flatColKey]) || void 0 === _29 ? void 0 : _29[i].value()),
262
+ this.indicatorStatistics[i].total.push(record);
224
263
  }
225
264
  }
226
265
  updateSortRules(sortRules) {
@@ -370,7 +409,7 @@ class Dataset {
370
409
  const that = this;
371
410
  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)) {
372
411
  const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
373
- 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;
412
+ 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;
374
413
  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]);
375
414
  const colKey = flatColKey.split(this.stringJoinChar);
376
415
  if (null === (_f = null === (_e = that.totals) || void 0 === _e ? void 0 : _e.column) || void 0 === _f ? void 0 : _f.subTotalsDimensions) for (let i = 0, len = 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; i < len; i++) {
@@ -381,32 +420,64 @@ class Dataset {
381
420
  const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
382
421
  if (null === (_l = null === (_k = this.totalRecordsTree) || void 0 === _k ? void 0 : _k[flatRowKey]) || void 0 === _l ? void 0 : _l[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_o = null === (_m = this.totalRecordsTree) || void 0 === _m ? void 0 : _m[flatRowKey]) || void 0 === _o ? void 0 : _o[flatColTotalKey]);
383
422
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
384
- for (let i = 0; i < this.indicatorKeys.length; i++) {
423
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
424
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
425
+ const calculatedFieldRule = null === (_p = this.calculatedFieldRules) || void 0 === _p ? void 0 : _p.find((rule => rule.key === toComputeIndicatorKeys[i]));
426
+ (null === (_r = null === (_q = this.tree[flatRowKey]) || void 0 === _q ? void 0 : _q[flatColTotalKey]) || void 0 === _r ? void 0 : _r[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
427
+ key: toComputeIndicatorKeys[i],
428
+ dimension: toComputeIndicatorKeys[i],
429
+ isRecord: !0,
430
+ formatFun: null === (_t = null === (_s = this.indicators) || void 0 === _s ? void 0 : _s.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _t ? void 0 : _t.format,
431
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
432
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
433
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
434
+ })), this.tree[flatRowKey][flatColTotalKey][i].push(null === (_v = null === (_u = that.tree[flatRowKey]) || void 0 === _u ? void 0 : _u[flatColKey]) || void 0 === _v ? void 0 : _v[i]);
435
+ } else {
385
436
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
386
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
387
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_p = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _p ? _p : ts_types_1.AggregationType.SUM](null !== (_q = null == aggRule ? void 0 : aggRule.field) && void 0 !== _q ? _q : this.indicatorKeys[i], null !== (_r = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _r ? _r : null === (_t = null === (_s = this.indicators) || void 0 === _s ? void 0 : _s.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _t ? void 0 : _t.format);
437
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
438
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_w = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _w ? _w : ts_types_1.AggregationType.SUM]({
439
+ key: toComputeIndicatorKeys[i],
440
+ dimension: null !== (_x = null == aggRule ? void 0 : aggRule.field) && void 0 !== _x ? _x : toComputeIndicatorKeys[i],
441
+ formatFun: null !== (_y = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _y ? _y : null === (_0 = null === (_z = this.indicators) || void 0 === _z ? void 0 : _z.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _0 ? void 0 : _0.format
442
+ });
388
443
  }
389
- this.tree[flatRowKey][flatColTotalKey][i].push(null === (_v = null === (_u = that.tree[flatRowKey]) || void 0 === _u ? void 0 : _u[flatColKey]) || void 0 === _v ? void 0 : _v[i]);
444
+ this.tree[flatRowKey][flatColTotalKey][i].push(null === (_2 = null === (_1 = that.tree[flatRowKey]) || void 0 === _1 ? void 0 : _1[flatColKey]) || void 0 === _2 ? void 0 : _2[i]);
390
445
  }
391
446
  }
392
447
  }
393
- if ((null === (_x = null === (_w = that.totals) || void 0 === _w ? void 0 : _w.column) || void 0 === _x ? void 0 : _x.showGrandTotals) || 0 === this.rows.length) {
448
+ if ((null === (_4 = null === (_3 = that.totals) || void 0 === _3 ? void 0 : _3.column) || void 0 === _4 ? void 0 : _4.showGrandTotals) || 0 === this.rows.length) {
394
449
  const flatColTotalKey = that.colGrandTotalLabel;
395
- if (null === (_z = null === (_y = this.totalRecordsTree) || void 0 === _y ? void 0 : _y[flatRowKey]) || void 0 === _z ? void 0 : _z[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_1 = null === (_0 = this.totalRecordsTree) || void 0 === _0 ? void 0 : _0[flatRowKey]) || void 0 === _1 ? void 0 : _1[flatColTotalKey]);
450
+ if (null === (_6 = null === (_5 = this.totalRecordsTree) || void 0 === _5 ? void 0 : _5[flatRowKey]) || void 0 === _6 ? void 0 : _6[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_8 = null === (_7 = this.totalRecordsTree) || void 0 === _7 ? void 0 : _7[flatRowKey]) || void 0 === _8 ? void 0 : _8[flatColTotalKey]);
396
451
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
397
- for (let i = 0; i < this.indicatorKeys.length; i++) {
452
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
453
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
454
+ const calculatedFieldRule = null === (_9 = this.calculatedFieldRules) || void 0 === _9 ? void 0 : _9.find((rule => rule.key === toComputeIndicatorKeys[i]));
455
+ (null === (_11 = null === (_10 = this.tree[flatRowKey]) || void 0 === _10 ? void 0 : _10[flatColTotalKey]) || void 0 === _11 ? void 0 : _11[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
456
+ key: toComputeIndicatorKeys[i],
457
+ dimension: toComputeIndicatorKeys[i],
458
+ isRecord: !0,
459
+ formatFun: null === (_13 = null === (_12 = this.indicators) || void 0 === _12 ? void 0 : _12.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _13 ? void 0 : _13.format,
460
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
461
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
462
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
463
+ })), this.tree[flatRowKey][flatColTotalKey][i].push(null === (_15 = null === (_14 = that.tree[flatRowKey]) || void 0 === _14 ? void 0 : _14[flatColKey]) || void 0 === _15 ? void 0 : _15[i]);
464
+ } else {
398
465
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
399
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
400
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_2 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _2 ? _2 : ts_types_1.AggregationType.SUM](null !== (_3 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _3 ? _3 : this.indicatorKeys[i], null !== (_4 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _4 ? _4 : null === (_6 = null === (_5 = this.indicators) || void 0 === _5 ? void 0 : _5.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _6 ? void 0 : _6.format);
466
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
467
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_16 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _16 ? _16 : ts_types_1.AggregationType.SUM]({
468
+ key: toComputeIndicatorKeys[i],
469
+ dimension: null !== (_17 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _17 ? _17 : toComputeIndicatorKeys[i],
470
+ formatFun: null !== (_18 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _18 ? _18 : 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
471
+ });
401
472
  }
402
- this.tree[flatRowKey][flatColTotalKey][i].push(null === (_8 = null === (_7 = that.tree[flatRowKey]) || void 0 === _7 ? void 0 : _7[flatColKey]) || void 0 === _8 ? void 0 : _8[i]);
473
+ this.tree[flatRowKey][flatColTotalKey][i].push(null === (_22 = null === (_21 = that.tree[flatRowKey]) || void 0 === _21 ? void 0 : _21[flatColKey]) || void 0 === _22 ? void 0 : _22[i]);
403
474
  }
404
475
  }
405
476
  };
406
477
  Object.keys(that.tree).forEach((flatRowKey => {
407
478
  const rowKey = flatRowKey.split(this.stringJoinChar);
408
479
  Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
409
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
480
+ 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;
410
481
  if (null === (_b = null === (_a = that.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) for (let i = 0, len = null === (_e = null === (_d = null === (_c = that.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length; i < len; i++) {
411
482
  const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
412
483
  if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
@@ -415,25 +486,57 @@ class Dataset {
415
486
  const flatRowTotalKey = rowTotalKey.join(this.stringJoinChar);
416
487
  this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
417
488
  this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
418
- for (let i = 0; i < this.indicatorKeys.length; i++) {
419
- if (!this.tree[flatRowTotalKey][flatColKey][i]) {
420
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
421
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_f = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _f ? _f : ts_types_1.AggregationType.SUM](null !== (_g = null == aggRule ? void 0 : aggRule.field) && void 0 !== _g ? _g : this.indicatorKeys[i], null !== (_h = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _h ? _h : null === (_k = null === (_j = this.indicators) || void 0 === _j ? void 0 : _j.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _k ? void 0 : _k.format);
489
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
490
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
491
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
492
+ const calculatedFieldRule = null === (_f = this.calculatedFieldRules) || void 0 === _f ? void 0 : _f.find((rule => rule.key === toComputeIndicatorKeys[i]));
493
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
494
+ key: toComputeIndicatorKeys[i],
495
+ dimension: toComputeIndicatorKeys[i],
496
+ isRecord: !0,
497
+ formatFun: null === (_h = null === (_g = this.indicators) || void 0 === _g ? void 0 : _g.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _h ? void 0 : _h.format,
498
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
499
+ dependAggregators: this.tree[flatRowTotalKey][flatColKey],
500
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
501
+ });
502
+ } else {
503
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
504
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_j = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _j ? _j : ts_types_1.AggregationType.SUM]({
505
+ key: toComputeIndicatorKeys[i],
506
+ dimension: null !== (_k = null == aggRule ? void 0 : aggRule.field) && void 0 !== _k ? _k : toComputeIndicatorKeys[i],
507
+ formatFun: null !== (_l = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _l ? _l : null === (_o = null === (_m = this.indicators) || void 0 === _m ? void 0 : _m.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _o ? void 0 : _o.format
508
+ });
422
509
  }
423
- this.tree[flatRowTotalKey][flatColKey][i].push(null === (_m = null === (_l = that.tree[flatRowKey]) || void 0 === _l ? void 0 : _l[flatColKey]) || void 0 === _m ? void 0 : _m[i]);
510
+ this.tree[flatRowTotalKey][flatColKey][i].push(null === (_q = null === (_p = that.tree[flatRowKey]) || void 0 === _p ? void 0 : _p[flatColKey]) || void 0 === _q ? void 0 : _q[i]);
424
511
  }
425
512
  }
426
513
  }
427
- if ((null === (_p = null === (_o = that.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotals) || 0 === this.columns.length) {
514
+ if ((null === (_s = null === (_r = that.totals) || void 0 === _r ? void 0 : _r.row) || void 0 === _s ? void 0 : _s.showGrandTotals) || 0 === this.columns.length) {
428
515
  const flatRowTotalKey = that.rowGrandTotalLabel;
429
516
  this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
430
517
  this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
431
- for (let i = 0; i < this.indicatorKeys.length; i++) {
432
- if (!this.tree[flatRowTotalKey][flatColKey][i]) {
433
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
434
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_q = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _q ? _q : ts_types_1.AggregationType.SUM](null !== (_r = null == aggRule ? void 0 : aggRule.field) && void 0 !== _r ? _r : this.indicatorKeys[i], null !== (_s = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _s ? _s : null === (_u = null === (_t = this.indicators) || void 0 === _t ? void 0 : _t.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _u ? void 0 : _u.format);
518
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
519
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
520
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
521
+ const calculatedFieldRule = null === (_t = this.calculatedFieldRules) || void 0 === _t ? void 0 : _t.find((rule => rule.key === toComputeIndicatorKeys[i]));
522
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
523
+ key: toComputeIndicatorKeys[i],
524
+ dimension: toComputeIndicatorKeys[i],
525
+ isRecord: !0,
526
+ formatFun: null === (_v = null === (_u = this.indicators) || void 0 === _u ? void 0 : _u.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _v ? void 0 : _v.format,
527
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
528
+ dependAggregators: this.tree[flatRowTotalKey][flatColKey],
529
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
530
+ });
531
+ } else {
532
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
533
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_w = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _w ? _w : ts_types_1.AggregationType.SUM]({
534
+ key: toComputeIndicatorKeys[i],
535
+ dimension: null !== (_x = null == aggRule ? void 0 : aggRule.field) && void 0 !== _x ? _x : toComputeIndicatorKeys[i],
536
+ formatFun: null !== (_y = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _y ? _y : null === (_0 = null === (_z = this.indicators) || void 0 === _z ? void 0 : _z.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _0 ? void 0 : _0.format
537
+ });
435
538
  }
436
- this.tree[flatRowTotalKey][flatColKey][i].push(null === (_w = null === (_v = that.tree[flatRowKey]) || void 0 === _v ? void 0 : _v[flatColKey]) || void 0 === _w ? void 0 : _w[i]);
539
+ this.tree[flatRowTotalKey][flatColKey][i].push(null === (_2 = null === (_1 = that.tree[flatRowKey]) || void 0 === _1 ? void 0 : _1[flatColKey]) || void 0 === _2 ? void 0 : _2[i]);
437
540
  }
438
541
  }
439
542
  colCompute(flatRowKey, flatColKey);