@visactor/vtable 1.26.7 → 1.26.8
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.d.ts +1 -1
- package/cjs/ListTable.js +21 -13
- package/cjs/ListTable.js.map +1 -1
- package/cjs/PivotChart.js +16 -16
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/PivotTable.d.ts +1 -1
- package/cjs/PivotTable.js +65 -63
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/body-helper/body-helper.js +2 -1
- package/cjs/components/index.js +1 -2
- package/cjs/core/BaseTable.js +2 -2
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/core/record-helper.d.ts +1 -1
- package/cjs/core/record-helper.js +60 -12
- package/cjs/core/record-helper.js.map +1 -1
- package/cjs/core/tableHelper.js +2 -1
- package/cjs/data/DataSource.d.ts +3 -1
- package/cjs/data/DataSource.js +71 -23
- package/cjs/data/DataSource.js.map +1 -1
- package/cjs/dataset/dataset.d.ts +9 -1
- package/cjs/dataset/dataset.js +344 -187
- package/cjs/dataset/dataset.js.map +1 -1
- package/cjs/event/event.d.ts +94 -8
- package/cjs/event/event.js +698 -191
- package/cjs/event/event.js.map +1 -1
- package/cjs/event/helper.js +1 -1
- package/cjs/event/media-click.js +4 -1
- package/cjs/event/media-click.js.map +1 -1
- package/cjs/event/scroll.js +1 -1
- package/cjs/event/sparkline-event.js +1 -2
- package/cjs/event/util.js +2 -2
- package/cjs/event/util.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/pivot-header-layout.js +33 -17
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/plugins/custom-cell-style.js +1 -1
- package/cjs/plugins/index.js +2 -1
- package/cjs/plugins/interface.js +1 -1
- package/cjs/plugins/invert-highlight.js +1 -1
- package/cjs/plugins/list-tree-stick-cell.js +1 -1
- package/cjs/plugins/plugin-manager.js +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js +27 -10
- package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/cjs/scenegraph/group-creater/cell-type/text-cell.d.ts +1 -1
- package/cjs/scenegraph/group-creater/cell-type/text-cell.js +14 -10
- package/cjs/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js +17 -4
- package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
- package/cjs/scenegraph/layout/compute-col-width.js +6 -1
- package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
- package/cjs/scenegraph/layout/compute-row-height.js +11 -3
- package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
- package/cjs/scenegraph/layout/update-height.d.ts +4 -3
- package/cjs/scenegraph/layout/update-height.js +43 -29
- package/cjs/scenegraph/layout/update-height.js.map +1 -1
- package/cjs/scenegraph/layout/update-width.d.ts +2 -1
- package/cjs/scenegraph/layout/update-width.js +49 -37
- package/cjs/scenegraph/layout/update-width.js.map +1 -1
- package/cjs/scenegraph/scenegraph.d.ts +2 -2
- package/cjs/scenegraph/scenegraph.js +6 -5
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/scenegraph/utils/corner-custom-merge.d.ts +10 -0
- package/cjs/scenegraph/utils/corner-custom-merge.js +68 -0
- package/cjs/scenegraph/utils/corner-custom-merge.js.map +1 -0
- package/cjs/state/resize/update-resize-column.js +25 -13
- package/cjs/state/resize/update-resize-column.js.map +1 -1
- package/cjs/state/resize/update-resize-row.js +24 -12
- package/cjs/state/resize/update-resize-row.js.map +1 -1
- package/cjs/themes.d.ts +4 -2
- package/cjs/themes.js +12 -4
- package/cjs/themes.js.map +1 -1
- package/cjs/tools/get-data-path/create-dataset.js +4 -4
- package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
- package/cjs/tools/get-data-path/index.js +4 -4
- package/cjs/tools/get-data-path/index.js.map +1 -1
- package/cjs/tools/style.d.ts +3 -1
- package/cjs/tools/style.js +2 -2
- package/cjs/tools/style.js.map +1 -1
- package/cjs/ts-types/common.d.ts +1 -0
- package/cjs/ts-types/common.js.map +1 -1
- package/cjs/ts-types/dataset/aggregation.d.ts +1 -0
- package/cjs/ts-types/dataset/aggregation.js +21 -3
- package/cjs/ts-types/dataset/aggregation.js.map +1 -1
- package/cjs/ts-types/new-data-set.d.ts +1 -0
- package/cjs/ts-types/new-data-set.js.map +1 -1
- package/cjs/ts-types/table-engine.d.ts +3 -2
- package/cjs/ts-types/table-engine.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +2224 -779
- package/dist/vtable.min.js +1 -1
- package/es/ListTable.d.ts +1 -1
- package/es/ListTable.js +21 -15
- package/es/ListTable.js.map +1 -1
- package/es/PivotChart.js +16 -16
- package/es/PivotChart.js.map +1 -1
- package/es/PivotTable.d.ts +1 -1
- package/es/PivotTable.js +65 -63
- package/es/PivotTable.js.map +1 -1
- package/es/body-helper/body-helper.js +2 -1
- package/es/components/index.js +1 -2
- package/es/core/BaseTable.js +2 -2
- package/es/core/BaseTable.js.map +1 -1
- package/es/core/record-helper.d.ts +1 -1
- package/es/core/record-helper.js +60 -12
- package/es/core/record-helper.js.map +1 -1
- package/es/core/tableHelper.js +2 -1
- package/es/data/DataSource.d.ts +3 -1
- package/es/data/DataSource.js +70 -23
- package/es/data/DataSource.js.map +1 -1
- package/es/dataset/dataset.d.ts +9 -1
- package/es/dataset/dataset.js +341 -187
- package/es/dataset/dataset.js.map +1 -1
- package/es/event/event.d.ts +94 -8
- package/es/event/event.js +696 -191
- package/es/event/event.js.map +1 -1
- package/es/event/helper.js +1 -1
- package/es/event/media-click.js +4 -1
- package/es/event/media-click.js.map +1 -1
- package/es/event/scroll.js +1 -1
- package/es/event/sparkline-event.js +1 -2
- package/es/event/util.js +2 -2
- package/es/event/util.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/pivot-header-layout.js +29 -17
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/plugins/custom-cell-style.js +1 -1
- package/es/plugins/index.js +2 -1
- package/es/plugins/interface.js +1 -1
- package/es/plugins/invert-highlight.js +1 -1
- package/es/plugins/list-tree-stick-cell.js +1 -1
- package/es/plugins/plugin-manager.js +1 -1
- package/es/scenegraph/group-creater/cell-helper.js +23 -9
- package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/es/scenegraph/group-creater/cell-type/text-cell.d.ts +1 -1
- package/es/scenegraph/group-creater/cell-type/text-cell.js +13 -8
- package/es/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
- package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js +17 -5
- package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
- package/es/scenegraph/layout/compute-col-width.js +6 -1
- package/es/scenegraph/layout/compute-col-width.js.map +1 -1
- package/es/scenegraph/layout/compute-row-height.js +11 -3
- package/es/scenegraph/layout/compute-row-height.js.map +1 -1
- package/es/scenegraph/layout/update-height.d.ts +4 -3
- package/es/scenegraph/layout/update-height.js +40 -26
- package/es/scenegraph/layout/update-height.js.map +1 -1
- package/es/scenegraph/layout/update-width.d.ts +2 -1
- package/es/scenegraph/layout/update-width.js +46 -34
- package/es/scenegraph/layout/update-width.js.map +1 -1
- package/es/scenegraph/scenegraph.d.ts +2 -2
- package/es/scenegraph/scenegraph.js +7 -5
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/scenegraph/utils/corner-custom-merge.d.ts +10 -0
- package/es/scenegraph/utils/corner-custom-merge.js +59 -0
- package/es/scenegraph/utils/corner-custom-merge.js.map +1 -0
- package/es/state/resize/update-resize-column.js +19 -10
- package/es/state/resize/update-resize-column.js.map +1 -1
- package/es/state/resize/update-resize-row.js +19 -9
- package/es/state/resize/update-resize-row.js.map +1 -1
- package/es/themes.d.ts +4 -2
- package/es/themes.js +11 -3
- package/es/themes.js.map +1 -1
- package/es/tools/get-data-path/create-dataset.js +4 -4
- package/es/tools/get-data-path/create-dataset.js.map +1 -1
- package/es/tools/get-data-path/index.js +4 -4
- package/es/tools/get-data-path/index.js.map +1 -1
- package/es/tools/style.d.ts +3 -1
- package/es/tools/style.js +2 -2
- package/es/tools/style.js.map +1 -1
- package/es/ts-types/common.d.ts +1 -0
- package/es/ts-types/common.js.map +1 -1
- package/es/ts-types/dataset/aggregation.d.ts +1 -0
- package/es/ts-types/dataset/aggregation.js +21 -3
- package/es/ts-types/dataset/aggregation.js.map +1 -1
- package/es/ts-types/new-data-set.d.ts +1 -0
- package/es/ts-types/new-data-set.js.map +1 -1
- package/es/ts-types/table-engine.d.ts +3 -2
- package/es/ts-types/table-engine.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +9 -9
package/cjs/dataset/dataset.js
CHANGED
|
@@ -12,9 +12,11 @@ class Dataset {
|
|
|
12
12
|
this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
|
|
13
13
|
this.colKeys = [], this.rowKeys = [], this.colKeys_normal = [], this.rowKeys_normal = [],
|
|
14
14
|
this.rowOrder = "key_a_to_z", this.colOrder = "key_a_to_z", this.sorted = !1, this.indicatorStatistics = [],
|
|
15
|
-
this.stringJoinChar = String.fromCharCode(0), this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
15
|
+
this.stringJoinChar = String.fromCharCode(0), this.groupedGrandTotalKey = String.fromCharCode(1) + "vtable_grouped_grand_total",
|
|
16
|
+
this.groupedGrandTotalSubtotalKey = String.fromCharCode(1) + "vtable_grouped_grand_total_subtotal",
|
|
17
|
+
this.rowsIsTotal = [], this.colsIsTotal = [], this.collectedValues = {}, this.cacheCollectedValues = {},
|
|
18
|
+
this.totalRecordsTree = {}, this.registerAggregators(), this.dataConfig = dataConfig,
|
|
19
|
+
this.filterRules = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules,
|
|
18
20
|
this.rowHierarchyType = null != rowHierarchyType ? rowHierarchyType : "grid", this.columnHierarchyType = null != columnHierarchyType ? columnHierarchyType : "grid",
|
|
19
21
|
this.sortRules = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.sortRules,
|
|
20
22
|
this.aggregationRules = null === (_c = this.dataConfig) || void 0 === _c ? void 0 : _c.aggregationRules,
|
|
@@ -51,7 +53,7 @@ class Dataset {
|
|
|
51
53
|
this.setRecords(records);
|
|
52
54
|
}
|
|
53
55
|
setRecords(records) {
|
|
54
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
56
|
+
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;
|
|
55
57
|
if (this.records = records, this.collectedValues = {}, this.cacheCollectedValues = {},
|
|
56
58
|
this.totalRecordsTree = {}, this.tree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
|
|
57
59
|
this.colKeys = [], this.rowKeys = [], this.rowsHasValue = [], this.columnsHasValue = [],
|
|
@@ -67,10 +69,10 @@ class Dataset {
|
|
|
67
69
|
"undefined" != typeof window && window.performance.now();
|
|
68
70
|
this.sortKeys();
|
|
69
71
|
"undefined" != typeof window && window.performance.now(), "undefined" != typeof window && window.performance.now();
|
|
70
|
-
this.customRowTree ? this.rowHeaderTree = this.customRowTree : "tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, null !== (_e = null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotalsOnTop) && void 0 !== _e && _e) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (
|
|
71
|
-
this.customColTree ? this.colHeaderTree = 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 === (
|
|
72
|
+
this.customRowTree ? this.rowHeaderTree = this.customRowTree : "tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, null !== (_e = null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotalsOnTop) && void 0 !== _e && _e, null === (_g = null === (_f = this.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.grandTotalDimensions, this.rowSubTotalLabel, null !== (_k = null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTop) && void 0 !== _k && _k, this.rows) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.row) || void 0 === _m ? void 0 : _m.showGrandTotals) || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotalsOnTop) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.row) || void 0 === _s ? void 0 : _s.showSubTotalsOnTop) && void 0 !== _t && _t, null === (_v = null === (_u = this.totals) || void 0 === _u ? void 0 : _u.row) || void 0 === _v ? void 0 : _v.grandTotalDimensions, !0, this.rows),
|
|
73
|
+
this.customColTree ? this.colHeaderTree = 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 === (_x = null === (_w = this.totals) || void 0 === _w ? void 0 : _w.column) || void 0 === _x ? void 0 : _x.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_0 = null === (_z = null === (_y = this.totals) || void 0 === _y ? void 0 : _y.column) || void 0 === _z ? void 0 : _z.showGrandTotalsOnLeft) && void 0 !== _0 && _0, null !== (_3 = null === (_2 = null === (_1 = this.totals) || void 0 === _1 ? void 0 : _1.column) || void 0 === _2 ? void 0 : _2.showSubTotalsOnLeft) && void 0 !== _3 && _3, null === (_5 = null === (_4 = this.totals) || void 0 === _4 ? void 0 : _4.column) || void 0 === _5 ? void 0 : _5.grandTotalDimensions, !1, this.columns);
|
|
72
74
|
"undefined" != typeof window && window.performance.now();
|
|
73
|
-
(null === (
|
|
75
|
+
(null === (_6 = this.dataConfig) || void 0 === _6 ? void 0 : _6.isPivotChart) && this.cacheDeminsionCollectedValues();
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
registerAggregator(type, aggregator) {
|
|
@@ -126,7 +128,10 @@ class Dataset {
|
|
|
126
128
|
processRecords() {
|
|
127
129
|
var _a, _b;
|
|
128
130
|
let isNeedFilter = !1;
|
|
129
|
-
|
|
131
|
+
(null !== (_b = null === (_a = this.filterRules) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0) >= 1 && (isNeedFilter = !0);
|
|
132
|
+
const records = (Array.isArray(this.records) ? this.records : Object.values(this.records).flat()).filter((record => !isNeedFilter || this.filterRecord(record)));
|
|
133
|
+
if (this.rowsHasValue = this.rows.map((row => records.some((record => record && row in record)))),
|
|
134
|
+
this.columnsHasValue = this.columns.map((column => records.some((record => record && column in record)))),
|
|
130
135
|
Array.isArray(this.records)) {
|
|
131
136
|
this.filteredRecords || (this.filteredRecords = []);
|
|
132
137
|
for (let i = 0, len = this.records.length; i < len; i++) {
|
|
@@ -162,53 +167,72 @@ class Dataset {
|
|
|
162
167
|
}
|
|
163
168
|
return isReserved;
|
|
164
169
|
}
|
|
170
|
+
collectValue(field, collectKeys, record) {
|
|
171
|
+
var _a;
|
|
172
|
+
if (this.collectedValues[field] || (this.collectedValues[field] = {}), this.collectedValues[field][collectKeys] || (this.collectValuesBy[field].sumBy ? this.collectedValues[field][collectKeys] = {} : this.collectValuesBy[field].range ? this.collectedValues[field][collectKeys] = {
|
|
173
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
174
|
+
max: Number.MIN_SAFE_INTEGER
|
|
175
|
+
} : this.collectedValues[field][collectKeys] = []), this.collectValuesBy[field].sumBy) {
|
|
176
|
+
const sumByKeys = null === (_a = this.collectValuesBy[field].sumBy) || void 0 === _a ? void 0 : _a.map((byField => record[byField])).join(this.stringJoinChar);
|
|
177
|
+
this.collectedValues[field][collectKeys][sumByKeys] || (this.collectedValues[field][collectKeys][sumByKeys] = new aggregation_1.registeredAggregators[ts_types_1.AggregationType.SUM]({
|
|
178
|
+
key: field,
|
|
179
|
+
field: field,
|
|
180
|
+
isRecord: void 0,
|
|
181
|
+
needSplitPositiveAndNegative: this.needSplitPositiveAndNegative
|
|
182
|
+
})), this.collectedValues[field][collectKeys][sumByKeys].push(record);
|
|
183
|
+
} else if (this.collectValuesBy[field].range) {
|
|
184
|
+
const fieldRange = this.collectedValues[field][collectKeys];
|
|
185
|
+
let max = Math.max(record[field], fieldRange.max), min = Math.min(record[field], fieldRange.min);
|
|
186
|
+
if (this.collectValuesBy[field].considerFields) for (const considerField of this.collectValuesBy[field].considerFields) record[considerField] && ("number" == typeof record[considerField] ? (max = Math.max(record[considerField], max),
|
|
187
|
+
min = Math.min(record[considerField], min)) : Array.isArray(record[considerField]) && (max = Math.max(...record[considerField], max),
|
|
188
|
+
min = Math.min(...record[considerField], min)));
|
|
189
|
+
isNaN(max) || (fieldRange.max = max, fieldRange.min = min);
|
|
190
|
+
} else {
|
|
191
|
+
const fieldValues = this.collectedValues[field][collectKeys];
|
|
192
|
+
-1 === fieldValues.indexOf(record[field]) && fieldValues.push(record[field]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
getGroupedCollectedValueKeys(by, record) {
|
|
196
|
+
var _a, _b, _c;
|
|
197
|
+
if (!(null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.isPivotChart)) return [];
|
|
198
|
+
const keys = new Set;
|
|
199
|
+
return [ {
|
|
200
|
+
dimensions: this.rows,
|
|
201
|
+
totals: null === (_b = this.totals) || void 0 === _b ? void 0 : _b.row
|
|
202
|
+
}, {
|
|
203
|
+
dimensions: this.columns,
|
|
204
|
+
totals: null === (_c = this.totals) || void 0 === _c ? void 0 : _c.column
|
|
205
|
+
} ].forEach((({dimensions: dimensions, totals: totals}) => {
|
|
206
|
+
if (!(null == totals ? void 0 : totals.showGrandTotals)) return;
|
|
207
|
+
const dimensionIndexes = this.getGrandTotalDimensionIndexes(dimensions, totals.grandTotalDimensions);
|
|
208
|
+
dimensionIndexes.length && dimensionIndexes.every((index => -1 !== by.indexOf(dimensions[index]))) && (keys.add((0,
|
|
209
|
+
join_1.join)([ this.groupedGrandTotalKey, ...dimensionIndexes.map((index => record[dimensions[index]])) ], this.stringJoinChar)),
|
|
210
|
+
keys.add((0, join_1.join)([ this.groupedGrandTotalKey, this.groupedGrandTotalSubtotalKey ], this.stringJoinChar)));
|
|
211
|
+
})), Array.from(keys);
|
|
212
|
+
}
|
|
165
213
|
processRecord(record, assignedIndicatorKey) {
|
|
166
|
-
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, _37, _38, _39, _40, _41;
|
|
214
|
+
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, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52;
|
|
167
215
|
null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
|
|
168
216
|
derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
|
|
169
217
|
}));
|
|
170
|
-
for (const field in this.collectValuesBy) if ((0, vutils_1.isValid)(record[field])) {
|
|
171
|
-
this.collectedValues[field] || (this.collectedValues[field] = {});
|
|
172
|
-
const collectKeys = this.collectValuesBy[field].by.map((byField => record[byField])).join(this.stringJoinChar);
|
|
173
|
-
if (this.collectedValues[field][collectKeys] || (this.collectValuesBy[field].sumBy ? this.collectedValues[field][collectKeys] = {} : this.collectValuesBy[field].range ? this.collectedValues[field][collectKeys] = {
|
|
174
|
-
min: Number.MAX_SAFE_INTEGER,
|
|
175
|
-
max: Number.MIN_SAFE_INTEGER
|
|
176
|
-
} : this.collectedValues[field][collectKeys] = []), this.collectValuesBy[field].sumBy) {
|
|
177
|
-
const sumByKeys = null === (_b = this.collectValuesBy[field].sumBy) || void 0 === _b ? void 0 : _b.map((byField => record[byField])).join(this.stringJoinChar);
|
|
178
|
-
this.collectedValues[field][collectKeys][sumByKeys] || (this.collectedValues[field][collectKeys][sumByKeys] = new aggregation_1.registeredAggregators[ts_types_1.AggregationType.SUM]({
|
|
179
|
-
key: field,
|
|
180
|
-
field: field,
|
|
181
|
-
isRecord: void 0,
|
|
182
|
-
needSplitPositiveAndNegative: this.needSplitPositiveAndNegative
|
|
183
|
-
})), this.collectedValues[field][collectKeys][sumByKeys].push(record);
|
|
184
|
-
} else if (this.collectValuesBy[field].range) {
|
|
185
|
-
const fieldRange = this.collectedValues[field][collectKeys];
|
|
186
|
-
let max = Math.max(record[field], fieldRange.max), min = Math.min(record[field], fieldRange.min);
|
|
187
|
-
if (this.collectValuesBy[field].considerFields) for (const considerField of this.collectValuesBy[field].considerFields) record[considerField] && ("number" == typeof record[considerField] ? (max = Math.max(record[considerField], max),
|
|
188
|
-
min = Math.min(record[considerField], min)) : Array.isArray(record[considerField]) && (max = Math.max(...record[considerField], max),
|
|
189
|
-
min = Math.min(...record[considerField], min)));
|
|
190
|
-
isNaN(max) || (fieldRange.max = max, fieldRange.min = min);
|
|
191
|
-
} else {
|
|
192
|
-
const fieldRange = this.collectedValues[field][collectKeys];
|
|
193
|
-
-1 === fieldRange.indexOf(record[field]) && fieldRange.push(record[field]);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
218
|
let isToTalRecord = !1;
|
|
197
219
|
const colKeys = [], rowKeys = [];
|
|
198
|
-
if (!this.parseCustomTreeToMatchRecords || (null === (
|
|
220
|
+
if (!this.parseCustomTreeToMatchRecords || (null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.isPivotChart) || !(null === (_c = this.customRowTree) || void 0 === _c ? void 0 : _c.length) || assignedIndicatorKey || this.hasExtensionRowTree) {
|
|
199
221
|
const rowKey = [];
|
|
200
222
|
rowKeys.push({
|
|
201
223
|
rowKey: rowKey,
|
|
202
224
|
indicatorKey: assignedIndicatorKey
|
|
203
225
|
});
|
|
204
|
-
|
|
226
|
+
const customGroupedGrandTotalKey = (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) && this.rowsHasValue[0] ? this.getCustomGroupedGrandTotalKey(record, this.rows, 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.grandTotalDimensions) : void 0;
|
|
227
|
+
if (customGroupedGrandTotalKey) rowKey.push(...customGroupedGrandTotalKey), isToTalRecord = !0; else for (let l = 0, len1 = this.rows.length; l < len1; l++) {
|
|
205
228
|
const rowAttr = this.rows[l];
|
|
206
229
|
if (rowAttr in record) this.rowsHasValue[l] = !0, rowKey.push(record[rowAttr]); else if (rowAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
|
|
207
|
-
if ((null === (
|
|
208
|
-
rowKey.push(this.rowGrandTotalLabel),
|
|
230
|
+
if ((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.showGrandTotals) && 0 === l && !this.rows.find((rk => rk in record))) {
|
|
231
|
+
this.getGrandTotalDimensionIndexes(this.rows, this.dataConfig.totals.row.grandTotalDimensions).length ? rowKey.push(this.groupedGrandTotalKey, this.groupedGrandTotalSubtotalKey) : rowKey.push(this.rowGrandTotalLabel),
|
|
232
|
+
isToTalRecord = !0;
|
|
209
233
|
break;
|
|
210
234
|
}
|
|
211
|
-
if ((null === (
|
|
235
|
+
if ((null === (_q = null === (_p = null === (_o = this.dataConfig) || void 0 === _o ? void 0 : _o.totals) || void 0 === _p ? void 0 : _p.row) || void 0 === _q ? void 0 : _q.subTotalsDimensions) && (null === (_t = null === (_s = null === (_r = this.dataConfig) || void 0 === _r ? void 0 : _r.totals) || void 0 === _s ? void 0 : _s.row) || void 0 === _t ? void 0 : _t.subTotalsDimensions.indexOf(this.rows[l - 1])) >= 0) {
|
|
212
236
|
"tree" !== this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
|
|
213
237
|
break;
|
|
214
238
|
}
|
|
@@ -226,20 +250,22 @@ class Dataset {
|
|
|
226
250
|
});
|
|
227
251
|
}
|
|
228
252
|
}
|
|
229
|
-
if (!this.parseCustomTreeToMatchRecords || (null === (
|
|
253
|
+
if (!this.parseCustomTreeToMatchRecords || (null === (_u = this.dataConfig) || void 0 === _u ? void 0 : _u.isPivotChart) || !(null === (_v = this.customColTree) || void 0 === _v ? void 0 : _v.length) || assignedIndicatorKey || this.hasExtensionRowTree) {
|
|
230
254
|
const colKey = [];
|
|
231
255
|
colKeys.push({
|
|
232
256
|
colKey: colKey,
|
|
233
257
|
indicatorKey: assignedIndicatorKey
|
|
234
258
|
});
|
|
235
|
-
|
|
259
|
+
const customGroupedGrandTotalKey = (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.showGrandTotals) && this.columnsHasValue[0] ? this.getCustomGroupedGrandTotalKey(record, this.columns, null === (_1 = null === (_0 = null === (_z = this.dataConfig) || void 0 === _z ? void 0 : _z.totals) || void 0 === _0 ? void 0 : _0.column) || void 0 === _1 ? void 0 : _1.grandTotalDimensions) : void 0;
|
|
260
|
+
if (customGroupedGrandTotalKey) colKey.push(...customGroupedGrandTotalKey), isToTalRecord = !0; else for (let n = 0, len2 = this.columns.length; n < len2; n++) {
|
|
236
261
|
const colAttr = this.columns[n];
|
|
237
262
|
if (colAttr in record) this.columnsHasValue[n] = !0, colKey.push(record[colAttr]); else if (colAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
|
|
238
|
-
if ((null === (
|
|
239
|
-
colKey.push(this.colGrandTotalLabel),
|
|
263
|
+
if ((null === (_4 = null === (_3 = null === (_2 = this.dataConfig) || void 0 === _2 ? void 0 : _2.totals) || void 0 === _3 ? void 0 : _3.column) || void 0 === _4 ? void 0 : _4.showGrandTotals) && 0 === n && !this.columns.find((ck => ck in record))) {
|
|
264
|
+
this.getGrandTotalDimensionIndexes(this.columns, this.dataConfig.totals.column.grandTotalDimensions).length ? colKey.push(this.groupedGrandTotalKey, this.groupedGrandTotalSubtotalKey) : colKey.push(this.colGrandTotalLabel),
|
|
265
|
+
isToTalRecord = !0;
|
|
240
266
|
break;
|
|
241
267
|
}
|
|
242
|
-
if ((null === (
|
|
268
|
+
if ((null === (_7 = null === (_6 = null === (_5 = this.dataConfig) || void 0 === _5 ? void 0 : _5.totals) || void 0 === _6 ? void 0 : _6.column) || void 0 === _7 ? void 0 : _7.subTotalsDimensions) && (null === (_10 = null === (_9 = null === (_8 = this.dataConfig) || void 0 === _8 ? void 0 : _8.totals) || void 0 === _9 ? void 0 : _9.column) || void 0 === _10 ? void 0 : _10.subTotalsDimensions.indexOf(this.columns[n - 1])) >= 0) {
|
|
243
269
|
colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
|
|
244
270
|
break;
|
|
245
271
|
}
|
|
@@ -257,6 +283,12 @@ class Dataset {
|
|
|
257
283
|
});
|
|
258
284
|
}
|
|
259
285
|
}
|
|
286
|
+
if (!isToTalRecord) for (const field in this.collectValuesBy) if ((0, vutils_1.isValid)(record[field])) {
|
|
287
|
+
const collectKeys = this.collectValuesBy[field].by.map((byField => record[byField])).join(this.stringJoinChar);
|
|
288
|
+
this.collectValue(field, collectKeys, record), this.getGroupedCollectedValueKeys(this.collectValuesBy[field].by, record).forEach((groupedCollectKeys => {
|
|
289
|
+
this.collectValue(field, groupedCollectKeys, record);
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
260
292
|
for (let row_i = 0; row_i < rowKeys.length; row_i++) {
|
|
261
293
|
const rowKey = rowKeys[row_i].rowKey;
|
|
262
294
|
let assignedIndicatorKey_value;
|
|
@@ -270,55 +302,55 @@ class Dataset {
|
|
|
270
302
|
this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
|
|
271
303
|
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
272
304
|
for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
273
|
-
const calculatedFieldRule = null === (
|
|
274
|
-
(null === (
|
|
305
|
+
const calculatedFieldRule = null === (_11 = this.calculatedFieldRules) || void 0 === _11 ? void 0 : _11.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
306
|
+
(null === (_13 = null === (_12 = this.totalRecordsTree[flatRowKey]) || void 0 === _12 ? void 0 : _12[flatColKey]) || void 0 === _13 ? void 0 : _13[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new aggregation_1.registeredAggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
275
307
|
key: toComputeIndicatorKeys[i],
|
|
276
308
|
field: toComputeIndicatorKeys[i],
|
|
277
309
|
isRecord: !0,
|
|
278
|
-
formatFun: null === (
|
|
310
|
+
formatFun: null === (_15 = null === (_14 = this.indicators) || void 0 === _14 ? void 0 : _14.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _15 ? void 0 : _15.format,
|
|
279
311
|
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
280
312
|
dependAggregators: this.totalRecordsTree[flatRowKey][flatColKey],
|
|
281
313
|
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
282
|
-
})), toComputeIndicatorKeys[i] in record && (null === (
|
|
314
|
+
})), toComputeIndicatorKeys[i] in record && (null === (_17 = null === (_16 = this.totalRecordsTree[flatRowKey]) || void 0 === _16 ? void 0 : _16[flatColKey]) || void 0 === _17 || _17[i].push(record));
|
|
283
315
|
} else {
|
|
284
316
|
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
285
|
-
(null === (
|
|
317
|
+
(null === (_19 = null === (_18 = this.totalRecordsTree[flatRowKey]) || void 0 === _18 ? void 0 : _18[flatColKey]) || void 0 === _19 ? void 0 : _19[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new aggregation_1.registeredAggregators[null !== (_20 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _20 ? _20 : ts_types_1.AggregationType.SUM]({
|
|
286
318
|
key: toComputeIndicatorKeys[i],
|
|
287
|
-
field: null !== (
|
|
319
|
+
field: null !== (_21 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _21 ? _21 : toComputeIndicatorKeys[i],
|
|
288
320
|
aggregationFun: null == aggRule ? void 0 : aggRule.aggregationFun,
|
|
289
|
-
formatFun: null !== (
|
|
290
|
-
})), toComputeIndicatorKeys[i] in record && (null === (
|
|
321
|
+
formatFun: 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 === toComputeIndicatorKeys[i]))) || void 0 === _24 ? void 0 : _24.format
|
|
322
|
+
})), toComputeIndicatorKeys[i] in record && (null === (_26 = null === (_25 = this.totalRecordsTree[flatRowKey]) || void 0 === _25 ? void 0 : _25[flatColKey]) || void 0 === _26 || _26[i].push(record));
|
|
291
323
|
}
|
|
292
324
|
return;
|
|
293
325
|
}
|
|
294
326
|
0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
|
|
295
327
|
this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
|
|
296
328
|
this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
|
|
297
|
-
(null === (
|
|
329
|
+
(null === (_27 = this.tree[flatRowKey]) || void 0 === _27 ? void 0 : _27[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
|
|
298
330
|
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
299
331
|
for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
300
|
-
const calculatedFieldRule = null === (
|
|
301
|
-
(null === (
|
|
332
|
+
const calculatedFieldRule = null === (_28 = this.calculatedFieldRules) || void 0 === _28 ? void 0 : _28.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
333
|
+
(null === (_30 = null === (_29 = this.tree[flatRowKey]) || void 0 === _29 ? void 0 : _29[flatColKey]) || void 0 === _30 ? void 0 : _30[i]) || (this.tree[flatRowKey][flatColKey][i] = new aggregation_1.registeredAggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
302
334
|
key: toComputeIndicatorKeys[i],
|
|
303
335
|
field: toComputeIndicatorKeys[i],
|
|
304
336
|
isRecord: !0,
|
|
305
|
-
formatFun: null === (
|
|
337
|
+
formatFun: null === (_32 = null === (_31 = this.indicators) || void 0 === _31 ? void 0 : _31.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _32 ? void 0 : _32.format,
|
|
306
338
|
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
307
339
|
dependAggregators: this.tree[flatRowKey][flatColKey],
|
|
308
340
|
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
309
|
-
})), null === (
|
|
341
|
+
})), null === (_34 = null === (_33 = this.tree[flatRowKey]) || void 0 === _33 ? void 0 : _33[flatColKey]) || void 0 === _34 || _34[i].push(record);
|
|
310
342
|
} else {
|
|
311
343
|
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
312
344
|
let needAddToAggregator = !1;
|
|
313
345
|
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 {
|
|
314
346
|
(null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
|
|
315
347
|
} else toComputeIndicatorKeys[i] in record && (needAddToAggregator = !0);
|
|
316
|
-
!(null === (
|
|
348
|
+
!(null === (_36 = null === (_35 = this.tree[flatRowKey]) || void 0 === _35 ? void 0 : _35[flatColKey]) || void 0 === _36 ? void 0 : _36[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new aggregation_1.registeredAggregators[null !== (_37 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _37 ? _37 : ts_types_1.AggregationType.SUM]({
|
|
317
349
|
key: toComputeIndicatorKeys[i],
|
|
318
|
-
field: null !== (
|
|
350
|
+
field: null !== (_38 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _38 ? _38 : toComputeIndicatorKeys[i],
|
|
319
351
|
aggregationFun: null == aggRule ? void 0 : aggRule.aggregationFun,
|
|
320
|
-
formatFun: null !== (
|
|
321
|
-
})), needAddToAggregator && (null === (
|
|
352
|
+
formatFun: null !== (_39 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _39 ? _39 : null === (_41 = null === (_40 = this.indicators) || void 0 === _40 ? void 0 : _40.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _41 ? void 0 : _41.format
|
|
353
|
+
})), needAddToAggregator && (null === (_43 = null === (_42 = this.tree[flatRowKey]) || void 0 === _42 ? void 0 : _42[flatColKey]) || void 0 === _43 || _43[i].push(record));
|
|
322
354
|
}
|
|
323
355
|
if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
324
356
|
if (!this.indicatorStatistics[i]) {
|
|
@@ -332,25 +364,25 @@ class Dataset {
|
|
|
332
364
|
key: this.indicatorKeys[i],
|
|
333
365
|
field: this.indicatorKeys[i]
|
|
334
366
|
}),
|
|
335
|
-
total: new aggregation_1.registeredAggregators[null !== (
|
|
367
|
+
total: new aggregation_1.registeredAggregators[null !== (_44 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _44 ? _44 : ts_types_1.AggregationType.SUM]({
|
|
336
368
|
key: this.indicatorKeys[i],
|
|
337
|
-
field: null !== (
|
|
369
|
+
field: null !== (_45 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _45 ? _45 : this.indicatorKeys[i],
|
|
338
370
|
aggregationFun: null == aggRule ? void 0 : aggRule.aggregationFun,
|
|
339
|
-
formatFun: null !== (
|
|
371
|
+
formatFun: null !== (_46 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _46 ? _46 : null === (_48 = null === (_47 = this.indicators) || void 0 === _47 ? void 0 : _47.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _48 ? void 0 : _48.format
|
|
340
372
|
})
|
|
341
373
|
};
|
|
342
374
|
}
|
|
343
|
-
this.indicatorStatistics[i].max.push(null === (
|
|
344
|
-
this.indicatorStatistics[i].min.push(null === (
|
|
375
|
+
this.indicatorStatistics[i].max.push(null === (_50 = null === (_49 = this.tree[flatRowKey]) || void 0 === _49 ? void 0 : _49[flatColKey]) || void 0 === _50 ? void 0 : _50[i].value()),
|
|
376
|
+
this.indicatorStatistics[i].min.push(null === (_52 = null === (_51 = this.tree[flatRowKey]) || void 0 === _51 ? void 0 : _51[flatColKey]) || void 0 === _52 ? void 0 : _52[i].value()),
|
|
345
377
|
this.indicatorStatistics[i].total.push(record);
|
|
346
378
|
}
|
|
347
379
|
}
|
|
348
380
|
}
|
|
349
381
|
}
|
|
350
382
|
updateSortRules(sortRules) {
|
|
351
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
352
|
-
this.sorted = !1, this.sortRules = sortRules, this.sortKeys(), this.customRowTree || ("tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, null !== (_e = null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotalsOnTop) && void 0 !== _e && _e) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (
|
|
353
|
-
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 === (
|
|
383
|
+
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;
|
|
384
|
+
this.sorted = !1, this.sortRules = sortRules, this.sortKeys(), this.customRowTree || ("tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, null !== (_e = null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotalsOnTop) && void 0 !== _e && _e, null === (_g = null === (_f = this.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.grandTotalDimensions, this.rowSubTotalLabel, null !== (_k = null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTop) && void 0 !== _k && _k, this.rows) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows.filter(((key, index) => this.rowsHasValue[index])), this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.row) || void 0 === _m ? void 0 : _m.showGrandTotals) || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotalsOnTop) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.row) || void 0 === _s ? void 0 : _s.showSubTotalsOnTop) && void 0 !== _t && _t, null === (_v = null === (_u = this.totals) || void 0 === _u ? void 0 : _u.row) || void 0 === _v ? void 0 : _v.grandTotalDimensions, !0, this.rows)),
|
|
385
|
+
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 === (_x = null === (_w = this.totals) || void 0 === _w ? void 0 : _w.column) || void 0 === _x ? void 0 : _x.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_0 = null === (_z = null === (_y = this.totals) || void 0 === _y ? void 0 : _y.column) || void 0 === _z ? void 0 : _z.showGrandTotalsOnLeft) && void 0 !== _0 && _0, null !== (_3 = null === (_2 = null === (_1 = this.totals) || void 0 === _1 ? void 0 : _1.column) || void 0 === _2 ? void 0 : _2.showSubTotalsOnLeft) && void 0 !== _3 && _3, null === (_5 = null === (_4 = this.totals) || void 0 === _4 ? void 0 : _4.column) || void 0 === _5 ? void 0 : _5.grandTotalDimensions, !1, this.columns));
|
|
354
386
|
}
|
|
355
387
|
updateFilterRules(filterRules, isResetTree = !1) {
|
|
356
388
|
var _a, _b;
|
|
@@ -364,7 +396,7 @@ class Dataset {
|
|
|
364
396
|
return null === (_a = this.aggregationRules) || void 0 === _a ? void 0 : _a.find(((value, index) => indicatorKey === value.indicatorKey));
|
|
365
397
|
}
|
|
366
398
|
getAggregator(rowKey = [], colKey = [], indicator, considerChangedValue = !0, indicatorPosition) {
|
|
367
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
399
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
368
400
|
const indicatorIndex = this.indicatorKeys.indexOf(indicator);
|
|
369
401
|
let rowDimensionKey, colDimensionKey, flatRowKey, flatColKey;
|
|
370
402
|
if ("row" === (null == indicatorPosition ? void 0 : indicatorPosition.position)) rowDimensionKey = rowKey.length >= 2 ? this.rows[rowKey.length - 2] : void 0; else {
|
|
@@ -375,15 +407,24 @@ class Dataset {
|
|
|
375
407
|
const colIndex = colKey.length - 1;
|
|
376
408
|
colDimensionKey = colIndex >= 0 && colIndex < this.columns.length ? this.columns[colIndex] : void 0;
|
|
377
409
|
}
|
|
378
|
-
"string" == typeof rowKey ? flatRowKey = rowKey : (indicatorPosition && "row" !== indicatorPosition.position || rowKey.map(((key, i) => {
|
|
410
|
+
if ("string" == typeof rowKey ? flatRowKey = rowKey : (indicatorPosition && "row" !== indicatorPosition.position || rowKey.map(((key, i) => {
|
|
379
411
|
key !== indicator || (0, vutils_1.isValid)(null == indicatorPosition ? void 0 : indicatorPosition.index) && i !== indicatorPosition.index || rowKey.splice(i, 1);
|
|
380
|
-
})), rowKey.length < this.rows.length && "grid-tree" === this.rowHierarchyType && (rowKey[0] === this.rowGrandTotalLabel || ((null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 && this.totals.row.subTotalsDimensions.find((dimension => dimension === rowDimensionKey)) || (null === (_g = null === (_f = this.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.showSubTotalsOnTreeNode)) && rowKey[rowKey.length - 1] !== this.rowSubTotalLabel && rowKey.push(this.rowSubTotalLabel)),
|
|
412
|
+
})), rowKey.length < this.rows.length && "grid-tree" === this.rowHierarchyType && (rowKey[0] === this.rowGrandTotalLabel || rowKey[0] === this.groupedGrandTotalKey || ((null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 && this.totals.row.subTotalsDimensions.find((dimension => dimension === rowDimensionKey)) || (null === (_g = null === (_f = this.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.showSubTotalsOnTreeNode)) && rowKey[rowKey.length - 1] !== this.rowSubTotalLabel && rowKey.push(this.rowSubTotalLabel)),
|
|
381
413
|
flatRowKey = (0, join_1.join)(rowKey, this.stringJoinChar)), "string" == typeof colKey ? flatColKey = colKey : (indicatorPosition && "col" !== indicatorPosition.position || colKey.map(((key, i) => {
|
|
382
414
|
key !== indicator || (0, vutils_1.isValid)(null == indicatorPosition ? void 0 : indicatorPosition.index) && i !== indicatorPosition.index || colKey.splice(i, 1);
|
|
383
|
-
})), colKey.length < this.columns.length && "grid-tree" === this.columnHierarchyType && (colKey[0] === this.colGrandTotalLabel || ((null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.column) || void 0 === _j ? void 0 : _j.subTotalsDimensions) && (null === (_m = null === (_l = null === (_k = this.totals) || void 0 === _k ? void 0 : _k.column) || void 0 === _l ? void 0 : _l.subTotalsDimensions) || void 0 === _m ? void 0 : _m.length) >= 1 && this.totals.column.subTotalsDimensions.find((dimension => dimension === colDimensionKey)) || (null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showSubTotalsOnTreeNode)) && colKey[colKey.length - 1] !== this.colSubTotalLabel && colKey.push(this.colSubTotalLabel)),
|
|
384
|
-
flatColKey = (0, join_1.join)(colKey, this.stringJoinChar))
|
|
385
|
-
|
|
386
|
-
|
|
415
|
+
})), colKey.length < this.columns.length && "grid-tree" === this.columnHierarchyType && (colKey[0] === this.colGrandTotalLabel || colKey[0] === this.groupedGrandTotalKey || ((null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.column) || void 0 === _j ? void 0 : _j.subTotalsDimensions) && (null === (_m = null === (_l = null === (_k = this.totals) || void 0 === _k ? void 0 : _k.column) || void 0 === _l ? void 0 : _l.subTotalsDimensions) || void 0 === _m ? void 0 : _m.length) >= 1 && this.totals.column.subTotalsDimensions.find((dimension => dimension === colDimensionKey)) || (null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showSubTotalsOnTreeNode)) && colKey[colKey.length - 1] !== this.colSubTotalLabel && colKey.push(this.colSubTotalLabel)),
|
|
416
|
+
flatColKey = (0, join_1.join)(colKey, this.stringJoinChar)), Array.isArray(rowKey) && rowKey[0] === this.rowGrandTotalLabel && !this.tree[flatRowKey] && this.getGrandTotalDimensionIndexes(this.rows.filter(((_, index) => this.rowsHasValue[index])), null === (_r = null === (_q = this.totals) || void 0 === _q ? void 0 : _q.row) || void 0 === _r ? void 0 : _r.grandTotalDimensions, this.rows).length) {
|
|
417
|
+
const internalRowKey = rowKey.slice();
|
|
418
|
+
internalRowKey[0] = this.groupedGrandTotalKey, 2 === internalRowKey.length && internalRowKey[1] === this.rowSubTotalLabel && (internalRowKey[1] = this.groupedGrandTotalSubtotalKey),
|
|
419
|
+
flatRowKey = (0, join_1.join)(internalRowKey, this.stringJoinChar);
|
|
420
|
+
}
|
|
421
|
+
if (Array.isArray(colKey) && colKey[0] === this.colGrandTotalLabel && !(null === (_s = this.tree[flatRowKey]) || void 0 === _s ? void 0 : _s[flatColKey]) && this.getGrandTotalDimensionIndexes(this.columns.filter(((_, index) => this.columnsHasValue[index])), null === (_u = null === (_t = this.totals) || void 0 === _t ? void 0 : _t.column) || void 0 === _u ? void 0 : _u.grandTotalDimensions, this.columns).length) {
|
|
422
|
+
const internalColKey = colKey.slice();
|
|
423
|
+
internalColKey[0] = this.groupedGrandTotalKey, 2 === internalColKey.length && internalColKey[1] === this.colSubTotalLabel && (internalColKey[1] = this.groupedGrandTotalSubtotalKey),
|
|
424
|
+
flatColKey = (0, join_1.join)(internalColKey, this.stringJoinChar);
|
|
425
|
+
}
|
|
426
|
+
const agg = null === (_w = null === (_v = this.tree[flatRowKey]) || void 0 === _v ? void 0 : _v[flatColKey]) || void 0 === _w ? void 0 : _w[indicatorIndex];
|
|
427
|
+
if (considerChangedValue && (0, vutils_1.isValid)(null === (_y = null === (_x = this.changedTree[flatRowKey]) || void 0 === _x ? void 0 : _x[flatColKey]) || void 0 === _y ? void 0 : _y[indicatorIndex])) {
|
|
387
428
|
const changeValue = this.changedTree[flatRowKey][flatColKey][indicatorIndex];
|
|
388
429
|
return agg ? {
|
|
389
430
|
value: () => changeValue,
|
|
@@ -427,7 +468,7 @@ class Dataset {
|
|
|
427
468
|
this.colKeys.sort(sortfun);
|
|
428
469
|
}
|
|
429
470
|
}
|
|
430
|
-
arrSort(fieldArr, isRow) {
|
|
471
|
+
arrSort(fieldArr, isRow, pathPrefix) {
|
|
431
472
|
let field;
|
|
432
473
|
const that = this, sortersArr = function(_this) {
|
|
433
474
|
const results = [];
|
|
@@ -451,9 +492,10 @@ class Dataset {
|
|
|
451
492
|
if (sorter = sortersArr[i], null === (_a = sorter.sortRule) || void 0 === _a ? void 0 : _a.sortByIndicator) {
|
|
452
493
|
let aChanged = a, bChanged = b;
|
|
453
494
|
sorter.fieldIndex < fieldArr.length - 1 && (aChanged = a.slice(0, sorter.fieldIndex + 1),
|
|
454
|
-
"grid" === that.rowHierarchyType && isRow ? aChanged.push(that.rowSubTotalLabel) : isRow || aChanged.push(that.colSubTotalLabel),
|
|
455
|
-
bChanged = b.slice(0, sorter.fieldIndex + 1), "grid" === that.rowHierarchyType && isRow ? bChanged.push(that.rowSubTotalLabel) : isRow || bChanged.push(that.colSubTotalLabel)),
|
|
456
|
-
|
|
495
|
+
!(null == pathPrefix ? void 0 : pathPrefix.length) && "grid" === that.rowHierarchyType && isRow ? aChanged.push(that.rowSubTotalLabel) : (null == pathPrefix ? void 0 : pathPrefix.length) || isRow || aChanged.push(that.colSubTotalLabel),
|
|
496
|
+
bChanged = b.slice(0, sorter.fieldIndex + 1), !(null == pathPrefix ? void 0 : pathPrefix.length) && "grid" === that.rowHierarchyType && isRow ? bChanged.push(that.rowSubTotalLabel) : (null == pathPrefix ? void 0 : pathPrefix.length) || isRow || bChanged.push(that.colSubTotalLabel)),
|
|
497
|
+
(null == pathPrefix ? void 0 : pathPrefix.length) && (aChanged = [ ...pathPrefix, ...aChanged ],
|
|
498
|
+
bChanged = [ ...pathPrefix, ...bChanged ]), comparison = sorter.func(aChanged, bChanged, null === (_b = sorter.sortRule) || void 0 === _b ? void 0 : _b.sortType);
|
|
457
499
|
} else comparison = null === (_c = sorter.func) || void 0 === _c ? void 0 : _c.call(sorter, a[sorter.fieldIndex], b[sorter.fieldIndex], null === (_d = sorter.sortRule) || void 0 === _d ? void 0 : _d.sortType);
|
|
458
500
|
if (0 !== comparison) return comparison;
|
|
459
501
|
}
|
|
@@ -464,8 +506,8 @@ class Dataset {
|
|
|
464
506
|
const that = this;
|
|
465
507
|
return sortRule.sortByIndicator ? (a, b, sortType) => {
|
|
466
508
|
const getValue = function(rowKey, colKey) {
|
|
467
|
-
return "grid" === that.rowHierarchyType && rowKey.length < that.rows.length && rowKey[rowKey.length - 1] !== that.rowSubTotalLabel && rowKey[rowKey.length - 1] !== that.rowGrandTotalLabel && rowKey.push(that.rowSubTotalLabel),
|
|
468
|
-
colKey.length < that.columns.length && colKey[colKey.length - 1] !== that.colSubTotalLabel && colKey[colKey.length - 1] !== that.colGrandTotalLabel && colKey.push(that.colSubTotalLabel),
|
|
509
|
+
return "grid" === that.rowHierarchyType && rowKey.length < that.rows.length && rowKey[rowKey.length - 1] !== that.rowSubTotalLabel && rowKey[rowKey.length - 1] !== that.rowGrandTotalLabel && rowKey[0] !== that.groupedGrandTotalKey && rowKey.push(that.rowSubTotalLabel),
|
|
510
|
+
colKey.length < that.columns.length && colKey[colKey.length - 1] !== that.colSubTotalLabel && colKey[colKey.length - 1] !== that.colGrandTotalLabel && colKey[0] !== that.groupedGrandTotalKey && colKey.push(that.colSubTotalLabel),
|
|
469
511
|
that.getAggregator(rowKey, colKey, sortRule.sortByIndicator).value();
|
|
470
512
|
};
|
|
471
513
|
return isSortRow ? sortRule.sortFunc ? sortRule.sortFunc(getValue(a, sortRule.query), getValue(b, sortRule.query), a, b, sortType) : (0,
|
|
@@ -476,7 +518,7 @@ class Dataset {
|
|
|
476
518
|
totalStatistics() {
|
|
477
519
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
478
520
|
const that = this, colCompute = (flatRowKey, flatColKey) => {
|
|
479
|
-
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;
|
|
521
|
+
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;
|
|
480
522
|
if (null === (_b = null === (_a = this.totalRecordsTree) || void 0 === _a ? void 0 : _a[flatRowKey]) || void 0 === _b ? void 0 : _b[flatColKey]) return this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
|
|
481
523
|
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]);
|
|
482
524
|
const colKey = flatColKey.split(this.stringJoinChar);
|
|
@@ -518,32 +560,38 @@ class Dataset {
|
|
|
518
560
|
}
|
|
519
561
|
}
|
|
520
562
|
}
|
|
521
|
-
if ((null === (_14 = null === (_13 = that.totals) || void 0 === _13 ? void 0 : _13.column) || void 0 === _14 ? void 0 : _14.showGrandTotals) || 0 === this.rows.length) {
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
534
|
-
dependAggregators: this.tree[flatRowKey][flatColTotalKey],
|
|
535
|
-
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
536
|
-
})), 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]);
|
|
537
|
-
} else {
|
|
538
|
-
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
539
|
-
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
540
|
-
this.tree[flatRowKey][flatColTotalKey][i] = new aggregation_1.registeredAggregators[null !== (_26 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _26 ? _26 : ts_types_1.AggregationType.SUM]({
|
|
563
|
+
if (((null === (_14 = null === (_13 = that.totals) || void 0 === _13 ? void 0 : _13.column) || void 0 === _14 ? void 0 : _14.showGrandTotals) || 0 === this.rows.length) && colKey[0] !== this.groupedGrandTotalKey) {
|
|
564
|
+
const flatColTotalKeys = this.getGrandTotalKeys(colKey, that.columns.filter(((_, index) => that.columnsHasValue[index])), null === (_16 = null === (_15 = that.totals) || void 0 === _15 ? void 0 : _15.column) || void 0 === _16 ? void 0 : _16.grandTotalDimensions, that.colGrandTotalLabel, that.columns);
|
|
565
|
+
for (const flatColTotalKey of flatColTotalKeys) {
|
|
566
|
+
if (null === (_18 = null === (_17 = this.totalRecordsTree) || void 0 === _17 ? void 0 : _17[flatRowKey]) || void 0 === _18 ? void 0 : _18[flatColTotalKey]) {
|
|
567
|
+
this.tree[flatRowKey][flatColTotalKey] = null === (_20 = null === (_19 = this.totalRecordsTree) || void 0 === _19 ? void 0 : _19[flatRowKey]) || void 0 === _20 ? void 0 : _20[flatColTotalKey];
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
|
|
571
|
+
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
572
|
+
for (let i = 0; i < toComputeIndicatorKeys.length; i++) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
573
|
+
const calculatedFieldRule = null === (_21 = this.calculatedFieldRules) || void 0 === _21 ? void 0 : _21.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
574
|
+
(null === (_23 = null === (_22 = this.tree[flatRowKey]) || void 0 === _22 ? void 0 : _22[flatColTotalKey]) || void 0 === _23 ? void 0 : _23[i]) || (this.tree[flatRowKey][flatColTotalKey][i] = new aggregation_1.registeredAggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
541
575
|
key: toComputeIndicatorKeys[i],
|
|
542
|
-
field:
|
|
543
|
-
|
|
544
|
-
|
|
576
|
+
field: toComputeIndicatorKeys[i],
|
|
577
|
+
isRecord: !0,
|
|
578
|
+
formatFun: 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,
|
|
579
|
+
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
580
|
+
dependAggregators: this.tree[flatRowKey][flatColTotalKey],
|
|
581
|
+
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
582
|
+
})), flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_27 = null === (_26 = that.tree[flatRowKey]) || void 0 === _26 ? void 0 : _26[flatColKey]) || void 0 === _27 ? void 0 : _27[i]);
|
|
583
|
+
} else {
|
|
584
|
+
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
585
|
+
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
586
|
+
this.tree[flatRowKey][flatColTotalKey][i] = new aggregation_1.registeredAggregators[null !== (_28 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _28 ? _28 : ts_types_1.AggregationType.SUM]({
|
|
587
|
+
key: toComputeIndicatorKeys[i],
|
|
588
|
+
field: null !== (_29 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _29 ? _29 : toComputeIndicatorKeys[i],
|
|
589
|
+
aggregationFun: null == aggRule ? void 0 : aggRule.aggregationFun,
|
|
590
|
+
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 === toComputeIndicatorKeys[i]))) || void 0 === _32 ? void 0 : _32.format
|
|
591
|
+
}), this.tree[flatRowKey][flatColTotalKey][i] instanceof aggregation_1.CustomAggregator && flatColTotalKey.startsWith(this.groupedGrandTotalKey) && (this.tree[flatRowKey][flatColTotalKey][i].recalculateFromChildren = !0);
|
|
592
|
+
}
|
|
593
|
+
flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_34 = null === (_33 = that.tree[flatRowKey]) || void 0 === _33 ? void 0 : _33[flatColKey]) || void 0 === _34 ? void 0 : _34[i]);
|
|
545
594
|
}
|
|
546
|
-
flatColTotalKey !== flatColKey && this.tree[flatRowKey][flatColTotalKey][i].push(null === (_32 = null === (_31 = that.tree[flatRowKey]) || void 0 === _31 ? void 0 : _31[flatColKey]) || void 0 === _32 ? void 0 : _32[i]);
|
|
547
595
|
}
|
|
548
596
|
}
|
|
549
597
|
};
|
|
@@ -552,7 +600,7 @@ class Dataset {
|
|
|
552
600
|
Object.keys(that.tree).forEach((flatRowKey => {
|
|
553
601
|
const rowKey = flatRowKey.split(this.stringJoinChar);
|
|
554
602
|
Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
|
|
555
|
-
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;
|
|
603
|
+
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;
|
|
556
604
|
if ((null === (_b = null === (_a = that.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = that.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) > 0 && (!1 !== (null === (_g = null === (_f = that.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.showSubTotals) || (null === (_j = null === (_h = that.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTreeNode)) || (null === (_l = null === (_k = that.totals) || void 0 === _k ? void 0 : _k.row) || void 0 === _l ? void 0 : _l.showSubTotalsOnTreeNode) && that.rows.length > 0) {
|
|
557
605
|
let rowSubTotalDimensions = (null === (_o = null === (_m = that.totals) || void 0 === _m ? void 0 : _m.row) || void 0 === _o ? void 0 : _o.subTotalsDimensions) || [];
|
|
558
606
|
(null === (_q = null === (_p = that.totals) || void 0 === _p ? void 0 : _p.row) || void 0 === _q ? void 0 : _q.showSubTotalsOnTreeNode) && 0 === rowSubTotalDimensions.length && (rowSubTotalDimensions = that.rows.map((row => row)));
|
|
@@ -590,32 +638,35 @@ class Dataset {
|
|
|
590
638
|
}
|
|
591
639
|
}
|
|
592
640
|
}
|
|
593
|
-
if ((null === (_2 = null === (_1 = that.totals) || void 0 === _1 ? void 0 : _1.row) || void 0 === _2 ? void 0 : _2.showGrandTotals) || 0 === this.columns.length) {
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
641
|
+
if (((null === (_2 = null === (_1 = that.totals) || void 0 === _1 ? void 0 : _1.row) || void 0 === _2 ? void 0 : _2.showGrandTotals) || 0 === this.columns.length) && rowKey[0] !== this.groupedGrandTotalKey) {
|
|
642
|
+
const flatRowTotalKeys = this.getGrandTotalKeys(rowKey, that.rows.filter(((_, index) => that.rowsHasValue[index])), null === (_4 = null === (_3 = that.totals) || void 0 === _3 ? void 0 : _3.row) || void 0 === _4 ? void 0 : _4.grandTotalDimensions, that.rowGrandTotalLabel, that.rows);
|
|
643
|
+
for (const flatRowTotalKey of flatRowTotalKeys) {
|
|
644
|
+
this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
|
|
645
|
+
this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
|
|
646
|
+
const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
|
|
647
|
+
for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
|
|
648
|
+
if (!this.tree[flatRowTotalKey][flatColKey][i]) if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
|
|
649
|
+
const calculatedFieldRule = null === (_5 = this.calculatedFieldRules) || void 0 === _5 ? void 0 : _5.find((rule => rule.key === toComputeIndicatorKeys[i]));
|
|
650
|
+
this.tree[flatRowTotalKey][flatColKey][i] = new aggregation_1.registeredAggregators[ts_types_1.AggregationType.RECALCULATE]({
|
|
651
|
+
key: toComputeIndicatorKeys[i],
|
|
652
|
+
field: toComputeIndicatorKeys[i],
|
|
653
|
+
isRecord: !0,
|
|
654
|
+
formatFun: null === (_7 = null === (_6 = this.indicators) || void 0 === _6 ? void 0 : _6.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _7 ? void 0 : _7.format,
|
|
655
|
+
calculateFun: null == calculatedFieldRule ? void 0 : calculatedFieldRule.calculateFun,
|
|
656
|
+
dependAggregators: this.tree[flatRowTotalKey][flatColKey],
|
|
657
|
+
dependIndicatorKeys: null == calculatedFieldRule ? void 0 : calculatedFieldRule.dependIndicatorKeys
|
|
658
|
+
});
|
|
659
|
+
} else {
|
|
660
|
+
const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
|
|
661
|
+
this.tree[flatRowTotalKey][flatColKey][i] = new aggregation_1.registeredAggregators[null !== (_8 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _8 ? _8 : ts_types_1.AggregationType.SUM]({
|
|
662
|
+
key: toComputeIndicatorKeys[i],
|
|
663
|
+
field: null !== (_9 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _9 ? _9 : toComputeIndicatorKeys[i],
|
|
664
|
+
aggregationFun: null == aggRule ? void 0 : aggRule.aggregationFun,
|
|
665
|
+
formatFun: null !== (_10 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _10 ? _10 : null === (_12 = null === (_11 = this.indicators) || void 0 === _11 ? void 0 : _11.find((indicator => "string" != typeof indicator && indicator.indicatorKey === toComputeIndicatorKeys[i]))) || void 0 === _12 ? void 0 : _12.format
|
|
666
|
+
}), this.tree[flatRowTotalKey][flatColKey][i] instanceof aggregation_1.CustomAggregator && flatRowTotalKey.startsWith(this.groupedGrandTotalKey) && (this.tree[flatRowTotalKey][flatColKey][i].recalculateFromChildren = !0);
|
|
667
|
+
}
|
|
668
|
+
flatRowTotalKey !== flatRowKey && this.tree[flatRowTotalKey][flatColKey][i].push(null === (_14 = null === (_13 = that.tree[flatRowKey]) || void 0 === _13 ? void 0 : _13[flatColKey]) || void 0 === _14 ? void 0 : _14[i]);
|
|
617
669
|
}
|
|
618
|
-
flatRowTotalKey !== flatRowKey && this.tree[flatRowTotalKey][flatColKey][i].push(null === (_12 = null === (_11 = that.tree[flatRowKey]) || void 0 === _11 ? void 0 : _11[flatColKey]) || void 0 === _12 ? void 0 : _12[i]);
|
|
619
670
|
}
|
|
620
671
|
}
|
|
621
672
|
colCompute(flatRowKey, flatColKey);
|
|
@@ -628,7 +679,37 @@ class Dataset {
|
|
|
628
679
|
}
|
|
629
680
|
for (const flatRowKey in that.totalRecordsTree) for (const flatColKey in that.totalRecordsTree[flatRowKey]) colCompute(flatRowKey, flatColKey);
|
|
630
681
|
}
|
|
631
|
-
|
|
682
|
+
getGrandTotalDimensionIndexes(dimensions, grandTotalDimensions, configuredDimensions = dimensions) {
|
|
683
|
+
return (null == grandTotalDimensions ? void 0 : grandTotalDimensions.length) ? grandTotalDimensions.map((dimension => ({
|
|
684
|
+
configuredIndex: configuredDimensions.indexOf(dimension),
|
|
685
|
+
activeIndex: dimensions.indexOf(dimension)
|
|
686
|
+
}))).filter((({configuredIndex: configuredIndex, activeIndex: activeIndex}, position, indexes) => configuredIndex > 0 && activeIndex >= 0 && indexes.findIndex((item => item.activeIndex === activeIndex)) === position)).map((({activeIndex: activeIndex}) => activeIndex)).sort(((a, b) => a - b)) : [];
|
|
687
|
+
}
|
|
688
|
+
getCustomGroupedGrandTotalKey(record, dimensions, grandTotalDimensions) {
|
|
689
|
+
const dimensionIndexes = this.getGrandTotalDimensionIndexes(dimensions, grandTotalDimensions);
|
|
690
|
+
if (!dimensionIndexes.length || dimensions.some(((dimension, index) => -1 === dimensionIndexes.indexOf(index) && dimension in record))) return;
|
|
691
|
+
const prefixIndexes = [];
|
|
692
|
+
for (const index of dimensionIndexes) {
|
|
693
|
+
if (!(dimensions[index] in record)) break;
|
|
694
|
+
prefixIndexes.push(index);
|
|
695
|
+
}
|
|
696
|
+
return prefixIndexes.length && !dimensionIndexes.slice(prefixIndexes.length).some((index => dimensions[index] in record)) ? [ this.groupedGrandTotalKey, ...prefixIndexes.map((index => record[dimensions[index]])) ] : void 0;
|
|
697
|
+
}
|
|
698
|
+
getGroupedGrandTotalPaths(keys, dimensions, grandTotalDimensions, isRow = !0, configuredDimensions = dimensions) {
|
|
699
|
+
const dimensionIndexes = this.getGrandTotalDimensionIndexes(dimensions, grandTotalDimensions, configuredDimensions), groupedPaths = new Map;
|
|
700
|
+
return keys.forEach((key => {
|
|
701
|
+
const path = dimensionIndexes.map((index => key[index]));
|
|
702
|
+
groupedPaths.set((0, join_1.join)(path, this.stringJoinChar), path);
|
|
703
|
+
})), Array.from(groupedPaths.values()).sort(this.arrSort(dimensionIndexes.map((index => dimensions[index])), isRow, [ this.groupedGrandTotalKey ]));
|
|
704
|
+
}
|
|
705
|
+
getGrandTotalKeys(dimensionKey, dimensions, grandTotalDimensions, grandTotalLabel, configuredDimensions = dimensions) {
|
|
706
|
+
const dimensionIndexes = this.getGrandTotalDimensionIndexes(dimensions, grandTotalDimensions, configuredDimensions);
|
|
707
|
+
if (!dimensionIndexes.length) return [ grandTotalLabel ];
|
|
708
|
+
const groupedKey = [ this.groupedGrandTotalKey, ...dimensionIndexes.map((dimensionIndex => dimensionKey[dimensionIndex])) ];
|
|
709
|
+
return [ ...groupedKey.slice(1).map(((_, index) => (0, join_1.join)(groupedKey.slice(0, index + 2), this.stringJoinChar))), (0,
|
|
710
|
+
join_1.join)([ this.groupedGrandTotalKey, this.groupedGrandTotalSubtotalKey ], this.stringJoinChar) ];
|
|
711
|
+
}
|
|
712
|
+
ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel, showGrandTotalsOnTop, grandTotalDimensions, subTotalLabel, showSubTotalsOnTop, configuredRows = rows) {
|
|
632
713
|
const result = [], concatStr = this.stringJoinChar, map = new Map;
|
|
633
714
|
function addList(list, isGrandTotal) {
|
|
634
715
|
const path = [];
|
|
@@ -652,10 +733,55 @@ class Dataset {
|
|
|
652
733
|
node = item;
|
|
653
734
|
}));
|
|
654
735
|
}
|
|
655
|
-
|
|
656
|
-
|
|
736
|
+
const createIndicatorChildren = () => {
|
|
737
|
+
var _a;
|
|
738
|
+
return null !== (_a = null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
739
|
+
indicatorKey: indicator,
|
|
740
|
+
value: indicator
|
|
741
|
+
} : {
|
|
742
|
+
indicatorKey: indicator.indicatorKey,
|
|
743
|
+
value: indicator.title
|
|
744
|
+
}))) && void 0 !== _a ? _a : [];
|
|
745
|
+
};
|
|
746
|
+
if (arr.forEach((item => addList(item, !1))), isGrandTotal) {
|
|
747
|
+
const grandTotalDimensionIndexes = this.getGrandTotalDimensionIndexes(rows, grandTotalDimensions, configuredRows);
|
|
748
|
+
if (grandTotalDimensionIndexes.length) {
|
|
749
|
+
const grandTotalNode = {
|
|
750
|
+
value: grandTotalLabel,
|
|
751
|
+
dataValue: this.groupedGrandTotalKey,
|
|
752
|
+
dimensionKey: rows[0],
|
|
753
|
+
children: [],
|
|
754
|
+
role: "grand-total"
|
|
755
|
+
}, grandTotalMap = new Map;
|
|
756
|
+
this.getGroupedGrandTotalPaths(arr, rows, grandTotalDimensions, !0, configuredRows).forEach((list => {
|
|
757
|
+
let parent = grandTotalNode;
|
|
758
|
+
const path = [ this.groupedGrandTotalKey ];
|
|
759
|
+
grandTotalDimensionIndexes.forEach(((dimensionIndex, index) => {
|
|
760
|
+
const value = list[index];
|
|
761
|
+
path.push(value);
|
|
762
|
+
const flatKey = (0, join_1.join)(path, concatStr);
|
|
763
|
+
let item = grandTotalMap.get(flatKey);
|
|
764
|
+
item || (item = {
|
|
765
|
+
value: value,
|
|
766
|
+
dataValue: value,
|
|
767
|
+
dimensionKey: rows[dimensionIndex],
|
|
768
|
+
children: index === grandTotalDimensionIndexes.length - 1 ? createIndicatorChildren() : []
|
|
769
|
+
}, grandTotalMap.set(flatKey, item), parent.children.push(item)), parent = item;
|
|
770
|
+
}));
|
|
771
|
+
}));
|
|
772
|
+
const totalChild = {
|
|
773
|
+
value: subTotalLabel,
|
|
774
|
+
dataValue: this.groupedGrandTotalSubtotalKey,
|
|
775
|
+
dimensionKey: rows[grandTotalDimensionIndexes[0]],
|
|
776
|
+
children: createIndicatorChildren()
|
|
777
|
+
};
|
|
778
|
+
showSubTotalsOnTop ? grandTotalNode.children.unshift(totalChild) : grandTotalNode.children.push(totalChild),
|
|
779
|
+
showGrandTotalsOnTop ? result.unshift(grandTotalNode) : result.push(grandTotalNode);
|
|
780
|
+
} else addList([ grandTotalLabel ], isGrandTotal);
|
|
781
|
+
}
|
|
782
|
+
return result;
|
|
657
783
|
}
|
|
658
|
-
ArrToTree(arr, rows, indicators, subTotalFlags, isGrandTotal, grandTotalLabel, subTotalLabel, showGrandTotalsOnTop, showSubTotalsOnTop) {
|
|
784
|
+
ArrToTree(arr, rows, indicators, subTotalFlags, isGrandTotal, grandTotalLabel, subTotalLabel, showGrandTotalsOnTop, showSubTotalsOnTop, grandTotalDimensions, isRow, configuredRows = rows) {
|
|
659
785
|
var _a;
|
|
660
786
|
let result = [];
|
|
661
787
|
const concatStr = this.stringJoinChar, map = new Map;
|
|
@@ -709,19 +835,56 @@ class Dataset {
|
|
|
709
835
|
value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
|
|
710
836
|
};
|
|
711
837
|
}))), isGrandTotal && (null == arr ? void 0 : arr.length)) {
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
levelSpan: subTotalFlags.length,
|
|
716
|
-
children: null !== (_a = null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
838
|
+
const grandTotalDimensionIndexes = this.getGrandTotalDimensionIndexes(rows, grandTotalDimensions, configuredRows), createIndicatorChildren = () => {
|
|
839
|
+
var _a;
|
|
840
|
+
return null !== (_a = null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
717
841
|
indicatorKey: indicator,
|
|
718
842
|
value: indicator
|
|
719
843
|
} : {
|
|
720
844
|
indicatorKey: indicator.indicatorKey,
|
|
721
845
|
value: indicator.title
|
|
722
|
-
}))) && void 0 !== _a ? _a : []
|
|
846
|
+
}))) && void 0 !== _a ? _a : [];
|
|
847
|
+
}, node = {
|
|
848
|
+
value: grandTotalLabel,
|
|
849
|
+
dataValue: grandTotalDimensionIndexes.length ? this.groupedGrandTotalKey : void 0,
|
|
850
|
+
dimensionKey: rows[0],
|
|
851
|
+
levelSpan: Math.max(1, null !== (_a = grandTotalDimensionIndexes[0]) && void 0 !== _a ? _a : subTotalFlags.length),
|
|
852
|
+
children: [],
|
|
723
853
|
role: "grand-total"
|
|
724
854
|
};
|
|
855
|
+
if (grandTotalDimensionIndexes.length) {
|
|
856
|
+
const grandTotalMap = new Map;
|
|
857
|
+
this.getGroupedGrandTotalPaths(arr, rows, grandTotalDimensions, isRow, configuredRows).forEach((list => {
|
|
858
|
+
let parent = node;
|
|
859
|
+
const path = [ this.groupedGrandTotalKey ];
|
|
860
|
+
grandTotalDimensionIndexes.forEach(((dimensionIndex, index) => {
|
|
861
|
+
var _a;
|
|
862
|
+
const value = list[index];
|
|
863
|
+
path.push(value);
|
|
864
|
+
const flatKey = (0, join_1.join)(path, concatStr);
|
|
865
|
+
let item = grandTotalMap.get(flatKey);
|
|
866
|
+
if (!item) {
|
|
867
|
+
const nextDimensionIndex = null !== (_a = grandTotalDimensionIndexes[index + 1]) && void 0 !== _a ? _a : rows.length;
|
|
868
|
+
item = {
|
|
869
|
+
value: value,
|
|
870
|
+
dataValue: value,
|
|
871
|
+
dimensionKey: rows[dimensionIndex],
|
|
872
|
+
levelSpan: nextDimensionIndex - dimensionIndex,
|
|
873
|
+
children: index === grandTotalDimensionIndexes.length - 1 ? createIndicatorChildren() : []
|
|
874
|
+
}, grandTotalMap.set(flatKey, item), parent.children.push(item);
|
|
875
|
+
}
|
|
876
|
+
parent = item;
|
|
877
|
+
}));
|
|
878
|
+
}));
|
|
879
|
+
const totalChild = {
|
|
880
|
+
value: subTotalLabel,
|
|
881
|
+
dataValue: this.groupedGrandTotalSubtotalKey,
|
|
882
|
+
dimensionKey: rows[grandTotalDimensionIndexes[0]],
|
|
883
|
+
levelSpan: rows.length - grandTotalDimensionIndexes[0],
|
|
884
|
+
children: createIndicatorChildren()
|
|
885
|
+
};
|
|
886
|
+
showSubTotalsOnTop ? node.children.unshift(totalChild) : node.children.push(totalChild);
|
|
887
|
+
} else node.children = createIndicatorChildren();
|
|
725
888
|
showGrandTotalsOnTop ? result.unshift(node) : result.push(node);
|
|
726
889
|
}
|
|
727
890
|
return result;
|
|
@@ -743,10 +906,10 @@ class Dataset {
|
|
|
743
906
|
}
|
|
744
907
|
"string" == typeof rowKey ? flatRowKey = rowKey : (indicatorPosition && "row" !== indicatorPosition.position || rowKey.map(((key, i) => {
|
|
745
908
|
key !== indicator || (0, vutils_1.isValid)(null == indicatorPosition ? void 0 : indicatorPosition.index) && i !== indicatorPosition.index || rowKey.splice(i, 1);
|
|
746
|
-
})), rowKey.length < this.rows.length && "grid-tree" === this.rowHierarchyType && (rowKey[0] === this.rowGrandTotalLabel || ((null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 && this.totals.row.subTotalsDimensions.find((dimension => dimension === rowDimensionKey)) || (null === (_g = null === (_f = this.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.showSubTotalsOnTreeNode)) && rowKey[rowKey.length - 1] !== this.rowSubTotalLabel && rowKey.push(this.rowSubTotalLabel)),
|
|
909
|
+
})), rowKey.length < this.rows.length && "grid-tree" === this.rowHierarchyType && (rowKey[0] === this.rowGrandTotalLabel || rowKey[0] === this.groupedGrandTotalKey || ((null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && (null === (_e = null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 && this.totals.row.subTotalsDimensions.find((dimension => dimension === rowDimensionKey)) || (null === (_g = null === (_f = this.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.showSubTotalsOnTreeNode)) && rowKey[rowKey.length - 1] !== this.rowSubTotalLabel && rowKey.push(this.rowSubTotalLabel)),
|
|
747
910
|
flatRowKey = (0, join_1.join)(rowKey, this.stringJoinChar)), "string" == typeof colKey ? flatColKey = colKey : (indicatorPosition && "col" !== indicatorPosition.position || colKey.map(((key, i) => {
|
|
748
911
|
key !== indicator || (0, vutils_1.isValid)(null == indicatorPosition ? void 0 : indicatorPosition.index) && i !== indicatorPosition.index || colKey.splice(i, 1);
|
|
749
|
-
})), colKey.length < this.columns.length && "grid-tree" === this.columnHierarchyType && (colKey[0] === this.colGrandTotalLabel || ((null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.column) || void 0 === _j ? void 0 : _j.subTotalsDimensions) && (null === (_m = null === (_l = null === (_k = this.totals) || void 0 === _k ? void 0 : _k.column) || void 0 === _l ? void 0 : _l.subTotalsDimensions) || void 0 === _m ? void 0 : _m.length) >= 1 && this.totals.column.subTotalsDimensions.find((dimension => dimension === colDimensionKey)) || (null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showSubTotalsOnTreeNode)) && colKey[colKey.length - 1] !== this.colSubTotalLabel && colKey.push(this.colSubTotalLabel)),
|
|
912
|
+
})), colKey.length < this.columns.length && "grid-tree" === this.columnHierarchyType && (colKey[0] === this.colGrandTotalLabel || colKey[0] === this.groupedGrandTotalKey || ((null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.column) || void 0 === _j ? void 0 : _j.subTotalsDimensions) && (null === (_m = null === (_l = null === (_k = this.totals) || void 0 === _k ? void 0 : _k.column) || void 0 === _l ? void 0 : _l.subTotalsDimensions) || void 0 === _m ? void 0 : _m.length) >= 1 && this.totals.column.subTotalsDimensions.find((dimension => dimension === colDimensionKey)) || (null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showSubTotalsOnTreeNode)) && colKey[colKey.length - 1] !== this.colSubTotalLabel && colKey.push(this.colSubTotalLabel)),
|
|
750
913
|
flatColKey = (0, join_1.join)(colKey, this.stringJoinChar)), "string" == typeof newValue && (isNaN(parseFloat(newValue)) || (newValue = parseFloat(newValue))),
|
|
751
914
|
(null === (_q = this.changedTree[flatRowKey]) || void 0 === _q ? void 0 : _q[flatColKey]) ? this.changedTree[flatRowKey][flatColKey][indicatorIndex] = newValue : this.changedTree[flatRowKey] ? (this.changedTree[flatRowKey][flatColKey] = [],
|
|
752
915
|
this.changedTree[flatRowKey][flatColKey][indicatorIndex] = newValue) : (this.changedTree[flatRowKey] = {},
|
|
@@ -764,60 +927,54 @@ class Dataset {
|
|
|
764
927
|
}
|
|
765
928
|
}
|
|
766
929
|
recalculateTotals(rowKey = [], colKey = [], indicator, newCellAggregator) {
|
|
767
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
930
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
768
931
|
if (!this.totals || 0 === Object.keys(this.tree).length || !((null === (_a = this.totals.row) || void 0 === _a ? void 0 : _a.showGrandTotals) || (null === (_b = this.totals.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && this.totals.row.subTotalsDimensions.length > 0 && !1 !== this.totals.row.showSubTotals) && !((null === (_c = this.totals.column) || void 0 === _c ? void 0 : _c.showGrandTotals) || (null === (_d = this.totals.column) || void 0 === _d ? void 0 : _d.subTotalsDimensions) && this.totals.column.subTotalsDimensions.length > 0 && !1 !== this.totals.column.showSubTotals)) return;
|
|
769
|
-
const flatRowKey = Array.isArray(rowKey) ?
|
|
932
|
+
const flatRowKey = Array.isArray(rowKey) ? (0, join_1.join)(rowKey, this.stringJoinChar) : rowKey, flatColKey = Array.isArray(colKey) ? (0,
|
|
933
|
+
join_1.join)(colKey, this.stringJoinChar) : colKey, indicatorIndex = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.indexOf(indicator), aggregatorsToReset = new Set, subTotalAggregators = new Set, rowKeyParts = Array.isArray(rowKey) ? rowKey.slice() : rowKey.split(this.stringJoinChar), colKeyParts = Array.isArray(colKey) ? colKey.slice() : colKey.split(this.stringJoinChar), addAggregatorToResetSet = (agg, rowKey, colKey) => {
|
|
770
934
|
!agg || rowKey === flatRowKey && colKey === flatColKey || (aggregatorsToReset.add(agg),
|
|
771
935
|
rowKey !== flatRowKey && colKey !== flatColKey || subTotalAggregators.add(agg));
|
|
772
|
-
};
|
|
936
|
+
}, rowAggregateKeys = [], colAggregateKeys = [];
|
|
773
937
|
if ((null === (_f = null === (_e = this.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.subTotalsDimensions) && !1 !== this.totals.row.showSubTotals) for (let i = 0; i < this.totals.row.subTotalsDimensions.length; i++) {
|
|
774
938
|
const dimension = this.totals.row.subTotalsDimensions[i], dimensionIndex = this.rows.indexOf(dimension);
|
|
775
939
|
if (dimensionIndex >= 0 && dimensionIndex < rowKeyParts.length) {
|
|
776
940
|
const rowSubTotalKeyParts = rowKeyParts.slice(0, dimensionIndex + 1);
|
|
777
941
|
"tree" !== this.rowHierarchyType && rowSubTotalKeyParts.push(this.rowSubTotalLabel);
|
|
778
942
|
const flatRowSubTotalKey = rowSubTotalKeyParts.join(this.stringJoinChar);
|
|
779
|
-
|
|
780
|
-
(null === (_k = null === (_j = this.totals) || void 0 === _j ? void 0 : _j.column) || void 0 === _k ? void 0 : _k.subTotalsDimensions) && !1 !== this.totals.column.showSubTotals) for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
|
|
781
|
-
const colDimension = this.totals.column.subTotalsDimensions[j], colDimensionIndex = this.columns.indexOf(colDimension);
|
|
782
|
-
if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
|
|
783
|
-
const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
|
|
784
|
-
colSubTotalKeyParts.push(this.colSubTotalLabel);
|
|
785
|
-
const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
|
|
786
|
-
(null === (_m = null === (_l = this.tree[flatRowSubTotalKey]) || void 0 === _l ? void 0 : _l[flatColSubTotalKey]) || void 0 === _m ? void 0 : _m[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowSubTotalKey][flatColSubTotalKey][indicatorIndex], flatRowSubTotalKey, flatColSubTotalKey);
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
(null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotals) && (null === (_r = null === (_q = this.tree[flatRowSubTotalKey]) || void 0 === _q ? void 0 : _q[this.colGrandTotalLabel]) || void 0 === _r ? void 0 : _r[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowSubTotalKey][this.colGrandTotalLabel][indicatorIndex], flatRowSubTotalKey, this.colGrandTotalLabel);
|
|
943
|
+
-1 === rowAggregateKeys.indexOf(flatRowSubTotalKey) && rowAggregateKeys.push(flatRowSubTotalKey);
|
|
790
944
|
}
|
|
791
945
|
}
|
|
792
|
-
if (null === (
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
(null === (_1 = null === (_0 = this.totals) || void 0 === _0 ? void 0 : _0.column) || void 0 === _1 ? void 0 : _1.showGrandTotals) && (null === (_3 = null === (_2 = this.tree[this.rowGrandTotalLabel]) || void 0 === _2 ? void 0 : _2[this.colGrandTotalLabel]) || void 0 === _3 ? void 0 : _3[indicatorIndex]) && addAggregatorToResetSet(this.tree[this.rowGrandTotalLabel][this.colGrandTotalLabel][indicatorIndex], this.rowGrandTotalLabel, this.colGrandTotalLabel);
|
|
805
|
-
}
|
|
806
|
-
if ((null === (_5 = null === (_4 = this.totals) || void 0 === _4 ? void 0 : _4.column) || void 0 === _5 ? void 0 : _5.subTotalsDimensions) && !1 !== this.totals.column.showSubTotals) for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
|
|
807
|
-
const colDimension = this.totals.column.subTotalsDimensions[j], colDimensionIndex = this.columns.indexOf(colDimension);
|
|
808
|
-
if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
|
|
809
|
-
const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
|
|
810
|
-
colSubTotalKeyParts.push(this.colSubTotalLabel);
|
|
811
|
-
const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
|
|
812
|
-
(null === (_7 = null === (_6 = this.tree[flatRowKey]) || void 0 === _6 ? void 0 : _6[flatColSubTotalKey]) || void 0 === _7 ? void 0 : _7[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowKey][flatColSubTotalKey][indicatorIndex], flatRowKey, flatColSubTotalKey);
|
|
813
|
-
}
|
|
946
|
+
if (null === (_h = null === (_g = this.totals) || void 0 === _g ? void 0 : _g.row) || void 0 === _h ? void 0 : _h.showGrandTotals) {
|
|
947
|
+
const rowGrandTotalKeys = this.getGrandTotalKeys(rowKeyParts, this.rows.filter(((_, index) => this.rowsHasValue[index])), this.totals.row.grandTotalDimensions, this.rowGrandTotalLabel, this.rows);
|
|
948
|
+
for (const rowGrandTotalKey of rowGrandTotalKeys) -1 === rowAggregateKeys.indexOf(rowGrandTotalKey) && rowAggregateKeys.push(rowGrandTotalKey);
|
|
949
|
+
}
|
|
950
|
+
if ((null === (_k = null === (_j = this.totals) || void 0 === _j ? void 0 : _j.column) || void 0 === _k ? void 0 : _k.subTotalsDimensions) && !1 !== this.totals.column.showSubTotals) for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
|
|
951
|
+
const colDimension = this.totals.column.subTotalsDimensions[j], colDimensionIndex = this.columns.indexOf(colDimension);
|
|
952
|
+
if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
|
|
953
|
+
const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
|
|
954
|
+
colSubTotalKeyParts.push(this.colSubTotalLabel);
|
|
955
|
+
const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
|
|
956
|
+
-1 === colAggregateKeys.indexOf(flatColSubTotalKey) && colAggregateKeys.push(flatColSubTotalKey);
|
|
814
957
|
}
|
|
815
|
-
(null === (_9 = null === (_8 = this.totals) || void 0 === _8 ? void 0 : _8.column) || void 0 === _9 ? void 0 : _9.showGrandTotals) && (null === (_11 = null === (_10 = this.tree[flatRowKey]) || void 0 === _10 ? void 0 : _10[this.colGrandTotalLabel]) || void 0 === _11 ? void 0 : _11[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowKey][this.colGrandTotalLabel][indicatorIndex], flatRowKey, this.colGrandTotalLabel),
|
|
816
|
-
aggregatorsToReset.forEach((agg => {
|
|
817
|
-
newCellAggregator && subTotalAggregators.has(agg) && agg.push(newCellAggregator),
|
|
818
|
-
agg.recalculate();
|
|
819
|
-
}));
|
|
820
958
|
}
|
|
959
|
+
if (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) {
|
|
960
|
+
const colGrandTotalKeys = this.getGrandTotalKeys(colKeyParts, this.columns.filter(((_, index) => this.columnsHasValue[index])), this.totals.column.grandTotalDimensions, this.colGrandTotalLabel, this.columns);
|
|
961
|
+
for (const colGrandTotalKey of colGrandTotalKeys) -1 === colAggregateKeys.indexOf(colGrandTotalKey) && colAggregateKeys.push(colGrandTotalKey);
|
|
962
|
+
}
|
|
963
|
+
rowAggregateKeys.forEach((rowAggregateKey => {
|
|
964
|
+
var _a, _b;
|
|
965
|
+
addAggregatorToResetSet(null === (_b = null === (_a = this.tree[rowAggregateKey]) || void 0 === _a ? void 0 : _a[flatColKey]) || void 0 === _b ? void 0 : _b[indicatorIndex], rowAggregateKey, flatColKey);
|
|
966
|
+
})), colAggregateKeys.forEach((colAggregateKey => {
|
|
967
|
+
var _a, _b;
|
|
968
|
+
addAggregatorToResetSet(null === (_b = null === (_a = this.tree[flatRowKey]) || void 0 === _a ? void 0 : _a[colAggregateKey]) || void 0 === _b ? void 0 : _b[indicatorIndex], flatRowKey, colAggregateKey);
|
|
969
|
+
})), rowAggregateKeys.forEach((rowAggregateKey => {
|
|
970
|
+
colAggregateKeys.forEach((colAggregateKey => {
|
|
971
|
+
var _a, _b;
|
|
972
|
+
addAggregatorToResetSet(null === (_b = null === (_a = this.tree[rowAggregateKey]) || void 0 === _a ? void 0 : _a[colAggregateKey]) || void 0 === _b ? void 0 : _b[indicatorIndex], rowAggregateKey, colAggregateKey);
|
|
973
|
+
}));
|
|
974
|
+
})), aggregatorsToReset.forEach((agg => {
|
|
975
|
+
newCellAggregator && subTotalAggregators.has(agg) && agg.push(newCellAggregator),
|
|
976
|
+
agg.recalculate();
|
|
977
|
+
}));
|
|
821
978
|
}
|
|
822
979
|
changeRecordFieldValue(fieldName, oldValue, value) {
|
|
823
980
|
var _a;
|