@visactor/vtable 0.12.1-alpha.0 → 0.12.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 (79) hide show
  1. package/cjs/components/menu/dom/logic/MenuContainer.js +3 -13
  2. package/cjs/components/menu/dom/logic/MenuContainer.js.map +1 -1
  3. package/cjs/components/menu/dom/logic/MenuElement.js +3 -13
  4. package/cjs/components/menu/dom/logic/MenuElement.js.map +1 -1
  5. package/cjs/components/tooltip/TooltipHandler.js +17 -8
  6. package/cjs/components/tooltip/TooltipHandler.js.map +1 -1
  7. package/cjs/components/tooltip/logic/BubbleTooltipElement.js +4 -14
  8. package/cjs/components/tooltip/logic/BubbleTooltipElement.js.map +1 -1
  9. package/cjs/core/BaseTable.d.ts +6 -2
  10. package/cjs/core/BaseTable.js +18 -2
  11. package/cjs/core/BaseTable.js.map +1 -1
  12. package/cjs/dataset/dataset.d.ts +1 -0
  13. package/cjs/dataset/dataset.js +89 -58
  14. package/cjs/dataset/dataset.js.map +1 -1
  15. package/cjs/dataset/flatDataToObject.js +1 -2
  16. package/cjs/event/EventHandler.js +3 -2
  17. package/cjs/event/EventHandler.js.map +1 -1
  18. package/cjs/event/sparkline-event.js +2 -1
  19. package/cjs/index.d.ts +1 -1
  20. package/cjs/index.js +1 -1
  21. package/cjs/index.js.map +1 -1
  22. package/cjs/layout/chart-helper/get-axis-config.d.ts +11 -0
  23. package/cjs/layout/chart-helper/get-axis-config.js +65 -62
  24. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  25. package/cjs/layout/chart-helper/get-chart-spec.js +9 -24
  26. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  27. package/cjs/layout/pivot-header-layout.d.ts +6 -2
  28. package/cjs/layout/pivot-header-layout.js +32 -5
  29. package/cjs/layout/pivot-header-layout.js.map +1 -1
  30. package/cjs/layout/simple-header-layout.d.ts +7 -3
  31. package/cjs/layout/simple-header-layout.js +36 -8
  32. package/cjs/layout/simple-header-layout.js.map +1 -1
  33. package/cjs/scenegraph/refresh-node/update-chart.js +6 -3
  34. package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
  35. package/cjs/ts-types/base-table.d.ts +6 -0
  36. package/cjs/ts-types/base-table.js.map +1 -1
  37. package/cjs/ts-types/list-table/layout-map/api.d.ts +4 -0
  38. package/cjs/ts-types/list-table/layout-map/api.js.map +1 -1
  39. package/dist/vtable.js +376 -269
  40. package/dist/vtable.min.js +2 -2
  41. package/es/components/menu/dom/logic/MenuContainer.js +3 -13
  42. package/es/components/menu/dom/logic/MenuContainer.js.map +1 -1
  43. package/es/components/menu/dom/logic/MenuElement.js +3 -13
  44. package/es/components/menu/dom/logic/MenuElement.js.map +1 -1
  45. package/es/components/tooltip/TooltipHandler.js +17 -8
  46. package/es/components/tooltip/TooltipHandler.js.map +1 -1
  47. package/es/components/tooltip/logic/BubbleTooltipElement.js +4 -14
  48. package/es/components/tooltip/logic/BubbleTooltipElement.js.map +1 -1
  49. package/es/core/BaseTable.d.ts +6 -2
  50. package/es/core/BaseTable.js +18 -2
  51. package/es/core/BaseTable.js.map +1 -1
  52. package/es/dataset/dataset.d.ts +1 -0
  53. package/es/dataset/dataset.js +89 -58
  54. package/es/dataset/dataset.js.map +1 -1
  55. package/es/dataset/flatDataToObject.js +1 -2
  56. package/es/event/EventHandler.js +3 -2
  57. package/es/event/EventHandler.js.map +1 -1
  58. package/es/event/sparkline-event.js +2 -1
  59. package/es/index.d.ts +1 -1
  60. package/es/index.js +1 -1
  61. package/es/index.js.map +1 -1
  62. package/es/layout/chart-helper/get-axis-config.d.ts +11 -0
  63. package/es/layout/chart-helper/get-axis-config.js +61 -57
  64. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  65. package/es/layout/chart-helper/get-chart-spec.js +6 -21
  66. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  67. package/es/layout/pivot-header-layout.d.ts +6 -2
  68. package/es/layout/pivot-header-layout.js +32 -5
  69. package/es/layout/pivot-header-layout.js.map +1 -1
  70. package/es/layout/simple-header-layout.d.ts +7 -3
  71. package/es/layout/simple-header-layout.js +37 -7
  72. package/es/layout/simple-header-layout.js.map +1 -1
  73. package/es/scenegraph/refresh-node/update-chart.js +6 -3
  74. package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
  75. package/es/ts-types/base-table.d.ts +6 -0
  76. package/es/ts-types/base-table.js.map +1 -1
  77. package/es/ts-types/list-table/layout-map/api.d.ts +4 -0
  78. package/es/ts-types/list-table/layout-map/api.js.map +1 -1
  79. package/package.json +3 -3
@@ -47,6 +47,7 @@ export declare class Dataset {
47
47
  rowHierarchyType: 'grid' | 'tree';
48
48
  indicators: (string | IIndicator)[];
49
49
  indicatorsAsCol: boolean;
50
+ totalRecordsTree: Record<string, Record<string, Aggregator[]>>;
50
51
  constructor(dataConfig: IDataConfig, 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);
51
52
  registerAggregator(type: string, aggregator: any): void;
52
53
  registerAggregators(): void;
@@ -8,13 +8,13 @@ import { getNewRangeToAlign } from "./util/zero-align";
8
8
 
9
9
  export class Dataset {
10
10
  constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
11
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
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;
12
12
  this.tree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {}, this.colKeys = [],
13
13
  this.rowKeys = [], this.rowOrder = "key_a_to_z", this.colOrder = "key_a_to_z", this.sorted = !1,
14
14
  this.indicatorStatistics = [], this.aggregators = {}, this.stringJoinChar = String.fromCharCode(0),
15
15
  this.rowsIsTotal = [], this.colsIsTotal = [], this.collectedValues = {}, this.cacheCollectedValues = {},
16
- this.registerAggregators(), this.dataConfig = dataConfig, this.rowHierarchyType = null != rowHierarchyType ? rowHierarchyType : "grid",
17
- this.sortRules = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.sortRules,
16
+ this.totalRecordsTree = {}, this.registerAggregators(), this.dataConfig = dataConfig,
17
+ this.rowHierarchyType = null != rowHierarchyType ? rowHierarchyType : "grid", this.sortRules = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.sortRules,
18
18
  this.aggregationRules = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.aggregationRules,
19
19
  this.derivedFieldRules = null === (_c = this.dataConfig) || void 0 === _c ? void 0 : _c.derivedFieldRules,
20
20
  this.mappingRules = null === (_d = this.dataConfig) || void 0 === _d ? void 0 : _d.mappingRules,
@@ -45,11 +45,11 @@ export class Dataset {
45
45
  this.sortKeys();
46
46
  "undefined" != typeof window && window.performance.now(), "undefined" != typeof window && window.performance.now();
47
47
  customRowTree ? (indicatorsAsCol || (customRowTree = this._adjustCustomTree(customRowTree)),
48
- this.rowHeaderTree = customRowTree) : "tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows, indicatorsAsCol ? void 0 : indicators) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows, indicatorsAsCol ? void 0 : indicators, this.rowsIsTotal, (null === (_1 = null === (_0 = null == this ? void 0 : this.totals) || void 0 === _0 ? void 0 : _0.row) || void 0 === _1 ? void 0 : _1.showGrandTotals) || 0 === this.columns.length, this.rowGrandTotalLabel, this.rowSubTotalLabel),
48
+ this.rowHeaderTree = customRowTree) : "tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows, indicatorsAsCol ? void 0 : indicators, (null === (_1 = null === (_0 = null == this ? void 0 : this.totals) || void 0 === _0 ? void 0 : _0.row) || void 0 === _1 ? void 0 : _1.showGrandTotals) || !indicatorsAsCol && 0 === this.columns.length || indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows, indicatorsAsCol ? void 0 : indicators, this.rowsIsTotal, (null === (_3 = null === (_2 = null == this ? void 0 : this.totals) || void 0 === _2 ? void 0 : _2.row) || void 0 === _3 ? void 0 : _3.showGrandTotals) || !indicatorsAsCol && 0 === this.columns.length || indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel),
49
49
  customColTree ? (indicatorsAsCol && (customColTree = this._adjustCustomTree(customColTree)),
50
- this.colHeaderTree = customColTree) : this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns, indicatorsAsCol ? indicators : void 0, this.colsIsTotal, null === (_3 = null === (_2 = this.totals) || void 0 === _2 ? void 0 : _2.column) || void 0 === _3 ? void 0 : _3.showGrandTotals, this.colGrandTotalLabel, this.colSubTotalLabel);
50
+ this.colHeaderTree = customColTree) : this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns, indicatorsAsCol ? indicators : void 0, this.colsIsTotal, null === (_5 = null === (_4 = this.totals) || void 0 === _4 ? void 0 : _4.column) || void 0 === _5 ? void 0 : _5.showGrandTotals, this.colGrandTotalLabel, this.colSubTotalLabel);
51
51
  "undefined" != typeof window && window.performance.now();
52
- (null === (_4 = this.dataConfig) || void 0 === _4 ? void 0 : _4.isPivotChart) && (this.dealWithZeroAlign(),
52
+ (null === (_6 = this.dataConfig) || void 0 === _6 ? void 0 : _6.isPivotChart) && (this.dealWithZeroAlign(),
53
53
  this.cacheDeminsionCollectedValues());
54
54
  }
55
55
  }
@@ -115,19 +115,10 @@ export class Dataset {
115
115
  return isReserved;
116
116
  }
117
117
  processRecord(record, assignedIndicatorKey) {
118
- 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;
118
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28;
119
119
  null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
120
120
  record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
121
121
  }));
122
- const colKey = [], rowKey = [];
123
- for (let l = 0, len1 = this.rows.length; l < len1; l++) {
124
- const rowAttr = this.rows[l];
125
- rowKey.push(record[rowAttr]);
126
- }
127
- for (let n = 0, len2 = this.columns.length; n < len2; n++) {
128
- const colAttr = this.columns[n];
129
- colKey.push(record[colAttr]);
130
- }
131
122
  for (const field in this.collectValuesBy) if (record[field]) {
132
123
  this.collectedValues[field] || (this.collectedValues[field] = {});
133
124
  const collectKeys = this.collectValuesBy[field].by.map((byField => record[byField])).join(this.stringJoinChar);
@@ -146,30 +137,67 @@ export class Dataset {
146
137
  -1 === fieldRange.indexOf(record[field]) && fieldRange.push(record[field]);
147
138
  }
148
139
  }
149
- const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
150
- 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
151
- this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
152
- this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
153
- (null === (_b = this.tree[flatRowKey]) || void 0 === _b ? void 0 : _b[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
154
- for (let i = 0; i < this.indicatorKeys.length; i++) {
155
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
156
- if ((null === (_d = null === (_c = this.tree[flatRowKey]) || void 0 === _c ? void 0 : _c[flatColKey]) || void 0 === _d ? void 0 : _d[i]) || (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_e = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _e ? _e : AggregationType.SUM](null !== (_f = null == aggRule ? void 0 : aggRule.field) && void 0 !== _f ? _f : this.indicatorKeys[i], null !== (_g = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _g ? _g : null === (_j = null === (_h = this.indicators) || void 0 === _h ? void 0 : _h.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _j ? void 0 : _j.format)),
157
- assignedIndicatorKey) this.indicatorKeys[i] === assignedIndicatorKey && (null === (_l = null === (_k = this.tree[flatRowKey]) || void 0 === _k ? void 0 : _k[flatColKey]) || void 0 === _l || _l[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 === (_o = null === (_m = this.tree[flatRowKey]) || void 0 === _m ? void 0 : _m[flatColKey]) || void 0 === _o || _o[i].push(record)); else {
158
- (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (null === (_q = null === (_p = this.tree[flatRowKey]) || void 0 === _p ? void 0 : _p[flatColKey]) || void 0 === _q || _q[i].push(record));
159
- } else this.indicatorKeys[i] in record && (null === (_s = null === (_r = this.tree[flatRowKey]) || void 0 === _r ? void 0 : _r[flatColKey]) || void 0 === _s || _s[i].push(record));
140
+ const colKey = [], rowKey = [];
141
+ let isToTalRecord = !1;
142
+ for (let l = 0, len1 = this.rows.length; l < len1; l++) {
143
+ const rowAttr = this.rows[l];
144
+ if (rowAttr in record) rowKey.push(record[rowAttr]); else {
145
+ 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))) {
146
+ rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
147
+ break;
148
+ }
149
+ 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.showSubTotals) && (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) {
150
+ "grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
151
+ break;
152
+ }
153
+ }
160
154
  }
161
- if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
162
- if (!this.indicatorStatistics[i]) {
155
+ for (let n = 0, len2 = this.columns.length; n < len2; n++) {
156
+ const colAttr = this.columns[n];
157
+ if (colAttr in record) colKey.push(record[colAttr]); else {
158
+ 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))) {
159
+ colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
160
+ break;
161
+ }
162
+ 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.showSubTotals) && (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) {
163
+ colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
164
+ break;
165
+ }
166
+ }
167
+ }
168
+ const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
169
+ if (isToTalRecord) {
170
+ this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
171
+ for (let i = 0; i < this.indicatorKeys.length; i++) {
163
172
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
164
- this.indicatorStatistics[i] = {
165
- max: new this.aggregators[AggregationType.MAX](this.indicatorKeys[i]),
166
- min: new this.aggregators[AggregationType.MIN](this.indicatorKeys[i]),
167
- total: new this.aggregators[null !== (_t = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _t ? _t : AggregationType.SUM](null !== (_u = null == aggRule ? void 0 : aggRule.field) && void 0 !== _u ? _u : this.indicatorKeys[i], null !== (_v = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _v ? _v : null === (_x = null === (_w = this.indicators) || void 0 === _w ? void 0 : _w.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _x ? void 0 : _x.format)
168
- };
173
+ (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)),
174
+ 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));
175
+ }
176
+ } else {
177
+ 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
178
+ this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
179
+ this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
180
+ (null === (_4 = this.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
181
+ for (let i = 0; i < this.indicatorKeys.length; i++) {
182
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
183
+ if ((null === (_6 = null === (_5 = this.tree[flatRowKey]) || void 0 === _5 ? void 0 : _5[flatColKey]) || void 0 === _6 ? void 0 : _6[i]) || (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)),
184
+ assignedIndicatorKey) this.indicatorKeys[i] === assignedIndicatorKey && (null === (_13 = null === (_12 = this.tree[flatRowKey]) || void 0 === _12 ? void 0 : _12[flatColKey]) || void 0 === _13 || _13[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 === (_15 = null === (_14 = this.tree[flatRowKey]) || void 0 === _14 ? void 0 : _14[flatColKey]) || void 0 === _15 || _15[i].push(record)); else {
185
+ (null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (null === (_17 = null === (_16 = this.tree[flatRowKey]) || void 0 === _16 ? void 0 : _16[flatColKey]) || void 0 === _17 || _17[i].push(record));
186
+ } else this.indicatorKeys[i] in record && (null === (_19 = null === (_18 = this.tree[flatRowKey]) || void 0 === _18 ? void 0 : _18[flatColKey]) || void 0 === _19 || _19[i].push(record));
187
+ }
188
+ if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
189
+ if (!this.indicatorStatistics[i]) {
190
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
191
+ this.indicatorStatistics[i] = {
192
+ max: new this.aggregators[AggregationType.MAX](this.indicatorKeys[i]),
193
+ min: new this.aggregators[AggregationType.MIN](this.indicatorKeys[i]),
194
+ total: new this.aggregators[null !== (_20 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _20 ? _20 : AggregationType.SUM](null !== (_21 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _21 ? _21 : this.indicatorKeys[i], null !== (_22 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _22 ? _22 : null === (_24 = null === (_23 = this.indicators) || void 0 === _23 ? void 0 : _23.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _24 ? void 0 : _24.format)
195
+ };
196
+ }
197
+ this.indicatorStatistics[i].max.push(null === (_26 = null === (_25 = this.tree[flatRowKey]) || void 0 === _25 ? void 0 : _25[flatColKey]) || void 0 === _26 ? void 0 : _26[i].value()),
198
+ this.indicatorStatistics[i].min.push(null === (_28 = null === (_27 = this.tree[flatRowKey]) || void 0 === _27 ? void 0 : _27[flatColKey]) || void 0 === _28 ? void 0 : _28[i].value()),
199
+ this.indicatorStatistics[i].total.push(record);
169
200
  }
170
- this.indicatorStatistics[i].max.push(null === (_z = null === (_y = this.tree[flatRowKey]) || void 0 === _y ? void 0 : _y[flatColKey]) || void 0 === _z ? void 0 : _z[i].value()),
171
- this.indicatorStatistics[i].min.push(null === (_1 = null === (_0 = this.tree[flatRowKey]) || void 0 === _0 ? void 0 : _0[flatColKey]) || void 0 === _1 ? void 0 : _1[i].value()),
172
- this.indicatorStatistics[i].total.push(record);
173
201
  }
174
202
  }
175
203
  updateSortRules(sortRules) {
@@ -296,33 +324,36 @@ export class Dataset {
296
324
  const that = this;
297
325
  if ((null === (_b = null === (_a = null == that ? void 0 : that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.showSubTotals) && (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.showSubTotals) && (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)) {
298
326
  const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
299
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
327
+ 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;
328
+ 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]);
300
329
  const colKey = flatColKey.split(this.stringJoinChar);
301
- for (let i = 0, len = null === (_c = null === (_b = null === (_a = that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.subTotalsDimensions) || void 0 === _c ? void 0 : _c.length; i < len; i++) {
330
+ 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++) {
302
331
  const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
303
332
  if (dimensionIndex >= 0) {
304
333
  const colTotalKey = colKey.slice(0, dimensionIndex + 1);
305
- "grid" === this.rowHierarchyType && colTotalKey.push(null !== (_f = null === (_e = null === (_d = that.totals) || void 0 === _d ? void 0 : _d.column) || void 0 === _e ? void 0 : _e.subTotalLabel) && void 0 !== _f ? _f : "小计");
334
+ colTotalKey.push(null !== (_k = null === (_j = null === (_h = that.totals) || void 0 === _h ? void 0 : _h.column) || void 0 === _j ? void 0 : _j.subTotalLabel) && void 0 !== _k ? _k : "小计");
306
335
  const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
336
+ if (null === (_m = null === (_l = this.totalRecordsTree) || void 0 === _l ? void 0 : _l[flatRowKey]) || void 0 === _m ? void 0 : _m[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_p = null === (_o = this.totalRecordsTree) || void 0 === _o ? void 0 : _o[flatRowKey]) || void 0 === _p ? void 0 : _p[flatColTotalKey]);
307
337
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
308
338
  for (let i = 0; i < this.indicatorKeys.length; i++) {
309
339
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
310
340
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
311
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_g = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _g ? _g : AggregationType.SUM](null !== (_h = null == aggRule ? void 0 : aggRule.field) && void 0 !== _h ? _h : this.indicatorKeys[i], null !== (_j = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _j ? _j : null === (_l = null === (_k = this.indicators) || void 0 === _k ? void 0 : _k.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _l ? void 0 : _l.format);
341
+ this.tree[flatRowKey][flatColTotalKey][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);
312
342
  }
313
- this.tree[flatRowKey][flatColTotalKey][i].push(null === (_o = null === (_m = that.tree[flatRowKey]) || void 0 === _m ? void 0 : _m[flatColKey]) || void 0 === _o ? void 0 : _o[i]);
343
+ this.tree[flatRowKey][flatColTotalKey][i].push(null === (_w = null === (_v = that.tree[flatRowKey]) || void 0 === _v ? void 0 : _v[flatColKey]) || void 0 === _w ? void 0 : _w[i]);
314
344
  }
315
345
  }
316
346
  }
317
- if ((null === (_q = null === (_p = that.totals) || void 0 === _p ? void 0 : _p.column) || void 0 === _q ? void 0 : _q.showGrandTotals) || 0 === this.rows.length) {
347
+ if ((null === (_y = null === (_x = that.totals) || void 0 === _x ? void 0 : _x.column) || void 0 === _y ? void 0 : _y.showGrandTotals) || 0 === this.rows.length) {
318
348
  const flatColTotalKey = that.colGrandTotalLabel;
349
+ if (null === (_0 = null === (_z = this.totalRecordsTree) || void 0 === _z ? void 0 : _z[flatRowKey]) || void 0 === _0 ? void 0 : _0[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_2 = null === (_1 = this.totalRecordsTree) || void 0 === _1 ? void 0 : _1[flatRowKey]) || void 0 === _2 ? void 0 : _2[flatColTotalKey]);
319
350
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
320
351
  for (let i = 0; i < this.indicatorKeys.length; i++) {
321
352
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
322
353
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
323
- this.tree[flatRowKey][flatColTotalKey][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);
354
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_3 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _3 ? _3 : AggregationType.SUM](null !== (_4 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _4 ? _4 : this.indicatorKeys[i], null !== (_5 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _5 ? _5 : null === (_7 = null === (_6 = this.indicators) || void 0 === _6 ? void 0 : _6.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _7 ? void 0 : _7.format);
324
355
  }
325
- this.tree[flatRowKey][flatColTotalKey][i].push(null === (_x = null === (_w = that.tree[flatRowKey]) || void 0 === _w ? void 0 : _w[flatColKey]) || void 0 === _x ? void 0 : _x[i]);
356
+ this.tree[flatRowKey][flatColTotalKey][i].push(null === (_9 = null === (_8 = that.tree[flatRowKey]) || void 0 === _8 ? void 0 : _8[flatColKey]) || void 0 === _9 ? void 0 : _9[i]);
326
357
  }
327
358
  }
328
359
  };
@@ -332,20 +363,18 @@ export class Dataset {
332
363
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
333
364
  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++) {
334
365
  const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
335
- if (dimensionIndex >= 0) {
366
+ if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
336
367
  const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
337
368
  "grid" === this.rowHierarchyType && rowTotalKey.push(null !== (_f = null === (_e = null === (_d = that.totals) || void 0 === _d ? void 0 : _d.row) || void 0 === _e ? void 0 : _e.subTotalLabel) && void 0 !== _f ? _f : "小计");
338
369
  const flatRowTotalKey = rowTotalKey.join(this.stringJoinChar);
339
- if (this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
340
- !this.tree[flatRowTotalKey][flatColKey]) {
341
- this.tree[flatRowTotalKey][flatColKey] = [];
342
- for (let i = 0; i < this.indicatorKeys.length; i++) {
343
- if (!this.tree[flatRowTotalKey][flatColKey][i]) {
344
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
345
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_g = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _g ? _g : AggregationType.SUM](null !== (_h = null == aggRule ? void 0 : aggRule.field) && void 0 !== _h ? _h : this.indicatorKeys[i], null !== (_j = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _j ? _j : null === (_l = null === (_k = this.indicators) || void 0 === _k ? void 0 : _k.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _l ? void 0 : _l.format);
346
- }
347
- this.tree[flatRowTotalKey][flatColKey][i].push(null === (_o = null === (_m = that.tree[flatRowKey]) || void 0 === _m ? void 0 : _m[flatColKey]) || void 0 === _o ? void 0 : _o[i]);
370
+ this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
371
+ this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
372
+ for (let i = 0; i < this.indicatorKeys.length; i++) {
373
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) {
374
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
375
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_g = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _g ? _g : AggregationType.SUM](null !== (_h = null == aggRule ? void 0 : aggRule.field) && void 0 !== _h ? _h : this.indicatorKeys[i], null !== (_j = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _j ? _j : null === (_l = null === (_k = this.indicators) || void 0 === _k ? void 0 : _k.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _l ? void 0 : _l.format);
348
376
  }
377
+ this.tree[flatRowTotalKey][flatColKey][i].push(null === (_o = null === (_m = that.tree[flatRowKey]) || void 0 === _m ? void 0 : _m[flatColKey]) || void 0 === _o ? void 0 : _o[i]);
349
378
  }
350
379
  }
351
380
  }
@@ -370,9 +399,9 @@ export class Dataset {
370
399
  }));
371
400
  }
372
401
  }
373
- ArrToTree1(arr, rows, indicators) {
402
+ ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel) {
374
403
  const result = [], concatStr = this.stringJoinChar, map = new Map;
375
- return arr.forEach((item => function(list) {
404
+ function addList(list) {
376
405
  const path = [];
377
406
  let node;
378
407
  list.forEach(((value, index) => {
@@ -392,7 +421,9 @@ export class Dataset {
392
421
  }, map.set(flatKey, item), node ? node.children.push(item) : result.push(item)),
393
422
  node = item;
394
423
  }));
395
- }(item))), result;
424
+ }
425
+ return arr.forEach((item => addList(item))), isGrandTotal && addList([ grandTotalLabel ]),
426
+ result;
396
427
  }
397
428
  ArrToTree(arr, rows, indicators, subTotalFlags, isGrandTotal, grandTotalLabel, subTotalLabel) {
398
429
  var _a;