@visactor/vtable 0.25.4 → 0.26.0-alpha.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 (121) hide show
  1. package/cjs/PivotChart.d.ts +9 -0
  2. package/cjs/PivotChart.js +90 -28
  3. package/cjs/PivotChart.js.map +1 -1
  4. package/cjs/PivotTable.d.ts +5 -2
  5. package/cjs/PivotTable.js +186 -152
  6. package/cjs/PivotTable.js.map +1 -1
  7. package/cjs/core/BaseTable.js +1 -1
  8. package/cjs/core/BaseTable.js.map +1 -1
  9. package/cjs/dataset/dataset.d.ts +20 -15
  10. package/cjs/dataset/dataset.js +85 -59
  11. package/cjs/dataset/dataset.js.map +1 -1
  12. package/cjs/dataset/statistics-helper.d.ts +13 -2
  13. package/cjs/dataset/statistics-helper.js +22 -27
  14. package/cjs/dataset/statistics-helper.js.map +1 -1
  15. package/cjs/index.d.ts +1 -1
  16. package/cjs/index.js +1 -1
  17. package/cjs/index.js.map +1 -1
  18. package/cjs/layout/chart-helper/get-chart-spec.d.ts +2 -1
  19. package/cjs/layout/chart-helper/get-chart-spec.js +3 -3
  20. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  21. package/cjs/layout/layout-helper.d.ts +12 -0
  22. package/cjs/layout/layout-helper.js +52 -4
  23. package/cjs/layout/layout-helper.js.map +1 -1
  24. package/cjs/layout/pivot-header-layout.d.ts +4 -3
  25. package/cjs/layout/pivot-header-layout.js +36 -46
  26. package/cjs/layout/pivot-header-layout.js.map +1 -1
  27. package/cjs/layout/tree-helper.d.ts +1 -0
  28. package/cjs/layout/tree-helper.js +12 -7
  29. package/cjs/layout/tree-helper.js.map +1 -1
  30. package/cjs/state/cell-move/adjust-header.js +1 -1
  31. package/cjs/state/cell-move/adjust-header.js.map +1 -1
  32. package/cjs/state/resize/update-resize-column.js +1 -1
  33. package/cjs/state/resize/update-resize-column.js.map +1 -1
  34. package/cjs/state/resize/update-resize-row.js +5 -4
  35. package/cjs/state/resize/update-resize-row.js.map +1 -1
  36. package/cjs/themes/ARCO.js +1 -1
  37. package/cjs/themes/BRIGHT.js +1 -1
  38. package/cjs/themes/DARK.js +1 -1
  39. package/cjs/themes/DEFAULT.js +1 -1
  40. package/cjs/themes/SIMPLIFY.js +1 -1
  41. package/cjs/tools/LimitPromiseQueue.js +1 -1
  42. package/cjs/tools/NumberMap.js +1 -1
  43. package/cjs/tools/Rect.js +1 -1
  44. package/cjs/tools/calc.js +1 -1
  45. package/cjs/tools/debounce.js +1 -1
  46. package/cjs/tools/get-data-path/create-dataset.d.ts +9 -1
  47. package/cjs/tools/get-data-path/create-dataset.js +19 -8
  48. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  49. package/cjs/tools/get-data-path/index.js +12 -3
  50. package/cjs/tools/get-data-path/index.js.map +1 -1
  51. package/cjs/ts-types/base-table.d.ts +6 -2
  52. package/cjs/ts-types/base-table.js.map +1 -1
  53. package/cjs/ts-types/common.d.ts +2 -0
  54. package/cjs/ts-types/common.js.map +1 -1
  55. package/cjs/ts-types/menu.d.ts +1 -1
  56. package/cjs/ts-types/menu.js.map +1 -1
  57. package/cjs/ts-types/table-engine.d.ts +1 -0
  58. package/cjs/ts-types/table-engine.js.map +1 -1
  59. package/cjs/vrender.js.map +1 -1
  60. package/dist/vtable.js +882 -546
  61. package/dist/vtable.min.js +2 -2
  62. package/es/PivotChart.d.ts +9 -0
  63. package/es/PivotChart.js +97 -29
  64. package/es/PivotChart.js.map +1 -1
  65. package/es/PivotTable.d.ts +5 -2
  66. package/es/PivotTable.js +188 -148
  67. package/es/PivotTable.js.map +1 -1
  68. package/es/core/BaseTable.js +1 -1
  69. package/es/core/BaseTable.js.map +1 -1
  70. package/es/dataset/dataset.d.ts +20 -15
  71. package/es/dataset/dataset.js +85 -59
  72. package/es/dataset/dataset.js.map +1 -1
  73. package/es/dataset/statistics-helper.d.ts +13 -2
  74. package/es/dataset/statistics-helper.js +22 -27
  75. package/es/dataset/statistics-helper.js.map +1 -1
  76. package/es/index.d.ts +1 -1
  77. package/es/index.js +1 -1
  78. package/es/index.js.map +1 -1
  79. package/es/layout/chart-helper/get-chart-spec.d.ts +2 -1
  80. package/es/layout/chart-helper/get-chart-spec.js +3 -3
  81. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  82. package/es/layout/layout-helper.d.ts +12 -0
  83. package/es/layout/layout-helper.js +50 -0
  84. package/es/layout/layout-helper.js.map +1 -1
  85. package/es/layout/pivot-header-layout.d.ts +4 -3
  86. package/es/layout/pivot-header-layout.js +34 -45
  87. package/es/layout/pivot-header-layout.js.map +1 -1
  88. package/es/layout/tree-helper.d.ts +1 -0
  89. package/es/layout/tree-helper.js +12 -7
  90. package/es/layout/tree-helper.js.map +1 -1
  91. package/es/state/cell-move/adjust-header.js +1 -1
  92. package/es/state/cell-move/adjust-header.js.map +1 -1
  93. package/es/state/resize/update-resize-column.js +1 -1
  94. package/es/state/resize/update-resize-column.js.map +1 -1
  95. package/es/state/resize/update-resize-row.js +5 -4
  96. package/es/state/resize/update-resize-row.js.map +1 -1
  97. package/es/themes/ARCO.js +1 -1
  98. package/es/themes/BRIGHT.js +1 -1
  99. package/es/themes/DARK.js +1 -1
  100. package/es/themes/DEFAULT.js +1 -1
  101. package/es/themes/SIMPLIFY.js +1 -1
  102. package/es/tools/LimitPromiseQueue.js +1 -1
  103. package/es/tools/NumberMap.js +1 -1
  104. package/es/tools/Rect.js +1 -1
  105. package/es/tools/calc.js +1 -1
  106. package/es/tools/debounce.js +1 -1
  107. package/es/tools/get-data-path/create-dataset.d.ts +9 -1
  108. package/es/tools/get-data-path/create-dataset.js +20 -7
  109. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  110. package/es/tools/get-data-path/index.js +15 -2
  111. package/es/tools/get-data-path/index.js.map +1 -1
  112. package/es/ts-types/base-table.d.ts +6 -2
  113. package/es/ts-types/base-table.js.map +1 -1
  114. package/es/ts-types/common.d.ts +2 -0
  115. package/es/ts-types/common.js.map +1 -1
  116. package/es/ts-types/menu.d.ts +1 -1
  117. package/es/ts-types/menu.js.map +1 -1
  118. package/es/ts-types/table-engine.d.ts +1 -0
  119. package/es/ts-types/table-engine.js.map +1 -1
  120. package/es/vrender.js.map +1 -1
  121. package/package.json +5 -5
@@ -1,9 +1,9 @@
1
1
  import type { FilterRules, IPivotTableDataConfig, SortRule, AggregationRules, SortRules, DerivedFieldRules, Totals, MappingRules, IHeaderTreeDefine, CollectValueBy, CollectedValue, IIndicator, IPivotChartDataConfig } from '../ts-types';
2
- import type { Aggregator } from './statistics-helper';
2
+ import type { Aggregator, IAggregator } from './statistics-helper';
3
3
  import { typeSort } from './statistics-helper';
4
4
  export declare class Dataset {
5
- dataConfig: IPivotTableDataConfig | IPivotChartDataConfig;
6
- records: any[] | Record<string, any[]>;
5
+ dataConfig?: IPivotTableDataConfig | IPivotChartDataConfig;
6
+ records?: any[] | Record<string, any[]>;
7
7
  tree: Record<string, Record<string, Aggregator[]>>;
8
8
  changedTree: Record<string, Record<string, any[]>>;
9
9
  private colFlatKeys;
@@ -13,12 +13,12 @@ export declare class Dataset {
13
13
  rowOrder: string;
14
14
  colOrder: string;
15
15
  sorted: boolean;
16
- sortRules: SortRules;
17
- filterRules: FilterRules;
18
- aggregationRules: AggregationRules;
19
- derivedFieldRules: DerivedFieldRules;
20
- mappingRules: MappingRules;
21
- totals: Totals;
16
+ sortRules?: SortRules;
17
+ filterRules?: FilterRules;
18
+ aggregationRules?: AggregationRules;
19
+ derivedFieldRules?: DerivedFieldRules;
20
+ mappingRules?: MappingRules;
21
+ totals?: Totals;
22
22
  indicatorStatistics: {
23
23
  max: Aggregator;
24
24
  min: Aggregator;
@@ -37,21 +37,21 @@ export declare class Dataset {
37
37
  private rowGrandTotalLabel;
38
38
  private rowSubTotalLabel;
39
39
  private needSplitPositiveAndNegative?;
40
- collectValuesBy: Record<string, CollectValueBy>;
40
+ collectValuesBy?: Record<string, CollectValueBy>;
41
41
  collectedValues: Record<string, Record<string, CollectedValue>>;
42
42
  cacheCollectedValues: Record<string, Record<string, CollectedValue>>;
43
43
  rows: string[];
44
44
  columns: string[];
45
45
  indicatorKeys: string[];
46
- customRowTree: IHeaderTreeDefine[];
47
- customColTree: IHeaderTreeDefine[];
46
+ customRowTree?: IHeaderTreeDefine[];
47
+ customColTree?: IHeaderTreeDefine[];
48
48
  colHeaderTree: any[];
49
49
  rowHeaderTree: any[];
50
50
  rowHierarchyType: 'grid' | 'tree';
51
- indicators: (string | IIndicator)[];
51
+ indicators?: (string | IIndicator)[];
52
52
  indicatorsAsCol: boolean;
53
53
  totalRecordsTree: Record<string, Record<string, Aggregator[]>>;
54
- constructor(dataConfig: IPivotTableDataConfig | IPivotChartDataConfig, rows: string[], columns: string[], indicatorKeys: string[], indicators: (string | IIndicator)[], indicatorsAsCol: boolean, records: any[] | Record<string, any[]>, rowHierarchyType?: 'grid' | 'tree', customColTree?: IHeaderTreeDefine[], customRowTree?: IHeaderTreeDefine[], needSplitPositiveAndNegative?: boolean);
54
+ constructor(dataConfig: IPivotTableDataConfig | IPivotChartDataConfig | undefined, rows: string[], columns: string[], indicatorKeys: string[], indicators: (string | IIndicator)[] | undefined, indicatorsAsCol: boolean, records: any[] | Record<string, any[]> | undefined, rowHierarchyType?: 'grid' | 'tree', customColTree?: IHeaderTreeDefine[], customRowTree?: IHeaderTreeDefine[], needSplitPositiveAndNegative?: boolean);
55
55
  setRecords(records: any[] | Record<string, any[]>): void;
56
56
  registerAggregator(type: string, aggregator: any): void;
57
57
  registerAggregators(): void;
@@ -64,7 +64,7 @@ export declare class Dataset {
64
64
  updateSortRules(sortRules: SortRules): void;
65
65
  updateFilterRules(filterRules: FilterRules, isResetTree?: boolean): void;
66
66
  private getAggregatorRule;
67
- getAggregator(rowKey: string[] | string, colKey: string[] | string, indicator: string, considerChangedValue?: boolean): Aggregator;
67
+ getAggregator(rowKey: string[] | string, colKey: string[] | string, indicator: string, considerChangedValue?: boolean): IAggregator;
68
68
  sortKeys(): void;
69
69
  arrSort(fieldArr: string[], isRow: boolean): (a: string[], b: string[]) => number;
70
70
  getSort(sortRule: SortRule, isSortRow: boolean): typeof typeSort;
@@ -76,4 +76,9 @@ export declare class Dataset {
76
76
  private _adjustCustomTree;
77
77
  changeTreeNodeValue(rowKey: string[] | string, colKey: string[] | string, indicator: string, newValue: string | number): void;
78
78
  changeRecordFieldValue(fieldName: string, oldValue: string | number, value: string | number): void;
79
+ changeDataConfig(dataConfig: {
80
+ rows: string[];
81
+ columns: string[];
82
+ }): void;
83
+ addRecords(records: any[]): void;
79
84
  }
@@ -6,7 +6,7 @@ import { AvgAggregator, CountAggregator, MaxAggregator, MinAggregator, NoneAggre
6
6
 
7
7
  export class Dataset {
8
8
  constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
9
- 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;
9
+ 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;
10
10
  if (this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
11
11
  this.colKeys = [], this.rowKeys = [], this.rowOrder = "key_a_to_z", this.colOrder = "key_a_to_z",
12
12
  this.sorted = !1, this.indicatorStatistics = [], this.aggregators = {}, this.stringJoinChar = String.fromCharCode(0),
@@ -27,11 +27,11 @@ export class Dataset {
27
27
  this.needSplitPositiveAndNegative = null != needSplitPositiveAndNegative && needSplitPositiveAndNegative,
28
28
  this.rowsIsTotal = new Array(null !== (_v = null === (_u = this.rows) || void 0 === _u ? void 0 : _u.length) && void 0 !== _v ? _v : 0).fill(!1),
29
29
  this.colsIsTotal = new Array(null !== (_x = null === (_w = this.columns) || void 0 === _w ? void 0 : _w.length) && void 0 !== _x ? _x : 0).fill(!1),
30
- (null === (_y = this.totals) || void 0 === _y ? void 0 : _y.row) && !1 !== this.totals.row.showSubTotals) for (let i = 0, len = 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; i < len; i++) {
30
+ (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++) {
31
31
  const dimension = this.totals.row.subTotalsDimensions[i], dimensionIndex = this.rows.indexOf(dimension);
32
32
  this.rowsIsTotal[dimensionIndex] = !0;
33
33
  }
34
- if ((null === (_2 = this.totals) || void 0 === _2 ? void 0 : _2.column) && !1 !== this.totals.column.showSubTotals) for (let i = 0, len = null === (_5 = null === (_4 = null === (_3 = this.totals) || void 0 === _3 ? void 0 : _3.column) || void 0 === _4 ? void 0 : _4.subTotalsDimensions) || void 0 === _5 ? void 0 : _5.length; i < len; i++) {
34
+ 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++) {
35
35
  const dimension = this.totals.column.subTotalsDimensions[i], dimensionIndex = this.columns.indexOf(dimension);
36
36
  this.colsIsTotal[dimensionIndex] = !0;
37
37
  }
@@ -69,12 +69,12 @@ export class Dataset {
69
69
  this.registerAggregator(AggregationType.NONE, NoneAggregator);
70
70
  }
71
71
  processCollectedValuesWithSumBy() {
72
- var _a, _b, _c, _d, _e;
73
- for (const field in this.collectedValues) if (null === (_a = this.collectValuesBy[field]) || void 0 === _a ? void 0 : _a.sumBy) for (const byKeys in this.collectedValues[field]) {
72
+ var _a, _b, _c, _d, _e, _f;
73
+ for (const field in this.collectedValues) if (null === (_b = null === (_a = this.collectValuesBy) || void 0 === _a ? void 0 : _a[field]) || void 0 === _b ? void 0 : _b.sumBy) for (const byKeys in this.collectedValues[field]) {
74
74
  let max;
75
- "sum" === (null === (_b = this.collectValuesBy[field]) || void 0 === _b ? void 0 : _b.extendRange) ? (max = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => acc + cur.value()), 0),
75
+ "sum" === (null === (_c = this.collectValuesBy[field]) || void 0 === _c ? void 0 : _c.extendRange) ? (max = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => acc + cur.value()), 0),
76
76
  max += Math.round(max / 20)) : (max = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => cur.value() > acc ? cur.value() : acc), Number.MIN_SAFE_INTEGER),
77
- "max" === (null === (_c = this.collectValuesBy[field]) || void 0 === _c ? void 0 : _c.extendRange) ? max += Math.round(max / 20) : "number" == typeof (null === (_d = this.collectValuesBy[field]) || void 0 === _d ? void 0 : _d.extendRange) && (max = Math.max(max, null === (_e = this.collectValuesBy[field]) || void 0 === _e ? void 0 : _e.extendRange)));
77
+ "max" === (null === (_d = this.collectValuesBy[field]) || void 0 === _d ? void 0 : _d.extendRange) ? max += Math.round(max / 20) : "number" == typeof (null === (_e = this.collectValuesBy[field]) || void 0 === _e ? void 0 : _e.extendRange) && (max = Math.max(max, null === (_f = this.collectValuesBy[field]) || void 0 === _f ? void 0 : _f.extendRange)));
78
78
  const min = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => cur.value() < acc ? cur.value() : acc), Number.MAX_SAFE_INTEGER);
79
79
  let positiveMax, negativeMin;
80
80
  this.needSplitPositiveAndNegative && (positiveMax = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => cur.positiveValue() > acc ? cur.positiveValue() : acc), Number.MIN_SAFE_INTEGER),
@@ -85,14 +85,15 @@ export class Dataset {
85
85
  }
86
86
  }
87
87
  processCollectedValuesWithSortBy() {
88
- var _a;
89
- for (const field in this.collectedValues) if (null === (_a = this.collectValuesBy[field]) || void 0 === _a ? void 0 : _a.sortBy) for (const byKeys in this.collectedValues[field]) this.collectedValues[field][byKeys] = this.collectedValues[field][byKeys].sort(((a, b) => {
90
- var _a, _b;
91
- return (null === (_a = this.collectValuesBy[field]) || void 0 === _a ? void 0 : _a.sortBy.indexOf(a)) - (null === (_b = this.collectValuesBy[field]) || void 0 === _b ? void 0 : _b.sortBy.indexOf(b));
88
+ var _a, _b;
89
+ const that = this;
90
+ for (const field in this.collectedValues) if (null === (_b = null === (_a = this.collectValuesBy) || void 0 === _a ? void 0 : _a[field]) || void 0 === _b ? void 0 : _b.sortBy) for (const byKeys in this.collectedValues[field]) this.collectedValues[field][byKeys] = this.collectedValues[field][byKeys].sort(((a, b) => {
91
+ var _a, _b, _c, _d;
92
+ return (null !== (_b = null === (_a = that.collectValuesBy[field].sortBy) || void 0 === _a ? void 0 : _a.indexOf(a)) && void 0 !== _b ? _b : -1) - (null !== (_d = null === (_c = that.collectValuesBy[field].sortBy) || void 0 === _c ? void 0 : _c.indexOf(b)) && void 0 !== _d ? _d : -1);
92
93
  }));
93
94
  }
94
95
  generateCollectedValuesSortRule() {
95
- for (const field in this.collectedValues) if (this.collectValuesBy[field] && !this.collectValuesBy[field].sortBy) {
96
+ for (const field in this.collectedValues) if (this.collectValuesBy && this.collectValuesBy[field] && !this.collectValuesBy[field].sortBy) {
96
97
  let sortByRule = [];
97
98
  for (const byKeys in this.collectedValues[field]) Array.isArray(this.collectedValues[field][byKeys]) && (sortByRule.push(...this.collectedValues[field][byKeys]),
98
99
  sortByRule = Array.from(new Set(sortByRule)));
@@ -100,9 +101,9 @@ export class Dataset {
100
101
  }
101
102
  }
102
103
  processRecords() {
103
- var _a, _b;
104
+ var _a, _b, _c;
104
105
  let isNeedFilter = !1;
105
- if ((null === (_b = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) || void 0 === _b ? void 0 : _b.length) >= 1 && (isNeedFilter = !0),
106
+ if ((null !== (_c = null === (_b = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) || void 0 === _b ? void 0 : _b.length) && void 0 !== _c ? _c : 0) >= 1 && (isNeedFilter = !0),
106
107
  Array.isArray(this.records)) for (let i = 0, len = this.records.length; i < len; i++) {
107
108
  const record = this.records[i];
108
109
  isNeedFilter && !this.filterRecord(record) || this.processRecord(record);
@@ -113,17 +114,17 @@ export class Dataset {
113
114
  this.rowFlatKeys = {}, this.colFlatKeys = {};
114
115
  }
115
116
  filterRecord(record) {
116
- var _a, _b;
117
+ var _a, _b, _c, _d;
117
118
  let isReserved = !0;
118
- for (let i = 0; i < this.dataConfig.filterRules.length; i++) {
119
- const filterRule = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules[i];
119
+ if (null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) for (let i = 0; i < this.dataConfig.filterRules.length; i++) {
120
+ const filterRule = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules[i];
120
121
  if (filterRule.filterKey) {
121
122
  const filterValue = record[filterRule.filterKey];
122
- if (-1 === filterRule.filteredValues.indexOf(filterValue)) {
123
+ if (-1 === (null === (_c = filterRule.filteredValues) || void 0 === _c ? void 0 : _c.indexOf(filterValue))) {
123
124
  isReserved = !1;
124
125
  break;
125
126
  }
126
- } else if (!(null === (_b = filterRule.filterFunc) || void 0 === _b ? void 0 : _b.call(filterRule, record))) {
127
+ } else if (!(null === (_d = filterRule.filterFunc) || void 0 === _d ? void 0 : _d.call(filterRule, record))) {
127
128
  isReserved = !1;
128
129
  break;
129
130
  }
@@ -133,7 +134,7 @@ export class Dataset {
133
134
  processRecord(record, assignedIndicatorKey) {
134
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;
135
136
  null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
136
- record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
137
+ derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
137
138
  }));
138
139
  for (const field in this.collectValuesBy) if (isValid(record[field])) {
139
140
  this.collectedValues[field] || (this.collectedValues[field] = {});
@@ -162,7 +163,7 @@ export class Dataset {
162
163
  rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
163
164
  break;
164
165
  }
165
- if ((null === (_g = null === (_f = null === (_e = this.dataConfig) || void 0 === _e ? void 0 : _e.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions.indexOf(this.rows[l - 1])) >= 0) {
166
+ if ((null === (_g = null === (_f = null === (_e = this.dataConfig) || void 0 === _e ? void 0 : _e.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions) && (null === (_k = null === (_j = null === (_h = this.dataConfig) || void 0 === _h ? void 0 : _h.totals) || void 0 === _j ? void 0 : _j.row) || void 0 === _k ? void 0 : _k.subTotalsDimensions.indexOf(this.rows[l - 1])) >= 0) {
166
167
  "grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
167
168
  break;
168
169
  }
@@ -171,11 +172,11 @@ export class Dataset {
171
172
  for (let n = 0, len2 = this.columns.length; n < len2; n++) {
172
173
  const colAttr = this.columns[n];
173
174
  if (colAttr in record) colKey.push(record[colAttr]); else {
174
- if ((null === (_k = null === (_j = null === (_h = this.dataConfig) || void 0 === _h ? void 0 : _h.totals) || void 0 === _j ? void 0 : _j.column) || void 0 === _k ? void 0 : _k.showGrandTotals) && 0 === n && !this.columns.find((ck => ck in record))) {
175
+ 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))) {
175
176
  colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
176
177
  break;
177
178
  }
178
- 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.subTotalsDimensions.indexOf(this.columns[n - 1])) >= 0) {
179
+ if ((null === (_r = null === (_q = null === (_p = this.dataConfig) || void 0 === _p ? void 0 : _p.totals) || void 0 === _q ? void 0 : _q.column) || void 0 === _r ? void 0 : _r.subTotalsDimensions) && (null === (_u = null === (_t = null === (_s = this.dataConfig) || void 0 === _s ? void 0 : _s.totals) || void 0 === _t ? void 0 : _t.column) || void 0 === _u ? void 0 : _u.subTotalsDimensions.indexOf(this.columns[n - 1])) >= 0) {
179
180
  colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
180
181
  break;
181
182
  }
@@ -186,20 +187,22 @@ export class Dataset {
186
187
  this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
187
188
  for (let i = 0; i < this.indicatorKeys.length; i++) {
188
189
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
189
- (null === (_q = null === (_p = this.totalRecordsTree[flatRowKey]) || void 0 === _p ? void 0 : _p[flatColKey]) || void 0 === _q ? void 0 : _q[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_r = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _r ? _r : AggregationType.SUM](null !== (_s = null == aggRule ? void 0 : aggRule.field) && void 0 !== _s ? _s : this.indicatorKeys[i], null !== (_t = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _t ? _t : null === (_v = null === (_u = this.indicators) || void 0 === _u ? void 0 : _u.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _v ? void 0 : _v.format)),
190
- this.indicatorKeys[i] in record && (null === (_x = null === (_w = this.totalRecordsTree[flatRowKey]) || void 0 === _w ? void 0 : _w[flatColKey]) || void 0 === _x || _x[i].push(record));
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));
191
192
  }
192
193
  } else {
193
194
  0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
194
195
  this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
195
196
  this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
196
- (null === (_y = this.tree[flatRowKey]) || void 0 === _y ? void 0 : _y[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
197
+ (null === (_4 = this.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
197
198
  for (let i = 0; i < this.indicatorKeys.length; i++) {
198
199
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
199
- if ((null === (_0 = null === (_z = this.tree[flatRowKey]) || void 0 === _z ? void 0 : _z[flatColKey]) || void 0 === _0 ? void 0 : _0[i]) || (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_1 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _1 ? _1 : AggregationType.SUM](null !== (_2 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _2 ? _2 : this.indicatorKeys[i], null !== (_3 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _3 ? _3 : null === (_5 = null === (_4 = this.indicators) || void 0 === _4 ? void 0 : _4.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _5 ? void 0 : _5.format)),
200
- assignedIndicatorKey) this.indicatorKeys[i] === assignedIndicatorKey && (null === (_7 = null === (_6 = this.tree[flatRowKey]) || void 0 === _6 ? void 0 : _6[flatColKey]) || void 0 === _7 || _7[i].push(record)); 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 && (null === (_9 = null === (_8 = this.tree[flatRowKey]) || void 0 === _8 ? void 0 : _8[flatColKey]) || void 0 === _9 || _9[i].push(record)); else {
201
- (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (null === (_11 = null === (_10 = this.tree[flatRowKey]) || void 0 === _10 ? void 0 : _10[flatColKey]) || void 0 === _11 || _11[i].push(record));
202
- } else this.indicatorKeys[i] in record && (null === (_13 = null === (_12 = this.tree[flatRowKey]) || void 0 === _12 ? void 0 : _12[flatColKey]) || void 0 === _13 || _13[i].push(record));
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));
203
206
  }
204
207
  if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
205
208
  if (!this.indicatorStatistics[i]) {
@@ -235,8 +238,11 @@ export class Dataset {
235
238
  var _a, _b, _c, _d;
236
239
  const indicatorIndex = this.indicatorKeys.indexOf(indicator);
237
240
  let flatRowKey, flatColKey;
238
- flatRowKey = "string" == typeof rowKey ? rowKey : rowKey.join(this.stringJoinChar),
239
- flatColKey = "string" == typeof colKey ? colKey : colKey.join(this.stringJoinChar);
241
+ "string" == typeof rowKey ? flatRowKey = rowKey : (rowKey.map(((key, i) => {
242
+ key === indicator && rowKey.splice(i, 1);
243
+ })), flatRowKey = rowKey.join(this.stringJoinChar)), "string" == typeof colKey ? flatColKey = colKey : (colKey.map(((key, i) => {
244
+ key === indicator && colKey.splice(i, 1);
245
+ })), flatColKey = colKey.join(this.stringJoinChar));
240
246
  const agg = null === (_b = null === (_a = this.tree[flatRowKey]) || void 0 === _a ? void 0 : _a[flatColKey]) || void 0 === _b ? void 0 : _b[indicatorIndex];
241
247
  if (considerChangedValue && isValid(null === (_d = null === (_c = this.changedTree[flatRowKey]) || void 0 === _c ? void 0 : _c[flatColKey]) || void 0 === _d ? void 0 : _d[indicatorIndex])) {
242
248
  const changeValue = this.changedTree[flatRowKey][flatColKey][indicatorIndex];
@@ -265,7 +271,6 @@ export class Dataset {
265
271
  push() {},
266
272
  recalculate() {},
267
273
  value: () => null,
268
- formatValue: () => "",
269
274
  clearCacheValue() {},
270
275
  reset() {}
271
276
  };
@@ -356,48 +361,48 @@ export class Dataset {
356
361
  } : sortRule.sortBy ? sortBy(sortRule.sortBy) : sortRule.sortType ? typeSort : sortRule.sortFunc ? sortRule.sortFunc : naturalSort;
357
362
  }
358
363
  totalStatistics() {
359
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
364
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
360
365
  const that = this;
361
- if ((null === (_c = null === (_b = null === (_a = null == that ? void 0 : that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.subTotalsDimensions) || void 0 === _c ? void 0 : _c.length) >= 1 || (null === (_f = null === (_e = null === (_d = null == that ? void 0 : that.totals) || void 0 === _d ? void 0 : _d.row) || void 0 === _e ? void 0 : _e.subTotalsDimensions) || void 0 === _f ? void 0 : _f.length) >= 1 || (null === (_h = null === (_g = null == that ? void 0 : that.totals) || void 0 === _g ? void 0 : _g.column) || void 0 === _h ? void 0 : _h.showGrandTotals) || (null === (_k = null === (_j = null == that ? void 0 : that.totals) || void 0 === _j ? void 0 : _j.row) || void 0 === _k ? void 0 : _k.showGrandTotals)) {
366
+ 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)) {
362
367
  const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
363
- 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;
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;
364
369
  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]);
365
370
  const colKey = flatColKey.split(this.stringJoinChar);
366
- for (let i = 0, len = null === (_g = null === (_f = null === (_e = that.totals) || void 0 === _e ? void 0 : _e.column) || void 0 === _f ? void 0 : _f.subTotalsDimensions) || void 0 === _g ? void 0 : _g.length; i < len; i++) {
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++) {
367
372
  const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
368
373
  if (dimensionIndex >= 0) {
369
374
  const colTotalKey = colKey.slice(0, dimensionIndex + 1);
370
375
  colTotalKey.push(that.colSubTotalLabel);
371
376
  const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
372
- if (null === (_j = null === (_h = this.totalRecordsTree) || void 0 === _h ? void 0 : _h[flatRowKey]) || void 0 === _j ? void 0 : _j[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_l = null === (_k = this.totalRecordsTree) || void 0 === _k ? void 0 : _k[flatRowKey]) || void 0 === _l ? void 0 : _l[flatColTotalKey]);
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]);
373
378
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
374
379
  for (let i = 0; i < this.indicatorKeys.length; i++) {
375
380
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
376
381
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
377
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_m = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _m ? _m : AggregationType.SUM](null !== (_o = null == aggRule ? void 0 : aggRule.field) && void 0 !== _o ? _o : this.indicatorKeys[i], 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 === this.indicatorKeys[i]))) || void 0 === _r ? void 0 : _r.format);
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);
378
383
  }
379
- this.tree[flatRowKey][flatColTotalKey][i].push(null === (_t = null === (_s = that.tree[flatRowKey]) || void 0 === _s ? void 0 : _s[flatColKey]) || void 0 === _t ? void 0 : _t[i]);
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]);
380
385
  }
381
386
  }
382
387
  }
383
- if ((null === (_v = null === (_u = that.totals) || void 0 === _u ? void 0 : _u.column) || void 0 === _v ? void 0 : _v.showGrandTotals) || 0 === this.rows.length) {
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) {
384
389
  const flatColTotalKey = that.colGrandTotalLabel;
385
- if (null === (_x = null === (_w = this.totalRecordsTree) || void 0 === _w ? void 0 : _w[flatRowKey]) || void 0 === _x ? void 0 : _x[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_z = null === (_y = this.totalRecordsTree) || void 0 === _y ? void 0 : _y[flatRowKey]) || void 0 === _z ? void 0 : _z[flatColTotalKey]);
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]);
386
391
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
387
392
  for (let i = 0; i < this.indicatorKeys.length; i++) {
388
393
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
389
394
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
390
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_0 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _0 ? _0 : AggregationType.SUM](null !== (_1 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _1 ? _1 : this.indicatorKeys[i], null !== (_2 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _2 ? _2 : null === (_4 = null === (_3 = this.indicators) || void 0 === _3 ? void 0 : _3.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _4 ? void 0 : _4.format);
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);
391
396
  }
392
- this.tree[flatRowKey][flatColTotalKey][i].push(null === (_6 = null === (_5 = that.tree[flatRowKey]) || void 0 === _5 ? void 0 : _5[flatColKey]) || void 0 === _6 ? void 0 : _6[i]);
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]);
393
398
  }
394
399
  }
395
400
  };
396
401
  Object.keys(that.tree).forEach((flatRowKey => {
397
402
  const rowKey = flatRowKey.split(this.stringJoinChar);
398
403
  Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
399
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
400
- for (let i = 0, len = null === (_c = null === (_b = null === (_a = that.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) || void 0 === _c ? void 0 : _c.length; i < len; i++) {
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++) {
401
406
  const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
402
407
  if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
403
408
  const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
@@ -408,22 +413,22 @@ export class Dataset {
408
413
  for (let i = 0; i < this.indicatorKeys.length; i++) {
409
414
  if (!this.tree[flatRowTotalKey][flatColKey][i]) {
410
415
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
411
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_d = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _d ? _d : AggregationType.SUM](null !== (_e = null == aggRule ? void 0 : aggRule.field) && void 0 !== _e ? _e : this.indicatorKeys[i], null !== (_f = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _f ? _f : null === (_h = null === (_g = this.indicators) || void 0 === _g ? void 0 : _g.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _h ? void 0 : _h.format);
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);
412
417
  }
413
- this.tree[flatRowTotalKey][flatColKey][i].push(null === (_k = null === (_j = that.tree[flatRowKey]) || void 0 === _j ? void 0 : _j[flatColKey]) || void 0 === _k ? void 0 : _k[i]);
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]);
414
419
  }
415
420
  }
416
421
  }
417
- if ((null === (_m = null === (_l = that.totals) || void 0 === _l ? void 0 : _l.row) || void 0 === _m ? void 0 : _m.showGrandTotals) || 0 === this.columns.length) {
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) {
418
423
  const flatRowTotalKey = that.rowGrandTotalLabel;
419
424
  this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
420
425
  this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
421
426
  for (let i = 0; i < this.indicatorKeys.length; i++) {
422
427
  if (!this.tree[flatRowTotalKey][flatColKey][i]) {
423
428
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
424
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_o = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _o ? _o : AggregationType.SUM](null !== (_p = null == aggRule ? void 0 : aggRule.field) && void 0 !== _p ? _p : this.indicatorKeys[i], null !== (_q = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _q ? _q : null === (_s = null === (_r = this.indicators) || void 0 === _r ? void 0 : _r.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _s ? void 0 : _s.format);
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);
425
430
  }
426
- this.tree[flatRowTotalKey][flatColKey][i].push(null === (_u = null === (_t = that.tree[flatRowKey]) || void 0 === _t ? void 0 : _t[flatColKey]) || void 0 === _u ? void 0 : _u[i]);
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]);
427
432
  }
428
433
  }
429
434
  colCompute(flatRowKey, flatColKey);
@@ -441,13 +446,14 @@ export class Dataset {
441
446
  const path = [];
442
447
  let node;
443
448
  list.forEach(((value, index) => {
449
+ var _a;
444
450
  path.push(value);
445
451
  const flatKey = path.join(concatStr);
446
452
  let item = map.get(flatKey);
447
453
  item || (item = {
448
454
  value: value,
449
455
  dimensionKey: rows[index],
450
- children: index === list.length - 1 && (null == indicators ? void 0 : indicators.length) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
456
+ children: index === list.length - 1 && (null !== (_a = null == indicators ? void 0 : indicators.length) && void 0 !== _a ? _a : 0) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
451
457
  indicatorKey: indicator,
452
458
  value: indicator
453
459
  } : {
@@ -469,6 +475,7 @@ export class Dataset {
469
475
  const path = [];
470
476
  let node;
471
477
  list.forEach(((value, index) => {
478
+ var _a, _b, _c, _d;
472
479
  path.push(value);
473
480
  const flatKey = path.join(concatStr);
474
481
  let item = map.get(flatKey);
@@ -476,7 +483,7 @@ export class Dataset {
476
483
  if (item = {
477
484
  value: value,
478
485
  dimensionKey: rows[index],
479
- children: index === list.length - 1 && (null == indicators ? void 0 : indicators.length) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
486
+ children: index === list.length - 1 && (null !== (_a = null == indicators ? void 0 : indicators.length) && void 0 !== _a ? _a : 0) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
480
487
  indicatorKey: indicator,
481
488
  value: indicator
482
489
  } : {
@@ -484,12 +491,12 @@ export class Dataset {
484
491
  value: indicator.title
485
492
  })) : []
486
493
  }, subTotalFlags[index]) {
487
- let curChild = item.children;
494
+ let curChild = null !== (_b = item.children) && void 0 !== _b ? _b : [];
488
495
  const totalChild = {
489
496
  value: subTotalLabel,
490
497
  dimensionKey: rows[index + 1],
491
498
  levelSpan: subTotalFlags.length - index - 1,
492
- children: (null == indicators ? void 0 : indicators.length) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
499
+ children: (null !== (_c = null == indicators ? void 0 : indicators.length) && void 0 !== _c ? _c : 0) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
493
500
  indicatorKey: indicator,
494
501
  value: indicator
495
502
  } : {
@@ -497,7 +504,7 @@ export class Dataset {
497
504
  value: indicator.title
498
505
  })) : []
499
506
  };
500
- curChild.push(totalChild), curChild = totalChild.children;
507
+ curChild.push(totalChild), curChild = null !== (_d = totalChild.children) && void 0 !== _d ? _d : [];
501
508
  }
502
509
  map.set(flatKey, item), node ? subTotalFlags[index - 1] && !showSubTotalsOnTop ? node.children.splice(node.children.length - 1, 0, item) : node.children.push(item) : result.push(item);
503
510
  }
@@ -505,7 +512,10 @@ export class Dataset {
505
512
  }));
506
513
  }(item))) : indicators && (result = null == indicators ? void 0 : indicators.map((indicator => {
507
514
  var _a;
508
- return {
515
+ return "string" == typeof indicator ? {
516
+ indicatorKey: indicator,
517
+ value: indicator
518
+ } : {
509
519
  indicatorKey: indicator.indicatorKey,
510
520
  value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
511
521
  };
@@ -544,7 +554,10 @@ export class Dataset {
544
554
  var _a, _b;
545
555
  node.indicatorKey || isHasIndicator || (null === (_a = node.children) || void 0 === _a ? void 0 : _a.length) && node.children ? node.children && Array.isArray(node.children) && checkNode(node.children, isHasIndicator || !!node.indicatorKey) : node.children = null === (_b = this.indicators) || void 0 === _b ? void 0 : _b.map((indicator => {
546
556
  var _a;
547
- return {
557
+ return "string" == typeof indicator ? {
558
+ indicatorKey: indicator,
559
+ value: indicator
560
+ } : {
548
561
  indicatorKey: indicator.indicatorKey,
549
562
  value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
550
563
  };
@@ -553,7 +566,10 @@ export class Dataset {
553
566
  };
554
567
  return (null == customTree ? void 0 : customTree.length) ? checkNode(customTree, !1) : customTree = null === (_a = this.indicators) || void 0 === _a ? void 0 : _a.map((indicator => {
555
568
  var _a;
556
- return {
569
+ return "string" == typeof indicator ? {
570
+ indicatorKey: indicator,
571
+ value: indicator
572
+ } : {
557
573
  indicatorKey: indicator.indicatorKey,
558
574
  value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
559
575
  };
@@ -583,6 +599,16 @@ export class Dataset {
583
599
  this.rowFlatKeys = {}, this.colFlatKeys = {}, this.tree = {}, this.processRecords();
584
600
  }
585
601
  }
602
+ changeDataConfig(dataConfig) {
603
+ this.rows = dataConfig.rows, this.columns = dataConfig.columns;
604
+ }
605
+ addRecords(records) {
606
+ for (let i = 0, len = records.length; i < len; i++) {
607
+ const record = records[i];
608
+ this.processRecord(record);
609
+ }
610
+ Array.isArray(this.records) && this.records.push(records);
611
+ }
586
612
  }
587
613
 
588
614
  function arraySortByAnotherArray(array, sortArray) {