@visactor/vtable 1.4.0-alpha.0 → 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 (251) hide show
  1. package/cjs/ListTable.js +38 -26
  2. package/cjs/ListTable.js.map +1 -1
  3. package/cjs/PivotChart.d.ts +1 -3
  4. package/cjs/PivotChart.js +5 -15
  5. package/cjs/PivotChart.js.map +1 -1
  6. package/cjs/PivotTable.d.ts +1 -1
  7. package/cjs/PivotTable.js +40 -18
  8. package/cjs/PivotTable.js.map +1 -1
  9. package/cjs/components/axis/axis.js +2 -3
  10. package/cjs/components/axis/axis.js.map +1 -1
  11. package/cjs/components/empty-tip/empty-tip.js +2 -2
  12. package/cjs/components/empty-tip/empty-tip.js.map +1 -1
  13. package/cjs/components/legend/discrete-legend/discrete-legend.js +1 -2
  14. package/cjs/components/legend/discrete-legend/discrete-legend.js.map +1 -1
  15. package/cjs/components/react/react-custom-layout.d.ts +21 -0
  16. package/cjs/components/react/react-custom-layout.js +48 -0
  17. package/cjs/components/react/react-custom-layout.js.map +1 -0
  18. package/cjs/components/tooltip/TooltipHandler.js +1 -3
  19. package/cjs/components/tooltip/TooltipHandler.js.map +1 -1
  20. package/cjs/components/tooltip/logic/BubbleTooltipElement.js +7 -3
  21. package/cjs/components/tooltip/logic/BubbleTooltipElement.js.map +1 -1
  22. package/cjs/components/tooltip/logic/BubbleTooltipElementStyle.js +1 -1
  23. package/cjs/components/tooltip/logic/BubbleTooltipElementStyle.js.map +1 -1
  24. package/cjs/core/BaseTable.d.ts +10 -28
  25. package/cjs/core/BaseTable.js +88 -75
  26. package/cjs/core/BaseTable.js.map +1 -1
  27. package/cjs/core/FouseInput.d.ts +0 -1
  28. package/cjs/core/FouseInput.js +2 -5
  29. package/cjs/core/FouseInput.js.map +1 -1
  30. package/cjs/core/style.js +1 -1
  31. package/cjs/core/style.js.map +1 -1
  32. package/cjs/data/DataSource.d.ts +6 -1
  33. package/cjs/data/DataSource.js +12 -2
  34. package/cjs/data/DataSource.js.map +1 -1
  35. package/cjs/dataset/dataset.d.ts +17 -2
  36. package/cjs/dataset/dataset.js +195 -79
  37. package/cjs/dataset/dataset.js.map +1 -1
  38. package/cjs/dataset/statistics-helper.d.ts +43 -3
  39. package/cjs/dataset/statistics-helper.js +61 -26
  40. package/cjs/dataset/statistics-helper.js.map +1 -1
  41. package/cjs/event/event.js +1 -2
  42. package/cjs/event/event.js.map +1 -1
  43. package/cjs/event/listener/container-dom.js +4 -3
  44. package/cjs/event/listener/container-dom.js.map +1 -1
  45. package/cjs/event/listener/table-group.js +7 -5
  46. package/cjs/event/listener/table-group.js.map +1 -1
  47. package/cjs/event/util.js +2 -2
  48. package/cjs/event/util.js.map +1 -1
  49. package/cjs/index.d.ts +3 -1
  50. package/cjs/index.js +13 -4
  51. package/cjs/index.js.map +1 -1
  52. package/cjs/layout/layout-helper.js.map +1 -1
  53. package/cjs/layout/pivot-header-layout.d.ts +1 -0
  54. package/cjs/layout/pivot-header-layout.js +66 -39
  55. package/cjs/layout/pivot-header-layout.js.map +1 -1
  56. package/cjs/layout/row-height-map.js +1 -0
  57. package/cjs/layout/row-height-map.js.map +1 -1
  58. package/cjs/scenegraph/component/custom.js +6 -4
  59. package/cjs/scenegraph/component/custom.js.map +1 -1
  60. package/cjs/scenegraph/debug-tool/debug-tool.js +1 -4
  61. package/cjs/scenegraph/debug-tool/debug-tool.js.map +1 -1
  62. package/cjs/scenegraph/graphic/chart.d.ts +0 -1
  63. package/cjs/scenegraph/graphic/chart.js +20 -34
  64. package/cjs/scenegraph/graphic/chart.js.map +1 -1
  65. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js +8 -20
  66. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  67. package/cjs/scenegraph/graphic/contributions/chart-render.d.ts +1 -2
  68. package/cjs/scenegraph/graphic/contributions/chart-render.js +24 -40
  69. package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  70. package/cjs/scenegraph/group-creater/cell-helper.js +6 -2
  71. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  72. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js +1 -2
  73. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  74. package/cjs/scenegraph/group-creater/progress/proxy.d.ts +3 -2
  75. package/cjs/scenegraph/group-creater/progress/proxy.js +10 -10
  76. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  77. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.d.ts +2 -1
  78. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +2 -3
  79. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  80. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.d.ts +3 -2
  81. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +15 -14
  82. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  83. package/cjs/scenegraph/group-creater/progress/update-position/update-auto-row.js +7 -5
  84. package/cjs/scenegraph/group-creater/progress/update-position/update-auto-row.js.map +1 -1
  85. package/cjs/scenegraph/layout/compute-col-width.js +2 -2
  86. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  87. package/cjs/scenegraph/layout/compute-row-height.js +7 -4
  88. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  89. package/cjs/scenegraph/layout/frozen.js +12 -4
  90. package/cjs/scenegraph/layout/frozen.js.map +1 -1
  91. package/cjs/scenegraph/layout/update-width.js +3 -0
  92. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  93. package/cjs/scenegraph/refresh-node/update-chart.d.ts +0 -1
  94. package/cjs/scenegraph/refresh-node/update-chart.js +2 -9
  95. package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
  96. package/cjs/scenegraph/scenegraph.d.ts +2 -1
  97. package/cjs/scenegraph/scenegraph.js +18 -15
  98. package/cjs/scenegraph/scenegraph.js.map +1 -1
  99. package/cjs/state/cell-move/index.js +1 -1
  100. package/cjs/state/cell-move/index.js.map +1 -1
  101. package/cjs/state/sort/index.js +2 -2
  102. package/cjs/state/sort/index.js.map +1 -1
  103. package/cjs/themes/theme.js +6 -0
  104. package/cjs/themes/theme.js.map +1 -1
  105. package/cjs/ts-types/base-table.d.ts +20 -40
  106. package/cjs/ts-types/base-table.js.map +1 -1
  107. package/cjs/ts-types/customLayout.d.ts +1 -1
  108. package/cjs/ts-types/customLayout.js.map +1 -1
  109. package/cjs/ts-types/icon.d.ts +2 -0
  110. package/cjs/ts-types/icon.js.map +1 -1
  111. package/cjs/ts-types/new-data-set.d.ts +9 -1
  112. package/cjs/ts-types/new-data-set.js +1 -1
  113. package/cjs/ts-types/new-data-set.js.map +1 -1
  114. package/cjs/ts-types/pivot-table/corner.d.ts +12 -0
  115. package/cjs/ts-types/pivot-table/corner.js.map +1 -1
  116. package/cjs/ts-types/table-engine.d.ts +12 -0
  117. package/cjs/ts-types/table-engine.js.map +1 -1
  118. package/cjs/ts-types/theme.d.ts +2 -0
  119. package/cjs/ts-types/theme.js.map +1 -1
  120. package/cjs/ts-types/tooltip.d.ts +2 -0
  121. package/cjs/ts-types/tooltip.js.map +1 -1
  122. package/cjs/vrender.d.ts +4 -0
  123. package/cjs/vrender.js +39 -11
  124. package/cjs/vrender.js.map +1 -1
  125. package/dist/vtable.js +25679 -9801
  126. package/dist/vtable.min.js +2 -2
  127. package/es/ListTable.js +34 -23
  128. package/es/ListTable.js.map +1 -1
  129. package/es/PivotChart.d.ts +1 -3
  130. package/es/PivotChart.js +8 -17
  131. package/es/PivotChart.js.map +1 -1
  132. package/es/PivotTable.d.ts +1 -1
  133. package/es/PivotTable.js +41 -19
  134. package/es/PivotTable.js.map +1 -1
  135. package/es/components/axis/axis.js +1 -3
  136. package/es/components/axis/axis.js.map +1 -1
  137. package/es/components/empty-tip/empty-tip.js +2 -2
  138. package/es/components/empty-tip/empty-tip.js.map +1 -1
  139. package/es/components/legend/discrete-legend/discrete-legend.js +1 -2
  140. package/es/components/legend/discrete-legend/discrete-legend.js.map +1 -1
  141. package/es/components/react/react-custom-layout.d.ts +21 -0
  142. package/es/components/react/react-custom-layout.js +38 -0
  143. package/es/components/react/react-custom-layout.js.map +1 -0
  144. package/es/components/tooltip/TooltipHandler.js +1 -3
  145. package/es/components/tooltip/TooltipHandler.js.map +1 -1
  146. package/es/components/tooltip/logic/BubbleTooltipElement.js +7 -3
  147. package/es/components/tooltip/logic/BubbleTooltipElement.js.map +1 -1
  148. package/es/components/tooltip/logic/BubbleTooltipElementStyle.js +1 -1
  149. package/es/components/tooltip/logic/BubbleTooltipElementStyle.js.map +1 -1
  150. package/es/core/BaseTable.d.ts +10 -28
  151. package/es/core/BaseTable.js +90 -74
  152. package/es/core/BaseTable.js.map +1 -1
  153. package/es/core/FouseInput.d.ts +0 -1
  154. package/es/core/FouseInput.js +2 -5
  155. package/es/core/FouseInput.js.map +1 -1
  156. package/es/core/style.js +1 -1
  157. package/es/core/style.js.map +1 -1
  158. package/es/data/DataSource.d.ts +6 -1
  159. package/es/data/DataSource.js +12 -2
  160. package/es/data/DataSource.js.map +1 -1
  161. package/es/dataset/dataset.d.ts +17 -2
  162. package/es/dataset/dataset.js +195 -80
  163. package/es/dataset/dataset.js.map +1 -1
  164. package/es/dataset/statistics-helper.d.ts +43 -3
  165. package/es/dataset/statistics-helper.js +55 -23
  166. package/es/dataset/statistics-helper.js.map +1 -1
  167. package/es/event/event.js +1 -2
  168. package/es/event/event.js.map +1 -1
  169. package/es/event/listener/container-dom.js +4 -3
  170. package/es/event/listener/container-dom.js.map +1 -1
  171. package/es/event/listener/table-group.js +7 -5
  172. package/es/event/listener/table-group.js.map +1 -1
  173. package/es/event/util.js +2 -2
  174. package/es/event/util.js.map +1 -1
  175. package/es/index.d.ts +3 -1
  176. package/es/index.js +5 -1
  177. package/es/index.js.map +1 -1
  178. package/es/layout/layout-helper.js.map +1 -1
  179. package/es/layout/pivot-header-layout.d.ts +1 -0
  180. package/es/layout/pivot-header-layout.js +65 -37
  181. package/es/layout/pivot-header-layout.js.map +1 -1
  182. package/es/layout/row-height-map.js +1 -0
  183. package/es/layout/row-height-map.js.map +1 -1
  184. package/es/scenegraph/component/custom.js +7 -3
  185. package/es/scenegraph/component/custom.js.map +1 -1
  186. package/es/scenegraph/debug-tool/debug-tool.js +1 -4
  187. package/es/scenegraph/debug-tool/debug-tool.js.map +1 -1
  188. package/es/scenegraph/graphic/chart.d.ts +0 -1
  189. package/es/scenegraph/graphic/chart.js +21 -33
  190. package/es/scenegraph/graphic/chart.js.map +1 -1
  191. package/es/scenegraph/graphic/contributions/chart-render-helper.js +8 -20
  192. package/es/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  193. package/es/scenegraph/graphic/contributions/chart-render.d.ts +1 -2
  194. package/es/scenegraph/graphic/contributions/chart-render.js +25 -41
  195. package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  196. package/es/scenegraph/group-creater/cell-helper.js +6 -2
  197. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  198. package/es/scenegraph/group-creater/cell-type/chart-cell.js +1 -2
  199. package/es/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  200. package/es/scenegraph/group-creater/progress/proxy.d.ts +3 -2
  201. package/es/scenegraph/group-creater/progress/proxy.js +10 -10
  202. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  203. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.d.ts +2 -1
  204. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +2 -3
  205. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  206. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.d.ts +3 -2
  207. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +15 -13
  208. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  209. package/es/scenegraph/group-creater/progress/update-position/update-auto-row.js +7 -5
  210. package/es/scenegraph/group-creater/progress/update-position/update-auto-row.js.map +1 -1
  211. package/es/scenegraph/layout/compute-col-width.js +3 -3
  212. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  213. package/es/scenegraph/layout/compute-row-height.js +8 -5
  214. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  215. package/es/scenegraph/layout/frozen.js +12 -4
  216. package/es/scenegraph/layout/frozen.js.map +1 -1
  217. package/es/scenegraph/layout/update-width.js +3 -0
  218. package/es/scenegraph/layout/update-width.js.map +1 -1
  219. package/es/scenegraph/refresh-node/update-chart.d.ts +0 -1
  220. package/es/scenegraph/refresh-node/update-chart.js +0 -6
  221. package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
  222. package/es/scenegraph/scenegraph.d.ts +2 -1
  223. package/es/scenegraph/scenegraph.js +18 -15
  224. package/es/scenegraph/scenegraph.js.map +1 -1
  225. package/es/state/cell-move/index.js +1 -1
  226. package/es/state/cell-move/index.js.map +1 -1
  227. package/es/state/sort/index.js +2 -2
  228. package/es/state/sort/index.js.map +1 -1
  229. package/es/themes/theme.js +6 -0
  230. package/es/themes/theme.js.map +1 -1
  231. package/es/ts-types/base-table.d.ts +20 -40
  232. package/es/ts-types/base-table.js.map +1 -1
  233. package/es/ts-types/customLayout.d.ts +1 -1
  234. package/es/ts-types/customLayout.js.map +1 -1
  235. package/es/ts-types/icon.d.ts +2 -0
  236. package/es/ts-types/icon.js.map +1 -1
  237. package/es/ts-types/new-data-set.d.ts +9 -1
  238. package/es/ts-types/new-data-set.js +1 -1
  239. package/es/ts-types/new-data-set.js.map +1 -1
  240. package/es/ts-types/pivot-table/corner.d.ts +12 -0
  241. package/es/ts-types/pivot-table/corner.js.map +1 -1
  242. package/es/ts-types/table-engine.d.ts +12 -0
  243. package/es/ts-types/table-engine.js.map +1 -1
  244. package/es/ts-types/theme.d.ts +2 -0
  245. package/es/ts-types/theme.js.map +1 -1
  246. package/es/ts-types/tooltip.d.ts +2 -0
  247. package/es/ts-types/tooltip.js.map +1 -1
  248. package/es/vrender.d.ts +4 -0
  249. package/es/vrender.js +9 -3
  250. package/es/vrender.js.map +1 -1
  251. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- import type { FilterRules, IPivotTableDataConfig, SortRule, AggregationRules, SortRules, DerivedFieldRules, Totals, MappingRules, IHeaderTreeDefine, CollectValueBy, CollectedValue, IIndicator, IPivotChartDataConfig } from '../ts-types';
1
+ import type { FilterRules, IPivotTableDataConfig, SortRule, AggregationRules, SortRules, DerivedFieldRules, Totals, MappingRules, IHeaderTreeDefine, CollectValueBy, CollectedValue, IIndicator, IPivotChartDataConfig, CalculateddFieldRules } from '../ts-types';
2
2
  import type { Aggregator, IAggregator } from './statistics-helper';
3
3
  import { typeSort } from './statistics-helper';
4
4
  export declare class Dataset {
@@ -18,6 +18,9 @@ export declare class Dataset {
18
18
  aggregationRules?: AggregationRules;
19
19
  derivedFieldRules?: DerivedFieldRules;
20
20
  mappingRules?: MappingRules;
21
+ calculatedFieldRules?: CalculateddFieldRules;
22
+ calculatedFiledKeys?: string[];
23
+ calculatedFieldDependIndicatorKeys?: string[];
21
24
  totals?: Totals;
22
25
  indicatorStatistics: {
23
26
  max: Aggregator;
@@ -26,7 +29,16 @@ export declare class Dataset {
26
29
  }[];
27
30
  aggregators: {
28
31
  [key: string]: {
29
- new (dimension: string | string[], formatFun?: any, isRecord?: boolean, needSplitPositiveAndNegative?: boolean): Aggregator;
32
+ new (args: {
33
+ key: string;
34
+ dimension: string | string[];
35
+ formatFun?: any;
36
+ isRecord?: boolean;
37
+ needSplitPositiveAndNegative?: boolean;
38
+ calculateFun?: any;
39
+ dependAggregators?: any;
40
+ dependIndicatorKeys?: string[];
41
+ }): Aggregator;
30
42
  };
31
43
  };
32
44
  stringJoinChar: string;
@@ -41,8 +53,11 @@ export declare class Dataset {
41
53
  collectedValues: Record<string, Record<string, CollectedValue>>;
42
54
  cacheCollectedValues: Record<string, Record<string, CollectedValue>>;
43
55
  rows: string[];
56
+ rowsHasValue: boolean[];
44
57
  columns: string[];
58
+ columnsHasValue: boolean[];
45
59
  indicatorKeys: string[];
60
+ indicatorKeysIncludeCalculatedFieldDependIndicatorKeys: string[];
46
61
  customRowTree?: IHeaderTreeDefine[];
47
62
  customColTree?: IHeaderTreeDefine[];
48
63
  colHeaderTree: any[];
@@ -2,14 +2,14 @@ import { isValid } from "@visactor/vutils";
2
2
 
3
3
  import { AggregationType, SortType } from "../ts-types";
4
4
 
5
- import { AvgAggregator, CountAggregator, MaxAggregator, MinAggregator, NoneAggregator, RecordAggregator, SumAggregator, naturalSort, sortBy, typeSort } from "./statistics-helper";
5
+ import { AvgAggregator, CountAggregator, MaxAggregator, MinAggregator, NoneAggregator, RecalculateAggregator, RecordAggregator, SumAggregator, naturalSort, sortBy, typeSort } from "./statistics-helper";
6
6
 
7
7
  import { IndicatorDimensionKeyPlaceholder } from "../tools/global";
8
8
 
9
9
  export 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 @@ export 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
  }
@@ -43,7 +49,8 @@ export class Dataset {
43
49
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
44
50
  if (this.records = records, this.collectedValues = {}, this.cacheCollectedValues = {},
45
51
  this.totalRecordsTree = {}, this.tree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
46
- this.colKeys = [], this.rowKeys = [], records) {
52
+ this.colKeys = [], this.rowKeys = [], this.rowsHasValue = [], this.columnsHasValue = [],
53
+ records) {
47
54
  this.records = records;
48
55
  "undefined" != typeof window && window.performance.now();
49
56
  this.processRecords(), this.processCollectedValuesWithSumBy(), this.generateCollectedValuesSortRule(),
@@ -53,8 +60,8 @@ export class Dataset {
53
60
  "undefined" != typeof window && window.performance.now(), "undefined" != typeof window && window.performance.now();
54
61
  this.sortKeys();
55
62
  "undefined" != typeof window && window.performance.now(), "undefined" != typeof window && window.performance.now();
56
- this.customRowTree ? this.rowHeaderTree = this.customRowTree : "tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows, this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows, this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel, null !== (_g = null === (_f = null === (_e = this.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.showGrandTotalsOnTop) && void 0 !== _g && _g, null !== (_k = null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTop) && void 0 !== _k && _k),
57
- this.customColTree ? this.colHeaderTree = this.customColTree : this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns, this.indicatorsAsCol ? this.indicators : void 0, this.colsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotalsOnLeft) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showSubTotalsOnLeft) && void 0 !== _t && _t);
63
+ this.customRowTree ? this.rowHeaderTree = this.customRowTree : "tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel, null !== (_g = null === (_f = null === (_e = this.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.showGrandTotalsOnTop) && void 0 !== _g && _g, null !== (_k = null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTop) && void 0 !== _k && _k),
64
+ this.customColTree ? this.colHeaderTree = this.customColTree : this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns.filter(((key, index) => this.columnsHasValue[index])), this.indicatorsAsCol ? this.indicators : void 0, this.colsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotalsOnLeft) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showSubTotalsOnLeft) && void 0 !== _t && _t);
58
65
  "undefined" != typeof window && window.performance.now();
59
66
  (null === (_u = this.dataConfig) || void 0 === _u ? void 0 : _u.isPivotChart) && this.cacheDeminsionCollectedValues();
60
67
  }
@@ -66,7 +73,7 @@ export class Dataset {
66
73
  this.registerAggregator(AggregationType.RECORD, RecordAggregator), this.registerAggregator(AggregationType.SUM, SumAggregator),
67
74
  this.registerAggregator(AggregationType.COUNT, CountAggregator), this.registerAggregator(AggregationType.MAX, MaxAggregator),
68
75
  this.registerAggregator(AggregationType.MIN, MinAggregator), this.registerAggregator(AggregationType.AVG, AvgAggregator),
69
- this.registerAggregator(AggregationType.NONE, NoneAggregator);
76
+ this.registerAggregator(AggregationType.NONE, NoneAggregator), this.registerAggregator(AggregationType.RECALCULATE, RecalculateAggregator);
70
77
  }
71
78
  processCollectedValuesWithSumBy() {
72
79
  var _a, _b, _c, _d, _e, _f;
@@ -132,7 +139,7 @@ export class Dataset {
132
139
  return isReserved;
133
140
  }
134
141
  processRecord(record, assignedIndicatorKey) {
135
- 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;
142
+ 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;
136
143
  null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
137
144
  derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
138
145
  }));
@@ -144,8 +151,12 @@ export class Dataset {
144
151
  max: Number.MIN_SAFE_INTEGER
145
152
  } : this.collectedValues[field][collectKeys] = []), this.collectValuesBy[field].sumBy) {
146
153
  const sumByKeys = this.collectValuesBy[field].sumBy.map((byField => record[byField])).join(this.stringJoinChar);
147
- this.collectedValues[field][collectKeys][sumByKeys] || (this.collectedValues[field][collectKeys][sumByKeys] = new this.aggregators[AggregationType.SUM](field, void 0, void 0, this.needSplitPositiveAndNegative)),
148
- this.collectedValues[field][collectKeys][sumByKeys].push(record);
154
+ this.collectedValues[field][collectKeys][sumByKeys] || (this.collectedValues[field][collectKeys][sumByKeys] = new this.aggregators[AggregationType.SUM]({
155
+ key: field,
156
+ dimension: field,
157
+ isRecord: void 0,
158
+ needSplitPositiveAndNegative: this.needSplitPositiveAndNegative
159
+ })), this.collectedValues[field][collectKeys][sumByKeys].push(record);
149
160
  } else if (this.collectValuesBy[field].range) {
150
161
  const fieldRange = this.collectedValues[field][collectKeys], max = Math.max(record[field], fieldRange.max), min = Math.min(record[field], fieldRange.min);
151
162
  isNaN(max) || (fieldRange.max = max, fieldRange.min = min);
@@ -158,7 +169,7 @@ export class Dataset {
158
169
  let isToTalRecord = !1;
159
170
  for (let l = 0, len1 = this.rows.length; l < len1; l++) {
160
171
  const rowAttr = this.rows[l];
161
- if (rowAttr in record) rowKey.push(record[rowAttr]); else if (rowAttr !== IndicatorDimensionKeyPlaceholder) {
172
+ if (rowAttr in record) this.rowsHasValue[l] = !0, rowKey.push(record[rowAttr]); else if (rowAttr !== IndicatorDimensionKeyPlaceholder) {
162
173
  if ((null === (_d = null === (_c = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) && 0 === l && !this.rows.find((rk => rk in record))) {
163
174
  rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
164
175
  break;
@@ -171,7 +182,7 @@ export class Dataset {
171
182
  }
172
183
  for (let n = 0, len2 = this.columns.length; n < len2; n++) {
173
184
  const colAttr = this.columns[n];
174
- if (colAttr in record) colKey.push(record[colAttr]); else if (colAttr !== IndicatorDimensionKeyPlaceholder) {
185
+ if (colAttr in record) this.columnsHasValue[n] = !0, colKey.push(record[colAttr]); else if (colAttr !== IndicatorDimensionKeyPlaceholder) {
175
186
  if ((null === (_o = null === (_m = null === (_l = this.dataConfig) || void 0 === _l ? void 0 : _l.totals) || void 0 === _m ? void 0 : _m.column) || void 0 === _o ? void 0 : _o.showGrandTotals) && 0 === n && !this.columns.find((ck => ck in record))) {
176
187
  colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
177
188
  break;
@@ -185,44 +196,84 @@ export class Dataset {
185
196
  const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
186
197
  if (isToTalRecord) {
187
198
  this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
188
- for (let i = 0; i < this.indicatorKeys.length; i++) {
189
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
190
- (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 : 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)),
191
- 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));
199
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
200
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
201
+ const calculatedFieldRule = null === (_v = this.calculatedFieldRules) || void 0 === _v ? void 0 : _v.find((rule => rule.key === toComputeIndicatorKeys[i]));
202
+ (null === (_x = null === (_w = this.totalRecordsTree[flatRowKey]) || void 0 === _w ? void 0 : _w[flatColKey]) || void 0 === _x ? void 0 : _x[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
203
+ key: toComputeIndicatorKeys[i],
204
+ dimension: toComputeIndicatorKeys[i],
205
+ isRecord: !0,
206
+ 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,
207
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
208
+ dependAggregators: this.totalRecordsTree[flatRowKey][flatColKey],
209
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
210
+ })), 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));
211
+ } else {
212
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
213
+ (null === (_3 = null === (_2 = this.totalRecordsTree[flatRowKey]) || void 0 === _2 ? void 0 : _2[flatColKey]) || void 0 === _3 ? void 0 : _3[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_4 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _4 ? _4 : AggregationType.SUM]({
214
+ key: toComputeIndicatorKeys[i],
215
+ dimension: null !== (_5 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _5 ? _5 : toComputeIndicatorKeys[i],
216
+ 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
217
+ })), 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));
192
218
  }
219
+ return;
220
+ }
221
+ 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
222
+ this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
223
+ this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
224
+ (null === (_11 = this.tree[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
225
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
226
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
227
+ const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
228
+ (null === (_14 = null === (_13 = this.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColKey]) || void 0 === _14 ? void 0 : _14[i]) || (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
229
+ key: toComputeIndicatorKeys[i],
230
+ dimension: toComputeIndicatorKeys[i],
231
+ isRecord: !0,
232
+ 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,
233
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
234
+ dependAggregators: this.tree[flatRowKey][flatColKey],
235
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
236
+ })), null === (_18 = null === (_17 = this.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 || _18[i].push(record);
193
237
  } else {
194
- 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
195
- this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
196
- this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
197
- (null === (_4 = this.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
198
- for (let i = 0; i < this.indicatorKeys.length; i++) {
238
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
239
+ let needAddToAggregator = !1;
240
+ 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 {
241
+ (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
242
+ } else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
243
+ !(null === (_20 = null === (_19 = this.tree[flatRowKey]) || void 0 === _19 ? void 0 : _19[flatColKey]) || void 0 === _20 ? void 0 : _20[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_21 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _21 ? _21 : AggregationType.SUM]({
244
+ key: toComputeIndicatorKeys[i],
245
+ dimension: null !== (_22 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _22 ? _22 : toComputeIndicatorKeys[i],
246
+ 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
247
+ })), needAddToAggregator && (null === (_27 = null === (_26 = this.tree[flatRowKey]) || void 0 === _26 ? void 0 : _26[flatColKey]) || void 0 === _27 || _27[i].push(record));
248
+ }
249
+ if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
250
+ if (!this.indicatorStatistics[i]) {
199
251
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
200
- let needAddToAggregator = !1;
201
- 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 {
202
- (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
203
- } else this.indicatorKeys[i] in record && (needAddToAggregator = !0);
204
- !(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 : 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)),
205
- needAddToAggregator && (null === (_13 = null === (_12 = this.tree[flatRowKey]) || void 0 === _12 ? void 0 : _12[flatColKey]) || void 0 === _13 || _13[i].push(record));
206
- }
207
- if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
208
- if (!this.indicatorStatistics[i]) {
209
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
210
- this.indicatorStatistics[i] = {
211
- max: new this.aggregators[AggregationType.MAX](this.indicatorKeys[i]),
212
- min: new this.aggregators[AggregationType.MIN](this.indicatorKeys[i]),
213
- total: new this.aggregators[null !== (_14 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _14 ? _14 : 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)
214
- };
215
- }
216
- 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()),
217
- 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()),
218
- this.indicatorStatistics[i].total.push(record);
252
+ this.indicatorStatistics[i] = {
253
+ max: new this.aggregators[AggregationType.MAX]({
254
+ key: this.indicatorKeys[i],
255
+ dimension: this.indicatorKeys[i]
256
+ }),
257
+ min: new this.aggregators[AggregationType.MIN]({
258
+ key: this.indicatorKeys[i],
259
+ dimension: this.indicatorKeys[i]
260
+ }),
261
+ total: new this.aggregators[null !== (_28 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _28 ? _28 : AggregationType.SUM]({
262
+ key: this.indicatorKeys[i],
263
+ dimension: null !== (_29 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _29 ? _29 : this.indicatorKeys[i],
264
+ 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
265
+ })
266
+ };
219
267
  }
268
+ 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()),
269
+ 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()),
270
+ this.indicatorStatistics[i].total.push(record);
220
271
  }
221
272
  }
222
273
  updateSortRules(sortRules) {
223
274
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
224
- this.sorted = !1, this.sortRules = sortRules, this.sortKeys(), this.customRowTree || ("tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows, this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows, this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel, null !== (_g = null === (_f = null === (_e = this.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.showGrandTotalsOnTop) && void 0 !== _g && _g, null !== (_k = null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTop) && void 0 !== _k && _k)),
225
- this.customColTree || (this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns, this.indicatorsAsCol ? this.indicators : void 0, this.colsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotalsOnLeft) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showSubTotalsOnLeft) && void 0 !== _t && _t));
275
+ this.sorted = !1, this.sortRules = sortRules, this.sortKeys(), this.customRowTree || ("tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel, null !== (_g = null === (_f = null === (_e = this.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.showGrandTotalsOnTop) && void 0 !== _g && _g, null !== (_k = null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTop) && void 0 !== _k && _k)),
276
+ this.customColTree || (this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns.filter(((key, index) => this.columnsHasValue[index])), this.indicatorsAsCol ? this.indicators : void 0, this.colsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotalsOnLeft) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showSubTotalsOnLeft) && void 0 !== _t && _t));
226
277
  }
227
278
  updateFilterRules(filterRules, isResetTree = !1) {
228
279
  var _a;
@@ -365,44 +416,76 @@ export class Dataset {
365
416
  const that = this;
366
417
  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)) {
367
418
  const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
368
- 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;
419
+ 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;
369
420
  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]);
370
421
  const colKey = flatColKey.split(this.stringJoinChar);
371
- 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++) {
422
+ 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++) {
372
423
  const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
373
424
  if (dimensionIndex >= 0) {
374
425
  const colTotalKey = colKey.slice(0, dimensionIndex + 1);
375
426
  colTotalKey.push(that.colSubTotalLabel);
376
427
  const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
377
- 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]);
428
+ 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]);
378
429
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
379
- for (let i = 0; i < this.indicatorKeys.length; i++) {
430
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
431
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
432
+ const calculatedFieldRule = null === (_s = this.calculatedFieldRules) || void 0 === _s ? void 0 : _s.find((rule => rule.key === toComputeIndicatorKeys[i]));
433
+ (null === (_u = null === (_t = this.tree[flatRowKey]) || void 0 === _t ? void 0 : _t[flatColTotalKey]) || void 0 === _u ? void 0 : _u[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
434
+ key: toComputeIndicatorKeys[i],
435
+ dimension: toComputeIndicatorKeys[i],
436
+ isRecord: !0,
437
+ 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,
438
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
439
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
440
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
441
+ })), 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]);
442
+ } else {
380
443
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
381
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
382
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_p = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _p ? _p : 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);
444
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
445
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_z = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _z ? _z : AggregationType.SUM]({
446
+ key: toComputeIndicatorKeys[i],
447
+ dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
448
+ 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
449
+ });
383
450
  }
384
- 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]);
451
+ 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]);
385
452
  }
386
453
  }
387
454
  }
388
- 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) {
455
+ 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) {
389
456
  const flatColTotalKey = that.colGrandTotalLabel;
390
- 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]);
457
+ 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]);
391
458
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
392
- for (let i = 0; i < this.indicatorKeys.length; i++) {
459
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
460
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
461
+ const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
462
+ (null === (_14 = null === (_13 = this.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColTotalKey]) || void 0 === _14 ? void 0 : _14[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
463
+ key: toComputeIndicatorKeys[i],
464
+ dimension: toComputeIndicatorKeys[i],
465
+ isRecord: !0,
466
+ 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,
467
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
468
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
469
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
470
+ })), 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]);
471
+ } else {
393
472
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
394
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
395
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_2 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _2 ? _2 : 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);
473
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
474
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_19 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _19 ? _19 : AggregationType.SUM]({
475
+ key: toComputeIndicatorKeys[i],
476
+ dimension: null !== (_20 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _20 ? _20 : toComputeIndicatorKeys[i],
477
+ formatFun: null !== (_21 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _21 ? _21 : null === (_23 = null === (_22 = this.indicators) || void 0 === _22 ? void 0 : _22.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _23 ? void 0 : _23.format
478
+ });
396
479
  }
397
- 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]);
480
+ 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]);
398
481
  }
399
482
  }
400
483
  };
401
484
  Object.keys(that.tree).forEach((flatRowKey => {
402
485
  const rowKey = flatRowKey.split(this.stringJoinChar);
403
486
  Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
404
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
405
- 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++) {
487
+ 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;
488
+ 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++) {
406
489
  const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
407
490
  if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
408
491
  const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
@@ -410,25 +493,57 @@ export class Dataset {
410
493
  const flatRowTotalKey = rowTotalKey.join(this.stringJoinChar);
411
494
  this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
412
495
  this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
413
- for (let i = 0; i < this.indicatorKeys.length; i++) {
414
- if (!this.tree[flatRowTotalKey][flatColKey][i]) {
415
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
416
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_f = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _f ? _f : 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);
496
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
497
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
498
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
499
+ const calculatedFieldRule = null === (_j = this.calculatedFieldRules) || void 0 === _j ? void 0 : _j.find((rule => rule.key === toComputeIndicatorKeys[i]));
500
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
501
+ key: toComputeIndicatorKeys[i],
502
+ dimension: toComputeIndicatorKeys[i],
503
+ isRecord: !0,
504
+ 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,
505
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
506
+ dependAggregators: this.tree[flatRowTotalKey][flatColKey],
507
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
508
+ });
509
+ } else {
510
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
511
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_m = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _m ? _m : AggregationType.SUM]({
512
+ key: toComputeIndicatorKeys[i],
513
+ dimension: null !== (_o = null == aggRule ? void 0 : aggRule.field) && void 0 !== _o ? _o : toComputeIndicatorKeys[i],
514
+ 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
515
+ });
417
516
  }
418
- 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]);
517
+ 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]);
419
518
  }
420
519
  }
421
520
  }
422
- 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) {
521
+ 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) {
423
522
  const flatRowTotalKey = that.rowGrandTotalLabel;
424
523
  this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
425
524
  this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
426
- for (let i = 0; i < this.indicatorKeys.length; i++) {
427
- if (!this.tree[flatRowTotalKey][flatColKey][i]) {
428
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
429
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_q = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _q ? _q : 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);
525
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
526
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
527
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
528
+ const calculatedFieldRule = null === (_w = this.calculatedFieldRules) || void 0 === _w ? void 0 : _w.find((rule => rule.key === toComputeIndicatorKeys[i]));
529
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[AggregationType.RECALCULATE]({
530
+ key: toComputeIndicatorKeys[i],
531
+ dimension: toComputeIndicatorKeys[i],
532
+ isRecord: !0,
533
+ 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,
534
+ calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
535
+ dependAggregators: this.tree[flatRowTotalKey][flatColKey],
536
+ dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
537
+ });
538
+ } else {
539
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
540
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_z = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _z ? _z : AggregationType.SUM]({
541
+ key: toComputeIndicatorKeys[i],
542
+ dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
543
+ 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
544
+ });
430
545
  }
431
- 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]);
546
+ 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]);
432
547
  }
433
548
  }
434
549
  colCompute(flatRowKey, flatColKey);