@visactor/vtable 0.25.4 → 0.26.0-alpha.0
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/PivotChart.d.ts +9 -0
- package/cjs/PivotChart.js +90 -28
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/PivotTable.d.ts +5 -2
- package/cjs/PivotTable.js +186 -152
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/core/BaseTable.js +1 -1
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/dataset/dataset.d.ts +20 -15
- package/cjs/dataset/dataset.js +85 -59
- package/cjs/dataset/dataset.js.map +1 -1
- package/cjs/dataset/statistics-helper.d.ts +13 -2
- package/cjs/dataset/statistics-helper.js +22 -27
- package/cjs/dataset/statistics-helper.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/chart-helper/get-chart-spec.d.ts +2 -1
- package/cjs/layout/chart-helper/get-chart-spec.js +3 -3
- package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
- package/cjs/layout/layout-helper.d.ts +12 -0
- package/cjs/layout/layout-helper.js +52 -4
- package/cjs/layout/layout-helper.js.map +1 -1
- package/cjs/layout/pivot-header-layout.d.ts +4 -3
- package/cjs/layout/pivot-header-layout.js +36 -46
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/layout/tree-helper.d.ts +1 -0
- package/cjs/layout/tree-helper.js +12 -7
- package/cjs/layout/tree-helper.js.map +1 -1
- package/cjs/state/cell-move/adjust-header.js +1 -1
- package/cjs/state/cell-move/adjust-header.js.map +1 -1
- package/cjs/state/resize/update-resize-column.js +1 -1
- package/cjs/state/resize/update-resize-column.js.map +1 -1
- package/cjs/state/resize/update-resize-row.js +5 -4
- package/cjs/state/resize/update-resize-row.js.map +1 -1
- package/cjs/themes/ARCO.js +1 -1
- package/cjs/themes/BRIGHT.js +1 -1
- package/cjs/themes/DARK.js +1 -1
- package/cjs/themes/DEFAULT.js +1 -1
- package/cjs/themes/SIMPLIFY.js +1 -1
- package/cjs/tools/LimitPromiseQueue.js +1 -1
- package/cjs/tools/NumberMap.js +1 -1
- package/cjs/tools/Rect.js +1 -1
- package/cjs/tools/calc.js +1 -1
- package/cjs/tools/debounce.js +1 -1
- package/cjs/tools/get-data-path/create-dataset.d.ts +9 -1
- package/cjs/tools/get-data-path/create-dataset.js +19 -8
- package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
- package/cjs/tools/get-data-path/index.js +12 -3
- package/cjs/tools/get-data-path/index.js.map +1 -1
- package/cjs/ts-types/base-table.d.ts +6 -2
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/ts-types/common.d.ts +2 -0
- package/cjs/ts-types/common.js.map +1 -1
- package/cjs/ts-types/menu.d.ts +1 -1
- package/cjs/ts-types/menu.js.map +1 -1
- package/cjs/ts-types/table-engine.d.ts +1 -0
- package/cjs/ts-types/table-engine.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +882 -546
- package/dist/vtable.min.js +2 -2
- package/es/PivotChart.d.ts +9 -0
- package/es/PivotChart.js +97 -29
- package/es/PivotChart.js.map +1 -1
- package/es/PivotTable.d.ts +5 -2
- package/es/PivotTable.js +188 -148
- package/es/PivotTable.js.map +1 -1
- package/es/core/BaseTable.js +1 -1
- package/es/core/BaseTable.js.map +1 -1
- package/es/dataset/dataset.d.ts +20 -15
- package/es/dataset/dataset.js +85 -59
- package/es/dataset/dataset.js.map +1 -1
- package/es/dataset/statistics-helper.d.ts +13 -2
- package/es/dataset/statistics-helper.js +22 -27
- package/es/dataset/statistics-helper.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/chart-helper/get-chart-spec.d.ts +2 -1
- package/es/layout/chart-helper/get-chart-spec.js +3 -3
- package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
- package/es/layout/layout-helper.d.ts +12 -0
- package/es/layout/layout-helper.js +50 -0
- package/es/layout/layout-helper.js.map +1 -1
- package/es/layout/pivot-header-layout.d.ts +4 -3
- package/es/layout/pivot-header-layout.js +34 -45
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/layout/tree-helper.d.ts +1 -0
- package/es/layout/tree-helper.js +12 -7
- package/es/layout/tree-helper.js.map +1 -1
- package/es/state/cell-move/adjust-header.js +1 -1
- package/es/state/cell-move/adjust-header.js.map +1 -1
- package/es/state/resize/update-resize-column.js +1 -1
- package/es/state/resize/update-resize-column.js.map +1 -1
- package/es/state/resize/update-resize-row.js +5 -4
- package/es/state/resize/update-resize-row.js.map +1 -1
- package/es/themes/ARCO.js +1 -1
- package/es/themes/BRIGHT.js +1 -1
- package/es/themes/DARK.js +1 -1
- package/es/themes/DEFAULT.js +1 -1
- package/es/themes/SIMPLIFY.js +1 -1
- package/es/tools/LimitPromiseQueue.js +1 -1
- package/es/tools/NumberMap.js +1 -1
- package/es/tools/Rect.js +1 -1
- package/es/tools/calc.js +1 -1
- package/es/tools/debounce.js +1 -1
- package/es/tools/get-data-path/create-dataset.d.ts +9 -1
- package/es/tools/get-data-path/create-dataset.js +20 -7
- package/es/tools/get-data-path/create-dataset.js.map +1 -1
- package/es/tools/get-data-path/index.js +15 -2
- package/es/tools/get-data-path/index.js.map +1 -1
- package/es/ts-types/base-table.d.ts +6 -2
- package/es/ts-types/base-table.js.map +1 -1
- package/es/ts-types/common.d.ts +2 -0
- package/es/ts-types/common.js.map +1 -1
- package/es/ts-types/menu.d.ts +1 -1
- package/es/ts-types/menu.js.map +1 -1
- package/es/ts-types/table-engine.d.ts +1 -0
- package/es/ts-types/table-engine.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +5 -5
package/cjs/dataset/dataset.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { FilterRules, IPivotTableDataConfig, SortRule, AggregationRules, SortRules, DerivedFieldRules, Totals, MappingRules, IHeaderTreeDefine, CollectValueBy, CollectedValue, IIndicator, IPivotChartDataConfig } from '../ts-types';
|
|
2
|
-
import type { Aggregator } from './statistics-helper';
|
|
2
|
+
import type { Aggregator, IAggregator } from './statistics-helper';
|
|
3
3
|
import { typeSort } from './statistics-helper';
|
|
4
4
|
export declare class Dataset {
|
|
5
|
-
dataConfig
|
|
6
|
-
records
|
|
5
|
+
dataConfig?: IPivotTableDataConfig | IPivotChartDataConfig;
|
|
6
|
+
records?: any[] | Record<string, any[]>;
|
|
7
7
|
tree: Record<string, Record<string, Aggregator[]>>;
|
|
8
8
|
changedTree: Record<string, Record<string, any[]>>;
|
|
9
9
|
private colFlatKeys;
|
|
@@ -13,12 +13,12 @@ export declare class Dataset {
|
|
|
13
13
|
rowOrder: string;
|
|
14
14
|
colOrder: string;
|
|
15
15
|
sorted: boolean;
|
|
16
|
-
sortRules
|
|
17
|
-
filterRules
|
|
18
|
-
aggregationRules
|
|
19
|
-
derivedFieldRules
|
|
20
|
-
mappingRules
|
|
21
|
-
totals
|
|
16
|
+
sortRules?: SortRules;
|
|
17
|
+
filterRules?: FilterRules;
|
|
18
|
+
aggregationRules?: AggregationRules;
|
|
19
|
+
derivedFieldRules?: DerivedFieldRules;
|
|
20
|
+
mappingRules?: MappingRules;
|
|
21
|
+
totals?: Totals;
|
|
22
22
|
indicatorStatistics: {
|
|
23
23
|
max: Aggregator;
|
|
24
24
|
min: Aggregator;
|
|
@@ -37,21 +37,21 @@ export declare class Dataset {
|
|
|
37
37
|
private rowGrandTotalLabel;
|
|
38
38
|
private rowSubTotalLabel;
|
|
39
39
|
private needSplitPositiveAndNegative?;
|
|
40
|
-
collectValuesBy
|
|
40
|
+
collectValuesBy?: Record<string, CollectValueBy>;
|
|
41
41
|
collectedValues: Record<string, Record<string, CollectedValue>>;
|
|
42
42
|
cacheCollectedValues: Record<string, Record<string, CollectedValue>>;
|
|
43
43
|
rows: string[];
|
|
44
44
|
columns: string[];
|
|
45
45
|
indicatorKeys: string[];
|
|
46
|
-
customRowTree
|
|
47
|
-
customColTree
|
|
46
|
+
customRowTree?: IHeaderTreeDefine[];
|
|
47
|
+
customColTree?: IHeaderTreeDefine[];
|
|
48
48
|
colHeaderTree: any[];
|
|
49
49
|
rowHeaderTree: any[];
|
|
50
50
|
rowHierarchyType: 'grid' | 'tree';
|
|
51
|
-
indicators
|
|
51
|
+
indicators?: (string | IIndicator)[];
|
|
52
52
|
indicatorsAsCol: boolean;
|
|
53
53
|
totalRecordsTree: Record<string, Record<string, Aggregator[]>>;
|
|
54
|
-
constructor(dataConfig: IPivotTableDataConfig | IPivotChartDataConfig, rows: string[], columns: string[], indicatorKeys: string[], indicators: (string | IIndicator)[], indicatorsAsCol: boolean, records: any[] | Record<string, any[]
|
|
54
|
+
constructor(dataConfig: IPivotTableDataConfig | IPivotChartDataConfig | undefined, rows: string[], columns: string[], indicatorKeys: string[], indicators: (string | IIndicator)[] | undefined, indicatorsAsCol: boolean, records: any[] | Record<string, any[]> | undefined, rowHierarchyType?: 'grid' | 'tree', customColTree?: IHeaderTreeDefine[], customRowTree?: IHeaderTreeDefine[], needSplitPositiveAndNegative?: boolean);
|
|
55
55
|
setRecords(records: any[] | Record<string, any[]>): void;
|
|
56
56
|
registerAggregator(type: string, aggregator: any): void;
|
|
57
57
|
registerAggregators(): void;
|
|
@@ -64,7 +64,7 @@ export declare class Dataset {
|
|
|
64
64
|
updateSortRules(sortRules: SortRules): void;
|
|
65
65
|
updateFilterRules(filterRules: FilterRules, isResetTree?: boolean): void;
|
|
66
66
|
private getAggregatorRule;
|
|
67
|
-
getAggregator(rowKey: string[] | string, colKey: string[] | string, indicator: string, considerChangedValue?: boolean):
|
|
67
|
+
getAggregator(rowKey: string[] | string, colKey: string[] | string, indicator: string, considerChangedValue?: boolean): IAggregator;
|
|
68
68
|
sortKeys(): void;
|
|
69
69
|
arrSort(fieldArr: string[], isRow: boolean): (a: string[], b: string[]) => number;
|
|
70
70
|
getSort(sortRule: SortRule, isSortRow: boolean): typeof typeSort;
|
|
@@ -76,4 +76,9 @@ export declare class Dataset {
|
|
|
76
76
|
private _adjustCustomTree;
|
|
77
77
|
changeTreeNodeValue(rowKey: string[] | string, colKey: string[] | string, indicator: string, newValue: string | number): void;
|
|
78
78
|
changeRecordFieldValue(fieldName: string, oldValue: string | number, value: string | number): void;
|
|
79
|
+
changeDataConfig(dataConfig: {
|
|
80
|
+
rows: string[];
|
|
81
|
+
columns: string[];
|
|
82
|
+
}): void;
|
|
83
|
+
addRecords(records: any[]): void;
|
|
79
84
|
}
|
package/cjs/dataset/dataset.js
CHANGED
|
@@ -8,7 +8,7 @@ const vutils_1 = require("@visactor/vutils"), ts_types_1 = require("../ts-types"
|
|
|
8
8
|
|
|
9
9
|
class Dataset {
|
|
10
10
|
constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
|
|
11
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
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;
|
|
12
12
|
if (this.tree = {}, this.changedTree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
|
|
13
13
|
this.colKeys = [], this.rowKeys = [], this.rowOrder = "key_a_to_z", this.colOrder = "key_a_to_z",
|
|
14
14
|
this.sorted = !1, this.indicatorStatistics = [], this.aggregators = {}, this.stringJoinChar = String.fromCharCode(0),
|
|
@@ -29,11 +29,11 @@ class Dataset {
|
|
|
29
29
|
this.needSplitPositiveAndNegative = null != needSplitPositiveAndNegative && needSplitPositiveAndNegative,
|
|
30
30
|
this.rowsIsTotal = new Array(null !== (_v = null === (_u = this.rows) || void 0 === _u ? void 0 : _u.length) && void 0 !== _v ? _v : 0).fill(!1),
|
|
31
31
|
this.colsIsTotal = new Array(null !== (_x = null === (_w = this.columns) || void 0 === _w ? void 0 : _w.length) && void 0 !== _x ? _x : 0).fill(!1),
|
|
32
|
-
(null === (_y = this.totals) || void 0 === _y ? void 0 : _y.row) && !1 !== this.totals.row.showSubTotals) for (let i = 0, len = null === (_1 = null === (_0 = null === (_z = this.totals) || void 0 === _z ? void 0 : _z.row) || void 0 === _0 ? void 0 : _0.subTotalsDimensions) || void 0 === _1 ? void 0 : _1.length; i < len; i++) {
|
|
32
|
+
(null === (_y = this.totals) || void 0 === _y ? void 0 : _y.row) && !1 !== this.totals.row.showSubTotals && this.totals.row.subTotalsDimensions) for (let i = 0, len = null !== (_2 = null === (_1 = null === (_0 = null === (_z = this.totals) || void 0 === _z ? void 0 : _z.row) || void 0 === _0 ? void 0 : _0.subTotalsDimensions) || void 0 === _1 ? void 0 : _1.length) && void 0 !== _2 ? _2 : 0; i < len; i++) {
|
|
33
33
|
const dimension = this.totals.row.subTotalsDimensions[i], dimensionIndex = this.rows.indexOf(dimension);
|
|
34
34
|
this.rowsIsTotal[dimensionIndex] = !0;
|
|
35
35
|
}
|
|
36
|
-
if ((null === (
|
|
36
|
+
if ((null === (_3 = this.totals) || void 0 === _3 ? void 0 : _3.column) && !1 !== this.totals.column.showSubTotals && this.totals.column.subTotalsDimensions) for (let i = 0, len = null !== (_7 = null === (_6 = null === (_5 = null === (_4 = this.totals) || void 0 === _4 ? void 0 : _4.column) || void 0 === _5 ? void 0 : _5.subTotalsDimensions) || void 0 === _6 ? void 0 : _6.length) && void 0 !== _7 ? _7 : 0; i < len; i++) {
|
|
37
37
|
const dimension = this.totals.column.subTotalsDimensions[i], dimensionIndex = this.columns.indexOf(dimension);
|
|
38
38
|
this.colsIsTotal[dimensionIndex] = !0;
|
|
39
39
|
}
|
|
@@ -74,12 +74,12 @@ class Dataset {
|
|
|
74
74
|
this.registerAggregator(ts_types_1.AggregationType.NONE, statistics_helper_1.NoneAggregator);
|
|
75
75
|
}
|
|
76
76
|
processCollectedValuesWithSumBy() {
|
|
77
|
-
var _a, _b, _c, _d, _e;
|
|
78
|
-
for (const field in this.collectedValues) if (null === (_a = this.collectValuesBy[field]) || void 0 ===
|
|
77
|
+
var _a, _b, _c, _d, _e, _f;
|
|
78
|
+
for (const field in this.collectedValues) if (null === (_b = null === (_a = this.collectValuesBy) || void 0 === _a ? void 0 : _a[field]) || void 0 === _b ? void 0 : _b.sumBy) for (const byKeys in this.collectedValues[field]) {
|
|
79
79
|
let max;
|
|
80
|
-
"sum" === (null === (
|
|
80
|
+
"sum" === (null === (_c = this.collectValuesBy[field]) || void 0 === _c ? void 0 : _c.extendRange) ? (max = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => acc + cur.value()), 0),
|
|
81
81
|
max += Math.round(max / 20)) : (max = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => cur.value() > acc ? cur.value() : acc), Number.MIN_SAFE_INTEGER),
|
|
82
|
-
"max" === (null === (
|
|
82
|
+
"max" === (null === (_d = this.collectValuesBy[field]) || void 0 === _d ? void 0 : _d.extendRange) ? max += Math.round(max / 20) : "number" == typeof (null === (_e = this.collectValuesBy[field]) || void 0 === _e ? void 0 : _e.extendRange) && (max = Math.max(max, null === (_f = this.collectValuesBy[field]) || void 0 === _f ? void 0 : _f.extendRange)));
|
|
83
83
|
const min = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => cur.value() < acc ? cur.value() : acc), Number.MAX_SAFE_INTEGER);
|
|
84
84
|
let positiveMax, negativeMin;
|
|
85
85
|
this.needSplitPositiveAndNegative && (positiveMax = Object.values(this.collectedValues[field][byKeys]).reduce(((acc, cur) => cur.positiveValue() > acc ? cur.positiveValue() : acc), Number.MIN_SAFE_INTEGER),
|
|
@@ -90,14 +90,15 @@ class Dataset {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
processCollectedValuesWithSortBy() {
|
|
93
|
-
var _a;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const that = this;
|
|
95
|
+
for (const field in this.collectedValues) if (null === (_b = null === (_a = this.collectValuesBy) || void 0 === _a ? void 0 : _a[field]) || void 0 === _b ? void 0 : _b.sortBy) for (const byKeys in this.collectedValues[field]) this.collectedValues[field][byKeys] = this.collectedValues[field][byKeys].sort(((a, b) => {
|
|
96
|
+
var _a, _b, _c, _d;
|
|
97
|
+
return (null !== (_b = null === (_a = that.collectValuesBy[field].sortBy) || void 0 === _a ? void 0 : _a.indexOf(a)) && void 0 !== _b ? _b : -1) - (null !== (_d = null === (_c = that.collectValuesBy[field].sortBy) || void 0 === _c ? void 0 : _c.indexOf(b)) && void 0 !== _d ? _d : -1);
|
|
97
98
|
}));
|
|
98
99
|
}
|
|
99
100
|
generateCollectedValuesSortRule() {
|
|
100
|
-
for (const field in this.collectedValues) if (this.collectValuesBy[field] && !this.collectValuesBy[field].sortBy) {
|
|
101
|
+
for (const field in this.collectedValues) if (this.collectValuesBy && this.collectValuesBy[field] && !this.collectValuesBy[field].sortBy) {
|
|
101
102
|
let sortByRule = [];
|
|
102
103
|
for (const byKeys in this.collectedValues[field]) Array.isArray(this.collectedValues[field][byKeys]) && (sortByRule.push(...this.collectedValues[field][byKeys]),
|
|
103
104
|
sortByRule = Array.from(new Set(sortByRule)));
|
|
@@ -105,9 +106,9 @@ class Dataset {
|
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
processRecords() {
|
|
108
|
-
var _a, _b;
|
|
109
|
+
var _a, _b, _c;
|
|
109
110
|
let isNeedFilter = !1;
|
|
110
|
-
if ((null === (_b = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) || void 0 === _b ? void 0 : _b.length) >= 1 && (isNeedFilter = !0),
|
|
111
|
+
if ((null !== (_c = null === (_b = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) || void 0 === _b ? void 0 : _b.length) && void 0 !== _c ? _c : 0) >= 1 && (isNeedFilter = !0),
|
|
111
112
|
Array.isArray(this.records)) for (let i = 0, len = this.records.length; i < len; i++) {
|
|
112
113
|
const record = this.records[i];
|
|
113
114
|
isNeedFilter && !this.filterRecord(record) || this.processRecord(record);
|
|
@@ -118,17 +119,17 @@ class Dataset {
|
|
|
118
119
|
this.rowFlatKeys = {}, this.colFlatKeys = {};
|
|
119
120
|
}
|
|
120
121
|
filterRecord(record) {
|
|
121
|
-
var _a, _b;
|
|
122
|
+
var _a, _b, _c, _d;
|
|
122
123
|
let isReserved = !0;
|
|
123
|
-
for (let i = 0; i < this.dataConfig.filterRules.length; i++) {
|
|
124
|
-
const filterRule = null === (
|
|
124
|
+
if (null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) for (let i = 0; i < this.dataConfig.filterRules.length; i++) {
|
|
125
|
+
const filterRule = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules[i];
|
|
125
126
|
if (filterRule.filterKey) {
|
|
126
127
|
const filterValue = record[filterRule.filterKey];
|
|
127
|
-
if (-1 === filterRule.filteredValues.indexOf(filterValue)) {
|
|
128
|
+
if (-1 === (null === (_c = filterRule.filteredValues) || void 0 === _c ? void 0 : _c.indexOf(filterValue))) {
|
|
128
129
|
isReserved = !1;
|
|
129
130
|
break;
|
|
130
131
|
}
|
|
131
|
-
} else if (!(null === (
|
|
132
|
+
} else if (!(null === (_d = filterRule.filterFunc) || void 0 === _d ? void 0 : _d.call(filterRule, record))) {
|
|
132
133
|
isReserved = !1;
|
|
133
134
|
break;
|
|
134
135
|
}
|
|
@@ -138,7 +139,7 @@ class Dataset {
|
|
|
138
139
|
processRecord(record, assignedIndicatorKey) {
|
|
139
140
|
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;
|
|
140
141
|
null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
|
|
141
|
-
record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
|
|
142
|
+
derivedFieldRule.fieldName && derivedFieldRule.derivedFunc && (record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record));
|
|
142
143
|
}));
|
|
143
144
|
for (const field in this.collectValuesBy) if ((0, vutils_1.isValid)(record[field])) {
|
|
144
145
|
this.collectedValues[field] || (this.collectedValues[field] = {});
|
|
@@ -167,7 +168,7 @@ class Dataset {
|
|
|
167
168
|
rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
|
|
168
169
|
break;
|
|
169
170
|
}
|
|
170
|
-
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.indexOf(this.rows[l - 1])) >= 0) {
|
|
171
|
+
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) {
|
|
171
172
|
"grid" === this.rowHierarchyType && rowKey.push(this.rowSubTotalLabel), isToTalRecord = !0;
|
|
172
173
|
break;
|
|
173
174
|
}
|
|
@@ -176,11 +177,11 @@ class Dataset {
|
|
|
176
177
|
for (let n = 0, len2 = this.columns.length; n < len2; n++) {
|
|
177
178
|
const colAttr = this.columns[n];
|
|
178
179
|
if (colAttr in record) colKey.push(record[colAttr]); else {
|
|
179
|
-
if ((null === (
|
|
180
|
+
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))) {
|
|
180
181
|
colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
|
|
181
182
|
break;
|
|
182
183
|
}
|
|
183
|
-
if ((null === (
|
|
184
|
+
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) {
|
|
184
185
|
colKey.push(this.colSubTotalLabel), isToTalRecord = !0;
|
|
185
186
|
break;
|
|
186
187
|
}
|
|
@@ -191,20 +192,22 @@ class Dataset {
|
|
|
191
192
|
this.totalRecordsTree[flatRowKey] || (this.totalRecordsTree[flatRowKey] = {}), this.totalRecordsTree[flatRowKey][flatColKey] || (this.totalRecordsTree[flatRowKey][flatColKey] = []);
|
|
192
193
|
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
193
194
|
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
194
|
-
(null === (
|
|
195
|
-
this.indicatorKeys[i] in record && (null === (
|
|
195
|
+
(null === (_w = null === (_v = this.totalRecordsTree[flatRowKey]) || void 0 === _v ? void 0 : _v[flatColKey]) || void 0 === _w ? void 0 : _w[i]) || (this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_x = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _x ? _x : ts_types_1.AggregationType.SUM](null !== (_y = null == aggRule ? void 0 : aggRule.field) && void 0 !== _y ? _y : this.indicatorKeys[i], null !== (_z = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _z ? _z : null === (_1 = null === (_0 = this.indicators) || void 0 === _0 ? void 0 : _0.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _1 ? void 0 : _1.format)),
|
|
196
|
+
this.indicatorKeys[i] in record && (null === (_3 = null === (_2 = this.totalRecordsTree[flatRowKey]) || void 0 === _2 ? void 0 : _2[flatColKey]) || void 0 === _3 || _3[i].push(record));
|
|
196
197
|
}
|
|
197
198
|
} else {
|
|
198
199
|
0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
|
|
199
200
|
this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
|
|
200
201
|
this.colFlatKeys[flatColKey] = 1)), this.tree[flatRowKey] || (this.tree[flatRowKey] = {}),
|
|
201
|
-
(null === (
|
|
202
|
+
(null === (_4 = this.tree[flatRowKey]) || void 0 === _4 ? void 0 : _4[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
|
|
202
203
|
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
203
204
|
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
204
|
-
|
|
205
|
-
assignedIndicatorKey) this.indicatorKeys[i] === assignedIndicatorKey && (
|
|
206
|
-
(null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (
|
|
207
|
-
} else this.indicatorKeys[i] in record && (
|
|
205
|
+
let needAddToAggregator = !1;
|
|
206
|
+
if (assignedIndicatorKey) this.indicatorKeys[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 {
|
|
207
|
+
(null == aggRule ? void 0 : aggRule.field.find((field => field in record))) && (needAddToAggregator = !0);
|
|
208
|
+
} else this.indicatorKeys[i] in record && (needAddToAggregator = !0);
|
|
209
|
+
!(null === (_6 = null === (_5 = this.tree[flatRowKey]) || void 0 === _5 ? void 0 : _5[flatColKey]) || void 0 === _6 ? void 0 : _6[i]) && needAddToAggregator && (this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_7 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _7 ? _7 : ts_types_1.AggregationType.SUM](null !== (_8 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _8 ? _8 : this.indicatorKeys[i], null !== (_9 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _9 ? _9 : null === (_11 = null === (_10 = this.indicators) || void 0 === _10 ? void 0 : _10.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _11 ? void 0 : _11.format)),
|
|
210
|
+
needAddToAggregator && (null === (_13 = null === (_12 = this.tree[flatRowKey]) || void 0 === _12 ? void 0 : _12[flatColKey]) || void 0 === _13 || _13[i].push(record));
|
|
208
211
|
}
|
|
209
212
|
if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
210
213
|
if (!this.indicatorStatistics[i]) {
|
|
@@ -240,8 +243,11 @@ class Dataset {
|
|
|
240
243
|
var _a, _b, _c, _d;
|
|
241
244
|
const indicatorIndex = this.indicatorKeys.indexOf(indicator);
|
|
242
245
|
let flatRowKey, flatColKey;
|
|
243
|
-
|
|
244
|
-
|
|
246
|
+
"string" == typeof rowKey ? flatRowKey = rowKey : (rowKey.map(((key, i) => {
|
|
247
|
+
key === indicator && rowKey.splice(i, 1);
|
|
248
|
+
})), flatRowKey = rowKey.join(this.stringJoinChar)), "string" == typeof colKey ? flatColKey = colKey : (colKey.map(((key, i) => {
|
|
249
|
+
key === indicator && colKey.splice(i, 1);
|
|
250
|
+
})), flatColKey = colKey.join(this.stringJoinChar));
|
|
245
251
|
const agg = null === (_b = null === (_a = this.tree[flatRowKey]) || void 0 === _a ? void 0 : _a[flatColKey]) || void 0 === _b ? void 0 : _b[indicatorIndex];
|
|
246
252
|
if (considerChangedValue && (0, vutils_1.isValid)(null === (_d = null === (_c = this.changedTree[flatRowKey]) || void 0 === _c ? void 0 : _c[flatColKey]) || void 0 === _d ? void 0 : _d[indicatorIndex])) {
|
|
247
253
|
const changeValue = this.changedTree[flatRowKey][flatColKey][indicatorIndex];
|
|
@@ -270,7 +276,6 @@ class Dataset {
|
|
|
270
276
|
push() {},
|
|
271
277
|
recalculate() {},
|
|
272
278
|
value: () => null,
|
|
273
|
-
formatValue: () => "",
|
|
274
279
|
clearCacheValue() {},
|
|
275
280
|
reset() {}
|
|
276
281
|
};
|
|
@@ -362,48 +367,48 @@ class Dataset {
|
|
|
362
367
|
} : sortRule.sortBy ? (0, statistics_helper_1.sortBy)(sortRule.sortBy) : sortRule.sortType ? statistics_helper_1.typeSort : sortRule.sortFunc ? sortRule.sortFunc : statistics_helper_1.naturalSort;
|
|
363
368
|
}
|
|
364
369
|
totalStatistics() {
|
|
365
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
370
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
366
371
|
const that = this;
|
|
367
|
-
if ((null === (
|
|
372
|
+
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)) {
|
|
368
373
|
const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
|
|
369
|
-
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;
|
|
374
|
+
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;
|
|
370
375
|
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]);
|
|
371
376
|
const colKey = flatColKey.split(this.stringJoinChar);
|
|
372
|
-
for (let i = 0, len = null === (
|
|
377
|
+
if (null === (_f = null === (_e = that.totals) || void 0 === _e ? void 0 : _e.column) || void 0 === _f ? void 0 : _f.subTotalsDimensions) for (let i = 0, len = 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; i < len; i++) {
|
|
373
378
|
const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
|
|
374
379
|
if (dimensionIndex >= 0) {
|
|
375
380
|
const colTotalKey = colKey.slice(0, dimensionIndex + 1);
|
|
376
381
|
colTotalKey.push(that.colSubTotalLabel);
|
|
377
382
|
const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
|
|
378
|
-
if (null === (
|
|
383
|
+
if (null === (_l = null === (_k = this.totalRecordsTree) || void 0 === _k ? void 0 : _k[flatRowKey]) || void 0 === _l ? void 0 : _l[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_o = null === (_m = this.totalRecordsTree) || void 0 === _m ? void 0 : _m[flatRowKey]) || void 0 === _o ? void 0 : _o[flatColTotalKey]);
|
|
379
384
|
this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
|
|
380
385
|
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
381
386
|
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
382
387
|
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
383
|
-
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (
|
|
388
|
+
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_p = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _p ? _p : ts_types_1.AggregationType.SUM](null !== (_q = null == aggRule ? void 0 : aggRule.field) && void 0 !== _q ? _q : this.indicatorKeys[i], null !== (_r = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _r ? _r : null === (_t = null === (_s = this.indicators) || void 0 === _s ? void 0 : _s.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _t ? void 0 : _t.format);
|
|
384
389
|
}
|
|
385
|
-
this.tree[flatRowKey][flatColTotalKey][i].push(null === (
|
|
390
|
+
this.tree[flatRowKey][flatColTotalKey][i].push(null === (_v = null === (_u = that.tree[flatRowKey]) || void 0 === _u ? void 0 : _u[flatColKey]) || void 0 === _v ? void 0 : _v[i]);
|
|
386
391
|
}
|
|
387
392
|
}
|
|
388
393
|
}
|
|
389
|
-
if ((null === (
|
|
394
|
+
if ((null === (_x = null === (_w = that.totals) || void 0 === _w ? void 0 : _w.column) || void 0 === _x ? void 0 : _x.showGrandTotals) || 0 === this.rows.length) {
|
|
390
395
|
const flatColTotalKey = that.colGrandTotalLabel;
|
|
391
|
-
if (null === (
|
|
396
|
+
if (null === (_z = null === (_y = this.totalRecordsTree) || void 0 === _y ? void 0 : _y[flatRowKey]) || void 0 === _z ? void 0 : _z[flatColTotalKey]) return void (this.tree[flatRowKey][flatColTotalKey] = null === (_1 = null === (_0 = this.totalRecordsTree) || void 0 === _0 ? void 0 : _0[flatRowKey]) || void 0 === _1 ? void 0 : _1[flatColTotalKey]);
|
|
392
397
|
this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
|
|
393
398
|
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
394
399
|
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
395
400
|
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
396
|
-
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (
|
|
401
|
+
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_2 = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _2 ? _2 : ts_types_1.AggregationType.SUM](null !== (_3 = null == aggRule ? void 0 : aggRule.field) && void 0 !== _3 ? _3 : this.indicatorKeys[i], null !== (_4 = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _4 ? _4 : null === (_6 = null === (_5 = this.indicators) || void 0 === _5 ? void 0 : _5.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _6 ? void 0 : _6.format);
|
|
397
402
|
}
|
|
398
|
-
this.tree[flatRowKey][flatColTotalKey][i].push(null === (
|
|
403
|
+
this.tree[flatRowKey][flatColTotalKey][i].push(null === (_8 = null === (_7 = that.tree[flatRowKey]) || void 0 === _7 ? void 0 : _7[flatColKey]) || void 0 === _8 ? void 0 : _8[i]);
|
|
399
404
|
}
|
|
400
405
|
}
|
|
401
406
|
};
|
|
402
407
|
Object.keys(that.tree).forEach((flatRowKey => {
|
|
403
408
|
const rowKey = flatRowKey.split(this.stringJoinChar);
|
|
404
409
|
Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
|
|
405
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
406
|
-
for (let i = 0, len = null === (
|
|
410
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
411
|
+
if (null === (_b = null === (_a = that.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) for (let i = 0, len = 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; i < len; i++) {
|
|
407
412
|
const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
|
|
408
413
|
if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
|
|
409
414
|
const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
|
|
@@ -414,22 +419,22 @@ class Dataset {
|
|
|
414
419
|
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
415
420
|
if (!this.tree[flatRowTotalKey][flatColKey][i]) {
|
|
416
421
|
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
417
|
-
this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (
|
|
422
|
+
this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_f = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _f ? _f : ts_types_1.AggregationType.SUM](null !== (_g = null == aggRule ? void 0 : aggRule.field) && void 0 !== _g ? _g : this.indicatorKeys[i], null !== (_h = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _h ? _h : null === (_k = null === (_j = this.indicators) || void 0 === _j ? void 0 : _j.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _k ? void 0 : _k.format);
|
|
418
423
|
}
|
|
419
|
-
this.tree[flatRowTotalKey][flatColKey][i].push(null === (
|
|
424
|
+
this.tree[flatRowTotalKey][flatColKey][i].push(null === (_m = null === (_l = that.tree[flatRowKey]) || void 0 === _l ? void 0 : _l[flatColKey]) || void 0 === _m ? void 0 : _m[i]);
|
|
420
425
|
}
|
|
421
426
|
}
|
|
422
427
|
}
|
|
423
|
-
if ((null === (
|
|
428
|
+
if ((null === (_p = null === (_o = that.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotals) || 0 === this.columns.length) {
|
|
424
429
|
const flatRowTotalKey = that.rowGrandTotalLabel;
|
|
425
430
|
this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
|
|
426
431
|
this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
|
|
427
432
|
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
428
433
|
if (!this.tree[flatRowTotalKey][flatColKey][i]) {
|
|
429
434
|
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
430
|
-
this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (
|
|
435
|
+
this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_q = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _q ? _q : ts_types_1.AggregationType.SUM](null !== (_r = null == aggRule ? void 0 : aggRule.field) && void 0 !== _r ? _r : this.indicatorKeys[i], null !== (_s = null == aggRule ? void 0 : aggRule.formatFun) && void 0 !== _s ? _s : null === (_u = null === (_t = this.indicators) || void 0 === _t ? void 0 : _t.find((indicator => "string" != typeof indicator && indicator.indicatorKey === this.indicatorKeys[i]))) || void 0 === _u ? void 0 : _u.format);
|
|
431
436
|
}
|
|
432
|
-
this.tree[flatRowTotalKey][flatColKey][i].push(null === (
|
|
437
|
+
this.tree[flatRowTotalKey][flatColKey][i].push(null === (_w = null === (_v = that.tree[flatRowKey]) || void 0 === _v ? void 0 : _v[flatColKey]) || void 0 === _w ? void 0 : _w[i]);
|
|
433
438
|
}
|
|
434
439
|
}
|
|
435
440
|
colCompute(flatRowKey, flatColKey);
|
|
@@ -447,13 +452,14 @@ class Dataset {
|
|
|
447
452
|
const path = [];
|
|
448
453
|
let node;
|
|
449
454
|
list.forEach(((value, index) => {
|
|
455
|
+
var _a;
|
|
450
456
|
path.push(value);
|
|
451
457
|
const flatKey = path.join(concatStr);
|
|
452
458
|
let item = map.get(flatKey);
|
|
453
459
|
item || (item = {
|
|
454
460
|
value: value,
|
|
455
461
|
dimensionKey: rows[index],
|
|
456
|
-
children: index === list.length - 1 && (null == indicators ? void 0 : indicators.length) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
462
|
+
children: index === list.length - 1 && (null !== (_a = null == indicators ? void 0 : indicators.length) && void 0 !== _a ? _a : 0) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
457
463
|
indicatorKey: indicator,
|
|
458
464
|
value: indicator
|
|
459
465
|
} : {
|
|
@@ -475,6 +481,7 @@ class Dataset {
|
|
|
475
481
|
const path = [];
|
|
476
482
|
let node;
|
|
477
483
|
list.forEach(((value, index) => {
|
|
484
|
+
var _a, _b, _c, _d;
|
|
478
485
|
path.push(value);
|
|
479
486
|
const flatKey = path.join(concatStr);
|
|
480
487
|
let item = map.get(flatKey);
|
|
@@ -482,7 +489,7 @@ class Dataset {
|
|
|
482
489
|
if (item = {
|
|
483
490
|
value: value,
|
|
484
491
|
dimensionKey: rows[index],
|
|
485
|
-
children: index === list.length - 1 && (null == indicators ? void 0 : indicators.length) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
492
|
+
children: index === list.length - 1 && (null !== (_a = null == indicators ? void 0 : indicators.length) && void 0 !== _a ? _a : 0) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
486
493
|
indicatorKey: indicator,
|
|
487
494
|
value: indicator
|
|
488
495
|
} : {
|
|
@@ -490,12 +497,12 @@ class Dataset {
|
|
|
490
497
|
value: indicator.title
|
|
491
498
|
})) : []
|
|
492
499
|
}, subTotalFlags[index]) {
|
|
493
|
-
let curChild = item.children;
|
|
500
|
+
let curChild = null !== (_b = item.children) && void 0 !== _b ? _b : [];
|
|
494
501
|
const totalChild = {
|
|
495
502
|
value: subTotalLabel,
|
|
496
503
|
dimensionKey: rows[index + 1],
|
|
497
504
|
levelSpan: subTotalFlags.length - index - 1,
|
|
498
|
-
children: (null == indicators ? void 0 : indicators.length) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
505
|
+
children: (null !== (_c = null == indicators ? void 0 : indicators.length) && void 0 !== _c ? _c : 0) >= 1 ? null == indicators ? void 0 : indicators.map((indicator => "string" == typeof indicator ? {
|
|
499
506
|
indicatorKey: indicator,
|
|
500
507
|
value: indicator
|
|
501
508
|
} : {
|
|
@@ -503,7 +510,7 @@ class Dataset {
|
|
|
503
510
|
value: indicator.title
|
|
504
511
|
})) : []
|
|
505
512
|
};
|
|
506
|
-
curChild.push(totalChild), curChild = totalChild.children;
|
|
513
|
+
curChild.push(totalChild), curChild = null !== (_d = totalChild.children) && void 0 !== _d ? _d : [];
|
|
507
514
|
}
|
|
508
515
|
map.set(flatKey, item), node ? subTotalFlags[index - 1] && !showSubTotalsOnTop ? node.children.splice(node.children.length - 1, 0, item) : node.children.push(item) : result.push(item);
|
|
509
516
|
}
|
|
@@ -511,7 +518,10 @@ class Dataset {
|
|
|
511
518
|
}));
|
|
512
519
|
}(item))) : indicators && (result = null == indicators ? void 0 : indicators.map((indicator => {
|
|
513
520
|
var _a;
|
|
514
|
-
return {
|
|
521
|
+
return "string" == typeof indicator ? {
|
|
522
|
+
indicatorKey: indicator,
|
|
523
|
+
value: indicator
|
|
524
|
+
} : {
|
|
515
525
|
indicatorKey: indicator.indicatorKey,
|
|
516
526
|
value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
|
|
517
527
|
};
|
|
@@ -550,7 +560,10 @@ class Dataset {
|
|
|
550
560
|
var _a, _b;
|
|
551
561
|
node.indicatorKey || isHasIndicator || (null === (_a = node.children) || void 0 === _a ? void 0 : _a.length) && node.children ? node.children && Array.isArray(node.children) && checkNode(node.children, isHasIndicator || !!node.indicatorKey) : node.children = null === (_b = this.indicators) || void 0 === _b ? void 0 : _b.map((indicator => {
|
|
552
562
|
var _a;
|
|
553
|
-
return {
|
|
563
|
+
return "string" == typeof indicator ? {
|
|
564
|
+
indicatorKey: indicator,
|
|
565
|
+
value: indicator
|
|
566
|
+
} : {
|
|
554
567
|
indicatorKey: indicator.indicatorKey,
|
|
555
568
|
value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
|
|
556
569
|
};
|
|
@@ -559,7 +572,10 @@ class Dataset {
|
|
|
559
572
|
};
|
|
560
573
|
return (null == customTree ? void 0 : customTree.length) ? checkNode(customTree, !1) : customTree = null === (_a = this.indicators) || void 0 === _a ? void 0 : _a.map((indicator => {
|
|
561
574
|
var _a;
|
|
562
|
-
return {
|
|
575
|
+
return "string" == typeof indicator ? {
|
|
576
|
+
indicatorKey: indicator,
|
|
577
|
+
value: indicator
|
|
578
|
+
} : {
|
|
563
579
|
indicatorKey: indicator.indicatorKey,
|
|
564
580
|
value: null !== (_a = indicator.title) && void 0 !== _a ? _a : indicator.indicatorKey
|
|
565
581
|
};
|
|
@@ -589,6 +605,16 @@ class Dataset {
|
|
|
589
605
|
this.rowFlatKeys = {}, this.colFlatKeys = {}, this.tree = {}, this.processRecords();
|
|
590
606
|
}
|
|
591
607
|
}
|
|
608
|
+
changeDataConfig(dataConfig) {
|
|
609
|
+
this.rows = dataConfig.rows, this.columns = dataConfig.columns;
|
|
610
|
+
}
|
|
611
|
+
addRecords(records) {
|
|
612
|
+
for (let i = 0, len = records.length; i < len; i++) {
|
|
613
|
+
const record = records[i];
|
|
614
|
+
this.processRecord(record);
|
|
615
|
+
}
|
|
616
|
+
Array.isArray(this.records) && this.records.push(records);
|
|
617
|
+
}
|
|
592
618
|
}
|
|
593
619
|
|
|
594
620
|
function arraySortByAnotherArray(array, sortArray) {
|