@visactor/vtable 0.12.1-alpha.1 → 0.12.2

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/ListTable.js +2 -0
  2. package/cjs/ListTable.js.map +1 -1
  3. package/cjs/PivotTable.js +2 -2
  4. package/cjs/PivotTable.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/core/BaseTable.js +1 -1
  8. package/cjs/core/BaseTable.js.map +1 -1
  9. package/cjs/dataset/dataset.d.ts +1 -0
  10. package/cjs/dataset/dataset.js +89 -58
  11. package/cjs/dataset/dataset.js.map +1 -1
  12. package/cjs/event/event.js +2 -3
  13. package/cjs/event/event.js.map +1 -1
  14. package/cjs/index.d.ts +1 -1
  15. package/cjs/index.js +1 -1
  16. package/cjs/index.js.map +1 -1
  17. package/cjs/layout/chart-helper/get-axis-config.d.ts +11 -0
  18. package/cjs/layout/chart-helper/get-axis-config.js +65 -62
  19. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  20. package/cjs/layout/chart-helper/get-chart-spec.js +9 -24
  21. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  22. package/cjs/layout/pivot-header-layout.js +2 -2
  23. package/cjs/layout/pivot-header-layout.js.map +1 -1
  24. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -3
  25. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  26. package/cjs/scenegraph/group-creater/progress/update-position/util.d.ts +1 -1
  27. package/cjs/scenegraph/group-creater/progress/update-position/util.js +10 -5
  28. package/cjs/scenegraph/group-creater/progress/update-position/util.js.map +1 -1
  29. package/cjs/scenegraph/stick-text/index.js +20 -18
  30. package/cjs/scenegraph/stick-text/index.js.map +1 -1
  31. package/cjs/themes/DARK.js +1 -1
  32. package/cjs/themes/DARK.js.map +1 -1
  33. package/cjs/themes/SIMPLIFY.js +1 -1
  34. package/cjs/themes/SIMPLIFY.js.map +1 -1
  35. package/cjs/ts-types/base-table.js.map +1 -1
  36. package/cjs/ts-types/new-data-set.js.map +1 -1
  37. package/cjs/ts-types/table-engine.js.map +1 -1
  38. package/dist/vtable.js +238 -199
  39. package/dist/vtable.min.js +2 -2
  40. package/es/ListTable.js +2 -0
  41. package/es/ListTable.js.map +1 -1
  42. package/es/PivotTable.js +2 -2
  43. package/es/PivotTable.js.map +1 -1
  44. package/es/components/tooltip/TooltipHandler.js +17 -8
  45. package/es/components/tooltip/TooltipHandler.js.map +1 -1
  46. package/es/core/BaseTable.js +1 -1
  47. package/es/core/BaseTable.js.map +1 -1
  48. package/es/dataset/dataset.d.ts +1 -0
  49. package/es/dataset/dataset.js +89 -58
  50. package/es/dataset/dataset.js.map +1 -1
  51. package/es/event/event.js +2 -3
  52. package/es/event/event.js.map +1 -1
  53. package/es/index.d.ts +1 -1
  54. package/es/index.js +1 -1
  55. package/es/index.js.map +1 -1
  56. package/es/layout/chart-helper/get-axis-config.d.ts +11 -0
  57. package/es/layout/chart-helper/get-axis-config.js +61 -57
  58. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  59. package/es/layout/chart-helper/get-chart-spec.js +6 -21
  60. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  61. package/es/layout/pivot-header-layout.js +2 -2
  62. package/es/layout/pivot-header-layout.js.map +1 -1
  63. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -3
  64. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  65. package/es/scenegraph/group-creater/progress/update-position/util.d.ts +1 -1
  66. package/es/scenegraph/group-creater/progress/update-position/util.js +10 -5
  67. package/es/scenegraph/group-creater/progress/update-position/util.js.map +1 -1
  68. package/es/scenegraph/stick-text/index.js +20 -18
  69. package/es/scenegraph/stick-text/index.js.map +1 -1
  70. package/es/themes/DARK.js +1 -1
  71. package/es/themes/DARK.js.map +1 -1
  72. package/es/themes/SIMPLIFY.js +1 -1
  73. package/es/themes/SIMPLIFY.js.map +1 -1
  74. package/es/ts-types/base-table.js.map +1 -1
  75. package/es/ts-types/new-data-set.js.map +1 -1
  76. package/es/ts-types/table-engine.js.map +1 -1
  77. package/package.json +2 -2
  78. package/cjs/components/axis/get-axis-attributes.d.ts +0 -151
  79. package/es/components/axis/get-axis-attributes.d.ts +0 -151
@@ -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 @@ const vutils_1 = require("@visactor/vutils"), ts_types_1 = require("../ts-types"
8
8
 
9
9
  class Dataset {
10
10
  constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
11
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
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 @@ 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) || !indicatorsAsCol && 0 === this.columns.length || indicatorsAsCol && 0 === this.rows.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
  }
@@ -118,19 +118,10 @@ class Dataset {
118
118
  return isReserved;
119
119
  }
120
120
  processRecord(record, assignedIndicatorKey) {
121
- 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;
121
+ 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;
122
122
  null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
123
123
  record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
124
124
  }));
125
- const colKey = [], rowKey = [];
126
- for (let l = 0, len1 = this.rows.length; l < len1; l++) {
127
- const rowAttr = this.rows[l];
128
- rowKey.push(record[rowAttr]);
129
- }
130
- for (let n = 0, len2 = this.columns.length; n < len2; n++) {
131
- const colAttr = this.columns[n];
132
- colKey.push(record[colAttr]);
133
- }
134
125
  for (const field in this.collectValuesBy) if (record[field]) {
135
126
  this.collectedValues[field] || (this.collectedValues[field] = {});
136
127
  const collectKeys = this.collectValuesBy[field].by.map((byField => record[byField])).join(this.stringJoinChar);
@@ -149,30 +140,67 @@ class Dataset {
149
140
  -1 === fieldRange.indexOf(record[field]) && fieldRange.push(record[field]);
150
141
  }
151
142
  }
152
- const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
153
- 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
154
- this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
155
- this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
156
- (null === (_b = this.tree[flatRowKey]) || void 0 === _b ? void 0 : _b[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
157
- for (let i = 0; i < this.indicatorKeys.length; i++) {
158
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
159
- 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 : ts_types_1.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)),
160
- 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 {
161
- (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));
162
- } 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));
143
+ const colKey = [], rowKey = [];
144
+ let isToTalRecord = !1;
145
+ for (let l = 0, len1 = this.rows.length; l < len1; l++) {
146
+ const rowAttr = this.rows[l];
147
+ if (rowAttr in record) rowKey.push(record[rowAttr]); else {
148
+ 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))) {
149
+ rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
150
+ break;
151
+ }
152
+ 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) {
153
+ "grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
154
+ break;
155
+ }
156
+ }
163
157
  }
164
- if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
165
- if (!this.indicatorStatistics[i]) {
158
+ for (let n = 0, len2 = this.columns.length; n < len2; n++) {
159
+ const colAttr = this.columns[n];
160
+ if (colAttr in record) colKey.push(record[colAttr]); else {
161
+ 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))) {
162
+ colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
163
+ break;
164
+ }
165
+ 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) {
166
+ colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
167
+ break;
168
+ }
169
+ }
170
+ }
171
+ const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
172
+ if (isToTalRecord) {
173
+ this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
174
+ for (let i = 0; i < this.indicatorKeys.length; i++) {
166
175
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
167
- this.indicatorStatistics[i] = {
168
- max: new this.aggregators[ts_types_1.AggregationType.MAX](this.indicatorKeys[i]),
169
- min: new this.aggregators[ts_types_1.AggregationType.MIN](this.indicatorKeys[i]),
170
- total: new this.aggregators[null !== (_t = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _t ? _t : ts_types_1.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)
171
- };
176
+ (null === (_w = null === (_v = this.totalRecordsTree[flatRowKey]) || void 0 === _v ? void 0 : _v[flatColKey]) || void 0 === _w ? void 0 : _w[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_x = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _x ? _x : ts_types_1.AggregationType.SUM](null !== (_y = null == aggRule ? void 0 : aggRule.field) && void 0 !== _y ? _y : this.indicatorKeys[i], null !== (_z = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _z ? _z : null === (_1 = null === (_0 = this.indicators) || void 0 === _0 ? void 0 : _0.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _1 ? void 0 : _1.format)),
177
+ 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));
178
+ }
179
+ } else {
180
+ 0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
181
+ this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
182
+ this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
183
+ (null === (_4 = this.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
184
+ for (let i = 0; i < this.indicatorKeys.length; i++) {
185
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
186
+ 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 : ts_types_1.AggregationType.SUM](null !== (_8 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _8 ? _8 : this.indicatorKeys[i], null !== (_9 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _9 ? _9 : null === (_11 = null === (_10 = this.indicators) || void 0 === _10 ? void 0 : _10.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _11 ? void 0 : _11.format)),
187
+ 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 {
188
+ (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));
189
+ } 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));
190
+ }
191
+ if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
192
+ if (!this.indicatorStatistics[i]) {
193
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
194
+ this.indicatorStatistics[i] = {
195
+ max: new this.aggregators[ts_types_1.AggregationType.MAX](this.indicatorKeys[i]),
196
+ min: new this.aggregators[ts_types_1.AggregationType.MIN](this.indicatorKeys[i]),
197
+ total: new this.aggregators[null !== (_20 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _20 ? _20 : ts_types_1.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)
198
+ };
199
+ }
200
+ 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()),
201
+ 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()),
202
+ this.indicatorStatistics[i].total.push(record);
172
203
  }
173
- 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()),
174
- 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()),
175
- this.indicatorStatistics[i].total.push(record);
176
204
  }
177
205
  }
178
206
  updateSortRules(sortRules) {
@@ -300,33 +328,36 @@ class Dataset {
300
328
  const that = this;
301
329
  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)) {
302
330
  const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
303
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
331
+ 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;
332
+ 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]);
304
333
  const colKey = flatColKey.split(this.stringJoinChar);
305
- 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++) {
334
+ 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++) {
306
335
  const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
307
336
  if (dimensionIndex >= 0) {
308
337
  const colTotalKey = colKey.slice(0, dimensionIndex + 1);
309
- "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 : "小计");
338
+ 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 : "小计");
310
339
  const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
340
+ 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]);
311
341
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
312
342
  for (let i = 0; i < this.indicatorKeys.length; i++) {
313
343
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
314
344
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
315
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_g = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _g ? _g : ts_types_1.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);
345
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_q = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _q ? _q : ts_types_1.AggregationType.SUM](null !== (_r = null == aggRule ? void 0 : aggRule.field) && void 0 !== _r ? _r : this.indicatorKeys[i], null !== (_s = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _s ? _s : null === (_u = null === (_t = this.indicators) || void 0 === _t ? void 0 : _t.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _u ? void 0 : _u.format);
316
346
  }
317
- 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]);
347
+ 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]);
318
348
  }
319
349
  }
320
350
  }
321
- 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) {
351
+ 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) {
322
352
  const flatColTotalKey = that.colGrandTotalLabel;
353
+ 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]);
323
354
  this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
324
355
  for (let i = 0; i < this.indicatorKeys.length; i++) {
325
356
  if (!this.tree[flatRowKey][flatColTotalKey][i]) {
326
357
  const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
327
- this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_r = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _r ? _r : ts_types_1.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);
358
+ this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_3 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _3 ? _3 : ts_types_1.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);
328
359
  }
329
- 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]);
360
+ 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]);
330
361
  }
331
362
  }
332
363
  };
@@ -336,20 +367,18 @@ class Dataset {
336
367
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
337
368
  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++) {
338
369
  const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
339
- if (dimensionIndex >= 0) {
370
+ if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
340
371
  const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
341
372
  "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 : "小计");
342
373
  const flatRowTotalKey = rowTotalKey.join(this.stringJoinChar);
343
- if (this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
344
- !this.tree[flatRowTotalKey][flatColKey]) {
345
- this.tree[flatRowTotalKey][flatColKey] = [];
346
- for (let i = 0; i < this.indicatorKeys.length; i++) {
347
- if (!this.tree[flatRowTotalKey][flatColKey][i]) {
348
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
349
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_g = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _g ? _g : ts_types_1.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);
350
- }
351
- 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]);
374
+ this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
375
+ this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
376
+ for (let i = 0; i < this.indicatorKeys.length; i++) {
377
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) {
378
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
379
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_g = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _g ? _g : ts_types_1.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);
352
380
  }
381
+ 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]);
353
382
  }
354
383
  }
355
384
  }
@@ -374,9 +403,9 @@ class Dataset {
374
403
  }));
375
404
  }
376
405
  }
377
- ArrToTree1(arr, rows, indicators) {
406
+ ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel) {
378
407
  const result = [], concatStr = this.stringJoinChar, map = new Map;
379
- return arr.forEach((item => function(list) {
408
+ function addList(list) {
380
409
  const path = [];
381
410
  let node;
382
411
  list.forEach(((value, index) => {
@@ -396,7 +425,9 @@ class Dataset {
396
425
  }, map.set(flatKey, item), node ? node.children.push(item) : result.push(item)),
397
426
  node = item;
398
427
  }));
399
- }(item))), result;
428
+ }
429
+ return arr.forEach((item => addList(item))), isGrandTotal && addList([ grandTotalLabel ]),
430
+ result;
400
431
  }
401
432
  ArrToTree(arr, rows, indicators, subTotalFlags, isGrandTotal, grandTotalLabel, subTotalLabel) {
402
433
  var _a;