@visactor/vtable 1.7.8-alpha.3 → 1.7.8-alpha.5
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/PivotTable.js +3 -3
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/core/BaseTable.d.ts +7 -0
- package/cjs/core/BaseTable.js +26 -9
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/dataset/DataStatistics.js +1 -2
- package/cjs/dataset/dataset.d.ts +2 -19
- package/cjs/dataset/dataset.js +160 -260
- package/cjs/dataset/dataset.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/layout-helper.js +2 -1
- package/cjs/layout/row-height-map.js +1 -1
- package/cjs/layout/simple-header-layout.js +1 -1
- package/cjs/layout/tree-helper.js +2 -2
- package/cjs/plugins/custom-cell-style.js +1 -2
- package/cjs/plugins/icons.js +1 -1
- package/cjs/plugins/list-tree-stick-cell.js +1 -1
- package/cjs/plugins/themes.js +1 -1
- package/cjs/scenegraph/layout/frozen-react.d.ts +5 -0
- package/cjs/scenegraph/layout/frozen-react.js +86 -0
- package/cjs/scenegraph/layout/frozen-react.js.map +1 -0
- package/cjs/scenegraph/layout/frozen.js +3 -2
- package/cjs/scenegraph/layout/frozen.js.map +1 -1
- package/cjs/scenegraph/scenegraph.js +2 -15
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/ts-types/base-table.d.ts +14 -0
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +507 -509
- package/dist/vtable.min.js +2 -2
- package/es/PivotTable.js +3 -3
- package/es/PivotTable.js.map +1 -1
- package/es/core/BaseTable.d.ts +7 -0
- package/es/core/BaseTable.js +27 -9
- package/es/core/BaseTable.js.map +1 -1
- package/es/dataset/DataStatistics.js +1 -2
- package/es/dataset/dataset.d.ts +2 -19
- package/es/dataset/dataset.js +161 -260
- package/es/dataset/dataset.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/layout-helper.js +2 -1
- package/es/layout/row-height-map.js +1 -1
- package/es/layout/simple-header-layout.js +1 -1
- package/es/layout/tree-helper.js +1 -1
- package/es/plugins/custom-cell-style.js +1 -2
- package/es/plugins/icons.js +1 -1
- package/es/plugins/list-tree-stick-cell.js +1 -1
- package/es/plugins/themes.js +1 -1
- package/es/scenegraph/layout/frozen-react.d.ts +5 -0
- package/es/scenegraph/layout/frozen-react.js +77 -0
- package/es/scenegraph/layout/frozen-react.js.map +1 -0
- package/es/scenegraph/layout/frozen.js +3 -1
- package/es/scenegraph/layout/frozen.js.map +1 -1
- package/es/scenegraph/scenegraph.js +3 -14
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/ts-types/base-table.d.ts +14 -0
- package/es/ts-types/base-table.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +4 -4
package/cjs/dataset/dataset.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), ts_types_1 = require("../ts-types"), statistics_helper_1 = require("./statistics-helper"), global_1 = require("../tools/global"), join_1 = require("../tools/join");
|
|
8
8
|
|
|
9
9
|
class Dataset {
|
|
10
|
-
constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative
|
|
10
|
+
constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
|
|
11
11
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
|
|
12
12
|
this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
|
|
13
13
|
this.colKeys = [], this.rowKeys = [], this.colKeys_normal = [], this.rowKeys_normal = [],
|
|
@@ -29,10 +29,7 @@ class Dataset {
|
|
|
29
29
|
this.rows = rows, this.columns = columns, this.indicatorKeys = indicatorKeys, this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys = [ ...indicatorKeys ];
|
|
30
30
|
for (let m = 0; m < this.calculatedFieldDependIndicatorKeys.length; m++) -1 === this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.indexOf(this.calculatedFieldDependIndicatorKeys[m]) && this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.push(this.calculatedFieldDependIndicatorKeys[m]);
|
|
31
31
|
if (this.indicatorsAsCol = indicatorsAsCol, this.indicators = indicators, this.customColTree = customColTree,
|
|
32
|
-
this.customRowTree = customRowTree, this.
|
|
33
|
-
this.customColTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customColTree, "col"),
|
|
34
|
-
this.hasExtensionRowTree || (this.customRowTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customRowTree, "row")),
|
|
35
|
-
this.colGrandTotalLabel = null !== (_p = null === (_o = null === (_m = this.totals) || void 0 === _m ? void 0 : _m.column) || void 0 === _o ? void 0 : _o.grandTotalLabel) && void 0 !== _p ? _p : "总计",
|
|
32
|
+
this.customRowTree = customRowTree, this.colGrandTotalLabel = null !== (_p = null === (_o = null === (_m = this.totals) || void 0 === _m ? void 0 : _m.column) || void 0 === _o ? void 0 : _o.grandTotalLabel) && void 0 !== _p ? _p : "总计",
|
|
36
33
|
this.colSubTotalLabel = null !== (_s = null === (_r = null === (_q = this.totals) || void 0 === _q ? void 0 : _q.column) || void 0 === _r ? void 0 : _r.subTotalLabel) && void 0 !== _s ? _s : "小计",
|
|
37
34
|
this.rowGrandTotalLabel = null !== (_v = null === (_u = null === (_t = this.totals) || void 0 === _t ? void 0 : _t.row) || void 0 === _u ? void 0 : _u.grandTotalLabel) && void 0 !== _v ? _v : "总计",
|
|
38
35
|
this.rowSubTotalLabel = null !== (_y = null === (_x = null === (_w = this.totals) || void 0 === _w ? void 0 : _w.row) || void 0 === _x ? void 0 : _x.subTotalLabel) && void 0 !== _y ? _y : "小计",
|
|
@@ -158,7 +155,7 @@ class Dataset {
|
|
|
158
155
|
return isReserved;
|
|
159
156
|
}
|
|
160
157
|
processRecord(record, assignedIndicatorKey) {
|
|
161
|
-
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, _29, _30, _31, _32, _33, _34, _35, _36
|
|
158
|
+
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, _29, _30, _31, _32, _33, _34, _35, _36;
|
|
162
159
|
null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
|
|
163
160
|
derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
|
|
164
161
|
}));
|
|
@@ -184,154 +181,109 @@ class Dataset {
|
|
|
184
181
|
-1 === fieldRange.indexOf(record[field]) && fieldRange.push(record[field]);
|
|
185
182
|
}
|
|
186
183
|
}
|
|
184
|
+
const colKey = [], rowKey = [];
|
|
187
185
|
let isToTalRecord = !1;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if ((null === (_f = null === (_e = null === (_d = this.dataConfig) || void 0 === _d ? void 0 : _d.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.showGrandTotals) && 0 === l && !this.rows.find((rk => rk in record))) {
|
|
199
|
-
rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
if ((null === (_j = null === (_h = null === (_g = this.dataConfig) || void 0 === _g ? void 0 : _g.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.subTotalsDimensions) && (null === (_m = null === (_l = null === (_k = this.dataConfig) || void 0 === _k ? void 0 : _k.totals) || void 0 === _l ? void 0 : _l.row) || void 0 === _m ? void 0 : _m.subTotalsDimensions.indexOf(this.rows[l - 1])) >= 0) {
|
|
203
|
-
"grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
186
|
+
for (let l = 0, len1 = this.rows.length; l < len1; l++) {
|
|
187
|
+
const rowAttr = this.rows[l];
|
|
188
|
+
if (rowAttr in record) this.rowsHasValue[l] = !0, rowKey.push(record[rowAttr]); else if (rowAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
|
|
189
|
+
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))) {
|
|
190
|
+
rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
if ((null === (_g = null === (_f = null === (_e = this.dataConfig) || void 0 === _e ? void 0 : _e.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions) && (null === (_k = null === (_j = null === (_h = this.dataConfig) || void 0 === _h ? void 0 : _h.totals) || void 0 === _j ? void 0 : _j.row) || void 0 === _k ? void 0 : _k.subTotalsDimensions.indexOf(this.rows[l - 1])) >= 0) {
|
|
194
|
+
"grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
|
|
195
|
+
break;
|
|
206
196
|
}
|
|
207
|
-
}
|
|
208
|
-
} else {
|
|
209
|
-
const rowTreePath = this.getFieldMatchRowDimensionPaths(record);
|
|
210
|
-
if (rowTreePath.length > 0) for (let i = 0, len = rowTreePath.length; i < len; i++) {
|
|
211
|
-
const rowPath = rowTreePath[i], rowKey = [];
|
|
212
|
-
let indicatorKey;
|
|
213
|
-
for (let j = 0, len1 = rowPath.length; j < len1; j++) (0, vutils_1.isValid)(rowPath[j].indicatorKey) ? indicatorKey = rowPath[j].indicatorKey : rowKey.push(rowPath[j].value);
|
|
214
|
-
rowKeys.push({
|
|
215
|
-
rowKey: rowKey,
|
|
216
|
-
indicatorKey: indicatorKey
|
|
217
|
-
});
|
|
218
197
|
}
|
|
219
198
|
}
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
if ((null === (_v = null === (_u = null === (_t = this.dataConfig) || void 0 === _t ? void 0 : _t.totals) || void 0 === _u ? void 0 : _u.column) || void 0 === _v ? void 0 : _v.subTotalsDimensions) && (null === (_y = null === (_x = null === (_w = this.dataConfig) || void 0 === _w ? void 0 : _w.totals) || void 0 === _x ? void 0 : _x.column) || void 0 === _y ? void 0 : _y.subTotalsDimensions.indexOf(this.columns[n - 1])) >= 0) {
|
|
234
|
-
colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
199
|
+
for (let n = 0, len2 = this.columns.length; n < len2; n++) {
|
|
200
|
+
const colAttr = this.columns[n];
|
|
201
|
+
if (colAttr in record) this.columnsHasValue[n] = !0, colKey.push(record[colAttr]); else if (colAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
|
|
202
|
+
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))) {
|
|
203
|
+
colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
if ((null === (_r = null === (_q = null === (_p = this.dataConfig) || void 0 === _p ? void 0 : _p.totals) || void 0 === _q ? void 0 : _q.column) || void 0 === _r ? void 0 : _r.subTotalsDimensions) && (null === (_u = null === (_t = null === (_s = this.dataConfig) || void 0 === _s ? void 0 : _s.totals) || void 0 === _t ? void 0 : _t.column) || void 0 === _u ? void 0 : _u.subTotalsDimensions.indexOf(this.columns[n - 1])) >= 0) {
|
|
207
|
+
colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
|
|
208
|
+
break;
|
|
237
209
|
}
|
|
238
210
|
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
211
|
+
}
|
|
212
|
+
const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
|
|
213
|
+
if (isToTalRecord) {
|
|
214
|
+
this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
|
|
215
|
+
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
216
|
+
for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
217
|
+
const calculatedFieldRule = null === (_v = this.calculatedFieldRules) || void 0 === _v ? void 0 : _v.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
218
|
+
(null === (_x = null === (_w = this.totalRecordsTree[flatRowKey]) || void 0 === _w ? void 0 : _w[flatColKey]) || void 0 === _x ? void 0 : _x[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
219
|
+
key: toComputeIndicatorKeys[i],
|
|
220
|
+
dimension: toComputeIndicatorKeys[i],
|
|
221
|
+
isRecord: !0,
|
|
222
|
+
formatFun: null === (_z = null === (_y = this.indicators) || void 0 === _y ? void 0 : _y.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _z ? void 0 : _z.format,
|
|
223
|
+
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
224
|
+
dependAggregators: this.totalRecordsTree[flatRowKey][flatColKey],
|
|
225
|
+
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
226
|
+
})), toComputeIndicatorKeys[i] in record && (null === (_1 = null === (_0 = this.totalRecordsTree[flatRowKey]) || void 0 === _0 ? void 0 : _0[flatColKey]) || void 0 === _1 || _1[i].push(record));
|
|
227
|
+
} else {
|
|
228
|
+
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
229
|
+
(null === (_3 = null === (_2 = this.totalRecordsTree[flatRowKey]) || void 0 === _2 ? void 0 : _2[flatColKey]) || void 0 === _3 ? void 0 : _3[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_4 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _4 ? _4 : ts_types_1.AggregationType.SUM]({
|
|
230
|
+
key: toComputeIndicatorKeys[i],
|
|
231
|
+
dimension: null !== (_5 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _5 ? _5 : toComputeIndicatorKeys[i],
|
|
232
|
+
formatFun: null !== (_6 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _6 ? _6 : null === (_8 = null === (_7 = this.indicators) || void 0 === _7 ? void 0 : _7.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _8 ? void 0 : _8.format
|
|
233
|
+
})), toComputeIndicatorKeys[i] in record && (null === (_10 = null === (_9 = this.totalRecordsTree[flatRowKey]) || void 0 === _9 ? void 0 : _9[flatColKey]) || void 0 === _10 || _10[i].push(record));
|
|
249
234
|
}
|
|
235
|
+
return;
|
|
250
236
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
formatFun: null === (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
298
|
-
})), null === (_22 = null === (_21 = this.tree[flatRowKey]) || void 0 === _21 ? void 0 : _21[flatColKey]) || void 0 === _22 || _22[i].push(record);
|
|
299
|
-
} else {
|
|
300
|
-
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
301
|
-
let needAddToAggregator = !1;
|
|
302
|
-
if (assignedIndicatorKey_value) assignedIndicatorKey === assignedIndicatorKey_value ? toComputeIndicatorKeys[i] === assignedIndicatorKey_value && (needAddToAggregator = !0) : toComputeIndicatorKeys[i] === assignedIndicatorKey_value && toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0); else if (null == aggRule ? void 0 : aggRule.field) if ("string" == typeof (null == aggRule ? void 0 : aggRule.field)) (null == aggRule ? void 0 : aggRule.field) in record && (needAddToAggregator = !0); else {
|
|
303
|
-
(null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
|
|
304
|
-
} else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
|
|
305
|
-
!(null === (_24 = null === (_23 = this.tree[flatRowKey]) || void 0 === _23 ? void 0 : _23[flatColKey]) || void 0 === _24 ? void 0 : _24[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_25 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _25 ? _25 : ts_types_1.AggregationType.SUM]({
|
|
306
|
-
key: toComputeIndicatorKeys[i],
|
|
307
|
-
dimension: null !== (_26 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _26 ? _26 : toComputeIndicatorKeys[i],
|
|
308
|
-
formatFun: null !== (_27 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _27 ? _27 : null === (_29 = null === (_28 = this.indicators) || void 0 === _28 ? void 0 : _28.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _29 ? void 0 : _29.format
|
|
309
|
-
})), needAddToAggregator && (null === (_31 = null === (_30 = this.tree[flatRowKey]) || void 0 === _30 ? void 0 : _30[flatColKey]) || void 0 === _31 || _31[i].push(record));
|
|
310
|
-
}
|
|
311
|
-
if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
312
|
-
if (!this.indicatorStatistics[i]) {
|
|
313
|
-
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
314
|
-
this.indicatorStatistics[i] = {
|
|
315
|
-
max: new this.aggregators[ts_types_1.AggregationType.MAX]({
|
|
316
|
-
key: this.indicatorKeys[i],
|
|
317
|
-
dimension: this.indicatorKeys[i]
|
|
318
|
-
}),
|
|
319
|
-
min: new this.aggregators[ts_types_1.AggregationType.MIN]({
|
|
320
|
-
key: this.indicatorKeys[i],
|
|
321
|
-
dimension: this.indicatorKeys[i]
|
|
322
|
-
}),
|
|
323
|
-
total: new this.aggregators[null !== (_32 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _32 ? _32 : ts_types_1.AggregationType.SUM]({
|
|
324
|
-
key: this.indicatorKeys[i],
|
|
325
|
-
dimension: null !== (_33 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _33 ? _33 : this.indicatorKeys[i],
|
|
326
|
-
formatFun: null !== (_34 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _34 ? _34 : null === (_36 = null === (_35 = this.indicators) || void 0 === _35 ? void 0 : _35.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _36 ? void 0 : _36.format
|
|
327
|
-
})
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
this.indicatorStatistics[i].max.push(null === (_38 = null === (_37 = this.tree[flatRowKey]) || void 0 === _37 ? void 0 : _37[flatColKey]) || void 0 === _38 ? void 0 : _38[i].value()),
|
|
331
|
-
this.indicatorStatistics[i].min.push(null === (_40 = null === (_39 = this.tree[flatRowKey]) || void 0 === _39 ? void 0 : _39[flatColKey]) || void 0 === _40 ? void 0 : _40[i].value()),
|
|
332
|
-
this.indicatorStatistics[i].total.push(record);
|
|
333
|
-
}
|
|
237
|
+
0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
|
|
238
|
+
this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
|
|
239
|
+
this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
|
|
240
|
+
(null === (_11 = this.tree[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
|
|
241
|
+
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
242
|
+
for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
243
|
+
const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
244
|
+
(null === (_14 = null === (_13 = this.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColKey]) || void 0 === _14 ? void 0 : _14[i]) || (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
245
|
+
key: toComputeIndicatorKeys[i],
|
|
246
|
+
dimension: toComputeIndicatorKeys[i],
|
|
247
|
+
isRecord: !0,
|
|
248
|
+
formatFun: null === (_16 = null === (_15 = this.indicators) || void 0 === _15 ? void 0 : _15.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _16 ? void 0 : _16.format,
|
|
249
|
+
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
250
|
+
dependAggregators: this.tree[flatRowKey][flatColKey],
|
|
251
|
+
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
252
|
+
})), null === (_18 = null === (_17 = this.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 || _18[i].push(record);
|
|
253
|
+
} else {
|
|
254
|
+
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
255
|
+
let needAddToAggregator = !1;
|
|
256
|
+
if (assignedIndicatorKey) toComputeIndicatorKeys[i] === assignedIndicatorKey && (needAddToAggregator = !0); else if (null == aggRule ? void 0 : aggRule.field) if ("string" == typeof (null == aggRule ? void 0 : aggRule.field)) (null == aggRule ? void 0 : aggRule.field) in record && (needAddToAggregator = !0); else {
|
|
257
|
+
(null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
|
|
258
|
+
} else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
|
|
259
|
+
!(null === (_20 = null === (_19 = this.tree[flatRowKey]) || void 0 === _19 ? void 0 : _19[flatColKey]) || void 0 === _20 ? void 0 : _20[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_21 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _21 ? _21 : ts_types_1.AggregationType.SUM]({
|
|
260
|
+
key: toComputeIndicatorKeys[i],
|
|
261
|
+
dimension: null !== (_22 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _22 ? _22 : toComputeIndicatorKeys[i],
|
|
262
|
+
formatFun: null !== (_23 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _23 ? _23 : null === (_25 = null === (_24 = this.indicators) || void 0 === _24 ? void 0 : _24.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _25 ? void 0 : _25.format
|
|
263
|
+
})), needAddToAggregator && (null === (_27 = null === (_26 = this.tree[flatRowKey]) || void 0 === _26 ? void 0 : _26[flatColKey]) || void 0 === _27 || _27[i].push(record));
|
|
264
|
+
}
|
|
265
|
+
if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
266
|
+
if (!this.indicatorStatistics[i]) {
|
|
267
|
+
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
268
|
+
this.indicatorStatistics[i] = {
|
|
269
|
+
max: new this.aggregators[ts_types_1.AggregationType.MAX]({
|
|
270
|
+
key: this.indicatorKeys[i],
|
|
271
|
+
dimension: this.indicatorKeys[i]
|
|
272
|
+
}),
|
|
273
|
+
min: new this.aggregators[ts_types_1.AggregationType.MIN]({
|
|
274
|
+
key: this.indicatorKeys[i],
|
|
275
|
+
dimension: this.indicatorKeys[i]
|
|
276
|
+
}),
|
|
277
|
+
total: new this.aggregators[null !== (_28 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _28 ? _28 : ts_types_1.AggregationType.SUM]({
|
|
278
|
+
key: this.indicatorKeys[i],
|
|
279
|
+
dimension: null !== (_29 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _29 ? _29 : this.indicatorKeys[i],
|
|
280
|
+
formatFun: null !== (_30 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _30 ? _30 : null === (_32 = null === (_31 = this.indicators) || void 0 === _31 ? void 0 : _31.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _32 ? void 0 : _32.format
|
|
281
|
+
})
|
|
282
|
+
};
|
|
334
283
|
}
|
|
284
|
+
this.indicatorStatistics[i].max.push(null === (_34 = null === (_33 = this.tree[flatRowKey]) || void 0 === _33 ? void 0 : _33[flatColKey]) || void 0 === _34 ? void 0 : _34[i].value()),
|
|
285
|
+
this.indicatorStatistics[i].min.push(null === (_36 = null === (_35 = this.tree[flatRowKey]) || void 0 === _35 ? void 0 : _35[flatColKey]) || void 0 === _36 ? void 0 : _36[i].value()),
|
|
286
|
+
this.indicatorStatistics[i].total.push(record);
|
|
335
287
|
}
|
|
336
288
|
}
|
|
337
289
|
updateSortRules(sortRules) {
|
|
@@ -340,10 +292,10 @@ class Dataset {
|
|
|
340
292
|
this.customColTree || (this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns.filter(((key, index) => this.columnsHasValue[index])), this.indicatorsAsCol ? this.indicators : void 0, this.colsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotalsOnLeft) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showSubTotalsOnLeft) && void 0 !== _t && _t));
|
|
341
293
|
}
|
|
342
294
|
updateFilterRules(filterRules, isResetTree = !1) {
|
|
343
|
-
var _a
|
|
344
|
-
if (this.filterRules = filterRules, this.filteredRecords = void 0, isResetTree) this.tree = {}; else for (const treeRowKey in this.tree) for (const treeColKey in this.tree[treeRowKey]) for (let i = 0; i < this.tree[treeRowKey][treeColKey].length; i++)
|
|
295
|
+
var _a;
|
|
296
|
+
if (this.filterRules = filterRules, this.filteredRecords = void 0, isResetTree) this.tree = {}; else for (const treeRowKey in this.tree) for (const treeColKey in this.tree[treeRowKey]) for (let i = 0; i < this.tree[treeRowKey][treeColKey].length; i++) this.tree[treeRowKey][treeColKey][i].reset();
|
|
345
297
|
this.collectedValues = {}, this.processRecords(), this.processCollectedValuesWithSumBy(),
|
|
346
|
-
this.processCollectedValuesWithSortBy(), this.totalStatistics(), (null === (
|
|
298
|
+
this.processCollectedValuesWithSortBy(), this.totalStatistics(), (null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.isPivotChart) && this.cacheDeminsionCollectedValues();
|
|
347
299
|
}
|
|
348
300
|
getAggregatorRule(indicatorKey) {
|
|
349
301
|
var _a;
|
|
@@ -445,75 +397,74 @@ class Dataset {
|
|
|
445
397
|
}
|
|
446
398
|
totalStatistics() {
|
|
447
399
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
448
|
-
const that = this
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
400
|
+
const that = this;
|
|
401
|
+
if ((null === (_b = null === (_a = null == that ? void 0 : that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = null == that ? void 0 : that.totals) || void 0 === _c ? void 0 : _c.column) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 || (null === (_g = null === (_f = null == that ? void 0 : that.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions) && (null === (_k = null === (_j = null === (_h = null == that ? void 0 : that.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.subTotalsDimensions) || void 0 === _k ? void 0 : _k.length) >= 1 || (null === (_m = null === (_l = null == that ? void 0 : that.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || (null === (_p = null === (_o = null == that ? void 0 : that.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotals)) {
|
|
402
|
+
const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
|
|
403
|
+
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;
|
|
404
|
+
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]);
|
|
405
|
+
const colKey = flatColKey.split(this.stringJoinChar);
|
|
406
|
+
if ((null === (_f = null === (_e = that.totals) || void 0 === _e ? void 0 : _e.column) || void 0 === _f ? void 0 : _f.subTotalsDimensions) && (null === (_j = null === (_h = null === (_g = that.totals) || void 0 === _g ? void 0 : _g.column) || void 0 === _h ? void 0 : _h.subTotalsDimensions) || void 0 === _j ? void 0 : _j.length) > 0 && !1 !== that.totals.column.showSubTotals) for (let i = 0, len = null === (_m = null === (_l = null === (_k = that.totals) || void 0 === _k ? void 0 : _k.column) || void 0 === _l ? void 0 : _l.subTotalsDimensions) || void 0 === _m ? void 0 : _m.length; i < len; i++) {
|
|
407
|
+
const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
|
|
408
|
+
if (dimensionIndex >= 0) {
|
|
409
|
+
const colTotalKey = colKey.slice(0, dimensionIndex + 1);
|
|
410
|
+
colTotalKey.push(that.colSubTotalLabel);
|
|
411
|
+
const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
|
|
412
|
+
if (null === (_p = null === (_o = this.totalRecordsTree) || void 0 === _o ? void 0 : _o[flatRowKey]) || void 0 === _p ? void 0 : _p[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_r = null === (_q = this.totalRecordsTree) || void 0 === _q ? void 0 : _q[flatRowKey]) || void 0 === _r ? void 0 : _r[flatColTotalKey]);
|
|
413
|
+
this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
|
|
414
|
+
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
415
|
+
for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
416
|
+
const calculatedFieldRule = null === (_s = this.calculatedFieldRules) || void 0 === _s ? void 0 : _s.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
417
|
+
(null === (_u = null === (_t = this.tree[flatRowKey]) || void 0 === _t ? void 0 : _t[flatColTotalKey]) || void 0 === _u ? void 0 : _u[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
418
|
+
key: toComputeIndicatorKeys[i],
|
|
419
|
+
dimension: toComputeIndicatorKeys[i],
|
|
420
|
+
isRecord: !0,
|
|
421
|
+
formatFun: null === (_w = null === (_v = this.indicators) || void 0 === _v ? void 0 : _v.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _w ? void 0 : _w.format,
|
|
422
|
+
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
423
|
+
dependAggregators: this.tree[flatRowKey][flatColTotalKey],
|
|
424
|
+
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
425
|
+
})), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_y = null === (_x = that.tree[flatRowKey]) || void 0 === _x ? void 0 : _x[flatColKey]) || void 0 === _y ? void 0 : _y[i]);
|
|
426
|
+
} else {
|
|
427
|
+
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
428
|
+
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
429
|
+
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_z = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _z ? _z : ts_types_1.AggregationType.SUM]({
|
|
430
|
+
key: toComputeIndicatorKeys[i],
|
|
431
|
+
dimension: null !== (_0 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _0 ? _0 : toComputeIndicatorKeys[i],
|
|
432
|
+
formatFun: null !== (_1 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _1 ? _1 : null === (_3 = null === (_2 = this.indicators) || void 0 === _2 ? void 0 : _2.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _3 ? void 0 : _3.format
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_5 = null === (_4 = that.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || void 0 === _5 ? void 0 : _5[i]);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
if ((null === (_7 = null === (_6 = that.totals) || void 0 === _6 ? void 0 : _6.column) || void 0 === _7 ? void 0 : _7.showGrandTotals) || 0 === this.rows.length) {
|
|
440
|
+
const flatColTotalKey = that.colGrandTotalLabel;
|
|
441
|
+
if (null === (_9 = null === (_8 = this.totalRecordsTree) || void 0 === _8 ? void 0 : _8[flatRowKey]) || void 0 === _9 ? void 0 : _9[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_11 = null === (_10 = this.totalRecordsTree) || void 0 === _10 ? void 0 : _10[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColTotalKey]);
|
|
460
442
|
this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
|
|
461
443
|
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
462
444
|
for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
463
|
-
const calculatedFieldRule = null === (
|
|
464
|
-
(null === (
|
|
445
|
+
const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
446
|
+
(null === (_14 = null === (_13 = this.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColTotalKey]) || void 0 === _14 ? void 0 : _14[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
465
447
|
key: toComputeIndicatorKeys[i],
|
|
466
448
|
dimension: toComputeIndicatorKeys[i],
|
|
467
449
|
isRecord: !0,
|
|
468
|
-
formatFun: null === (
|
|
450
|
+
formatFun: null === (_16 = null === (_15 = this.indicators) || void 0 === _15 ? void 0 : _15.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _16 ? void 0 : _16.format,
|
|
469
451
|
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
470
452
|
dependAggregators: this.tree[flatRowKey][flatColTotalKey],
|
|
471
453
|
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
472
|
-
})), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (
|
|
454
|
+
})), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_18 = null === (_17 = that.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 ? void 0 : _18[i]);
|
|
473
455
|
} else {
|
|
474
456
|
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
475
457
|
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
476
|
-
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (
|
|
458
|
+
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_19 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _19 ? _19 : ts_types_1.AggregationType.SUM]({
|
|
477
459
|
key: toComputeIndicatorKeys[i],
|
|
478
|
-
dimension: null !== (
|
|
479
|
-
formatFun: null !== (
|
|
460
|
+
dimension: null !== (_20 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _20 ? _20 : toComputeIndicatorKeys[i],
|
|
461
|
+
formatFun: null !== (_21 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _21 ? _21 : null === (_23 = null === (_22 = this.indicators) || void 0 === _22 ? void 0 : _22.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _23 ? void 0 : _23.format
|
|
480
462
|
});
|
|
481
463
|
}
|
|
482
|
-
flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (
|
|
464
|
+
flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_25 = null === (_24 = that.tree[flatRowKey]) || void 0 === _24 ? void 0 : _24[flatColKey]) || void 0 === _25 ? void 0 : _25[i]);
|
|
483
465
|
}
|
|
484
466
|
}
|
|
485
|
-
}
|
|
486
|
-
if ((null === (_7 = null === (_6 = that.totals) || void 0 === _6 ? void 0 : _6.column) || void 0 === _7 ? void 0 : _7.showGrandTotals) || 0 === this.rows.length) {
|
|
487
|
-
const flatColTotalKey = that.colGrandTotalLabel;
|
|
488
|
-
if (null === (_9 = null === (_8 = this.totalRecordsTree) || void 0 === _8 ? void 0 : _8[flatRowKey]) || void 0 === _9 ? void 0 : _9[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_11 = null === (_10 = this.totalRecordsTree) || void 0 === _10 ? void 0 : _10[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColTotalKey]);
|
|
489
|
-
this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
|
|
490
|
-
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
491
|
-
for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
492
|
-
const calculatedFieldRule = null === (_12 = this.calculatedFieldRules) || void 0 === _12 ? void 0 : _12.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
493
|
-
(null === (_14 = null === (_13 = this.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColTotalKey]) || void 0 === _14 ? void 0 : _14[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
494
|
-
key: toComputeIndicatorKeys[i],
|
|
495
|
-
dimension: toComputeIndicatorKeys[i],
|
|
496
|
-
isRecord: !0,
|
|
497
|
-
formatFun: null === (_16 = null === (_15 = this.indicators) || void 0 === _15 ? void 0 : _15.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _16 ? void 0 : _16.format,
|
|
498
|
-
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
499
|
-
dependAggregators: this.tree[flatRowKey][flatColTotalKey],
|
|
500
|
-
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
501
|
-
})), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_18 = null === (_17 = that.tree[flatRowKey]) || void 0 === _17 ? void 0 : _17[flatColKey]) || void 0 === _18 ? void 0 : _18[i]);
|
|
502
|
-
} else {
|
|
503
|
-
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
504
|
-
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
505
|
-
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_19 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _19 ? _19 : ts_types_1.AggregationType.SUM]({
|
|
506
|
-
key: toComputeIndicatorKeys[i],
|
|
507
|
-
dimension: null !== (_20 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _20 ? _20 : toComputeIndicatorKeys[i],
|
|
508
|
-
formatFun: null !== (_21 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _21 ? _21 : null === (_23 = null === (_22 = this.indicators) || void 0 === _22 ? void 0 : _22.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _23 ? void 0 : _23.format
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_25 = null === (_24 = that.tree[flatRowKey]) || void 0 === _24 ? void 0 : _24[flatColKey]) || void 0 === _25 ? void 0 : _25[i]);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
if ((null === (_b = null === (_a = null == that ? void 0 : that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = null == that ? void 0 : that.totals) || void 0 === _c ? void 0 : _c.column) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 || (null === (_g = null === (_f = null == that ? void 0 : that.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalsDimensions) && (null === (_k = null === (_j = null === (_h = null == that ? void 0 : that.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.subTotalsDimensions) || void 0 === _k ? void 0 : _k.length) >= 1 || (null === (_m = null === (_l = null == that ? void 0 : that.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || (null === (_p = null === (_o = null == that ? void 0 : that.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotals)) {
|
|
516
|
-
const rowTotalKeys = [];
|
|
467
|
+
};
|
|
517
468
|
Object.keys(that.tree).forEach((flatRowKey => {
|
|
518
469
|
const rowKey = flatRowKey.split(this.stringJoinChar);
|
|
519
470
|
Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
|
|
@@ -587,7 +538,6 @@ class Dataset {
|
|
|
587
538
|
}));
|
|
588
539
|
}));
|
|
589
540
|
}
|
|
590
|
-
for (const flatRowKey in that.totalRecordsTree) for (const flatColKey in that.totalRecordsTree[flatRowKey]) colCompute(flatRowKey, flatColKey);
|
|
591
541
|
}
|
|
592
542
|
ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel) {
|
|
593
543
|
const result = [], concatStr = this.stringJoinChar, map = new Map;
|
|
@@ -685,6 +635,14 @@ class Dataset {
|
|
|
685
635
|
}
|
|
686
636
|
return result;
|
|
687
637
|
}
|
|
638
|
+
TreeToArr(tree) {
|
|
639
|
+
const result = [];
|
|
640
|
+
function getPath(node, arr) {
|
|
641
|
+
var _a;
|
|
642
|
+
arr.push(node.id), node.children.length > 0 ? null === (_a = node.children) || void 0 === _a || _a.forEach((childItem => getPath(childItem, [ ...arr ]))) : result.push(arr);
|
|
643
|
+
}
|
|
644
|
+
return tree.forEach((treeNode => getPath(treeNode, []))), result;
|
|
645
|
+
}
|
|
688
646
|
cacheDeminsionCollectedValues() {
|
|
689
647
|
for (const key in this.collectValuesBy) "xField" !== this.collectValuesBy[key].type && "yField" !== this.collectValuesBy[key].type || (this.dataConfig.dimensionSortArray ? this.cacheCollectedValues[key] = arraySortByAnotherArray(this.collectedValues[key], this.dataConfig.dimensionSortArray) : this.cacheCollectedValues[key] = this.collectedValues[key]);
|
|
690
648
|
}
|
|
@@ -714,9 +672,6 @@ class Dataset {
|
|
|
714
672
|
this.rowFlatKeys = {}, this.colFlatKeys = {}, this.tree = {}, this.processRecords();
|
|
715
673
|
}
|
|
716
674
|
}
|
|
717
|
-
_rowTreeHasChanged() {
|
|
718
|
-
this.hasExtensionRowTree || (this.customRowTreeDimensionPaths = this.customTreeToDimensionPathArr(this.customRowTree, "row"));
|
|
719
|
-
}
|
|
720
675
|
changeDataConfig(dataConfig) {
|
|
721
676
|
this.rows = dataConfig.rows, this.columns = dataConfig.columns;
|
|
722
677
|
}
|
|
@@ -727,62 +682,6 @@ class Dataset {
|
|
|
727
682
|
}
|
|
728
683
|
Array.isArray(this.records) && this.records.push(records);
|
|
729
684
|
}
|
|
730
|
-
customTreeToDimensionPathArr(tree, type) {
|
|
731
|
-
const result = [], that = this;
|
|
732
|
-
function getPath(node, arr) {
|
|
733
|
-
var _a, _b, _c;
|
|
734
|
-
node.virtual || ((null === (_a = arr[arr.length - 1]) || void 0 === _a ? void 0 : _a.childKeys) && node.dimensionKey && -1 === arr[arr.length - 1].childKeys.indexOf(node.dimensionKey) && node.dimensionKey !== arr[arr.length - 1].dimensionKey && arr[arr.length - 1].childKeys.push(node.dimensionKey),
|
|
735
|
-
arr.push({
|
|
736
|
-
dimensionKey: (0, vutils_1.isValid)(node.indicatorKey) ? void 0 : node.dimensionKey,
|
|
737
|
-
value: node.value,
|
|
738
|
-
indicatorKey: node.indicatorKey,
|
|
739
|
-
virtual: node.virtual
|
|
740
|
-
})), (null === (_b = node.children) || void 0 === _b ? void 0 : _b.length) > 0 ? ("tree" === that.rowHierarchyType && "row" === type && (arr[arr.length - 1].childKeys = [],
|
|
741
|
-
result.push([ ...arr ])), null === (_c = node.children) || void 0 === _c || _c.forEach((childItem => getPath(childItem, [ ...arr ])))) : result.push(arr);
|
|
742
|
-
}
|
|
743
|
-
return null == tree || tree.forEach((treeNode => getPath(treeNode, []))), result;
|
|
744
|
-
}
|
|
745
|
-
getFieldMatchColDimensionPaths(record) {
|
|
746
|
-
var _a, _b;
|
|
747
|
-
const fieldMatchDimensionPaths = [];
|
|
748
|
-
for (let i = 0; null !== (_b = i < (null === (_a = this.customColTreeDimensionPaths) || void 0 === _a ? void 0 : _a.length)) && void 0 !== _b && _b; i++) {
|
|
749
|
-
const dimensionPath = this.customColTreeDimensionPaths[i];
|
|
750
|
-
let isMatch = !0;
|
|
751
|
-
for (let j = 0; j < dimensionPath.length; j++) {
|
|
752
|
-
const dimension = dimensionPath[j];
|
|
753
|
-
if (dimension.dimensionKey && record[dimension.dimensionKey] !== dimension.value || dimension.indicatorKey && void 0 === record[dimension.indicatorKey]) {
|
|
754
|
-
isMatch = !1;
|
|
755
|
-
break;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
isMatch && fieldMatchDimensionPaths.push(dimensionPath);
|
|
759
|
-
}
|
|
760
|
-
return fieldMatchDimensionPaths;
|
|
761
|
-
}
|
|
762
|
-
getFieldMatchRowDimensionPaths(record) {
|
|
763
|
-
var _a, _b;
|
|
764
|
-
const fieldMatchDimensionPaths = [];
|
|
765
|
-
let lastIsMatch = !1;
|
|
766
|
-
for (let i = 0; null !== (_b = i < (null === (_a = this.customRowTreeDimensionPaths) || void 0 === _a ? void 0 : _a.length)) && void 0 !== _b && _b; i++) {
|
|
767
|
-
const dimensionPath = this.customRowTreeDimensionPaths[i];
|
|
768
|
-
let isMatch = !0;
|
|
769
|
-
for (let j = 0; j < dimensionPath.length; j++) {
|
|
770
|
-
const dimension = dimensionPath[j];
|
|
771
|
-
if (dimension.dimensionKey && record[dimension.dimensionKey] !== dimension.value || dimension.indicatorKey && void 0 === record[dimension.indicatorKey]) {
|
|
772
|
-
isMatch = !1;
|
|
773
|
-
break;
|
|
774
|
-
}
|
|
775
|
-
if (dimension.childKeys && j === dimensionPath.length - 1 && dimension.childKeys.length > 0 && dimension.childKeys.find((key => (0,
|
|
776
|
-
vutils_1.isValid)(record[key])))) {
|
|
777
|
-
isMatch = !1;
|
|
778
|
-
break;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
isMatch && (this.indicatorsAsCol || "tree" !== this.rowHierarchyType || dimensionPath.find((path => path.indicatorKey)) || (isMatch = !1)),
|
|
782
|
-
isMatch && fieldMatchDimensionPaths.push(dimensionPath), lastIsMatch = isMatch;
|
|
783
|
-
}
|
|
784
|
-
return fieldMatchDimensionPaths;
|
|
785
|
-
}
|
|
786
685
|
}
|
|
787
686
|
|
|
788
687
|
function arraySortByAnotherArray(array, sortArray) {
|
|
@@ -792,4 +691,5 @@ function arraySortByAnotherArray(array, sortArray) {
|
|
|
792
691
|
}));
|
|
793
692
|
}
|
|
794
693
|
|
|
694
|
+
//# sourceMappingURL=dataset.js.map
|
|
795
695
|
exports.Dataset = Dataset;
|