@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/PivotTable.js
CHANGED
|
@@ -29,50 +29,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
29
29
|
value: !0
|
|
30
30
|
}), exports.PivotTable = void 0;
|
|
31
31
|
|
|
32
|
-
const ts_types_1 = require("./ts-types"), pivot_header_layout_1 = require("./layout/pivot-header-layout"), flatDataToObject_1 = require("./dataset/flatDataToObject"), PIVOT_TABLE_EVENT_TYPE_1 = require("./ts-types/pivot-table/PIVOT_TABLE_EVENT_TYPE"), helper_1 = require("./tools/helper"), dataset_1 = require("./dataset/dataset"), BaseTable_1 = require("./core/BaseTable"), title_1 = require("./components/title/title"), vutils_1 = require("@visactor/vutils"), env_1 = require("./tools/env"), TABLE_EVENT_TYPE_1 = require("./core/TABLE_EVENT_TYPE"), edit_manager_1 = require("./edit/edit-manager"), editors = __importStar(require("./edit/editors")), compute_col_width_1 = require("./scenegraph/layout/compute-col-width"), compute_row_height_1 = require("./scenegraph/layout/compute-row-height"), util_1 = require("./tools/util"), vutil_extension_temp_1 = require("./vutil-extension-temp");
|
|
32
|
+
const ts_types_1 = require("./ts-types"), pivot_header_layout_1 = require("./layout/pivot-header-layout"), flatDataToObject_1 = require("./dataset/flatDataToObject"), PIVOT_TABLE_EVENT_TYPE_1 = require("./ts-types/pivot-table/PIVOT_TABLE_EVENT_TYPE"), helper_1 = require("./tools/helper"), dataset_1 = require("./dataset/dataset"), BaseTable_1 = require("./core/BaseTable"), title_1 = require("./components/title/title"), vutils_1 = require("@visactor/vutils"), env_1 = require("./tools/env"), tree_helper_1 = require("./layout/tree-helper"), TABLE_EVENT_TYPE_1 = require("./core/TABLE_EVENT_TYPE"), edit_manager_1 = require("./edit/edit-manager"), editors = __importStar(require("./edit/editors")), compute_col_width_1 = require("./scenegraph/layout/compute-col-width"), compute_row_height_1 = require("./scenegraph/layout/compute-row-height"), util_1 = require("./tools/util"), vutil_extension_temp_1 = require("./vutil-extension-temp"), layout_helper_1 = require("./layout/layout-helper");
|
|
33
33
|
|
|
34
34
|
class PivotTable extends BaseTable_1.BaseTable {
|
|
35
35
|
constructor(container, options) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
37
|
-
"node" === env_1.Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container,
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
37
|
+
if ("node" === env_1.Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container,
|
|
38
38
|
container = container.container ? container.container : null), super(container, options),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
39
|
+
this.layoutNodeId = {
|
|
40
|
+
seqId: 0
|
|
41
|
+
}, options) {
|
|
42
|
+
options.layout && Object.assign(options, options.layout), this.internalProps.columns = (0,
|
|
43
|
+
vutils_1.cloneDeep)(options.columns), this.internalProps.rows = (0, vutils_1.cloneDeep)(options.rows),
|
|
44
|
+
this.internalProps.indicators = (0, vutil_extension_temp_1.cloneDeepSpec)(options.indicators),
|
|
45
|
+
null === (_a = options.indicators) || void 0 === _a || _a.forEach(((indicatorDefine, index) => {
|
|
46
|
+
"object" == typeof indicatorDefine && (null == indicatorDefine ? void 0 : indicatorDefine.editor) && (this.internalProps.indicators[index].editor = indicatorDefine.editor);
|
|
47
|
+
})), this.internalProps.columnTree = !options.indicatorsAsCol || (null === (_b = options.columns) || void 0 === _b ? void 0 : _b.length) || options.columnTree ? (0,
|
|
48
|
+
vutils_1.cloneDeep)(options.columnTree) : [], this.internalProps.rowTree = options.indicatorsAsCol || (null === (_c = options.rows) || void 0 === _c ? void 0 : _c.length) || options.rowTree ? (0,
|
|
49
|
+
vutils_1.cloneDeep)(options.rowTree) : [], this.internalProps.records = options.records,
|
|
50
|
+
this.pagination = options.pagination, this.internalProps.columnResizeType = null !== (_d = options.columnResizeType) && void 0 !== _d ? _d : "column",
|
|
51
|
+
this.internalProps.rowResizeType = null !== (_e = options.rowResizeType) && void 0 !== _e ? _e : "row",
|
|
52
|
+
this.internalProps.dataConfig = (0, vutils_1.cloneDeep)(options.dataConfig);
|
|
53
|
+
const records = this.internalProps.records;
|
|
54
|
+
if (this.internalProps.recordsIsTwoDimensionalArray = !1, (null === (_f = null == records ? void 0 : records[0]) || void 0 === _f ? void 0 : _f.constructor) === Array && (this.internalProps.recordsIsTwoDimensionalArray = !0),
|
|
55
|
+
!1 === (null === (_g = options.customConfig) || void 0 === _g ? void 0 : _g.enableDataAnalysis)) {
|
|
56
|
+
const columnDimensionTree = new tree_helper_1.DimensionTree(null !== (_h = this.internalProps.columnTree) && void 0 !== _h ? _h : [], this.layoutNodeId), rowDimensionTree = new tree_helper_1.DimensionTree(null !== (_j = this.internalProps.rowTree) && void 0 !== _j ? _j : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_k = this.options.rowExpandLevel) && void 0 !== _k ? _k : 1 : void 0);
|
|
57
|
+
this.internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, null, columnDimensionTree, rowDimensionTree),
|
|
58
|
+
!1 === this.internalProps.recordsIsTwoDimensionalArray && (this.flatDataToObjects = new flatDataToObject_1.FlatDataToObjects({
|
|
59
|
+
rows: this.internalProps.layoutMap.fullRowDimensionKeys,
|
|
60
|
+
columns: this.internalProps.layoutMap.colDimensionKeys,
|
|
61
|
+
indicators: this.internalProps.layoutMap.indicatorKeys,
|
|
62
|
+
indicatorsAsCol: this.internalProps.layoutMap.indicatorsAsCol,
|
|
63
|
+
indicatorDimensionKey: this.internalProps.layoutMap.indicatorDimensionKey
|
|
64
|
+
}, records));
|
|
65
|
+
} else {
|
|
66
|
+
const keysResults = (0, layout_helper_1.parseColKeyRowKeyForPivotTable)(this, options), {rowKeys: rowKeys, columnKeys: columnKeys, indicatorKeys: indicatorKeys, isNeedResetColumnDimensionTree: isNeedResetColumnDimensionTree, isNeedResetRowDimensionTree: isNeedResetRowDimensionTree} = keysResults;
|
|
67
|
+
let {columnDimensionTree: columnDimensionTree, rowDimensionTree: rowDimensionTree} = keysResults;
|
|
68
|
+
this.dataset = new dataset_1.Dataset(this.internalProps.dataConfig, rowKeys, columnKeys, indicatorKeys, this.internalProps.indicators, null === (_l = options.indicatorsAsCol) || void 0 === _l || _l, options.records, options.rowHierarchyType, this.internalProps.columnTree, this.internalProps.rowTree),
|
|
69
|
+
options.columnTree && !isNeedResetColumnDimensionTree || (columnDimensionTree = new tree_helper_1.DimensionTree(null !== (_m = this.dataset.colHeaderTree) && void 0 !== _m ? _m : [], this.layoutNodeId)),
|
|
70
|
+
options.rowTree && !isNeedResetRowDimensionTree || (rowDimensionTree = new tree_helper_1.DimensionTree(null !== (_o = this.dataset.rowHeaderTree) && void 0 !== _o ? _o : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_p = this.options.rowExpandLevel) && void 0 !== _p ? _p : 1 : void 0)),
|
|
71
|
+
this.internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, this.dataset, columnDimensionTree, rowDimensionTree);
|
|
72
|
+
}
|
|
73
|
+
this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState),
|
|
74
|
+
"node" !== env_1.Env.mode && (this.editorManager = new edit_manager_1.EditManeger(this)),
|
|
75
|
+
this.refreshHeader(), this.stateManager.initCheckedState(records), this.scenegraph.createSceneGraph(),
|
|
76
|
+
options.title && (this.internalProps.title = new title_1.Title(options.title, this),
|
|
77
|
+
this.scenegraph.resize()), setTimeout((() => {
|
|
78
|
+
this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.INITIALIZED, null);
|
|
79
|
+
}), 0);
|
|
68
80
|
}
|
|
69
|
-
this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState),
|
|
70
|
-
"node" !== env_1.Env.mode && (this.editorManager = new edit_manager_1.EditManeger(this)),
|
|
71
|
-
this.refreshHeader(), this.stateManager.initCheckedState(records), this.scenegraph.createSceneGraph(),
|
|
72
|
-
options.title && (this.internalProps.title = new title_1.Title(options.title, this),
|
|
73
|
-
this.scenegraph.resize()), setTimeout((() => {
|
|
74
|
-
this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.INITIALIZED, null);
|
|
75
|
-
}), 0);
|
|
76
81
|
}
|
|
77
82
|
static get EVENT_TYPE() {
|
|
78
83
|
return PIVOT_TABLE_EVENT_TYPE_1.PIVOT_TABLE_EVENT_TYPE;
|
|
@@ -99,10 +104,12 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
99
104
|
return ifCan;
|
|
100
105
|
}
|
|
101
106
|
updateOption(options) {
|
|
102
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
107
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
103
108
|
const internalProps = this.internalProps;
|
|
104
|
-
if (super.updateOption(options), this.
|
|
105
|
-
|
|
109
|
+
if (super.updateOption(options), this.layoutNodeId = {
|
|
110
|
+
seqId: 0
|
|
111
|
+
}, this.internalProps.columns = (0, vutils_1.cloneDeep)(options.columns), this.internalProps.rows = (0,
|
|
112
|
+
vutils_1.cloneDeep)(options.rows), this.internalProps.indicators = (null === (_a = options.indicators) || void 0 === _a ? void 0 : _a.length) ? (0,
|
|
106
113
|
vutil_extension_temp_1.cloneDeepSpec)(options.indicators) : [], null === (_b = options.indicators) || void 0 === _b || _b.forEach(((indicatorDefine, index) => {
|
|
107
114
|
"object" == typeof indicatorDefine && (null == indicatorDefine ? void 0 : indicatorDefine.editor) && (this.internalProps.indicators[index].editor = indicatorDefine.editor);
|
|
108
115
|
})), this.internalProps.columnTree = !options.indicatorsAsCol || (null === (_c = options.columns) || void 0 === _c ? void 0 : _c.length) || options.columnTree ? (0,
|
|
@@ -111,8 +118,7 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
111
118
|
this.stateManager.initCheckedState(this.internalProps.records), this.stateManager.updateDrillState(void 0, void 0, !1, !1, -1, -1),
|
|
112
119
|
this.pagination = options.pagination, internalProps.columnResizeType = null !== (_e = options.columnResizeType) && void 0 !== _e ? _e : "column",
|
|
113
120
|
internalProps.rowResizeType = null !== (_f = options.rowResizeType) && void 0 !== _f ? _f : "row",
|
|
114
|
-
internalProps.dataConfig = (0, vutils_1.cloneDeep)(options.dataConfig),
|
|
115
|
-
"tree" === (null == options ? void 0 : options.rowHierarchyType) && "tree" === this.internalProps.layoutMap.rowHierarchyType && this.internalProps.layoutMap.rowExpandLevel === (null == options ? void 0 : options.rowExpandLevel)) {
|
|
121
|
+
internalProps.dataConfig = (0, vutils_1.cloneDeep)(options.dataConfig), "tree" === (null == options ? void 0 : options.rowHierarchyType) && "tree" === this.internalProps.layoutMap.rowHierarchyType && this.internalProps.layoutMap.rowExpandLevel === (null == options ? void 0 : options.rowExpandLevel)) {
|
|
116
122
|
const beforeRowDimensions = this.internalProps.layoutMap.rowDimensionTree.tree.children;
|
|
117
123
|
null === (_g = this.internalProps.rowTree) || void 0 === _g || _g.forEach(((node, index) => {
|
|
118
124
|
const beforeRowDimension = beforeRowDimensions.find((item => item.dimensionKey === node.dimensionKey && item.value === node.value));
|
|
@@ -120,23 +126,26 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
120
126
|
}));
|
|
121
127
|
}
|
|
122
128
|
const records = this.internalProps.records;
|
|
123
|
-
if (this.internalProps.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
internalProps.
|
|
130
|
-
} else {
|
|
131
|
-
if (!Array.isArray(this.internalProps.columnTree) && !Array.isArray(this.internalProps.rowTree)) return this;
|
|
132
|
-
internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, null),
|
|
133
|
-
(null === (_m = null == records ? void 0 : records[0]) || void 0 === _m ? void 0 : _m.constructor) !== Array && (this.flatDataToObjects = new flatDataToObject_1.FlatDataToObjects({
|
|
129
|
+
if (this.internalProps.recordsIsTwoDimensionalArray = !1, (null === (_h = null == records ? void 0 : records[0]) || void 0 === _h ? void 0 : _h.constructor) === Array && (this.internalProps.recordsIsTwoDimensionalArray = !0),
|
|
130
|
+
!1 === (null === (_j = options.customConfig) || void 0 === _j ? void 0 : _j.enableDataAnalysis)) {
|
|
131
|
+
let columnDimensionTree, rowDimensionTree;
|
|
132
|
+
options.columnTree && (columnDimensionTree = new tree_helper_1.DimensionTree(null !== (_k = this.internalProps.columnTree) && void 0 !== _k ? _k : [], this.layoutNodeId)),
|
|
133
|
+
options.rowTree && (rowDimensionTree = new tree_helper_1.DimensionTree(null !== (_l = this.internalProps.rowTree) && void 0 !== _l ? _l : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_m = this.options.rowExpandLevel) && void 0 !== _m ? _m : 1 : void 0)),
|
|
134
|
+
internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, null, columnDimensionTree, rowDimensionTree),
|
|
135
|
+
!1 === this.internalProps.recordsIsTwoDimensionalArray && (this.flatDataToObjects = new flatDataToObject_1.FlatDataToObjects({
|
|
134
136
|
rows: internalProps.layoutMap.fullRowDimensionKeys,
|
|
135
137
|
columns: internalProps.layoutMap.colDimensionKeys,
|
|
136
138
|
indicators: internalProps.layoutMap.indicatorKeys,
|
|
137
139
|
indicatorsAsCol: internalProps.layoutMap.indicatorsAsCol,
|
|
138
140
|
indicatorDimensionKey: internalProps.layoutMap.indicatorDimensionKey
|
|
139
141
|
}, records));
|
|
142
|
+
} else {
|
|
143
|
+
const keysResults = (0, layout_helper_1.parseColKeyRowKeyForPivotTable)(this, options), {rowKeys: rowKeys, columnKeys: columnKeys, indicatorKeys: indicatorKeys, isNeedResetColumnDimensionTree: isNeedResetColumnDimensionTree, isNeedResetRowDimensionTree: isNeedResetRowDimensionTree} = keysResults;
|
|
144
|
+
let {columnDimensionTree: columnDimensionTree, rowDimensionTree: rowDimensionTree} = keysResults;
|
|
145
|
+
this.dataset = new dataset_1.Dataset(internalProps.dataConfig, rowKeys, columnKeys, indicatorKeys, this.internalProps.indicators, null === (_o = options.indicatorsAsCol) || void 0 === _o || _o, records, options.rowHierarchyType, this.internalProps.columnTree, this.internalProps.rowTree),
|
|
146
|
+
options.columnTree && !isNeedResetColumnDimensionTree || (columnDimensionTree = new tree_helper_1.DimensionTree(null !== (_p = this.dataset.colHeaderTree) && void 0 !== _p ? _p : [], this.layoutNodeId)),
|
|
147
|
+
options.rowTree && !isNeedResetRowDimensionTree || (rowDimensionTree = new tree_helper_1.DimensionTree(null !== (_q = this.dataset.rowHeaderTree) && void 0 !== _q ? _q : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_r = this.options.rowExpandLevel) && void 0 !== _r ? _r : 1 : void 0)),
|
|
148
|
+
internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, this.dataset, columnDimensionTree, rowDimensionTree);
|
|
140
149
|
}
|
|
141
150
|
return this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState),
|
|
142
151
|
this.refreshHeader(), internalProps.releaseList && (internalProps.releaseList.forEach((releaseObj => {
|
|
@@ -200,34 +209,37 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
200
209
|
}
|
|
201
210
|
getFieldData(field, col, row) {
|
|
202
211
|
var _a;
|
|
203
|
-
if (this.internalProps.layoutMap.isHeader(col, row))
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
212
|
+
if (!this.internalProps.layoutMap.isHeader(col, row)) {
|
|
213
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) {
|
|
214
|
+
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
215
|
+
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
216
|
+
}
|
|
217
|
+
if (this.dataset) {
|
|
218
|
+
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
|
|
219
|
+
if (cellDimensionPath) {
|
|
220
|
+
const colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
221
|
+
var _a;
|
|
222
|
+
return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
|
|
223
|
+
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
224
|
+
var _a;
|
|
225
|
+
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
226
|
+
})), aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
|
|
227
|
+
if (aggregator.records && aggregator.records.length >= 1) return aggregator.records[0][field];
|
|
228
|
+
}
|
|
229
|
+
} else if (this.flatDataToObjects) {
|
|
230
|
+
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
208
231
|
var _a;
|
|
209
232
|
return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
|
|
210
233
|
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
211
234
|
var _a;
|
|
212
235
|
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
213
|
-
})),
|
|
214
|
-
if (
|
|
236
|
+
})), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
|
|
237
|
+
if (null == treeNode ? void 0 : treeNode.record) return null == treeNode ? void 0 : treeNode.record[field];
|
|
215
238
|
}
|
|
216
|
-
} else if (this.flatDataToObjects) {
|
|
217
|
-
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
218
|
-
var _a;
|
|
219
|
-
return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
|
|
220
|
-
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
221
|
-
var _a;
|
|
222
|
-
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
223
|
-
})), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
|
|
224
|
-
if (null == treeNode ? void 0 : treeNode.record) return null == treeNode ? void 0 : treeNode.record[field];
|
|
225
239
|
}
|
|
226
|
-
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
227
|
-
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
228
240
|
}
|
|
229
241
|
getCellValue(col, row, skipCustomMerge) {
|
|
230
|
-
var _a, _b;
|
|
242
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
231
243
|
if (!skipCustomMerge) {
|
|
232
244
|
const customMergeText = this.getCustomMergeValue(col, row);
|
|
233
245
|
if (customMergeText) return customMergeText;
|
|
@@ -244,15 +256,22 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
244
256
|
const {title: title, fieldFormat: fieldFormat} = this.internalProps.layoutMap.getHeader(col, row);
|
|
245
257
|
return "function" == typeof fieldFormat ? fieldFormat(title, col, row, this) : title;
|
|
246
258
|
}
|
|
259
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) {
|
|
260
|
+
const {fieldFormat: fieldFormat} = this.internalProps.layoutMap.getBody(col, row), rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col), dataValue = null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
261
|
+
if ("function" == typeof fieldFormat) {
|
|
262
|
+
return fieldFormat(dataValue, col, row, this);
|
|
263
|
+
}
|
|
264
|
+
return dataValue;
|
|
265
|
+
}
|
|
247
266
|
if (this.dataset) {
|
|
248
|
-
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
267
|
+
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = null === (_c = null === (_b = cellDimensionPath.colHeaderPaths) || void 0 === _b ? void 0 : _b.filter((path => !path.virtual))) || void 0 === _c ? void 0 : _c.map((colPath => {
|
|
249
268
|
var _a;
|
|
250
269
|
return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
|
|
251
|
-
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
270
|
+
})), rowKeys = null === (_e = null === (_d = cellDimensionPath.rowHeaderPaths) || void 0 === _d ? void 0 : _d.filter((path => !path.virtual))) || void 0 === _e ? void 0 : _e.map((rowPath => {
|
|
252
271
|
var _a;
|
|
253
272
|
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
254
|
-
})), aggregator = this.dataset.getAggregator(
|
|
255
|
-
return aggregator.formatValue ? aggregator.formatValue(col, row, this) : "";
|
|
273
|
+
})), aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)), {fieldFormat: fieldFormat} = this.internalProps.layoutMap.getBody(col, row);
|
|
274
|
+
return aggregator.formatValue ? aggregator.formatValue(col, row, this) : "function" == typeof fieldFormat ? fieldFormat(null == aggregator ? void 0 : aggregator.value(), col, row, this) : null !== (_f = null == aggregator ? void 0 : aggregator.value()) && void 0 !== _f ? _f : "";
|
|
256
275
|
}
|
|
257
276
|
if (this.flatDataToObjects) {
|
|
258
277
|
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
@@ -262,13 +281,8 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
262
281
|
var _a;
|
|
263
282
|
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
264
283
|
})), valueNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey), {fieldFormat: fieldFormat} = this.internalProps.layoutMap.getBody(col, row);
|
|
265
|
-
return "function" == typeof fieldFormat ? fieldFormat(null == valueNode ? void 0 : valueNode.value, col, row, this) : null !== (
|
|
284
|
+
return "function" == typeof fieldFormat ? fieldFormat(null == valueNode ? void 0 : valueNode.value, col, row, this) : null !== (_g = null == valueNode ? void 0 : valueNode.value) && void 0 !== _g ? _g : "";
|
|
266
285
|
}
|
|
267
|
-
const {fieldFormat: fieldFormat} = this.internalProps.layoutMap.getBody(col, row), rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col), dataValue = null === (_b = this.records[rowIndex]) || void 0 === _b ? void 0 : _b[colIndex];
|
|
268
|
-
if ("function" == typeof fieldFormat) {
|
|
269
|
-
return fieldFormat(dataValue, col, row, this);
|
|
270
|
-
}
|
|
271
|
-
return dataValue;
|
|
272
286
|
}
|
|
273
287
|
getCellOriginValue(col, row) {
|
|
274
288
|
var _a;
|
|
@@ -277,6 +291,10 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
277
291
|
const {title: title} = table.internalProps.layoutMap.getHeader(col, row);
|
|
278
292
|
return "function" == typeof title ? title() : title;
|
|
279
293
|
}
|
|
294
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) {
|
|
295
|
+
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
296
|
+
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
297
|
+
}
|
|
280
298
|
if (this.dataset) {
|
|
281
299
|
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
282
300
|
var _a;
|
|
@@ -284,7 +302,7 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
284
302
|
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
285
303
|
var _a;
|
|
286
304
|
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
287
|
-
})), aggregator = this.dataset.getAggregator(
|
|
305
|
+
})), aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
|
|
288
306
|
return aggregator.value ? aggregator.value() : void 0;
|
|
289
307
|
}
|
|
290
308
|
if (this.flatDataToObjects) {
|
|
@@ -297,8 +315,6 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
297
315
|
})), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
|
|
298
316
|
return null == treeNode ? void 0 : treeNode.value;
|
|
299
317
|
}
|
|
300
|
-
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
301
|
-
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
302
318
|
}
|
|
303
319
|
getCellRawValue(col, row) {
|
|
304
320
|
var _a;
|
|
@@ -307,6 +323,10 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
307
323
|
const {title: title} = table.internalProps.layoutMap.getHeader(col, row);
|
|
308
324
|
return "function" == typeof title ? title() : title;
|
|
309
325
|
}
|
|
326
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) {
|
|
327
|
+
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
328
|
+
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
329
|
+
}
|
|
310
330
|
if (this.dataset) {
|
|
311
331
|
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
312
332
|
var _a;
|
|
@@ -314,7 +334,7 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
314
334
|
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
315
335
|
var _a;
|
|
316
336
|
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
317
|
-
})), aggregator = this.dataset.getAggregator(
|
|
337
|
+
})), aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), !1);
|
|
318
338
|
return aggregator.value ? aggregator.value() : void 0;
|
|
319
339
|
}
|
|
320
340
|
if (this.flatDataToObjects) {
|
|
@@ -327,60 +347,64 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
327
347
|
})), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
|
|
328
348
|
return null == treeNode ? void 0 : treeNode.value;
|
|
329
349
|
}
|
|
330
|
-
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
331
|
-
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
332
350
|
}
|
|
333
351
|
getCellOriginRecord(col, row) {
|
|
334
352
|
var _a;
|
|
335
|
-
if (this.internalProps.layoutMap.isHeader(col, row))
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
if (!this.internalProps.layoutMap.isHeader(col, row)) {
|
|
354
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) {
|
|
355
|
+
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
356
|
+
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
357
|
+
}
|
|
358
|
+
if (this.dataset) {
|
|
359
|
+
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
360
|
+
var _a;
|
|
361
|
+
return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
|
|
362
|
+
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
363
|
+
var _a;
|
|
364
|
+
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
365
|
+
}));
|
|
366
|
+
return this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
|
|
367
|
+
}
|
|
368
|
+
if (this.flatDataToObjects) {
|
|
369
|
+
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
370
|
+
var _a;
|
|
371
|
+
return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
|
|
372
|
+
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
373
|
+
var _a;
|
|
374
|
+
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
375
|
+
})), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
|
|
376
|
+
return null == treeNode ? void 0 : treeNode.record;
|
|
377
|
+
}
|
|
355
378
|
}
|
|
356
|
-
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
357
|
-
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
358
379
|
}
|
|
359
380
|
getCellRawRecord(col, row) {
|
|
360
381
|
var _a;
|
|
361
|
-
if (this.internalProps.layoutMap.isHeader(col, row))
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
382
|
+
if (!this.internalProps.layoutMap.isHeader(col, row)) {
|
|
383
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) {
|
|
384
|
+
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
385
|
+
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
386
|
+
}
|
|
387
|
+
if (this.dataset) {
|
|
388
|
+
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
389
|
+
var _a;
|
|
390
|
+
return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
|
|
391
|
+
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
392
|
+
var _a;
|
|
393
|
+
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
394
|
+
}));
|
|
395
|
+
return this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
|
|
396
|
+
}
|
|
397
|
+
if (this.flatDataToObjects) {
|
|
398
|
+
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
|
|
399
|
+
var _a;
|
|
400
|
+
return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
|
|
401
|
+
})), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
|
|
402
|
+
var _a;
|
|
403
|
+
return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
|
|
404
|
+
})), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
|
|
405
|
+
return null == treeNode ? void 0 : treeNode.record;
|
|
406
|
+
}
|
|
381
407
|
}
|
|
382
|
-
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
383
|
-
return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
|
|
384
408
|
}
|
|
385
409
|
updateSortRules(sortRules) {
|
|
386
410
|
this.internalProps.dataConfig.sortRules = sortRules, this.dataset.updateSortRules(sortRules),
|
|
@@ -406,18 +430,17 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
406
430
|
}
|
|
407
431
|
}
|
|
408
432
|
_moveHeaderPosition(source, target) {
|
|
409
|
-
var _a, _b, _c, _d;
|
|
410
433
|
const sourceCellRange = this.getCellRange(source.col, source.row), targetCellRange = this.getCellRange(target.col, target.row), moveContext = this.internalProps.layoutMap.moveHeaderPosition(source, target);
|
|
411
434
|
if (moveContext) {
|
|
412
435
|
if ("column" === moveContext.moveType) {
|
|
413
|
-
if (
|
|
436
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) for (let row = 0; row < this.internalProps.records.length; row++) {
|
|
414
437
|
const sourceColumns = this.internalProps.records[row].splice(moveContext.sourceIndex - this.rowHeaderLevelCount, moveContext.sourceSize);
|
|
415
438
|
sourceColumns.unshift(moveContext.targetIndex - this.rowHeaderLevelCount, 0), Array.prototype.splice.apply(this.internalProps.records[row], sourceColumns);
|
|
416
439
|
}
|
|
417
440
|
this.colWidthsMap.exchangeOrder(sourceCellRange.start.col, sourceCellRange.end.col - sourceCellRange.start.col + 1, targetCellRange.start.col, targetCellRange.end.col - targetCellRange.start.col + 1, moveContext.targetIndex),
|
|
418
441
|
this.setMinMaxLimitWidth();
|
|
419
442
|
} else if ("row" === moveContext.moveType) {
|
|
420
|
-
if (
|
|
443
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) {
|
|
421
444
|
const sourceRows = this.internalProps.records.splice(moveContext.sourceIndex - this.columnHeaderLevelCount, moveContext.sourceSize);
|
|
422
445
|
sourceRows.unshift(moveContext.targetIndex - this.columnHeaderLevelCount, 0), Array.prototype.splice.apply(this.internalProps.records, sourceRows);
|
|
423
446
|
}
|
|
@@ -435,7 +458,7 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
435
458
|
row: row,
|
|
436
459
|
hierarchyState: ts_types_1.HierarchyState.collapse
|
|
437
460
|
}); else if (hierarchyState === ts_types_1.HierarchyState.collapse) {
|
|
438
|
-
const
|
|
461
|
+
const headerTreeNode = this.internalProps.layoutMap.getHeadNode(col, row);
|
|
439
462
|
Array.isArray(headerTreeNode.children) && this._refreshHierarchyState(col, row),
|
|
440
463
|
this.fireListeners(PIVOT_TABLE_EVENT_TYPE_1.PIVOT_TABLE_EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE, {
|
|
441
464
|
col: col,
|
|
@@ -486,7 +509,7 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
486
509
|
return this.internalProps.layoutMap.getLayoutRowTreeCount();
|
|
487
510
|
}
|
|
488
511
|
getCellHeaderTreeNodes(col, row) {
|
|
489
|
-
return this.internalProps.layoutMap.
|
|
512
|
+
return this.internalProps.layoutMap.getCellHeaderPathsWithTreeNode(col, row);
|
|
490
513
|
}
|
|
491
514
|
_hasHierarchyTreeHeader() {
|
|
492
515
|
return "tree" === this.internalProps.layoutMap.rowHierarchyType;
|
|
@@ -502,22 +525,28 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
502
525
|
};
|
|
503
526
|
}
|
|
504
527
|
setRecords(records) {
|
|
505
|
-
var _a;
|
|
528
|
+
var _a, _b, _c, _d, _e;
|
|
506
529
|
const oldHoverState = {
|
|
507
530
|
col: this.stateManager.hover.cellPos.col,
|
|
508
531
|
row: this.stateManager.hover.cellPos.row
|
|
509
532
|
};
|
|
510
|
-
this.options.records = this.internalProps.records = records
|
|
533
|
+
this.options.records = this.internalProps.records = records, this.internalProps.recordsIsTwoDimensionalArray = !1,
|
|
534
|
+
(null === (_a = null == records ? void 0 : records[0]) || void 0 === _a ? void 0 : _a.constructor) === Array && (this.internalProps.recordsIsTwoDimensionalArray = !0);
|
|
511
535
|
const options = this.options, internalProps = this.internalProps;
|
|
512
|
-
|
|
513
|
-
internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, this.dataset),
|
|
514
|
-
this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState)) : (Array.isArray(this.internalProps.columnTree) || Array.isArray(this.internalProps.rowTree)) && (null === (_a = null == records ? void 0 : records[0]) || void 0 === _a ? void 0 : _a.constructor) !== Array && (this.flatDataToObjects = new flatDataToObject_1.FlatDataToObjects({
|
|
536
|
+
if (!1 === (null === (_b = this.options.customConfig) || void 0 === _b ? void 0 : _b.enableDataAnalysis)) !1 === this.internalProps.recordsIsTwoDimensionalArray && (this.flatDataToObjects = new flatDataToObject_1.FlatDataToObjects({
|
|
515
537
|
rows: internalProps.layoutMap.fullRowDimensionKeys,
|
|
516
538
|
columns: internalProps.layoutMap.colDimensionKeys,
|
|
517
539
|
indicators: internalProps.layoutMap.indicatorKeys,
|
|
518
540
|
indicatorsAsCol: internalProps.layoutMap.indicatorsAsCol,
|
|
519
541
|
indicatorDimensionKey: internalProps.layoutMap.indicatorDimensionKey
|
|
520
|
-
}, records))
|
|
542
|
+
}, records)); else {
|
|
543
|
+
let columnDimensionTree, rowDimensionTree;
|
|
544
|
+
this.dataset.setRecords(records), columnDimensionTree = options.columnTree ? internalProps.layoutMap.columnDimensionTree : new tree_helper_1.DimensionTree(null !== (_c = this.dataset.colHeaderTree) && void 0 !== _c ? _c : [], this.layoutNodeId),
|
|
545
|
+
rowDimensionTree = options.rowTree ? internalProps.layoutMap.rowDimensionTree : new tree_helper_1.DimensionTree(null !== (_d = this.dataset.rowHeaderTree) && void 0 !== _d ? _d : [], this.layoutNodeId, this.options.rowHierarchyType, "tree" === this.options.rowHierarchyType ? null !== (_e = this.options.rowExpandLevel) && void 0 !== _e ? _e : 1 : void 0),
|
|
546
|
+
internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, this.dataset, columnDimensionTree, rowDimensionTree),
|
|
547
|
+
this.pivotSortState = [], options.pivotSortState && this.updatePivotSortState(options.pivotSortState);
|
|
548
|
+
}
|
|
549
|
+
this.refreshHeader(), this.scenegraph.clearCells(), this.clearCellStyleCache(),
|
|
521
550
|
this.scenegraph.createSceneGraph(), this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row),
|
|
522
551
|
this.internalProps.title && !this.internalProps.title.isReleased && (this._updateSize(),
|
|
523
552
|
this.internalProps.title.resize(), this.scenegraph.resize()), this.eventManager.updateEventBinder();
|
|
@@ -635,7 +664,10 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
635
664
|
}
|
|
636
665
|
_changeCellValueToDataSet(col, row, oldValue, newValue) {
|
|
637
666
|
var _a, _b, _c, _d, _e, _f;
|
|
638
|
-
if (this.
|
|
667
|
+
if (this.internalProps.recordsIsTwoDimensionalArray) {
|
|
668
|
+
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
669
|
+
this.records[rowIndex][colIndex] = newValue;
|
|
670
|
+
} else if (this.dataset) {
|
|
639
671
|
const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
|
|
640
672
|
if (this.isHeader(col, row)) this.internalProps.layoutMap.changeTreeNodeTitle(col, row, newValue),
|
|
641
673
|
!this.isCornerHeader(col, row) && this.dataset.changeRecordFieldValue((null === (_a = cellDimensionPath.colHeaderPaths) || void 0 === _a ? void 0 : _a.length) ? null !== (_b = cellDimensionPath.colHeaderPaths[cellDimensionPath.colHeaderPaths.length - 1].indicatorKey) && void 0 !== _b ? _b : cellDimensionPath.colHeaderPaths[cellDimensionPath.colHeaderPaths.length - 1].dimensionKey : null !== (_c = cellDimensionPath.rowHeaderPaths[cellDimensionPath.rowHeaderPaths.length - 1].indicatorKey) && void 0 !== _c ? _c : cellDimensionPath.rowHeaderPaths[cellDimensionPath.rowHeaderPaths.length - 1].dimensionKey, oldValue, newValue); else {
|
|
@@ -661,9 +693,6 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
661
693
|
}));
|
|
662
694
|
this.flatDataToObjects.changeTreeNodeValue(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, newValue);
|
|
663
695
|
}
|
|
664
|
-
} else {
|
|
665
|
-
const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
|
|
666
|
-
this.records[rowIndex][colIndex] = newValue;
|
|
667
696
|
}
|
|
668
697
|
}
|
|
669
698
|
_hasCustomRenderOrLayout() {
|
|
@@ -686,9 +715,7 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
686
715
|
changeRecordOrder(source, target) {}
|
|
687
716
|
setTreeNodeChildren(children, records, col, row) {
|
|
688
717
|
if (this.flatDataToObjects) {
|
|
689
|
-
|
|
690
|
-
this.internalProps.layoutMap.getHeadNode(headerPaths.rowHeaderPaths.slice(0, headerPaths.rowHeaderPaths.length)).children = children,
|
|
691
|
-
this._refreshHierarchyState(col, row, (() => {
|
|
718
|
+
this.internalProps.layoutMap.getHeadNode(col, row).children = children, this._refreshHierarchyState(col, row, (() => {
|
|
692
719
|
this.flatDataToObjects.changeDataConfig({
|
|
693
720
|
rows: this.internalProps.layoutMap.fullRowDimensionKeys,
|
|
694
721
|
columns: this.internalProps.layoutMap.colDimensionKeys,
|
|
@@ -697,6 +724,13 @@ class PivotTable extends BaseTable_1.BaseTable {
|
|
|
697
724
|
indicatorDimensionKey: this.internalProps.layoutMap.indicatorDimensionKey
|
|
698
725
|
}), this.flatDataToObjects.addRecords(records);
|
|
699
726
|
}));
|
|
727
|
+
} else {
|
|
728
|
+
this.internalProps.layoutMap.getHeadNode(col, row).children = children, this._refreshHierarchyState(col, row, (() => {
|
|
729
|
+
this.dataset.changeDataConfig({
|
|
730
|
+
rows: this.internalProps.layoutMap.fullRowDimensionKeys,
|
|
731
|
+
columns: this.internalProps.layoutMap.colDimensionKeys
|
|
732
|
+
}), this.dataset.addRecords(records);
|
|
733
|
+
}));
|
|
700
734
|
}
|
|
701
735
|
}
|
|
702
736
|
}
|