@visactor/vtable 0.25.5 → 0.26.0-alpha.1

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 (105) 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 +4 -5
  8. package/cjs/core/BaseTable.js.map +1 -1
  9. package/cjs/dataset/dataset.d.ts +20 -15
  10. package/cjs/dataset/dataset.js +88 -62
  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/event/listener/table-group.js +3 -10
  16. package/cjs/event/listener/table-group.js.map +1 -1
  17. package/cjs/index.d.ts +1 -1
  18. package/cjs/index.js +1 -1
  19. package/cjs/index.js.map +1 -1
  20. package/cjs/layout/chart-helper/get-chart-spec.d.ts +2 -1
  21. package/cjs/layout/chart-helper/get-chart-spec.js +3 -3
  22. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  23. package/cjs/layout/layout-helper.d.ts +12 -0
  24. package/cjs/layout/layout-helper.js +52 -4
  25. package/cjs/layout/layout-helper.js.map +1 -1
  26. package/cjs/layout/pivot-header-layout.d.ts +4 -3
  27. package/cjs/layout/pivot-header-layout.js +43 -47
  28. package/cjs/layout/pivot-header-layout.js.map +1 -1
  29. package/cjs/layout/tree-helper.d.ts +2 -0
  30. package/cjs/layout/tree-helper.js +19 -11
  31. package/cjs/layout/tree-helper.js.map +1 -1
  32. package/cjs/state/cell-move/adjust-header.js +1 -1
  33. package/cjs/state/cell-move/adjust-header.js.map +1 -1
  34. package/cjs/state/resize/update-resize-column.js +1 -1
  35. package/cjs/state/resize/update-resize-column.js.map +1 -1
  36. package/cjs/state/resize/update-resize-row.js +5 -4
  37. package/cjs/state/resize/update-resize-row.js.map +1 -1
  38. package/cjs/tools/get-data-path/create-dataset.d.ts +9 -1
  39. package/cjs/tools/get-data-path/create-dataset.js +19 -8
  40. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  41. package/cjs/tools/get-data-path/index.js +12 -3
  42. package/cjs/tools/get-data-path/index.js.map +1 -1
  43. package/cjs/ts-types/base-table.d.ts +6 -4
  44. package/cjs/ts-types/base-table.js.map +1 -1
  45. package/cjs/ts-types/common.d.ts +2 -0
  46. package/cjs/ts-types/common.js.map +1 -1
  47. package/cjs/ts-types/menu.d.ts +1 -1
  48. package/cjs/ts-types/menu.js.map +1 -1
  49. package/cjs/ts-types/table-engine.d.ts +1 -0
  50. package/cjs/ts-types/table-engine.js.map +1 -1
  51. package/cjs/vrender.js.map +1 -1
  52. package/dist/vtable.js +902 -566
  53. package/dist/vtable.min.js +2 -2
  54. package/es/PivotChart.d.ts +9 -0
  55. package/es/PivotChart.js +97 -29
  56. package/es/PivotChart.js.map +1 -1
  57. package/es/PivotTable.d.ts +5 -2
  58. package/es/PivotTable.js +188 -148
  59. package/es/PivotTable.js.map +1 -1
  60. package/es/core/BaseTable.js +4 -5
  61. package/es/core/BaseTable.js.map +1 -1
  62. package/es/dataset/dataset.d.ts +20 -15
  63. package/es/dataset/dataset.js +89 -61
  64. package/es/dataset/dataset.js.map +1 -1
  65. package/es/dataset/statistics-helper.d.ts +13 -2
  66. package/es/dataset/statistics-helper.js +22 -27
  67. package/es/dataset/statistics-helper.js.map +1 -1
  68. package/es/event/listener/table-group.js +2 -11
  69. package/es/event/listener/table-group.js.map +1 -1
  70. package/es/index.d.ts +1 -1
  71. package/es/index.js +1 -1
  72. package/es/index.js.map +1 -1
  73. package/es/layout/chart-helper/get-chart-spec.d.ts +2 -1
  74. package/es/layout/chart-helper/get-chart-spec.js +3 -3
  75. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  76. package/es/layout/layout-helper.d.ts +12 -0
  77. package/es/layout/layout-helper.js +50 -0
  78. package/es/layout/layout-helper.js.map +1 -1
  79. package/es/layout/pivot-header-layout.d.ts +4 -3
  80. package/es/layout/pivot-header-layout.js +41 -46
  81. package/es/layout/pivot-header-layout.js.map +1 -1
  82. package/es/layout/tree-helper.d.ts +2 -0
  83. package/es/layout/tree-helper.js +19 -11
  84. package/es/layout/tree-helper.js.map +1 -1
  85. package/es/state/cell-move/adjust-header.js +1 -1
  86. package/es/state/cell-move/adjust-header.js.map +1 -1
  87. package/es/state/resize/update-resize-column.js +1 -1
  88. package/es/state/resize/update-resize-column.js.map +1 -1
  89. package/es/state/resize/update-resize-row.js +5 -4
  90. package/es/state/resize/update-resize-row.js.map +1 -1
  91. package/es/tools/get-data-path/create-dataset.d.ts +9 -1
  92. package/es/tools/get-data-path/create-dataset.js +20 -7
  93. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  94. package/es/tools/get-data-path/index.js +15 -2
  95. package/es/tools/get-data-path/index.js.map +1 -1
  96. package/es/ts-types/base-table.d.ts +6 -4
  97. package/es/ts-types/base-table.js.map +1 -1
  98. package/es/ts-types/common.d.ts +2 -0
  99. package/es/ts-types/common.js.map +1 -1
  100. package/es/ts-types/menu.d.ts +1 -1
  101. package/es/ts-types/menu.js.map +1 -1
  102. package/es/ts-types/table-engine.d.ts +1 -0
  103. package/es/ts-types/table-engine.js.map +1 -1
  104. package/es/vrender.js.map +1 -1
  105. 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
  }
@@ -4,9 +4,11 @@ import { AggregationType, SortType } from "../ts-types";
4
4
 
5
5
  import { AvgAggregator, CountAggregator, MaxAggregator, MinAggregator, NoneAggregator, RecordAggregator, SumAggregator, naturalSort, sortBy, typeSort } from "./statistics-helper";
6
6
 
7
+ import { IndicatorDimensionKeyPlaceholder } from "../tools/global";
8
+
7
9
  export class Dataset {
8
10
  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;
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;
10
12
  if (this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
11
13
  this.colKeys = [], this.rowKeys = [], this.rowOrder = "key_a_to_z", this.colOrder = "key_a_to_z",
12
14
  this.sorted = !1, this.indicatorStatistics = [], this.aggregators = {}, this.stringJoinChar = String.fromCharCode(0),
@@ -27,11 +29,11 @@ export class Dataset {
27
29
  this.needSplitPositiveAndNegative = null != needSplitPositiveAndNegative && needSplitPositiveAndNegative,
28
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),
29
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),
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++) {
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++) {
31
33
  const dimension = this.totals.row.subTotalsDimensions[i], dimensionIndex = this.rows.indexOf(dimension);
32
34
  this.rowsIsTotal[dimensionIndex] = !0;
33
35
  }
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++) {
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++) {
35
37
  const dimension = this.totals.column.subTotalsDimensions[i], dimensionIndex = this.columns.indexOf(dimension);
36
38
  this.colsIsTotal[dimensionIndex] = !0;
37
39
  }
@@ -69,12 +71,12 @@ export class Dataset {
69
71
  this.registerAggregator(AggregationType.NONE, NoneAggregator);
70
72
  }
71
73
  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]) {
74
+ var _a, _b, _c, _d, _e, _f;
75
+ 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
76
  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),
77
+ "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
78
  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)));
79
+ "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
80
  const min = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => cur.value() < acc ? cur.value() : acc), Number.MAX_SAFE_INTEGER);
79
81
  let positiveMax, negativeMin;
80
82
  this.needSplitPositiveAndNegative && (positiveMax = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => cur.positiveValue() > acc ? cur.positiveValue() : acc), Number.MIN_SAFE_INTEGER),
@@ -85,14 +87,15 @@ export class Dataset {
85
87
  }
86
88
  }
87
89
  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));
90
+ var _a, _b;
91
+ const that = this;
92
+ 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) => {
93
+ var _a, _b, _c, _d;
94
+ 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
95
  }));
93
96
  }
94
97
  generateCollectedValuesSortRule() {
95
- for (const field in this.collectedValues) if (this.collectValuesBy[field] && !this.collectValuesBy[field].sortBy) {
98
+ for (const field in this.collectedValues) if (this.collectValuesBy && this.collectValuesBy[field] && !this.collectValuesBy[field].sortBy) {
96
99
  let sortByRule = [];
97
100
  for (const byKeys in this.collectedValues[field]) Array.isArray(this.collectedValues[field][byKeys]) && (sortByRule.push(...this.collectedValues[field][byKeys]),
98
101
  sortByRule = Array.from(new Set(sortByRule)));
@@ -100,9 +103,9 @@ export class Dataset {
100
103
  }
101
104
  }
102
105
  processRecords() {
103
- var _a, _b;
106
+ var _a, _b, _c;
104
107
  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),
108
+ 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
109
  Array.isArray(this.records)) for (let i = 0, len = this.records.length; i < len; i++) {
107
110
  const record = this.records[i];
108
111
  isNeedFilter && !this.filterRecord(record) || this.processRecord(record);
@@ -113,17 +116,17 @@ export class Dataset {
113
116
  this.rowFlatKeys = {}, this.colFlatKeys = {};
114
117
  }
115
118
  filterRecord(record) {
116
- var _a, _b;
119
+ var _a, _b, _c, _d;
117
120
  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];
121
+ if (null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) for (let i = 0; i < this.dataConfig.filterRules.length; i++) {
122
+ const filterRule = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules[i];
120
123
  if (filterRule.filterKey) {
121
124
  const filterValue = record[filterRule.filterKey];
122
- if (-1 === filterRule.filteredValues.indexOf(filterValue)) {
125
+ if (-1 === (null === (_c = filterRule.filteredValues) || void 0 === _c ? void 0 : _c.indexOf(filterValue))) {
123
126
  isReserved = !1;
124
127
  break;
125
128
  }
126
- } else if (!(null === (_b = filterRule.filterFunc) || void 0 === _b ? void 0 : _b.call(filterRule, record))) {
129
+ } else if (!(null === (_d = filterRule.filterFunc) || void 0 === _d ? void 0 : _d.call(filterRule, record))) {
127
130
  isReserved = !1;
128
131
  break;
129
132
  }
@@ -133,7 +136,7 @@ export class Dataset {
133
136
  processRecord(record, assignedIndicatorKey) {
134
137
  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
138
  null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
136
- record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
139
+ derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
137
140
  }));
138
141
  for (const field in this.collectValuesBy) if (isValid(record[field])) {
139
142
  this.collectedValues[field] || (this.collectedValues[field] = {});
@@ -157,12 +160,12 @@ export class Dataset {
157
160
  let isToTalRecord = !1;
158
161
  for (let l = 0, len1 = this.rows.length; l < len1; l++) {
159
162
  const rowAttr = this.rows[l];
160
- if (rowAttr in record) rowKey.push(record[rowAttr]); else {
163
+ if (rowAttr in record) rowKey.push(record[rowAttr]); else if (rowAttr !== IndicatorDimensionKeyPlaceholder) {
161
164
  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))) {
162
165
  rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
163
166
  break;
164
167
  }
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) {
168
+ 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
169
  "grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
167
170
  break;
168
171
  }
@@ -170,12 +173,12 @@ export class Dataset {
170
173
  }
171
174
  for (let n = 0, len2 = this.columns.length; n < len2; n++) {
172
175
  const colAttr = this.columns[n];
173
- 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))) {
176
+ if (colAttr in record) colKey.push(record[colAttr]); else if (colAttr !== IndicatorDimensionKeyPlaceholder) {
177
+ 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
178
  colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
176
179
  break;
177
180
  }
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) {
181
+ 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
182
  colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
180
183
  break;
181
184
  }
@@ -186,20 +189,22 @@ export class Dataset {
186
189
  this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
187
190
  for (let i = 0; i < this.indicatorKeys.length; i++) {
188
191
  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));
192
+ (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)),
193
+ 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
194
  }
192
195
  } else {
193
196
  0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
194
197
  this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
195
198
  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] = []);
199
+ (null === (_4 = this.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
197
200
  for (let i = 0; i < this.indicatorKeys.length; i++) {
198
201
  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));
202
+ let needAddToAggregator = !1;
203
+ 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 {
204
+ (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
205
+ } else this.indicatorKeys[i] in record && (needAddToAggregator = !0);
206
+ !(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)),
207
+ needAddToAggregator && (null === (_13 = null === (_12 = this.tree[flatRowKey]) || void 0 === _12 ? void 0 : _12[flatColKey]) || void 0 === _13 || _13[i].push(record));
203
208
  }
204
209
  if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
205
210
  if (!this.indicatorStatistics[i]) {
@@ -235,8 +240,11 @@ export class Dataset {
235
240
  var _a, _b, _c, _d;
236
241
  const indicatorIndex = this.indicatorKeys.indexOf(indicator);
237
242
  let flatRowKey, flatColKey;
238
- flatRowKey = "string" == typeof rowKey ? rowKey : rowKey.join(this.stringJoinChar),
239
- flatColKey = "string" == typeof colKey ? colKey : colKey.join(this.stringJoinChar);
243
+ "string" == typeof rowKey ? flatRowKey = rowKey : (rowKey.map(((key, i) => {
244
+ key === indicator && rowKey.splice(i, 1);
245
+ })), flatRowKey = rowKey.join(this.stringJoinChar)), "string" == typeof colKey ? flatColKey = colKey : (colKey.map(((key, i) => {
246
+ key === indicator && colKey.splice(i, 1);
247
+ })), flatColKey = colKey.join(this.stringJoinChar));
240
248
  const agg = null === (_b = null === (_a = this.tree[flatRowKey]) || void 0 === _a ? void 0 : _a[flatColKey]) || void 0 === _b ? void 0 : _b[indicatorIndex];
241
249
  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
250
  const changeValue = this.changedTree[flatRowKey][flatColKey][indicatorIndex];
@@ -265,7 +273,6 @@ export class Dataset {
265
273
  push() {},
266
274
  recalculate() {},
267
275
  value: () => null,
268
- formatValue: () => "",
269
276
  clearCacheValue() {},
270
277
  reset() {}
271
278
  };
@@ -356,48 +363,48 @@ export class Dataset {
356
363
  } : sortRule.sortBy ? sortBy(sortRule.sortBy) : sortRule.sortType ? typeSort : sortRule.sortFunc ? sortRule.sortFunc : naturalSort;
357
364
  }
358
365
  totalStatistics() {
359
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
366
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
360
367
  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)) {
368
+ 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
369
  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;
370
+ 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
371
  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
372
  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++) {
373
+ 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
374
  const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
368
375
  if (dimensionIndex >= 0) {
369
376
  const colTotalKey = colKey.slice(0, dimensionIndex + 1);
370
377
  colTotalKey.push(that.colSubTotalLabel);
371
378
  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]);
379
+ 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
380
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
374
381
  for (let i = 0; i < this.indicatorKeys.length; i++) {
375
382
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
376
383
  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);
384
+ 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
385
  }
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]);
386
+ 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
387
  }
381
388
  }
382
389
  }
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) {
390
+ 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
391
  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]);
392
+ 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
393
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
387
394
  for (let i = 0; i < this.indicatorKeys.length; i++) {
388
395
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
389
396
  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);
397
+ 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
398
  }
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]);
399
+ 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
400
  }
394
401
  }
395
402
  };
396
403
  Object.keys(that.tree).forEach((flatRowKey => {
397
404
  const rowKey = flatRowKey.split(this.stringJoinChar);
398
405
  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++) {
406
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
407
+ 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
408
  const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
402
409
  if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
403
410
  const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
@@ -408,22 +415,22 @@ export class Dataset {
408
415
  for (let i = 0; i < this.indicatorKeys.length; i++) {
409
416
  if (!this.tree[flatRowTotalKey][flatColKey][i]) {
410
417
  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);
418
+ 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
419
  }
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]);
420
+ 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
421
  }
415
422
  }
416
423
  }
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) {
424
+ 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
425
  const flatRowTotalKey = that.rowGrandTotalLabel;
419
426
  this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
420
427
  this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
421
428
  for (let i = 0; i < this.indicatorKeys.length; i++) {
422
429
  if (!this.tree[flatRowTotalKey][flatColKey][i]) {
423
430
  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);
431
+ 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
432
  }
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]);
433
+ 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
434
  }
428
435
  }
429
436
  colCompute(flatRowKey, flatColKey);
@@ -441,13 +448,14 @@ export class Dataset {
441
448
  const path = [];
442
449
  let node;
443
450
  list.forEach(((value, index) => {
451
+ var _a;
444
452
  path.push(value);
445
453
  const flatKey = path.join(concatStr);
446
454
  let item = map.get(flatKey);
447
455
  item || (item = {
448
456
  value: value,
449
457
  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 ? {
458
+ 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
459
  indicatorKey: indicator,
452
460
  value: indicator
453
461
  } : {
@@ -469,6 +477,7 @@ export class Dataset {
469
477
  const path = [];
470
478
  let node;
471
479
  list.forEach(((value, index) => {
480
+ var _a, _b, _c, _d;
472
481
  path.push(value);
473
482
  const flatKey = path.join(concatStr);
474
483
  let item = map.get(flatKey);
@@ -476,7 +485,7 @@ export class Dataset {
476
485
  if (item = {
477
486
  value: value,
478
487
  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 ? {
488
+ 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
489
  indicatorKey: indicator,
481
490
  value: indicator
482
491
  } : {
@@ -484,12 +493,12 @@ export class Dataset {
484
493
  value: indicator.title
485
494
  })) : []
486
495
  }, subTotalFlags[index]) {
487
- let curChild = item.children;
496
+ let curChild = null !== (_b = item.children) && void 0 !== _b ? _b : [];
488
497
  const totalChild = {
489
498
  value: subTotalLabel,
490
499
  dimensionKey: rows[index + 1],
491
500
  levelSpan: subTotalFlags.length - index - 1,
492
- children: (null == indicators ? void 0 : indicators.length) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
501
+ 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
502
  indicatorKey: indicator,
494
503
  value: indicator
495
504
  } : {
@@ -497,7 +506,7 @@ export class Dataset {
497
506
  value: indicator.title
498
507
  })) : []
499
508
  };
500
- curChild.push(totalChild), curChild = totalChild.children;
509
+ curChild.push(totalChild), curChild = null !== (_d = totalChild.children) && void 0 !== _d ? _d : [];
501
510
  }
502
511
  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
512
  }
@@ -505,7 +514,10 @@ export class Dataset {
505
514
  }));
506
515
  }(item))) : indicators && (result = null == indicators ? void 0 : indicators.map((indicator => {
507
516
  var _a;
508
- return {
517
+ return "string" == typeof indicator ? {
518
+ indicatorKey: indicator,
519
+ value: indicator
520
+ } : {
509
521
  indicatorKey: indicator.indicatorKey,
510
522
  value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
511
523
  };
@@ -544,7 +556,10 @@ export class Dataset {
544
556
  var _a, _b;
545
557
  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
558
  var _a;
547
- return {
559
+ return "string" == typeof indicator ? {
560
+ indicatorKey: indicator,
561
+ value: indicator
562
+ } : {
548
563
  indicatorKey: indicator.indicatorKey,
549
564
  value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
550
565
  };
@@ -553,7 +568,10 @@ export class Dataset {
553
568
  };
554
569
  return (null == customTree ? void 0 : customTree.length) ? checkNode(customTree, !1) : customTree = null === (_a = this.indicators) || void 0 === _a ? void 0 : _a.map((indicator => {
555
570
  var _a;
556
- return {
571
+ return "string" == typeof indicator ? {
572
+ indicatorKey: indicator,
573
+ value: indicator
574
+ } : {
557
575
  indicatorKey: indicator.indicatorKey,
558
576
  value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
559
577
  };
@@ -583,6 +601,16 @@ export class Dataset {
583
601
  this.rowFlatKeys = {}, this.colFlatKeys = {}, this.tree = {}, this.processRecords();
584
602
  }
585
603
  }
604
+ changeDataConfig(dataConfig) {
605
+ this.rows = dataConfig.rows, this.columns = dataConfig.columns;
606
+ }
607
+ addRecords(records) {
608
+ for (let i = 0, len = records.length; i < len; i++) {
609
+ const record = records[i];
610
+ this.processRecord(record);
611
+ }
612
+ Array.isArray(this.records) && this.records.push(records);
613
+ }
586
614
  }
587
615
 
588
616
  function arraySortByAnotherArray(array, sortArray) {