@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.
Files changed (121) hide show
  1. package/cjs/PivotChart.d.ts +9 -0
  2. package/cjs/PivotChart.js +90 -28
  3. package/cjs/PivotChart.js.map +1 -1
  4. package/cjs/PivotTable.d.ts +5 -2
  5. package/cjs/PivotTable.js +186 -152
  6. package/cjs/PivotTable.js.map +1 -1
  7. package/cjs/core/BaseTable.js +1 -1
  8. package/cjs/core/BaseTable.js.map +1 -1
  9. package/cjs/dataset/dataset.d.ts +20 -15
  10. package/cjs/dataset/dataset.js +85 -59
  11. package/cjs/dataset/dataset.js.map +1 -1
  12. package/cjs/dataset/statistics-helper.d.ts +13 -2
  13. package/cjs/dataset/statistics-helper.js +22 -27
  14. package/cjs/dataset/statistics-helper.js.map +1 -1
  15. package/cjs/index.d.ts +1 -1
  16. package/cjs/index.js +1 -1
  17. package/cjs/index.js.map +1 -1
  18. package/cjs/layout/chart-helper/get-chart-spec.d.ts +2 -1
  19. package/cjs/layout/chart-helper/get-chart-spec.js +3 -3
  20. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  21. package/cjs/layout/layout-helper.d.ts +12 -0
  22. package/cjs/layout/layout-helper.js +52 -4
  23. package/cjs/layout/layout-helper.js.map +1 -1
  24. package/cjs/layout/pivot-header-layout.d.ts +4 -3
  25. package/cjs/layout/pivot-header-layout.js +36 -46
  26. package/cjs/layout/pivot-header-layout.js.map +1 -1
  27. package/cjs/layout/tree-helper.d.ts +1 -0
  28. package/cjs/layout/tree-helper.js +12 -7
  29. package/cjs/layout/tree-helper.js.map +1 -1
  30. package/cjs/state/cell-move/adjust-header.js +1 -1
  31. package/cjs/state/cell-move/adjust-header.js.map +1 -1
  32. package/cjs/state/resize/update-resize-column.js +1 -1
  33. package/cjs/state/resize/update-resize-column.js.map +1 -1
  34. package/cjs/state/resize/update-resize-row.js +5 -4
  35. package/cjs/state/resize/update-resize-row.js.map +1 -1
  36. package/cjs/themes/ARCO.js +1 -1
  37. package/cjs/themes/BRIGHT.js +1 -1
  38. package/cjs/themes/DARK.js +1 -1
  39. package/cjs/themes/DEFAULT.js +1 -1
  40. package/cjs/themes/SIMPLIFY.js +1 -1
  41. package/cjs/tools/LimitPromiseQueue.js +1 -1
  42. package/cjs/tools/NumberMap.js +1 -1
  43. package/cjs/tools/Rect.js +1 -1
  44. package/cjs/tools/calc.js +1 -1
  45. package/cjs/tools/debounce.js +1 -1
  46. package/cjs/tools/get-data-path/create-dataset.d.ts +9 -1
  47. package/cjs/tools/get-data-path/create-dataset.js +19 -8
  48. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  49. package/cjs/tools/get-data-path/index.js +12 -3
  50. package/cjs/tools/get-data-path/index.js.map +1 -1
  51. package/cjs/ts-types/base-table.d.ts +6 -2
  52. package/cjs/ts-types/base-table.js.map +1 -1
  53. package/cjs/ts-types/common.d.ts +2 -0
  54. package/cjs/ts-types/common.js.map +1 -1
  55. package/cjs/ts-types/menu.d.ts +1 -1
  56. package/cjs/ts-types/menu.js.map +1 -1
  57. package/cjs/ts-types/table-engine.d.ts +1 -0
  58. package/cjs/ts-types/table-engine.js.map +1 -1
  59. package/cjs/vrender.js.map +1 -1
  60. package/dist/vtable.js +882 -546
  61. package/dist/vtable.min.js +2 -2
  62. package/es/PivotChart.d.ts +9 -0
  63. package/es/PivotChart.js +97 -29
  64. package/es/PivotChart.js.map +1 -1
  65. package/es/PivotTable.d.ts +5 -2
  66. package/es/PivotTable.js +188 -148
  67. package/es/PivotTable.js.map +1 -1
  68. package/es/core/BaseTable.js +1 -1
  69. package/es/core/BaseTable.js.map +1 -1
  70. package/es/dataset/dataset.d.ts +20 -15
  71. package/es/dataset/dataset.js +85 -59
  72. package/es/dataset/dataset.js.map +1 -1
  73. package/es/dataset/statistics-helper.d.ts +13 -2
  74. package/es/dataset/statistics-helper.js +22 -27
  75. package/es/dataset/statistics-helper.js.map +1 -1
  76. package/es/index.d.ts +1 -1
  77. package/es/index.js +1 -1
  78. package/es/index.js.map +1 -1
  79. package/es/layout/chart-helper/get-chart-spec.d.ts +2 -1
  80. package/es/layout/chart-helper/get-chart-spec.js +3 -3
  81. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  82. package/es/layout/layout-helper.d.ts +12 -0
  83. package/es/layout/layout-helper.js +50 -0
  84. package/es/layout/layout-helper.js.map +1 -1
  85. package/es/layout/pivot-header-layout.d.ts +4 -3
  86. package/es/layout/pivot-header-layout.js +34 -45
  87. package/es/layout/pivot-header-layout.js.map +1 -1
  88. package/es/layout/tree-helper.d.ts +1 -0
  89. package/es/layout/tree-helper.js +12 -7
  90. package/es/layout/tree-helper.js.map +1 -1
  91. package/es/state/cell-move/adjust-header.js +1 -1
  92. package/es/state/cell-move/adjust-header.js.map +1 -1
  93. package/es/state/resize/update-resize-column.js +1 -1
  94. package/es/state/resize/update-resize-column.js.map +1 -1
  95. package/es/state/resize/update-resize-row.js +5 -4
  96. package/es/state/resize/update-resize-row.js.map +1 -1
  97. package/es/themes/ARCO.js +1 -1
  98. package/es/themes/BRIGHT.js +1 -1
  99. package/es/themes/DARK.js +1 -1
  100. package/es/themes/DEFAULT.js +1 -1
  101. package/es/themes/SIMPLIFY.js +1 -1
  102. package/es/tools/LimitPromiseQueue.js +1 -1
  103. package/es/tools/NumberMap.js +1 -1
  104. package/es/tools/Rect.js +1 -1
  105. package/es/tools/calc.js +1 -1
  106. package/es/tools/debounce.js +1 -1
  107. package/es/tools/get-data-path/create-dataset.d.ts +9 -1
  108. package/es/tools/get-data-path/create-dataset.js +20 -7
  109. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  110. package/es/tools/get-data-path/index.js +15 -2
  111. package/es/tools/get-data-path/index.js.map +1 -1
  112. package/es/ts-types/base-table.d.ts +6 -2
  113. package/es/ts-types/base-table.js.map +1 -1
  114. package/es/ts-types/common.d.ts +2 -0
  115. package/es/ts-types/common.js.map +1 -1
  116. package/es/ts-types/menu.d.ts +1 -1
  117. package/es/ts-types/menu.js.map +1 -1
  118. package/es/ts-types/table-engine.d.ts +1 -0
  119. package/es/ts-types/table-engine.js.map +1 -1
  120. package/es/vrender.js.map +1 -1
  121. 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
- options.layout && Object.assign(options, options.layout), this.internalProps.columns = (0,
40
- vutils_1.cloneDeep)(options.columns), this.internalProps.rows = (0, vutils_1.cloneDeep)(options.rows),
41
- this.internalProps.indicators = (0, vutil_extension_temp_1.cloneDeepSpec)(options.indicators),
42
- null === (_a = options.indicators) || void 0 === _a || _a.forEach(((indicatorDefine, index) => {
43
- "object" == typeof indicatorDefine && (null == indicatorDefine ? void 0 : indicatorDefine.editor) && (this.internalProps.indicators[index].editor = indicatorDefine.editor);
44
- })), this.internalProps.columnTree = !options.indicatorsAsCol || (null === (_b = options.columns) || void 0 === _b ? void 0 : _b.length) || options.columnTree ? (0,
45
- vutils_1.cloneDeep)(options.columnTree) : [], this.internalProps.rowTree = options.indicatorsAsCol || (null === (_c = options.rows) || void 0 === _c ? void 0 : _c.length) || options.rowTree ? (0,
46
- vutils_1.cloneDeep)(options.rowTree) : [], this.internalProps.records = options.records,
47
- this.pagination = options.pagination, this.internalProps.columnResizeType = null !== (_d = options.columnResizeType) && void 0 !== _d ? _d : "column",
48
- this.internalProps.rowResizeType = null !== (_e = options.rowResizeType) && void 0 !== _e ? _e : "row",
49
- this.internalProps.dataConfig = (0, vutils_1.cloneDeep)(options.dataConfig), options.rowTree || options.columnTree ? this.internalProps.enableDataAnalysis = !1 : this.internalProps.enableDataAnalysis = !0;
50
- const records = this.internalProps.records;
51
- if (this.internalProps.enableDataAnalysis && (options.rows || options.columns)) {
52
- const rowKeys = null !== (_g = null === (_f = options.rows) || void 0 === _f ? void 0 : _f.reduce(((keys, rowObj) => ("string" == typeof rowObj ? keys.push(rowObj) : keys.push(rowObj.dimensionKey),
53
- keys)), [])) && void 0 !== _g ? _g : [], columnKeys = null !== (_j = null === (_h = options.columns) || void 0 === _h ? void 0 : _h.reduce(((keys, columnObj) => ("string" == typeof columnObj ? keys.push(columnObj) : keys.push(columnObj.dimensionKey),
54
- keys)), [])) && void 0 !== _j ? _j : [], indicatorKeys = null !== (_l = null === (_k = options.indicators) || void 0 === _k ? void 0 : _k.reduce(((keys, indicatorObj) => ("string" == typeof indicatorObj ? keys.push(indicatorObj) : keys.push(indicatorObj.indicatorKey),
55
- keys)), [])) && void 0 !== _l ? _l : [];
56
- this.dataset = new dataset_1.Dataset(this.internalProps.dataConfig, rowKeys, columnKeys, indicatorKeys, this.internalProps.indicators, null === (_m = options.indicatorsAsCol) || void 0 === _m || _m, options.records, options.rowHierarchyType, this.internalProps.columnTree, this.internalProps.rowTree),
57
- this.internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, this.dataset);
58
- } else {
59
- if (!Array.isArray(this.internalProps.columnTree) && !Array.isArray(this.internalProps.rowTree)) return;
60
- this.internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, null),
61
- (null === (_o = null == records ? void 0 : records[0]) || void 0 === _o ? void 0 : _o.constructor) !== Array && (this.flatDataToObjects = new flatDataToObject_1.FlatDataToObjects({
62
- rows: this.internalProps.layoutMap.fullRowDimensionKeys,
63
- columns: this.internalProps.layoutMap.colDimensionKeys,
64
- indicators: this.internalProps.layoutMap.indicatorKeys,
65
- indicatorsAsCol: this.internalProps.layoutMap.indicatorsAsCol,
66
- indicatorDimensionKey: this.internalProps.layoutMap.indicatorDimensionKey
67
- }, records));
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.internalProps.columns = (0, vutils_1.cloneDeep)(options.columns),
105
- this.internalProps.rows = (0, vutils_1.cloneDeep)(options.rows), this.internalProps.indicators = (null === (_a = options.indicators) || void 0 === _a ? void 0 : _a.length) ? (0,
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), options.rowTree || options.columnTree ? internalProps.enableDataAnalysis = !1 : internalProps.enableDataAnalysis = !0,
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.enableDataAnalysis && (options.rows || options.columns)) {
124
- const rowKeys = null === (_h = options.rows) || void 0 === _h ? void 0 : _h.reduce(((keys, rowObj) => ("string" == typeof rowObj ? keys.push(rowObj) : keys.push(rowObj.dimensionKey),
125
- keys)), []), columnKeys = null === (_j = options.columns) || void 0 === _j ? void 0 : _j.reduce(((keys, columnObj) => ("string" == typeof columnObj ? keys.push(columnObj) : keys.push(columnObj.dimensionKey),
126
- keys)), []), indicatorKeys = null === (_k = options.indicators) || void 0 === _k ? void 0 : _k.reduce(((keys, indicatorObj) => ("string" == typeof indicatorObj ? keys.push(indicatorObj) : keys.push(indicatorObj.indicatorKey),
127
- keys)), []);
128
- this.dataset = new dataset_1.Dataset(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),
129
- internalProps.layoutMap = new pivot_header_layout_1.PivotHeaderLayoutMap(this, this.dataset);
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)) return;
204
- if (this.dataset) {
205
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
206
- if (cellDimensionPath) {
207
- const colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
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
- })), aggregator = this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
214
- if (aggregator.records && aggregator.records.length >= 1) return aggregator.records[0][field];
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(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
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 !== (_a = null == valueNode ? void 0 : valueNode.value) && void 0 !== _a ? _a : "";
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(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
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(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), !1);
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)) return;
336
- if (this.dataset) {
337
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
338
- var _a;
339
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
340
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
341
- var _a;
342
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
343
- }));
344
- return this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
345
- }
346
- if (this.flatDataToObjects) {
347
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
348
- var _a;
349
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
350
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
351
- var _a;
352
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
353
- })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
354
- return null == treeNode ? void 0 : treeNode.record;
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)) return;
362
- if (this.dataset) {
363
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
364
- var _a;
365
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
366
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
367
- var _a;
368
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
369
- }));
370
- return this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
371
- }
372
- if (this.flatDataToObjects) {
373
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
374
- var _a;
375
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
376
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
377
- var _a;
378
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
379
- })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
380
- return null == treeNode ? void 0 : treeNode.record;
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 ((null === (_b = null === (_a = this.options.records) || void 0 === _a ? void 0 : _a[0]) || void 0 === _b ? void 0 : _b.constructor) === Array) for (let row = 0; row < this.internalProps.records.length; row++) {
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 ((null === (_d = null === (_c = this.options.records) || void 0 === _c ? void 0 : _c[0]) || void 0 === _d ? void 0 : _d.constructor) === Array) {
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 headerPaths = this.internalProps.layoutMap.getCellHeaderPaths(col, row), headerTreeNode = this.internalProps.layoutMap.getHeadNode(headerPaths.rowHeaderPaths.slice(0, headerPaths.rowHeaderPaths.length));
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.getCellHeaderPathsWidthTreeNode(col, row);
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
- this.internalProps.enableDataAnalysis && (options.rows || options.columns) ? (this.dataset.setRecords(records),
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)), this.refreshHeader(), this.scenegraph.clearCells(), this.clearCellStyleCache(),
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.dataset) {
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
- const headerPaths = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
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
  }