@visactor/vtable 1.3.3 → 1.4.0

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 +25 -15
  2. package/cjs/ListTable.js.map +1 -1
  3. package/cjs/PivotChart.d.ts +1 -2
  4. package/cjs/PivotChart.js +0 -7
  5. package/cjs/PivotChart.js.map +1 -1
  6. package/cjs/PivotTable.d.ts +1 -1
  7. package/cjs/PivotTable.js +34 -14
  8. package/cjs/PivotTable.js.map +1 -1
  9. package/cjs/components/react/react-custom-layout.d.ts +21 -0
  10. package/cjs/components/react/react-custom-layout.js +48 -0
  11. package/cjs/components/react/react-custom-layout.js.map +1 -0
  12. package/cjs/core/BaseTable.d.ts +5 -0
  13. package/cjs/core/BaseTable.js +37 -23
  14. package/cjs/core/BaseTable.js.map +1 -1
  15. package/cjs/core/style.js +1 -1
  16. package/cjs/core/style.js.map +1 -1
  17. package/cjs/data/DataSource.d.ts +6 -1
  18. package/cjs/data/DataSource.js +12 -2
  19. package/cjs/data/DataSource.js.map +1 -1
  20. package/cjs/dataset/dataset.d.ts +15 -2
  21. package/cjs/dataset/dataset.js +187 -72
  22. package/cjs/dataset/dataset.js.map +1 -1
  23. package/cjs/dataset/statistics-helper.d.ts +43 -3
  24. package/cjs/dataset/statistics-helper.js +61 -26
  25. package/cjs/dataset/statistics-helper.js.map +1 -1
  26. package/cjs/event/listener/table-group.js +2 -2
  27. package/cjs/event/listener/table-group.js.map +1 -1
  28. package/cjs/index.d.ts +3 -1
  29. package/cjs/index.js +14 -5
  30. package/cjs/index.js.map +1 -1
  31. package/cjs/layout/pivot-header-layout.d.ts +1 -0
  32. package/cjs/layout/pivot-header-layout.js +7 -0
  33. package/cjs/layout/pivot-header-layout.js.map +1 -1
  34. package/cjs/scenegraph/component/custom.js +6 -4
  35. package/cjs/scenegraph/component/custom.js.map +1 -1
  36. package/cjs/scenegraph/group-creater/cell-helper.js +4 -0
  37. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  38. package/cjs/scenegraph/layout/compute-col-width.js +2 -2
  39. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  40. package/cjs/scenegraph/layout/compute-row-height.js +3 -3
  41. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  42. package/cjs/scenegraph/scenegraph.d.ts +2 -1
  43. package/cjs/scenegraph/scenegraph.js +12 -3
  44. package/cjs/scenegraph/scenegraph.js.map +1 -1
  45. package/cjs/ts-types/base-table.d.ts +8 -0
  46. package/cjs/ts-types/base-table.js.map +1 -1
  47. package/cjs/ts-types/customLayout.d.ts +1 -1
  48. package/cjs/ts-types/customLayout.js.map +1 -1
  49. package/cjs/ts-types/new-data-set.d.ts +9 -1
  50. package/cjs/ts-types/new-data-set.js +1 -1
  51. package/cjs/ts-types/new-data-set.js.map +1 -1
  52. package/cjs/ts-types/pivot-table/corner.d.ts +12 -0
  53. package/cjs/ts-types/pivot-table/corner.js.map +1 -1
  54. package/cjs/vrender.d.ts +4 -0
  55. package/cjs/vrender.js +39 -11
  56. package/cjs/vrender.js.map +1 -1
  57. package/dist/vtable.js +25311 -9542
  58. package/dist/vtable.min.js +2 -2
  59. package/es/ListTable.js +21 -11
  60. package/es/ListTable.js.map +1 -1
  61. package/es/PivotChart.d.ts +1 -2
  62. package/es/PivotChart.js +0 -7
  63. package/es/PivotChart.js.map +1 -1
  64. package/es/PivotTable.d.ts +1 -1
  65. package/es/PivotTable.js +34 -14
  66. package/es/PivotTable.js.map +1 -1
  67. package/es/components/react/react-custom-layout.d.ts +21 -0
  68. package/es/components/react/react-custom-layout.js +38 -0
  69. package/es/components/react/react-custom-layout.js.map +1 -0
  70. package/es/core/BaseTable.d.ts +5 -0
  71. package/es/core/BaseTable.js +40 -23
  72. package/es/core/BaseTable.js.map +1 -1
  73. package/es/core/style.js +1 -1
  74. package/es/core/style.js.map +1 -1
  75. package/es/data/DataSource.d.ts +6 -1
  76. package/es/data/DataSource.js +12 -2
  77. package/es/data/DataSource.js.map +1 -1
  78. package/es/dataset/dataset.d.ts +15 -2
  79. package/es/dataset/dataset.js +187 -73
  80. package/es/dataset/dataset.js.map +1 -1
  81. package/es/dataset/statistics-helper.d.ts +43 -3
  82. package/es/dataset/statistics-helper.js +55 -23
  83. package/es/dataset/statistics-helper.js.map +1 -1
  84. package/es/event/listener/table-group.js +2 -2
  85. package/es/event/listener/table-group.js.map +1 -1
  86. package/es/index.d.ts +3 -1
  87. package/es/index.js +5 -1
  88. package/es/index.js.map +1 -1
  89. package/es/layout/pivot-header-layout.d.ts +1 -0
  90. package/es/layout/pivot-header-layout.js +7 -0
  91. package/es/layout/pivot-header-layout.js.map +1 -1
  92. package/es/scenegraph/component/custom.js +7 -3
  93. package/es/scenegraph/component/custom.js.map +1 -1
  94. package/es/scenegraph/group-creater/cell-helper.js +4 -0
  95. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  96. package/es/scenegraph/layout/compute-col-width.js +3 -3
  97. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  98. package/es/scenegraph/layout/compute-row-height.js +4 -4
  99. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  100. package/es/scenegraph/scenegraph.d.ts +2 -1
  101. package/es/scenegraph/scenegraph.js +12 -3
  102. package/es/scenegraph/scenegraph.js.map +1 -1
  103. package/es/ts-types/base-table.d.ts +8 -0
  104. package/es/ts-types/base-table.js.map +1 -1
  105. package/es/ts-types/customLayout.d.ts +1 -1
  106. package/es/ts-types/customLayout.js.map +1 -1
  107. package/es/ts-types/new-data-set.d.ts +9 -1
  108. package/es/ts-types/new-data-set.js +1 -1
  109. package/es/ts-types/new-data-set.js.map +1 -1
  110. package/es/ts-types/pivot-table/corner.d.ts +12 -0
  111. package/es/ts-types/pivot-table/corner.js.map +1 -1
  112. package/es/vrender.d.ts +4 -0
  113. package/es/vrender.js +9 -3
  114. package/es/vrender.js.map +1 -1
  115. 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, _30, _31, _32, _33, _34, _35, _36;
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);
@@ -189,38 +200,78 @@ class Dataset {
189
200
  const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
190
201
  if (isToTalRecord) {
191
202
  this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
192
- for (let i = 0; i < this.indicatorKeys.length; i++) {
193
- 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));
203
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
204
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
205
+ const calculatedFieldRule = null === (_v = this.calculatedFieldRules) || void 0 === _v ? void 0 : _v.find((rule => rule.key === toComputeIndicatorKeys[i]));
206
+ (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]({
207
+ key: toComputeIndicatorKeys[i],
208
+ dimension: toComputeIndicatorKeys[i],
209
+ isRecord: !0,
210
+ 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,
211
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
212
+ dependAggregators: this.totalRecordsTree[flatRowKey][flatColKey],
213
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
214
+ })), 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));
215
+ } else {
216
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
217
+ (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]({
218
+ key: toComputeIndicatorKeys[i],
219
+ dimension: null !== (_5 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _5 ? _5 : toComputeIndicatorKeys[i],
220
+ 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
221
+ })), 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));
196
222
  }
223
+ return;
224
+ }
225
+ 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
226
+ this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
227
+ this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
228
+ (null === (_11 = this.tree[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
229
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
230
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
231
+ const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
232
+ (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]({
233
+ key: toComputeIndicatorKeys[i],
234
+ dimension: toComputeIndicatorKeys[i],
235
+ isRecord: !0,
236
+ 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,
237
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
238
+ dependAggregators: this.tree[flatRowKey][flatColKey],
239
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
240
+ })), null === (_18 = null === (_17 = this.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 || _18[i].push(record);
197
241
  } 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++) {
242
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
243
+ let needAddToAggregator = !1;
244
+ 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 {
245
+ (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
246
+ } else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
247
+ !(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]({
248
+ key: toComputeIndicatorKeys[i],
249
+ dimension: null !== (_22 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _22 ? _22 : toComputeIndicatorKeys[i],
250
+ 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
251
+ })), needAddToAggregator && (null === (_27 = null === (_26 = this.tree[flatRowKey]) || void 0 === _26 ? void 0 : _26[flatColKey]) || void 0 === _27 || _27[i].push(record));
252
+ }
253
+ if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
254
+ if (!this.indicatorStatistics[i]) {
203
255
  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);
256
+ this.indicatorStatistics[i] = {
257
+ max: new this.aggregators[ts_types_1.AggregationType.MAX]({
258
+ key: this.indicatorKeys[i],
259
+ dimension: this.indicatorKeys[i]
260
+ }),
261
+ min: new this.aggregators[ts_types_1.AggregationType.MIN]({
262
+ key: this.indicatorKeys[i],
263
+ dimension: this.indicatorKeys[i]
264
+ }),
265
+ total: new this.aggregators[null !== (_28 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _28 ? _28 : ts_types_1.AggregationType.SUM]({
266
+ key: this.indicatorKeys[i],
267
+ dimension: null !== (_29 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _29 ? _29 : this.indicatorKeys[i],
268
+ 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
269
+ })
270
+ };
223
271
  }
272
+ 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()),
273
+ 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()),
274
+ this.indicatorStatistics[i].total.push(record);
224
275
  }
225
276
  }
226
277
  updateSortRules(sortRules) {
@@ -370,44 +421,76 @@ class Dataset {
370
421
  const that = this;
371
422
  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
423
  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;
424
+ 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;
374
425
  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
426
  const colKey = flatColKey.split(this.stringJoinChar);
376
- 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++) {
427
+ 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++) {
377
428
  const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
378
429
  if (dimensionIndex >= 0) {
379
430
  const colTotalKey = colKey.slice(0, dimensionIndex + 1);
380
431
  colTotalKey.push(that.colSubTotalLabel);
381
432
  const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
382
- 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]);
433
+ 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]);
383
434
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
384
- for (let i = 0; i < this.indicatorKeys.length; i++) {
435
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
436
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
437
+ const calculatedFieldRule = null === (_s = this.calculatedFieldRules) || void 0 === _s ? void 0 : _s.find((rule => rule.key === toComputeIndicatorKeys[i]));
438
+ (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]({
439
+ key: toComputeIndicatorKeys[i],
440
+ dimension: toComputeIndicatorKeys[i],
441
+ isRecord: !0,
442
+ 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,
443
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
444
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
445
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
446
+ })), 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]);
447
+ } else {
385
448
  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);
449
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
450
+ 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]({
451
+ key: toComputeIndicatorKeys[i],
452
+ dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
453
+ 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
454
+ });
388
455
  }
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]);
456
+ 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]);
390
457
  }
391
458
  }
392
459
  }
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) {
460
+ 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) {
394
461
  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]);
462
+ 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]);
396
463
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
397
- for (let i = 0; i < this.indicatorKeys.length; i++) {
464
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
465
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
466
+ const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
467
+ (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]({
468
+ key: toComputeIndicatorKeys[i],
469
+ dimension: toComputeIndicatorKeys[i],
470
+ isRecord: !0,
471
+ 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,
472
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
473
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
474
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
475
+ })), 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]);
476
+ } else {
398
477
  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);
478
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
479
+ 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]({
480
+ key: toComputeIndicatorKeys[i],
481
+ dimension: null !== (_20 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _20 ? _20 : toComputeIndicatorKeys[i],
482
+ 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
483
+ });
401
484
  }
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]);
485
+ 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]);
403
486
  }
404
487
  }
405
488
  };
406
489
  Object.keys(that.tree).forEach((flatRowKey => {
407
490
  const rowKey = flatRowKey.split(this.stringJoinChar);
408
491
  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;
410
- 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++) {
492
+ 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;
493
+ if ((null === (_b = null === (_a = that.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (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) > 0 && !1 !== that.totals.row.showSubTotals) for (let i = 0, len = null === (_h = null === (_g = null === (_f = that.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions) || void 0 === _h ? void 0 : _h.length; i < len; i++) {
411
494
  const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
412
495
  if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
413
496
  const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
@@ -415,25 +498,57 @@ class Dataset {
415
498
  const flatRowTotalKey = rowTotalKey.join(this.stringJoinChar);
416
499
  this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
417
500
  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);
501
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
502
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
503
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
504
+ const calculatedFieldRule = null === (_j = this.calculatedFieldRules) || void 0 === _j ? void 0 : _j.find((rule => rule.key === toComputeIndicatorKeys[i]));
505
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
506
+ key: toComputeIndicatorKeys[i],
507
+ dimension: toComputeIndicatorKeys[i],
508
+ isRecord: !0,
509
+ formatFun: null === (_l = null === (_k = this.indicators) || void 0 === _k ? void 0 : _k.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _l ? void 0 : _l.format,
510
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
511
+ dependAggregators: this.tree[flatRowTotalKey][flatColKey],
512
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
513
+ });
514
+ } else {
515
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
516
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_m = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _m ? _m : ts_types_1.AggregationType.SUM]({
517
+ key: toComputeIndicatorKeys[i],
518
+ dimension: null !== (_o = null == aggRule ? void 0 : aggRule.field) && void 0 !== _o ? _o : toComputeIndicatorKeys[i],
519
+ formatFun: null !== (_p = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _p ? _p : null === (_r = null === (_q = this.indicators) || void 0 === _q ? void 0 : _q.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _r ? void 0 : _r.format
520
+ });
422
521
  }
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]);
522
+ this.tree[flatRowTotalKey][flatColKey][i].push(null === (_t = null === (_s = that.tree[flatRowKey]) || void 0 === _s ? void 0 : _s[flatColKey]) || void 0 === _t ? void 0 : _t[i]);
424
523
  }
425
524
  }
426
525
  }
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) {
526
+ if ((null === (_v = null === (_u = that.totals) || void 0 === _u ? void 0 : _u.row) || void 0 === _v ? void 0 : _v.showGrandTotals) || 0 === this.columns.length) {
428
527
  const flatRowTotalKey = that.rowGrandTotalLabel;
429
528
  this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
430
529
  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);
530
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
531
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
532
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
533
+ const calculatedFieldRule = null === (_w = this.calculatedFieldRules) || void 0 === _w ? void 0 : _w.find((rule => rule.key === toComputeIndicatorKeys[i]));
534
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
535
+ key: toComputeIndicatorKeys[i],
536
+ dimension: toComputeIndicatorKeys[i],
537
+ isRecord: !0,
538
+ formatFun: null === (_y = null === (_x = this.indicators) || void 0 === _x ? void 0 : _x.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _y ? void 0 : _y.format,
539
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
540
+ dependAggregators: this.tree[flatRowTotalKey][flatColKey],
541
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
542
+ });
543
+ } else {
544
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
545
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_z = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _z ? _z : ts_types_1.AggregationType.SUM]({
546
+ key: toComputeIndicatorKeys[i],
547
+ dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
548
+ 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
549
+ });
435
550
  }
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]);
551
+ this.tree[flatRowTotalKey][flatColKey][i].push(null === (_5 = null === (_4 = that.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || void 0 === _5 ? void 0 : _5[i]);
437
552
  }
438
553
  }
439
554
  colCompute(flatRowKey, flatColKey);