@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.
- package/cjs/ListTable.js +2 -0
- package/cjs/ListTable.js.map +1 -1
- package/cjs/PivotTable.js +2 -2
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/components/tooltip/TooltipHandler.js +17 -8
- package/cjs/components/tooltip/TooltipHandler.js.map +1 -1
- package/cjs/core/BaseTable.js +1 -1
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/dataset/dataset.d.ts +1 -0
- package/cjs/dataset/dataset.js +89 -58
- package/cjs/dataset/dataset.js.map +1 -1
- package/cjs/event/event.js +2 -3
- package/cjs/event/event.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/chart-helper/get-axis-config.d.ts +11 -0
- package/cjs/layout/chart-helper/get-axis-config.js +65 -62
- package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
- package/cjs/layout/chart-helper/get-chart-spec.js +9 -24
- package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
- package/cjs/layout/pivot-header-layout.js +2 -2
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -3
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/update-position/util.d.ts +1 -1
- package/cjs/scenegraph/group-creater/progress/update-position/util.js +10 -5
- package/cjs/scenegraph/group-creater/progress/update-position/util.js.map +1 -1
- package/cjs/scenegraph/stick-text/index.js +20 -18
- package/cjs/scenegraph/stick-text/index.js.map +1 -1
- package/cjs/themes/DARK.js +1 -1
- package/cjs/themes/DARK.js.map +1 -1
- package/cjs/themes/SIMPLIFY.js +1 -1
- package/cjs/themes/SIMPLIFY.js.map +1 -1
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/ts-types/new-data-set.js.map +1 -1
- package/cjs/ts-types/table-engine.js.map +1 -1
- package/dist/vtable.js +238 -199
- package/dist/vtable.min.js +2 -2
- package/es/ListTable.js +2 -0
- package/es/ListTable.js.map +1 -1
- package/es/PivotTable.js +2 -2
- package/es/PivotTable.js.map +1 -1
- package/es/components/tooltip/TooltipHandler.js +17 -8
- package/es/components/tooltip/TooltipHandler.js.map +1 -1
- package/es/core/BaseTable.js +1 -1
- package/es/core/BaseTable.js.map +1 -1
- package/es/dataset/dataset.d.ts +1 -0
- package/es/dataset/dataset.js +89 -58
- package/es/dataset/dataset.js.map +1 -1
- package/es/event/event.js +2 -3
- package/es/event/event.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/chart-helper/get-axis-config.d.ts +11 -0
- package/es/layout/chart-helper/get-axis-config.js +61 -57
- package/es/layout/chart-helper/get-axis-config.js.map +1 -1
- package/es/layout/chart-helper/get-chart-spec.js +6 -21
- package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
- package/es/layout/pivot-header-layout.js +2 -2
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -3
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
- package/es/scenegraph/group-creater/progress/update-position/util.d.ts +1 -1
- package/es/scenegraph/group-creater/progress/update-position/util.js +10 -5
- package/es/scenegraph/group-creater/progress/update-position/util.js.map +1 -1
- package/es/scenegraph/stick-text/index.js +20 -18
- package/es/scenegraph/stick-text/index.js.map +1 -1
- package/es/themes/DARK.js +1 -1
- package/es/themes/DARK.js.map +1 -1
- package/es/themes/SIMPLIFY.js +1 -1
- package/es/themes/SIMPLIFY.js.map +1 -1
- package/es/ts-types/base-table.js.map +1 -1
- package/es/ts-types/new-data-set.js.map +1 -1
- package/es/ts-types/table-engine.js.map +1 -1
- package/package.json +2 -2
- package/cjs/components/axis/get-axis-attributes.d.ts +0 -151
- package/es/components/axis/get-axis-attributes.d.ts +0 -151
package/cjs/dataset/dataset.d.ts
CHANGED
|
@@ -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;
|
package/cjs/dataset/dataset.js
CHANGED
|
@@ -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,
|
|
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 === (
|
|
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 === (
|
|
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 === (
|
|
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
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
(null
|
|
162
|
-
|
|
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
|
-
|
|
165
|
-
|
|
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.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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 === (
|
|
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
|
-
|
|
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 !== (
|
|
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 === (
|
|
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 === (
|
|
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 !== (
|
|
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 === (
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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;
|