@visactor/vtable 0.11.1-alpha.9 → 0.12.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 (247) hide show
  1. package/cjs/ListTable.d.ts +0 -2
  2. package/cjs/ListTable.js +10 -16
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotChart.d.ts +2 -2
  5. package/cjs/PivotChart.js +53 -28
  6. package/cjs/PivotChart.js.map +1 -1
  7. package/cjs/PivotTable.d.ts +1 -1
  8. package/cjs/PivotTable.js +63 -31
  9. package/cjs/PivotTable.js.map +1 -1
  10. package/cjs/core/BaseTable.js +6 -6
  11. package/cjs/core/BaseTable.js.map +1 -1
  12. package/cjs/dataset/dataset-pivot-table.js +5 -12
  13. package/cjs/dataset/dataset.d.ts +9 -8
  14. package/cjs/dataset/dataset.js +105 -61
  15. package/cjs/dataset/dataset.js.map +1 -1
  16. package/cjs/dataset/flatDataToObject.js +2 -3
  17. package/cjs/event/event.js +2 -1
  18. package/cjs/event/event.js.map +1 -1
  19. package/cjs/event/listener/container-dom.js +1 -1
  20. package/cjs/event/listener/scroll-bar.js +6 -6
  21. package/cjs/event/listener/scroll-bar.js.map +1 -1
  22. package/cjs/event/pivot-chart/axis-click.js.map +1 -1
  23. package/cjs/event/pivot-chart/axis-hover.js.map +1 -1
  24. package/cjs/event/sparkline-event.js.map +1 -1
  25. package/cjs/index.d.ts +1 -2
  26. package/cjs/index.js +2 -3
  27. package/cjs/index.js.map +1 -1
  28. package/cjs/layout/chart-helper/get-axis-config.d.ts +4 -4
  29. package/cjs/layout/chart-helper/get-axis-config.js +25 -23
  30. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  31. package/cjs/layout/chart-helper/get-axis-domain.d.ts +1 -1
  32. package/cjs/layout/chart-helper/get-axis-domain.js +2 -2
  33. package/cjs/layout/chart-helper/get-axis-domain.js.map +1 -1
  34. package/cjs/layout/chart-helper/get-chart-spec.d.ts +4 -5
  35. package/cjs/layout/chart-helper/get-chart-spec.js +14 -13
  36. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  37. package/cjs/layout/pivot-header-layout.d.ts +58 -44
  38. package/cjs/layout/pivot-header-layout.js +425 -200
  39. package/cjs/layout/pivot-header-layout.js.map +1 -1
  40. package/cjs/layout/pivot-layout-helper.d.ts +40 -0
  41. package/cjs/layout/pivot-layout-helper.js +96 -0
  42. package/cjs/layout/pivot-layout-helper.js.map +1 -0
  43. package/cjs/layout/pivot-layout.d.ts +1 -145
  44. package/cjs/layout/pivot-layout.js +0 -819
  45. package/cjs/layout/pivot-layout.js.map +1 -1
  46. package/cjs/layout/simple-header-layout.d.ts +1 -1
  47. package/cjs/layout/simple-header-layout.js +2 -2
  48. package/cjs/layout/simple-header-layout.js.map +1 -1
  49. package/cjs/scenegraph/component/menu.d.ts +41 -0
  50. package/cjs/scenegraph/context/module.js +2 -4
  51. package/cjs/scenegraph/debug-tool/debug-tool.js +1 -1
  52. package/cjs/scenegraph/graphic/chart.js.map +1 -1
  53. package/cjs/scenegraph/graphic/contributions/chart-render.js +2 -2
  54. package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  55. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js +9 -9
  56. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  57. package/cjs/scenegraph/graphic/contributions/image-contribution-render.js +3 -3
  58. package/cjs/scenegraph/graphic/contributions/image-contribution-render.js.map +1 -1
  59. package/cjs/scenegraph/graphic/contributions/index.d.ts +1 -1
  60. package/cjs/scenegraph/graphic/contributions/index.js +2 -2
  61. package/cjs/scenegraph/graphic/contributions/index.js.map +1 -1
  62. package/cjs/scenegraph/graphic/contributions/rect-contribution-render.js +3 -3
  63. package/cjs/scenegraph/graphic/contributions/rect-contribution-render.js.map +1 -1
  64. package/cjs/scenegraph/graphic/group.d.ts +3 -0
  65. package/cjs/scenegraph/graphic/group.js +20 -0
  66. package/cjs/scenegraph/graphic/group.js.map +1 -1
  67. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  68. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js +1 -1
  69. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  70. package/cjs/scenegraph/group-creater/progress/proxy.d.ts +3 -0
  71. package/cjs/scenegraph/group-creater/progress/proxy.js +15 -13
  72. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  73. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +2 -3
  74. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  75. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +1 -1
  76. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  77. package/cjs/scenegraph/layout/compute-col-width.js +1 -1
  78. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  79. package/cjs/scenegraph/layout/compute-row-height.js +2 -2
  80. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  81. package/cjs/scenegraph/layout/update-row.d.ts +1 -1
  82. package/cjs/scenegraph/layout/update-row.js +5 -1
  83. package/cjs/scenegraph/layout/update-row.js.map +1 -1
  84. package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
  85. package/cjs/scenegraph/scenegraph.d.ts +1 -1
  86. package/cjs/scenegraph/scenegraph.js +9 -6
  87. package/cjs/scenegraph/scenegraph.js.map +1 -1
  88. package/cjs/scenegraph/utils/break-string.js +3 -4
  89. package/cjs/scenegraph/utils/deal-promise-data.js +1 -3
  90. package/cjs/scenegraph/utils/render-service.d.ts +7 -0
  91. package/cjs/scenegraph/utils/render-service.js +27 -0
  92. package/cjs/scenegraph/utils/render-service.js.map +1 -0
  93. package/{es/scenegraph/utils/measure-text.d.ts → cjs/scenegraph/utils/text-measure.d.ts} +10 -3
  94. package/cjs/scenegraph/utils/{measure-text.js → text-measure.js} +30 -15
  95. package/cjs/scenegraph/utils/text-measure.js.map +1 -0
  96. package/cjs/state/state.d.ts +1 -0
  97. package/cjs/state/state.js +4 -2
  98. package/cjs/state/state.js.map +1 -1
  99. package/cjs/themes/BRIGHT.js +1 -2
  100. package/cjs/themes/DARK.js +2 -1
  101. package/cjs/tools/LimitPromiseQueue.js +1 -1
  102. package/cjs/tools/calc.js +1 -1
  103. package/cjs/tools/diff-cell.d.ts +9 -2
  104. package/cjs/tools/diff-cell.js +16 -4
  105. package/cjs/tools/diff-cell.js.map +1 -1
  106. package/cjs/tools/get-data-path/create-dataset.js +2 -2
  107. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  108. package/cjs/tools/get-data-path/index.js +9 -4
  109. package/cjs/tools/get-data-path/index.js.map +1 -1
  110. package/cjs/tools/isx.d.ts +1 -1
  111. package/cjs/tools/util.d.ts +1 -3
  112. package/cjs/tools/util.js +2 -33
  113. package/cjs/tools/util.js.map +1 -1
  114. package/cjs/ts-types/base-table.d.ts +14 -6
  115. package/cjs/ts-types/base-table.js.map +1 -1
  116. package/cjs/ts-types/list-table/layout-map/api.d.ts +2 -2
  117. package/cjs/ts-types/list-table/layout-map/api.js.map +1 -1
  118. package/cjs/ts-types/new-data-set.js.map +1 -1
  119. package/cjs/ts-types/table-engine.d.ts +9 -0
  120. package/cjs/ts-types/table-engine.js.map +1 -1
  121. package/dist/vtable.js +58066 -69799
  122. package/dist/vtable.min.js +12 -14
  123. package/es/ListTable.d.ts +0 -2
  124. package/es/ListTable.js +8 -12
  125. package/es/ListTable.js.map +1 -1
  126. package/es/PivotChart.d.ts +2 -2
  127. package/es/PivotChart.js +53 -29
  128. package/es/PivotChart.js.map +1 -1
  129. package/es/PivotTable.d.ts +1 -1
  130. package/es/PivotTable.js +61 -32
  131. package/es/PivotTable.js.map +1 -1
  132. package/es/core/BaseTable.js +5 -5
  133. package/es/core/BaseTable.js.map +1 -1
  134. package/es/dataset/dataset-pivot-table.js +5 -12
  135. package/es/dataset/dataset.d.ts +9 -8
  136. package/es/dataset/dataset.js +104 -61
  137. package/es/dataset/dataset.js.map +1 -1
  138. package/es/dataset/flatDataToObject.js +2 -3
  139. package/es/event/event.js +2 -1
  140. package/es/event/event.js.map +1 -1
  141. package/es/event/listener/container-dom.js +1 -1
  142. package/es/event/listener/scroll-bar.js +6 -6
  143. package/es/event/listener/scroll-bar.js.map +1 -1
  144. package/es/event/pivot-chart/axis-click.js.map +1 -1
  145. package/es/event/pivot-chart/axis-hover.js.map +1 -1
  146. package/es/event/sparkline-event.js.map +1 -1
  147. package/es/index.d.ts +1 -2
  148. package/es/index.js +1 -3
  149. package/es/index.js.map +1 -1
  150. package/es/layout/chart-helper/get-axis-config.d.ts +4 -4
  151. package/es/layout/chart-helper/get-axis-config.js +21 -19
  152. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  153. package/es/layout/chart-helper/get-axis-domain.d.ts +1 -1
  154. package/es/layout/chart-helper/get-axis-domain.js +2 -2
  155. package/es/layout/chart-helper/get-axis-domain.js.map +1 -1
  156. package/es/layout/chart-helper/get-chart-spec.d.ts +4 -5
  157. package/es/layout/chart-helper/get-chart-spec.js +13 -12
  158. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  159. package/es/layout/pivot-header-layout.d.ts +58 -44
  160. package/es/layout/pivot-header-layout.js +425 -197
  161. package/es/layout/pivot-header-layout.js.map +1 -1
  162. package/es/layout/pivot-layout-helper.d.ts +40 -0
  163. package/es/layout/pivot-layout-helper.js +94 -0
  164. package/es/layout/pivot-layout-helper.js.map +1 -0
  165. package/es/layout/pivot-layout.d.ts +1 -145
  166. package/es/layout/pivot-layout.js +1 -823
  167. package/es/layout/pivot-layout.js.map +1 -1
  168. package/es/layout/simple-header-layout.d.ts +1 -1
  169. package/es/layout/simple-header-layout.js +2 -2
  170. package/es/layout/simple-header-layout.js.map +1 -1
  171. package/es/scenegraph/component/menu.d.ts +41 -0
  172. package/es/scenegraph/context/module.js +2 -4
  173. package/es/scenegraph/debug-tool/debug-tool.js +1 -1
  174. package/es/scenegraph/graphic/chart.js.map +1 -1
  175. package/es/scenegraph/graphic/contributions/chart-render.js +1 -3
  176. package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  177. package/es/scenegraph/graphic/contributions/group-contribution-render.js +1 -3
  178. package/es/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  179. package/es/scenegraph/graphic/contributions/image-contribution-render.js +1 -3
  180. package/es/scenegraph/graphic/contributions/image-contribution-render.js.map +1 -1
  181. package/es/scenegraph/graphic/contributions/index.d.ts +1 -1
  182. package/es/scenegraph/graphic/contributions/index.js +1 -3
  183. package/es/scenegraph/graphic/contributions/index.js.map +1 -1
  184. package/es/scenegraph/graphic/contributions/rect-contribution-render.js +1 -3
  185. package/es/scenegraph/graphic/contributions/rect-contribution-render.js.map +1 -1
  186. package/es/scenegraph/graphic/group.d.ts +3 -0
  187. package/es/scenegraph/graphic/group.js +20 -0
  188. package/es/scenegraph/graphic/group.js.map +1 -1
  189. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  190. package/es/scenegraph/group-creater/cell-type/chart-cell.js +1 -1
  191. package/es/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  192. package/es/scenegraph/group-creater/progress/proxy.d.ts +3 -0
  193. package/es/scenegraph/group-creater/progress/proxy.js +15 -13
  194. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  195. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +2 -3
  196. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  197. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +1 -1
  198. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  199. package/es/scenegraph/layout/compute-col-width.js +1 -1
  200. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  201. package/es/scenegraph/layout/compute-row-height.js +2 -2
  202. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  203. package/es/scenegraph/layout/update-row.d.ts +1 -1
  204. package/es/scenegraph/layout/update-row.js +5 -1
  205. package/es/scenegraph/layout/update-row.js.map +1 -1
  206. package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
  207. package/es/scenegraph/scenegraph.d.ts +1 -1
  208. package/es/scenegraph/scenegraph.js +10 -7
  209. package/es/scenegraph/scenegraph.js.map +1 -1
  210. package/es/scenegraph/utils/break-string.js +3 -4
  211. package/es/scenegraph/utils/deal-promise-data.js +1 -3
  212. package/es/scenegraph/utils/render-service.d.ts +7 -0
  213. package/es/scenegraph/utils/render-service.js +19 -0
  214. package/es/scenegraph/utils/render-service.js.map +1 -0
  215. package/{cjs/scenegraph/utils/measure-text.d.ts → es/scenegraph/utils/text-measure.d.ts} +10 -3
  216. package/es/scenegraph/utils/{measure-text.js → text-measure.js} +31 -19
  217. package/es/scenegraph/utils/text-measure.js.map +1 -0
  218. package/es/state/state.d.ts +1 -0
  219. package/es/state/state.js +4 -2
  220. package/es/state/state.js.map +1 -1
  221. package/es/themes/BRIGHT.js +1 -2
  222. package/es/themes/DARK.js +2 -1
  223. package/es/tools/LimitPromiseQueue.js +1 -1
  224. package/es/tools/calc.js +1 -1
  225. package/es/tools/diff-cell.d.ts +9 -2
  226. package/es/tools/diff-cell.js +16 -4
  227. package/es/tools/diff-cell.js.map +1 -1
  228. package/es/tools/get-data-path/create-dataset.js +2 -2
  229. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  230. package/es/tools/get-data-path/index.js +10 -5
  231. package/es/tools/get-data-path/index.js.map +1 -1
  232. package/es/tools/isx.d.ts +1 -1
  233. package/es/tools/util.d.ts +1 -3
  234. package/es/tools/util.js +1 -31
  235. package/es/tools/util.js.map +1 -1
  236. package/es/ts-types/base-table.d.ts +14 -6
  237. package/es/ts-types/base-table.js.map +1 -1
  238. package/es/ts-types/list-table/layout-map/api.d.ts +2 -2
  239. package/es/ts-types/list-table/layout-map/api.js.map +1 -1
  240. package/es/ts-types/new-data-set.js.map +1 -1
  241. package/es/ts-types/table-engine.d.ts +9 -0
  242. package/es/ts-types/table-engine.js.map +1 -1
  243. package/package.json +6 -7
  244. package/cjs/components/axis/get-axis-attributes.d.ts +0 -151
  245. package/cjs/scenegraph/utils/measure-text.js.map +0 -1
  246. package/es/components/axis/get-axis-attributes.d.ts +0 -151
  247. package/es/scenegraph/utils/measure-text.js.map +0 -1
@@ -1,820 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: !0
5
- }), exports.PivotLayoutMap = void 0;
6
-
7
- const util_1 = require("../tools/util"), global_1 = require("../tools/global"), vutils_1 = require("@visactor/vutils"), get_axis_config_1 = require("./chart-helper/get-axis-config"), get_chart_spec_1 = require("./chart-helper/get-chart-spec"), padding_1 = require("../scenegraph/utils/padding"), EMPTY_HEADER = {
8
- isEmpty: !0,
9
- id: void 0,
10
- field: void 0,
11
- headerType: void 0,
12
- define: void 0
13
- };
14
-
15
- class PivotLayoutMap {
16
- constructor(table, dataset) {
17
- var _a, _b, _c, _d, _e, _f, _g, _h;
18
- this._headerObjects = [], this._headerObjectMap = {}, this._indicatorObjects = [],
19
- this._columnWidths = [], this._showRowHeader = !0, this._showColumnHeader = !0,
20
- this._indicatorShowType = "column", this.indicatorsAsCol = !0, this.hideIndicatorName = !1,
21
- this.indicatorDimensionKey = global_1.IndicatorDimensionKeyPlaceholder, this._table = table,
22
- this._chartItemSpanSize = 0, this._chartItemBandSize = 0, this.rowTree = table.options.rowTree,
23
- this.columnTree = table.options.columnTree, this.rowsDefine = null !== (_a = table.options.rows) && void 0 !== _a ? _a : [],
24
- this.columnsDefine = null !== (_b = table.options.columns) && void 0 !== _b ? _b : [],
25
- this.indicatorsDefine = null !== (_c = table.options.indicators) && void 0 !== _c ? _c : [],
26
- this.indicatorTitle = table.options.indicatorTitle, this.dataset = dataset, this.dataConfig = dataset.dataConfig,
27
- this.indicatorKeys = dataset.indicatorKeys, this.indicatorsAsCol = null === (_d = table.options.indicatorsAsCol) || void 0 === _d || _d,
28
- this.hideIndicatorName = null !== (_e = table.options.hideIndicatorName) && void 0 !== _e && _e,
29
- this.showRowHeader = null === (_f = table.options.showRowHeader) || void 0 === _f || _f,
30
- this.showColumnHeader = null === (_g = table.options.showColumnHeader) || void 0 === _g || _g,
31
- this.rowHeaderTitle = table.options.rowHeaderTitle, this.columnHeaderTitle = table.options.columnHeaderTitle,
32
- this.cornerSetting = null !== (_h = table.options.corner) && void 0 !== _h ? _h : {
33
- titleOnDimension: "column"
34
- }, this.columns = dataset.columns, this.rows = dataset.rows, this.rowKeysPath = dataset.rowKeysPath,
35
- this.colKeysPath = dataset.colKeysPath, this.tree = dataset.tree, this.initState(),
36
- this.convertColKeys = (0, util_1.transpose)(this.colKeysPath);
37
- }
38
- initState() {
39
- var _a, _b, _c, _d, _e;
40
- if (this.indicatorsAsCol && !this.hideIndicatorName ? this._indicatorShowType = "column" : this.indicatorsAsCol || this.hideIndicatorName ? this._indicatorShowType = "none" : this._indicatorShowType = "row",
41
- this.colShowAttrs = "column" === this._indicatorShowType ? this.columns.concat(this.indicatorDimensionKey) : Array.from(this.columns),
42
- this.rowShowAttrs = "row" === this._indicatorShowType ? this.rows.concat(this.indicatorDimensionKey) : Array.from(this.rows),
43
- this._bodyRowCount = this.rowKeysPath.length * (this.indicatorsAsCol ? 1 : this.indicatorKeys.length),
44
- this.initHeaderObjects(), this.initIndicatorObjects(), this.rowHeaderTitle) {
45
- const cell_id = "rowHeaderTitle", title = "string" == typeof this.rowHeaderTitle.title ? this.rowHeaderTitle.title : this.rowsDefine.reduce(((title, value) => "string" == typeof value ? title : title + (title ? `/${value.title}` : `${value.title}`)), "");
46
- this._headerObjectMap[title] = {
47
- id: title,
48
- title: title,
49
- field: cell_id,
50
- headerType: null !== (_a = this.rowHeaderTitle.headerType) && void 0 !== _a ? _a : "text",
51
- style: this.rowHeaderTitle.headerStyle,
52
- define: {}
53
- }, this._headerObjectMap[cell_id] = {
54
- id: cell_id,
55
- title: "",
56
- field: cell_id,
57
- headerType: null !== (_b = this.cornerSetting.headerType) && void 0 !== _b ? _b : "text",
58
- style: this.cornerSetting.headerStyle,
59
- define: {}
60
- }, this._headerObjects.push(this._headerObjectMap[title]), this._headerObjects.push(this._headerObjectMap[cell_id]),
61
- this.rowShowAttrs.unshift(cell_id), this.rowKeysPath.forEach(((rowKey, index) => {
62
- rowKey.unshift(title);
63
- }));
64
- }
65
- if (this.columnHeaderTitle) {
66
- const cell_id = "columnHeaderTitleCell", title = "string" == typeof this.columnHeaderTitle.title ? this.columnHeaderTitle.title : this.columnsDefine.reduce(((title, value) => "string" == typeof value ? title : title + (title ? `/${value.title}` : `${value.title}`)), "");
67
- this._headerObjectMap[title] = {
68
- id: title,
69
- title: title,
70
- field: cell_id,
71
- headerType: null !== (_c = this.columnHeaderTitle.headerType) && void 0 !== _c ? _c : "text",
72
- style: this.columnHeaderTitle.headerStyle,
73
- define: {}
74
- }, this._headerObjectMap[cell_id] = {
75
- id: cell_id,
76
- title: "",
77
- field: cell_id,
78
- headerType: null !== (_d = this.cornerSetting.headerType) && void 0 !== _d ? _d : "text",
79
- style: this.cornerSetting.headerStyle,
80
- define: {}
81
- }, this._headerObjects.push(this._headerObjectMap[title]), this._headerObjects.push(this._headerObjectMap[cell_id]),
82
- this.colShowAttrs.unshift(cell_id), this.colKeysPath.forEach(((columnKey, index) => {
83
- columnKey.unshift(title);
84
- }));
85
- }
86
- if (this._table.isPivotChart()) if (this.hasTwoIndicatorAxes = this._indicatorObjects.some((indicatorObject => !!(indicatorObject.chartSpec && indicatorObject.chartSpec.series && indicatorObject.chartSpec.series.length > 1))),
87
- this._chartItemSpanSize = 0, this._chartItemBandSize = 0, this._indicatorObjects.find((indicatorObject => {
88
- var _a, _b, _c, _d, _e, _f, _g, _h;
89
- (null === (_a = null == indicatorObject ? void 0 : indicatorObject.style) || void 0 === _a ? void 0 : _a.padding) && (this._chartPadding = indicatorObject.style.padding),
90
- (null === (_b = indicatorObject.chartSpec) || void 0 === _b ? void 0 : _b.barWidth) && (this._chartItemSpanSize = null === (_c = indicatorObject.chartSpec) || void 0 === _c ? void 0 : _c.barWidth);
91
- const bandAxisConfig = null === (_e = null === (_d = indicatorObject.chartSpec) || void 0 === _d ? void 0 : _d.axes) || void 0 === _e ? void 0 : _e.find((axis => "band" === axis.type));
92
- return (null == bandAxisConfig ? void 0 : bandAxisConfig.bandSize) && (this._chartItemBandSize = null == bandAxisConfig ? void 0 : bandAxisConfig.bandSize,
93
- this._chartPaddingInner = null !== (_f = (0, vutils_1.isArray)(bandAxisConfig.paddingInner) ? bandAxisConfig.paddingInner[0] : bandAxisConfig.paddingInner) && void 0 !== _f ? _f : 0,
94
- this._chartPaddingOuter = null !== (_g = (0, vutils_1.isArray)(bandAxisConfig.paddingOuter) ? bandAxisConfig.paddingOuter[0] : bandAxisConfig.paddingOuter) && void 0 !== _g ? _g : 0),
95
- this._chartItemSpanSize > 0 || (null === (_h = indicatorObject.chartSpec.series) || void 0 === _h || _h.find((seriesObject => (seriesObject.barWidth && (this._chartItemSpanSize = seriesObject.barWidth),
96
- this._chartItemSpanSize > 0))), !1);
97
- })), this.indicatorsAsCol) {
98
- const cell_id = "rowHeaderEmpty";
99
- this._headerObjectMap[cell_id] = {
100
- id: cell_id,
101
- title: "",
102
- field: cell_id,
103
- headerType: null !== (_e = this.cornerSetting.headerType) && void 0 !== _e ? _e : "text",
104
- style: this.cornerSetting.headerStyle,
105
- define: {}
106
- }, this._headerObjects.push(this._headerObjectMap[cell_id]), this.rowShowAttrs.push(cell_id),
107
- this.hasTwoIndicatorAxes || this.colShowAttrs.pop();
108
- } else {
109
- const axisOption = this._table.pivotChartAxes.find((axisOption => "left" === axisOption.orient));
110
- !1 === (null == axisOption ? void 0 : axisOption.visible) && this.rowShowAttrs.pop();
111
- }
112
- this._colCount = (0 === this.colKeysPath.length ? 1 : this.colKeysPath.length) * (this.indicatorsAsCol ? this.indicatorKeys.length : 1) + this.rowHeaderLevelCount + this.rightFrozenColCount,
113
- this._rowCount = (0 === this.rowKeysPath.length ? 1 : this.rowKeysPath.length) * (this.indicatorsAsCol ? 1 : this.indicatorKeys.length) + this.columnHeaderLevelCount + this.bottomFrozenRowCount,
114
- this.setColumnWidths();
115
- }
116
- setColumnWidths() {
117
- const returnWidths = new Array(this.colCount).fill(void 0);
118
- if (this.showRowHeader && (this.rowHeaderTitle && (returnWidths[0] = {}), this.rowShowAttrs.forEach(((objKey, index) => {
119
- var _a;
120
- const dimension = null === (_a = this.rowsDefine) || void 0 === _a ? void 0 : _a.find((dimension => "string" != typeof dimension && dimension.dimensionKey === objKey));
121
- dimension && (returnWidths[index + (this.rowHeaderTitle ? 1 : 0)] = {
122
- width: dimension.width,
123
- minWidth: dimension.minWidth,
124
- maxWidth: dimension.maxWidth
125
- });
126
- }))), this.indicatorsAsCol) for (let i = this.rowHeaderLevelCount; i < this.colCount; i++) {
127
- const cellDefine = this.getBody(i, this.columnHeaderLevelCount);
128
- returnWidths[i] = {
129
- width: null == cellDefine ? void 0 : cellDefine.width,
130
- minWidth: null == cellDefine ? void 0 : cellDefine.minWidth,
131
- maxWidth: null == cellDefine ? void 0 : cellDefine.maxWidth
132
- };
133
- } else {
134
- let maxWidth, minWidth, isAuto, width = 0;
135
- this._indicatorObjects.forEach(((obj, index) => {
136
- "number" == typeof obj.width ? width = Math.max(obj.width, width) : "auto" === obj.width && (isAuto = !0),
137
- "number" == typeof obj.minWidth && (minWidth = Math.max(obj.minWidth, minWidth)),
138
- "number" == typeof obj.maxWidth && (maxWidth = Math.max(obj.maxWidth, maxWidth));
139
- })), width = width > 0 ? width : isAuto ? "auto" : void 0, returnWidths.fill({
140
- width: width,
141
- minWidth: minWidth,
142
- maxWidth: maxWidth
143
- }, this.rowHeaderLevelCount, this.colCount - this.rightFrozenColCount);
144
- }
145
- this._columnWidths = returnWidths;
146
- }
147
- get columnWidths() {
148
- return this._columnWidths;
149
- }
150
- getColumnWidthDefined(col) {
151
- return this._columnWidths[col];
152
- }
153
- getDimensionInfo(dimensionKey) {
154
- var _a, _b, _c;
155
- return null !== (_b = null === (_a = this.rowsDefine) || void 0 === _a ? void 0 : _a.find((dimension => "string" != typeof dimension && dimension.dimensionKey === dimensionKey))) && void 0 !== _b ? _b : null === (_c = this.columnsDefine) || void 0 === _c ? void 0 : _c.find((dimension => "string" != typeof dimension && dimension.dimensionKey === dimensionKey));
156
- }
157
- getIndicatorInfo(indicatorKey, indicatorValue = "") {
158
- var _a;
159
- return null === (_a = this.indicatorsDefine) || void 0 === _a ? void 0 : _a.find((indicator => "string" != typeof indicator && (indicatorKey ? indicator.indicatorKey === indicatorKey : !!indicatorValue && indicator.title === indicatorValue)));
160
- }
161
- getColKeysPath() {
162
- return this.colKeysPath;
163
- }
164
- getRowKeysPath() {
165
- return this.rowKeysPath;
166
- }
167
- initHeaderObjects() {
168
- var _a, _b, _c, _d, _e, _f, _g, _h;
169
- for (let i = 0, len = this.rowKeysPath.length; i <= len - 1; i++) {
170
- const rowKey = this.rowKeysPath[i];
171
- for (let j = 0, len2 = rowKey.length; j <= len2 - 1; j++) if (!this._headerObjectMap[rowKey[j]]) {
172
- const ids = rowKey[j].split(this.dataset.stringJoinChar), dimensionInfo = this.getDimensionInfo(this.rows[ids.length - 1]);
173
- this._headerObjectMap[rowKey[j]] = {
174
- id: rowKey[j],
175
- field: null !== (_a = null == dimensionInfo ? void 0 : dimensionInfo.dimensionKey) && void 0 !== _a ? _a : this.rows[ids.length - 1],
176
- title: ids[ids.length - 1],
177
- style: null == dimensionInfo ? void 0 : dimensionInfo.headerStyle,
178
- define: {
179
- field: null !== (_b = null == dimensionInfo ? void 0 : dimensionInfo.dimensionKey) && void 0 !== _b ? _b : this.rows[ids.length - 1],
180
- headerType: null !== (_c = null == dimensionInfo ? void 0 : dimensionInfo.headerType) && void 0 !== _c ? _c : "text",
181
- cellType: "text"
182
- },
183
- fieldFormat: null == dimensionInfo ? void 0 : dimensionInfo.headerFormat,
184
- dropDownMenu: null == dimensionInfo ? void 0 : dimensionInfo.dropDownMenu,
185
- headerType: null !== (_d = null == dimensionInfo ? void 0 : dimensionInfo.headerType) && void 0 !== _d ? _d : "text",
186
- width: null == dimensionInfo ? void 0 : dimensionInfo.width
187
- }, this._headerObjects.push(this._headerObjectMap[rowKey[j]]);
188
- }
189
- }
190
- for (let i = 0, len = this.colKeysPath.length; i <= len - 1; i++) {
191
- const colKey = this.colKeysPath[i];
192
- for (let j = 0, len2 = colKey.length; j <= len2 - 1; j++) if (!this._headerObjectMap[colKey[j]]) {
193
- const ids = colKey[j].split(this.dataset.stringJoinChar), dimensionInfo = this.getDimensionInfo(this.columns[ids.length - 1]);
194
- this._headerObjectMap[colKey[j]] = {
195
- id: colKey[j],
196
- field: null !== (_e = null == dimensionInfo ? void 0 : dimensionInfo.dimensionKey) && void 0 !== _e ? _e : this.columns[ids.length - 1],
197
- title: ids[ids.length - 1],
198
- style: null == dimensionInfo ? void 0 : dimensionInfo.headerStyle,
199
- define: {
200
- field: null !== (_f = null == dimensionInfo ? void 0 : dimensionInfo.dimensionKey) && void 0 !== _f ? _f : this.columns[ids.length - 1],
201
- headerType: null !== (_g = null == dimensionInfo ? void 0 : dimensionInfo.headerType) && void 0 !== _g ? _g : "text",
202
- cellType: "text"
203
- },
204
- fieldFormat: null == dimensionInfo ? void 0 : dimensionInfo.headerFormat,
205
- dropDownMenu: null == dimensionInfo ? void 0 : dimensionInfo.dropDownMenu,
206
- headerType: null !== (_h = null == dimensionInfo ? void 0 : dimensionInfo.headerType) && void 0 !== _h ? _h : "text",
207
- width: null == dimensionInfo ? void 0 : dimensionInfo.width
208
- }, this._headerObjects.push(this._headerObjectMap[colKey[j]]);
209
- }
210
- }
211
- let cornerAttrs;
212
- this.indicatorsDefine.forEach((indicator => {
213
- var _a, _b, _c;
214
- const indicatorKey = "string" == typeof indicator ? indicator : indicator.indicatorKey, indicatorInfo = "string" == typeof indicator ? void 0 : indicator;
215
- this._headerObjectMap[indicatorKey] || (this._headerObjectMap[indicatorKey] = {
216
- id: indicatorKey,
217
- field: this.indicatorDimensionKey,
218
- title: null !== (_a = null == indicatorInfo ? void 0 : indicatorInfo.title) && void 0 !== _a ? _a : indicatorKey,
219
- style: null == indicatorInfo ? void 0 : indicatorInfo.headerStyle,
220
- define: {
221
- field: this.indicatorDimensionKey,
222
- headerType: null !== (_b = null == indicatorInfo ? void 0 : indicatorInfo.headerType) && void 0 !== _b ? _b : "text",
223
- cellType: "text"
224
- },
225
- dropDownMenu: null == indicatorInfo ? void 0 : indicatorInfo.dropDownMenu,
226
- headerType: null !== (_c = null == indicatorInfo ? void 0 : indicatorInfo.headerType) && void 0 !== _c ? _c : "text",
227
- width: null == indicatorInfo ? void 0 : indicatorInfo.width
228
- }, this._headerObjects.push(this._headerObjectMap[indicatorKey]));
229
- })), "column" === this.cornerSetting.titleOnDimension ? cornerAttrs = this.colShowAttrs : "row" === this.cornerSetting.titleOnDimension && (cornerAttrs = this.rowShowAttrs),
230
- null == cornerAttrs || cornerAttrs.forEach((cornerAttrStr => {
231
- var _a, _b, _c, _d, _e, _f;
232
- if (!this._headerObjectMap[cornerAttrStr]) {
233
- const dimensionInfo = this.getDimensionInfo(cornerAttrStr);
234
- this._headerObjectMap[cornerAttrStr] = {
235
- id: cornerAttrStr,
236
- field: cornerAttrStr,
237
- title: cornerAttrStr === this.indicatorDimensionKey ? this.indicatorTitle : null !== (_a = null == dimensionInfo ? void 0 : dimensionInfo.title) && void 0 !== _a ? _a : cornerAttrStr,
238
- style: null === (_b = this.cornerSetting) || void 0 === _b ? void 0 : _b.headerStyle,
239
- define: {
240
- field: cornerAttrStr,
241
- headerType: null !== (_d = null === (_c = this.cornerSetting) || void 0 === _c ? void 0 : _c.headerType) && void 0 !== _d ? _d : "text",
242
- cellType: "text"
243
- },
244
- dropDownMenu: null == dimensionInfo ? void 0 : dimensionInfo.dropDownMenu,
245
- headerType: null !== (_f = null === (_e = this.cornerSetting) || void 0 === _e ? void 0 : _e.headerType) && void 0 !== _f ? _f : "text",
246
- width: null == dimensionInfo ? void 0 : dimensionInfo.width
247
- }, this._headerObjects.push(this._headerObjectMap[cornerAttrStr]);
248
- }
249
- }));
250
- }
251
- initIndicatorObjects() {
252
- this.indicatorKeys.forEach((indicatorKey => {
253
- var _a, _b, _c, _d, _e;
254
- const indicatorInfo = null === (_a = this.indicatorsDefine) || void 0 === _a ? void 0 : _a.find((indicator => "string" != typeof indicator && indicator.indicatorKey === indicatorKey));
255
- this._indicatorObjects.push({
256
- id: indicatorKey,
257
- indicatorKey: indicatorKey,
258
- field: indicatorKey,
259
- define: Object.assign({
260
- field: indicatorKey,
261
- headerType: "text",
262
- cellType: null !== (_c = null !== (_b = null == indicatorInfo ? void 0 : indicatorInfo.cellType) && void 0 !== _b ? _b : null == indicatorInfo ? void 0 : indicatorInfo.columnType) && void 0 !== _c ? _c : "text"
263
- }, indicatorInfo),
264
- fieldFormat: null == indicatorInfo ? void 0 : indicatorInfo.format,
265
- cellType: null !== (_e = null !== (_d = null == indicatorInfo ? void 0 : indicatorInfo.cellType) && void 0 !== _d ? _d : null == indicatorInfo ? void 0 : indicatorInfo.columnType) && void 0 !== _e ? _e : "text",
266
- chartModule: indicatorInfo && ("chartModule" in indicatorInfo ? null == indicatorInfo ? void 0 : indicatorInfo.chartModule : null),
267
- chartSpec: indicatorInfo && ("chartSpec" in indicatorInfo ? null == indicatorInfo ? void 0 : indicatorInfo.chartSpec : null),
268
- sparklineSpec: indicatorInfo && ("sparklineSpec" in indicatorInfo ? null == indicatorInfo ? void 0 : indicatorInfo.sparklineSpec : null),
269
- style: null == indicatorInfo ? void 0 : indicatorInfo.style,
270
- icon: null == indicatorInfo ? void 0 : indicatorInfo.icon,
271
- width: null == indicatorInfo ? void 0 : indicatorInfo.width,
272
- minWidth: null == indicatorInfo ? void 0 : indicatorInfo.minWidth,
273
- maxWidth: null == indicatorInfo ? void 0 : indicatorInfo.maxWidth,
274
- disableColumnResize: null == indicatorInfo ? void 0 : indicatorInfo.disableColumnResize
275
- });
276
- }));
277
- }
278
- get showColumnHeader() {
279
- return this._showColumnHeader;
280
- }
281
- set showColumnHeader(_showColumnHeader) {
282
- this._showColumnHeader = _showColumnHeader;
283
- }
284
- get showRowHeader() {
285
- return this._showRowHeader;
286
- }
287
- set showRowHeader(_showRowHeader) {
288
- this._showRowHeader = _showRowHeader;
289
- }
290
- get columnHeaderTitle() {
291
- return this._columnHeaderTitle;
292
- }
293
- set columnHeaderTitle(_columnHeaderTitle) {
294
- this._columnHeaderTitle = _columnHeaderTitle;
295
- }
296
- get rowHeaderTitle() {
297
- return this._rowHeaderTitle;
298
- }
299
- set rowHeaderTitle(_rowHeaderTitle) {
300
- this._rowHeaderTitle = _rowHeaderTitle;
301
- }
302
- getCellLocation(col, row) {
303
- return this.isCornerHeader(col, row) ? "cornerHeader" : this.isColumnHeader(col, row) ? "columnHeader" : this.isRowHeader(col, row) ? "rowHeader" : "body";
304
- }
305
- isHeader(col, row) {
306
- return col < this.rowHeaderLevelCount || (row < this.columnHeaderLevelCount || (col >= this.colCount - this.rightFrozenColCount || row >= this.rowCount - this.bottomFrozenRowCount));
307
- }
308
- isCornerHeader(col, row) {
309
- return col < this.rowHeaderLevelCount && row < this.columnHeaderLevelCount;
310
- }
311
- isColumnHeader(col, row) {
312
- return col >= this.rowHeaderLevelCount && row < this.columnHeaderLevelCount;
313
- }
314
- isRightFrozenColumn(col, row) {
315
- return col >= this.colCount - this.rightFrozenColCount && row >= this.columnHeaderLevelCount && row < this.rowCount - this.bottomFrozenRowCount;
316
- }
317
- isBottomFrozenRow(col, row) {
318
- return col >= this.rowHeaderLevelCount && row >= this.rowCount - this.bottomFrozenRowCount && col < this.colCount - this.rightFrozenColCount;
319
- }
320
- isLeftBottomCorner(col, row) {
321
- return col < this.rowHeaderLevelCount && row >= this.rowCount - this.bottomFrozenRowCount;
322
- }
323
- isRightTopCorner(col, row) {
324
- return col >= this.colCount - this.rightFrozenColCount && row < this.columnHeaderLevelCount;
325
- }
326
- isRightBottomCorner(col, row) {
327
- return col >= this.colCount - this.rightFrozenColCount && row >= this.rowCount - this.bottomFrozenRowCount;
328
- }
329
- isRowHeader(col, row) {
330
- return col < this.rowHeaderLevelCount && row >= this.columnHeaderLevelCount;
331
- }
332
- isColumnIndicatorHeader(col, row) {
333
- return "column" === this._indicatorShowType && row === this.columnHeaderLevelCount - 1 && col >= this.rowHeaderLevelCount;
334
- }
335
- isRowIndicatorHeader(col, row) {
336
- return "row" === this._indicatorShowType && col === this.rowHeaderLevelCount - 1 && row >= this.columnHeaderLevelCount;
337
- }
338
- isIndicatorHeader(col, row) {
339
- return this.isColumnIndicatorHeader(col, row) || this.isRowIndicatorHeader(col, row);
340
- }
341
- getColumnHeaderRange() {
342
- return {
343
- start: {
344
- col: this.rowHeaderLevelCount,
345
- row: 0
346
- },
347
- end: {
348
- col: this.colCount - 1,
349
- row: this.columnHeaderLevelCount - 1
350
- }
351
- };
352
- }
353
- getRowHeaderRange() {
354
- return {
355
- start: {
356
- col: 0,
357
- row: this.columnHeaderLevelCount
358
- },
359
- end: {
360
- col: this.rowHeaderLevelCount - 1,
361
- row: this.rowCount - 1
362
- }
363
- };
364
- }
365
- getCornerHeaderRange() {
366
- return {
367
- start: {
368
- col: 0,
369
- row: 0
370
- },
371
- end: {
372
- col: this.rowHeaderLevelCount - 1,
373
- row: this.columnHeaderLevelCount - 1
374
- }
375
- };
376
- }
377
- getBodyRange() {
378
- return {
379
- start: {
380
- col: this.rowHeaderLevelCount,
381
- row: this.columnHeaderLevelCount
382
- },
383
- end: {
384
- col: this.colCount - 1,
385
- row: this.rowCount - 1
386
- }
387
- };
388
- }
389
- resetCellIds() {}
390
- get headerLevelCount() {
391
- return this.columnHeaderLevelCount;
392
- }
393
- get columnHeaderLevelCount() {
394
- const colLevelCount = this.colShowAttrs.length;
395
- if (this.showColumnHeader) {
396
- return this.indicatorsAsCol && this.hideIndicatorName && this.colShowAttrs[this.colShowAttrs.length - 1] === this.indicatorDimensionKey ? colLevelCount - 1 : colLevelCount;
397
- }
398
- return this.indicatorsAsCol ? this.hideIndicatorName ? 0 : 1 : 0;
399
- }
400
- get rowHeaderLevelCount() {
401
- const rowLevelCount = this.rowShowAttrs.length;
402
- if (this.showRowHeader) {
403
- return this.indicatorsAsCol ? rowLevelCount : this.hideIndicatorName && this.rowShowAttrs[this.rowShowAttrs.length - 1] === this.indicatorDimensionKey ? rowLevelCount - 1 : rowLevelCount;
404
- }
405
- return this.indicatorsAsCol || this.hideIndicatorName ? 0 : 1;
406
- }
407
- get colCount() {
408
- return this._colCount;
409
- }
410
- get rowCount() {
411
- return this._rowCount;
412
- }
413
- get bodyRowCount() {
414
- return this._bodyRowCount;
415
- }
416
- get bottomFrozenRowCount() {
417
- if (!this._table.isPivotChart()) return 0;
418
- const axisOption = this._table.pivotChartAxes.find((axisOption => "bottom" === axisOption.orient));
419
- return !1 === (null == axisOption ? void 0 : axisOption.visible) ? 0 : (this.indicatorsAsCol,
420
- 1);
421
- }
422
- get rightFrozenColCount() {
423
- if (!this._table.isPivotChart()) return 0;
424
- const axisOption = this._table.pivotChartAxes.find((axisOption => "right" === axisOption.orient));
425
- return !1 === (null == axisOption ? void 0 : axisOption.visible) || this.indicatorsAsCol ? 0 : this.hasTwoIndicatorAxes ? 1 : 0;
426
- }
427
- get leftAxesCount() {
428
- if (!this._table.isPivotChart()) return 0;
429
- const axisOption = this._table.pivotChartAxes.find((axisOption => "left" === axisOption.orient));
430
- return !1 === (null == axisOption ? void 0 : axisOption.visible) ? 0 : (this.indicatorsAsCol,
431
- 1);
432
- }
433
- get topAxesCount() {
434
- if (!this._table.isPivotChart()) return 0;
435
- const axisOption = this._table.pivotChartAxes.find((axisOption => "top" === axisOption.orient));
436
- return !1 === (null == axisOption ? void 0 : axisOption.visible) ? 0 : this.indicatorsAsCol && this.hasTwoIndicatorAxes ? 1 : 0;
437
- }
438
- get rightAxesCount() {
439
- return this.rightFrozenColCount;
440
- }
441
- get bottomAxesCount() {
442
- return this.bottomFrozenRowCount;
443
- }
444
- get headerObjects() {
445
- return this._headerObjects;
446
- }
447
- get columnObjects() {
448
- return this._indicatorObjects;
449
- }
450
- getCellId(col, row) {
451
- var _a, _b, _c, _d, _e;
452
- if (col < this.rowHeaderLevelCount && row >= this.rowCount - this.bottomFrozenRowCount || row < this.columnHeaderLevelCount && col >= this.colCount - this.rightFrozenColCount) return 0;
453
- if (row >= 0 && col >= 0) if (this.isCornerHeader(col, row)) {
454
- if ("column" === this.cornerSetting.titleOnDimension) return this.colShowAttrs[row];
455
- if ("row" === this.cornerSetting.titleOnDimension) return this.rowShowAttrs[col];
456
- } else {
457
- if (this.isColumnHeader(col, row)) return row < this.columns.length + (this.columnHeaderTitle ? 1 : 0) ? null !== (_b = null === (_a = this.convertColKeys[row]) || void 0 === _a ? void 0 : _a[this.indicatorsAsCol ? Math.floor((col - this.rowHeaderLevelCount) / this.indicatorKeys.length) : col - this.rowHeaderLevelCount]) && void 0 !== _b ? _b : `colHeaderAxis-${col}-${row}` : this.indicatorKeys[(col - this.rowHeaderLevelCount) % this.indicatorKeys.length];
458
- if (this.isRowHeader(col, row)) return col < this.rows.length + (this.rowHeaderTitle ? 1 : 0) ? null !== (_d = null === (_c = this.rowKeysPath[this.indicatorsAsCol ? row - this.columnHeaderLevelCount : Math.floor((row - this.columnHeaderLevelCount) / this.indicatorKeys.length)]) || void 0 === _c ? void 0 : _c[col]) && void 0 !== _d ? _d : `rowHeaderAxis-${col}-${row}` : this.indicatorsAsCol && col === this.rowHeaderLevelCount - 1 ? `rowHeaderAxis-${col}-${row}` : this.indicatorKeys[(row - this.columnHeaderLevelCount) % this.indicatorKeys.length];
459
- if (this.isRightFrozenColumn(col, row)) return this.indicatorsAsCol ? this.rowKeysPath[row - this.columnHeaderLevelCount][this.rowHeaderLevelCount - 1] : this.indicatorKeys[(row - this.columnHeaderLevelCount) % this.indicatorKeys.length];
460
- if (this.isBottomFrozenRow(col, row)) return this.indicatorsAsCol ? this.indicatorKeys[(col - this.rowHeaderLevelCount) % this.indicatorKeys.length] : null === (_e = this.convertColKeys[this.convertColKeys.length - 1]) || void 0 === _e ? void 0 : _e[Math.floor((col - this.rowHeaderLevelCount) / this.indicatorKeys.length)];
461
- }
462
- return 0;
463
- }
464
- getIndicatorKey(col, row) {
465
- if (this.isHeader(col, row)) return "";
466
- if (this.indicatorsAsCol) {
467
- const bodyCol = col - this.rowHeaderLevelCount;
468
- return this.indicatorKeys[bodyCol % this.indicatorKeys.length];
469
- }
470
- const bodyRow = row - this.columnHeaderLevelCount;
471
- return this.indicatorKeys[bodyRow % this.indicatorKeys.length];
472
- }
473
- getHeader(col, row) {
474
- var _a;
475
- let id = this.getCellId(col, row);
476
- return (null == id ? void 0 : id.toString().startsWith("rowHeaderAxis")) && (id = "rowHeaderEmpty"),
477
- null !== (_a = this._headerObjectMap[id]) && void 0 !== _a ? _a : EMPTY_HEADER;
478
- }
479
- getHeaderField(col, row) {
480
- var _a, _b;
481
- const id = this.getCellId(col, row);
482
- return (null === (_a = this._headerObjectMap[id]) || void 0 === _a ? void 0 : _a.field) || (null === (_b = this.getBody(col, row)) || void 0 === _b ? void 0 : _b.field);
483
- }
484
- getHeaderFieldKey(col, row) {}
485
- getHeaderCellAdress(id) {}
486
- getHeaderCellAddressByField(field) {
487
- throw new Error(`Method not implemented.${field}`);
488
- }
489
- getBody(_col, _row) {
490
- var _a, _b, _c, _d, _e, _f;
491
- const paths = this.getCellHeaderPaths(_col, _row);
492
- if (this.indicatorsAsCol) {
493
- const indicatorKey = null === (_a = paths.colHeaderPaths.find((colPath => colPath.indicatorKey))) || void 0 === _a ? void 0 : _a.indicatorKey;
494
- return null !== (_c = null !== (_b = this._indicatorObjects.find((indicator => indicator.indicatorKey === indicatorKey))) && void 0 !== _b ? _b : this._indicatorObjects[0]) && void 0 !== _c ? _c : {
495
- id: "",
496
- field: void 0,
497
- indicatorKey: void 0,
498
- cellType: void 0,
499
- define: void 0
500
- };
501
- }
502
- const indicatorKey = null === (_d = paths.rowHeaderPaths.find((rowPath => rowPath.indicatorKey))) || void 0 === _d ? void 0 : _d.indicatorKey;
503
- return null !== (_f = null !== (_e = this._indicatorObjects.find((indicator => indicator.indicatorKey === indicatorKey))) && void 0 !== _e ? _e : this._indicatorObjects[0]) && void 0 !== _f ? _f : {
504
- id: "",
505
- field: void 0,
506
- indicatorKey: void 0,
507
- cellType: void 0,
508
- define: void 0
509
- };
510
- }
511
- getBodyLayoutRangeById(id) {
512
- var _a;
513
- for (let col = 0; col < (null !== (_a = this.colCount) && void 0 !== _a ? _a : 0); col++) if (id === this.columnObjects[col].id) return {
514
- start: {
515
- col: col,
516
- row: 0
517
- },
518
- end: {
519
- col: col,
520
- row: 0
521
- }
522
- };
523
- throw new Error(`can not found body layout @id=${id}`);
524
- }
525
- getCellRange(col, row) {
526
- var _a, _b;
527
- const result = {
528
- start: {
529
- col: col,
530
- row: row
531
- },
532
- end: {
533
- col: col,
534
- row: row
535
- }
536
- };
537
- if (!this.isHeader(col, row) || -1 === col || -1 === row || this.isIndicatorHeader(col, row)) return result;
538
- if (this.isRightFrozenColumn(col, row) || this.isBottomFrozenRow(col, row)) return result;
539
- const id = this.getCellId(col, row);
540
- for (let c = col - 1; c >= 0 && id === this.getCellId(c, row); c--) result.start.col = c;
541
- for (let c = col + 1; c < (null !== (_a = this.colCount) && void 0 !== _a ? _a : 0) && id === this.getCellId(c, row); c++) result.end.col = c;
542
- for (let r = row - 1; r >= 0 && id === this.getCellId(col, r); r--) result.start.row = r;
543
- for (let r = row + 1; r < (null !== (_b = this.rowCount) && void 0 !== _b ? _b : 0) && id === this.getCellId(col, r); r++) result.end.row = r;
544
- return result;
545
- }
546
- isCellRangeEqual(col, row, targetCol, targetRow) {
547
- const range1 = this.getCellRange(col, row), range2 = this.getCellRange(targetCol, targetRow);
548
- return range1.start.col === range2.start.col && range1.end.col === range2.end.col && range1.start.row === range2.start.row && range1.end.row === range2.end.row;
549
- }
550
- getRecordIndexByRow(row) {
551
- return row < this.columnHeaderLevelCount ? -1 : this.indicatorsAsCol ? row - this.columnHeaderLevelCount : Math.floor((row - this.columnHeaderLevelCount) / this.indicatorKeys.length);
552
- }
553
- getRecordIndexByCol(col) {
554
- return col < this.rowHeaderLevelCount ? -1 : this.indicatorsAsCol ? Math.floor((col - this.rowHeaderLevelCount) / this.indicatorKeys.length) : col - this.rowHeaderLevelCount;
555
- }
556
- getRecordStartRowByRecordIndex(index) {
557
- return this.columnHeaderLevelCount + index;
558
- }
559
- getCellHeaderPaths(col, row) {
560
- var _a, _b, _c, _d;
561
- const recordCol = this.getRecordIndexByCol(col), recordRow = this.getRecordIndexByRow(row);
562
- let colPath, rowPath, colHeaderPaths, rowHeaderPaths;
563
- return recordCol >= 0 && (colPath = this.colKeysPath[recordCol], colHeaderPaths = null === (_a = null == colPath ? void 0 : colPath[colPath.length - 1]) || void 0 === _a ? void 0 : _a.split(this.dataset.stringJoinChar),
564
- colHeaderPaths && this.showColumnHeader && row < this.columns.length - 1 ? colHeaderPaths = colHeaderPaths.slice(0, row + 1) : colHeaderPaths || (colHeaderPaths = [])),
565
- recordRow >= 0 && (rowPath = this.rowKeysPath[recordRow], rowHeaderPaths = null === (_b = null == rowPath ? void 0 : rowPath[rowPath.length - 1]) || void 0 === _b ? void 0 : _b.split(this.dataset.stringJoinChar),
566
- rowHeaderPaths && this.showRowHeader && col < this.rows.length - 1 ? rowHeaderPaths = rowHeaderPaths.slice(0, col + 1) : rowHeaderPaths || (rowHeaderPaths = [])),
567
- colHeaderPaths && this.indicatorsAsCol && col >= this.rowHeaderLevelCount ? colHeaderPaths.push(this.indicatorKeys[(col - this.rowHeaderLevelCount) % this.indicatorKeys.length]) : rowHeaderPaths && row >= this.columnHeaderLevelCount && rowHeaderPaths.push(this.indicatorKeys[(row - this.columnHeaderLevelCount) % this.indicatorKeys.length]),
568
- {
569
- colHeaderPaths: null !== (_c = null == colHeaderPaths ? void 0 : colHeaderPaths.map(((key, index) => {
570
- const indicatorObject = this._indicatorObjects.find((indicator => indicator.indicatorKey === key));
571
- return {
572
- dimensionKey: indicatorObject ? void 0 : this.colShowAttrs[index],
573
- indicatorKey: indicatorObject ? key : void 0,
574
- value: indicatorObject ? indicatorObject.define.title : key
575
- };
576
- }))) && void 0 !== _c ? _c : [],
577
- rowHeaderPaths: null !== (_d = null == rowHeaderPaths ? void 0 : rowHeaderPaths.map(((key, index) => {
578
- const indicatorObject = this._indicatorObjects.find((indicator => indicator.indicatorKey === key));
579
- return {
580
- dimensionKey: indicatorObject ? void 0 : this.rowShowAttrs[index],
581
- indicatorKey: indicatorObject ? key : void 0,
582
- value: indicatorObject ? indicatorObject.define.title : key
583
- };
584
- }))) && void 0 !== _d ? _d : []
585
- };
586
- }
587
- getCellAdressByHeaderPath(dimensionPaths) {
588
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
589
- let colHeaderPaths, rowHeaderPaths;
590
- if (Array.isArray(dimensionPaths)) {
591
- if (dimensionPaths.length > this.rowShowAttrs.length + this.colShowAttrs.length) return;
592
- colHeaderPaths = dimensionPaths.filter((path => this.colShowAttrs.indexOf(path.dimensionKey) >= 0)),
593
- rowHeaderPaths = dimensionPaths.filter((path => this.rowShowAttrs.indexOf(path.dimensionKey) >= 0));
594
- } else colHeaderPaths = dimensionPaths.colHeaderPaths, rowHeaderPaths = dimensionPaths.rowHeaderPaths;
595
- if (!Array.isArray(colHeaderPaths) && !Array.isArray(rowHeaderPaths)) return;
596
- null == colHeaderPaths || colHeaderPaths.sort(((a, b) => {
597
- var _a, _b;
598
- return this.colShowAttrs.indexOf(null !== (_a = a.dimensionKey) && void 0 !== _a ? _a : this.indicatorDimensionKey) - this.colShowAttrs.indexOf(null !== (_b = b.dimensionKey) && void 0 !== _b ? _b : this.indicatorDimensionKey);
599
- })), null == rowHeaderPaths || rowHeaderPaths.sort(((a, b) => {
600
- var _a, _b;
601
- return this.rowShowAttrs.indexOf(null !== (_a = a.dimensionKey) && void 0 !== _a ? _a : this.indicatorDimensionKey) - this.rowShowAttrs.indexOf(null !== (_b = b.dimensionKey) && void 0 !== _b ? _b : this.indicatorDimensionKey);
602
- }));
603
- let needLowestLevel = !1;
604
- (null == colHeaderPaths ? void 0 : colHeaderPaths.length) >= 1 && (null == rowHeaderPaths ? void 0 : rowHeaderPaths.length) >= 1 && (needLowestLevel = !0);
605
- let toFindIndicator, col = 0, row = 0, rowTree = this.rowTree, columnTree = this.columnTree;
606
- if (colHeaderPaths) for (let i = 0; i < colHeaderPaths.length; i++) {
607
- const colDimension = colHeaderPaths[i];
608
- if (colDimension.indicatorKey) {
609
- toFindIndicator = colDimension.indicatorKey;
610
- break;
611
- }
612
- for (let j = 0; j < columnTree.length; j++) {
613
- const dimension = columnTree[j];
614
- if (!(0, util_1.isValid)(colDimension.indicatorKey) && dimension.dimensionKey === colDimension.dimensionKey && dimension.value === colDimension.value) {
615
- columnTree = dimension.children, columnTree && 0 !== columnTree.length && !(null === (_a = null == columnTree ? void 0 : columnTree[0]) || void 0 === _a ? void 0 : _a.indicatorKey) || (col += j);
616
- break;
617
- }
618
- col += (null === (_c = null === (_b = dimension.children) || void 0 === _b ? void 0 : _b[0]) || void 0 === _c ? void 0 : _c.indicatorKey) ? 0 : null !== (_e = null === (_d = dimension.children) || void 0 === _d ? void 0 : _d.length) && void 0 !== _e ? _e : 0;
619
- }
620
- }
621
- if (rowHeaderPaths) for (let i = 0; i < rowHeaderPaths.length; i++) {
622
- const rowDimension = rowHeaderPaths[i];
623
- if (rowDimension.indicatorKey) {
624
- toFindIndicator = rowDimension.indicatorKey;
625
- break;
626
- }
627
- for (let j = 0; j < rowTree.length; j++) {
628
- const dimension = rowTree[j];
629
- if (!(0, util_1.isValid)(rowDimension.indicatorKey) && dimension.dimensionKey === rowDimension.dimensionKey && dimension.value === rowDimension.value) {
630
- rowTree = dimension.children, rowTree && 0 !== rowTree.length && !(null === (_f = null == rowTree ? void 0 : rowTree[0]) || void 0 === _f ? void 0 : _f.indicatorKey) || (row += j);
631
- break;
632
- }
633
- row += (null === (_h = null === (_g = dimension.children) || void 0 === _g ? void 0 : _g[0]) || void 0 === _h ? void 0 : _h.indicatorKey) ? 0 : null !== (_k = null === (_j = dimension.children) || void 0 === _j ? void 0 : _j.length) && void 0 !== _k ? _k : 0;
634
- }
635
- }
636
- return col = (this.indicatorsAsCol ? col * this.indicatorKeys.length + this.indicatorKeys.indexOf(toFindIndicator) : col) + this.rowHeaderLevelCount,
637
- row = (this.indicatorsAsCol ? row : row * this.indicatorKeys.length + this.indicatorKeys.indexOf(toFindIndicator)) + this.columnHeaderLevelCount,
638
- (0, util_1.isValid)(col) || (0, util_1.isValid)(row) ? {
639
- col: null != col ? col : undefined,
640
- row: null != row ? row : undefined
641
- } : void 0;
642
- }
643
- getHeaderDimension(col, row) {
644
- var _a, _b, _c;
645
- if (this.isHeader(col, row)) {
646
- const header = this.getHeader(col, row);
647
- return null !== (_b = null === (_a = this.rowsDefine) || void 0 === _a ? void 0 : _a.find((dimension => "string" != typeof dimension && dimension.dimensionKey === header.field))) && void 0 !== _b ? _b : null === (_c = this.columnsDefine) || void 0 === _c ? void 0 : _c.find((dimension => "string" != typeof dimension && dimension.dimensionKey === header.field));
648
- }
649
- }
650
- updateDataset(dataset) {
651
- this.dataset = dataset, this.dataConfig = dataset.dataConfig, this.rowKeysPath = dataset.rowKeysPath,
652
- this.colKeysPath = dataset.colKeysPath, this.tree = dataset.tree, this._indicatorObjects = [],
653
- this._headerObjects = [], this._headerObjectMap = {}, this.initState(), this.convertColKeys = (0,
654
- util_1.transpose)(this.colKeysPath);
655
- }
656
- isHeaderForColWidth(col, row) {
657
- return this.isHeader(col, row);
658
- }
659
- getHeaderForColWidth(col, row) {
660
- return this.getHeader(col, row);
661
- }
662
- setChartInstance(_col, _row, chartInstance) {
663
- var _a, _b;
664
- const paths = this.getCellHeaderPaths(_col, _row);
665
- let indicatorObj;
666
- if (this.indicatorsAsCol) {
667
- const indicatorKey = null === (_a = paths.colHeaderPaths.find((colPath => colPath.indicatorKey))) || void 0 === _a ? void 0 : _a.indicatorKey;
668
- indicatorObj = this._indicatorObjects.find((indicator => indicator.indicatorKey === indicatorKey));
669
- } else {
670
- const indicatorKey = null === (_b = paths.rowHeaderPaths.find((rowPath => rowPath.indicatorKey))) || void 0 === _b ? void 0 : _b.indicatorKey;
671
- indicatorObj = this._indicatorObjects.find((indicator => indicator.indicatorKey === indicatorKey));
672
- }
673
- indicatorObj && (indicatorObj.chartInstance = chartInstance);
674
- }
675
- getChartInstance(_col, _row) {
676
- var _a, _b;
677
- const paths = this.getCellHeaderPaths(_col, _row);
678
- let indicatorObj;
679
- if (this.indicatorsAsCol) {
680
- const indicatorKey = null === (_a = paths.colHeaderPaths.find((colPath => colPath.indicatorKey))) || void 0 === _a ? void 0 : _a.indicatorKey;
681
- indicatorObj = this._indicatorObjects.find((indicator => indicator.indicatorKey === indicatorKey));
682
- } else {
683
- const indicatorKey = null === (_b = paths.rowHeaderPaths.find((rowPath => rowPath.indicatorKey))) || void 0 === _b ? void 0 : _b.indicatorKey;
684
- indicatorObj = this._indicatorObjects.find((indicator => indicator.indicatorKey === indicatorKey));
685
- }
686
- return null == indicatorObj ? void 0 : indicatorObj.chartInstance;
687
- }
688
- _generateChartState() {
689
- return {
690
- vtable_selected: {
691
- filter: datum => {
692
- var _a;
693
- if (this._table._selectedDataItemsInChart.length >= 1) {
694
- return !!this._table._selectedDataItemsInChart.find((item => {
695
- for (const itemKey in item) if (item[itemKey] !== datum[itemKey]) return !1;
696
- return !0;
697
- }));
698
- }
699
- if (null === (_a = this._table._selectedDimensionInChart) || void 0 === _a ? void 0 : _a.length) {
700
- return !!this._table._selectedDimensionInChart.every((item => datum[item.key] === item.value));
701
- }
702
- return !1;
703
- }
704
- },
705
- vtable_selected_reverse: {
706
- filter: datum => {
707
- var _a;
708
- if (this._table._selectedDataItemsInChart.length >= 1) {
709
- return !this._table._selectedDataItemsInChart.find((item => {
710
- for (const itemKey in item) if (item[itemKey] !== datum[itemKey]) return !1;
711
- return !0;
712
- }));
713
- }
714
- if (null === (_a = this._table._selectedDimensionInChart) || void 0 === _a ? void 0 : _a.length) {
715
- return !this._table._selectedDimensionInChart.every((item => datum[item.key] === item.value));
716
- }
717
- return !1;
718
- }
719
- }
720
- };
721
- }
722
- updateDataStateToChartInstance(activeChartInstance) {
723
- activeChartInstance || (activeChartInstance = this._table._getActiveChartInstance());
724
- const state = this._generateChartState();
725
- this._indicatorObjects.forEach((_indicatorObject => {
726
- _indicatorObject.chartInstance.updateState(state);
727
- })), null == activeChartInstance || activeChartInstance.updateState(state);
728
- }
729
- updateDataStateToActiveChartInstance(activeChartInstance) {
730
- activeChartInstance || (activeChartInstance = this._table._getActiveChartInstance());
731
- const state = this._generateChartState();
732
- null == activeChartInstance || activeChartInstance.updateState(state);
733
- }
734
- getOptimunWidthForChart(col) {
735
- var _a, _b, _c, _d;
736
- const path = this.getCellHeaderPaths(col, this.columnHeaderLevelCount).colHeaderPaths;
737
- let collectedValues, width;
738
- for (const key in this.dataset.collectValuesBy) if ("xField" === this.dataset.collectValuesBy[key].type && !this.dataset.collectValuesBy[key].range) {
739
- collectedValues = this.dataset.collectedValues[key][path.map((pathObj => pathObj.value)).join(this.dataset.stringJoinChar)];
740
- break;
741
- }
742
- if (this._chartItemBandSize) width = scaleWholeRangeSize(null !== (_a = null == collectedValues ? void 0 : collectedValues.length) && void 0 !== _a ? _a : 0, this._chartItemBandSize, this._chartPaddingInner, this._chartPaddingOuter); else {
743
- const barWidth = this._chartItemSpanSize || 25;
744
- width = (null !== (_b = null == collectedValues ? void 0 : collectedValues.length) && void 0 !== _b ? _b : 0) * (barWidth + barWidth / 3);
745
- }
746
- const padding = (0, padding_1.getQuadProps)(null !== (_d = null !== (_c = this._chartPadding) && void 0 !== _c ? _c : this._table.theme.bodyStyle.padding) && void 0 !== _d ? _d : 0);
747
- return width + padding[1] + padding[3];
748
- }
749
- getOptimunHeightForChart(row) {
750
- var _a, _b, _c, _d;
751
- const path = this.getCellHeaderPaths(this.rowHeaderLevelCount, row).rowHeaderPaths;
752
- let collectedValues, height;
753
- for (const key in this.dataset.collectValuesBy) if ("yField" === this.dataset.collectValuesBy[key].type && !this.dataset.collectValuesBy[key].range) {
754
- collectedValues = this.dataset.collectedValues[key][path.map((pathObj => pathObj.value)).join(this.dataset.stringJoinChar)];
755
- break;
756
- }
757
- if (this._chartItemBandSize) height = scaleWholeRangeSize(null !== (_a = null == collectedValues ? void 0 : collectedValues.length) && void 0 !== _a ? _a : 0, this._chartItemBandSize, this._chartPaddingInner, this._chartPaddingOuter); else {
758
- const barWidth = this._chartItemSpanSize || 25;
759
- height = (null !== (_b = null == collectedValues ? void 0 : collectedValues.length) && void 0 !== _b ? _b : 0) * (barWidth + barWidth / 3);
760
- }
761
- const padding = (0, padding_1.getQuadProps)(null !== (_d = null !== (_c = this._chartPadding) && void 0 !== _c ? _c : this._table.theme.bodyStyle.padding) && void 0 !== _d ? _d : 0);
762
- return height + padding[0] + padding[2];
763
- }
764
- getIndicatorKeyInChartSpec(_col, _row) {
765
- const chartSpec = this.getRawChartSpec(_col, _row), indicatorKeys = [];
766
- return chartSpec ? (!1 === this.indicatorsAsCol ? chartSpec.series ? chartSpec.series.forEach((chartSeries => {
767
- const yField = chartSeries.yField;
768
- indicatorKeys.push(yField);
769
- })) : indicatorKeys.push(chartSpec.yField) : chartSpec.series ? chartSpec.series.forEach((chartSeries => {
770
- const xField = chartSeries.xField;
771
- indicatorKeys.push(xField);
772
- })) : indicatorKeys.push(chartSpec.xField), indicatorKeys) : null;
773
- }
774
- getDimensionKeyInChartSpec(_col, _row) {
775
- var _a, _b, _c, _d;
776
- const chartSpec = this.getRawChartSpec(_col, _row), dimensionKeys = [];
777
- return chartSpec ? (!1 === this.indicatorsAsCol ? dimensionKeys.push(null !== (_a = chartSpec.xField) && void 0 !== _a ? _a : null === (_b = null == chartSpec ? void 0 : chartSpec.series[0]) || void 0 === _b ? void 0 : _b.xField) : dimensionKeys.push(null !== (_c = chartSpec.yField) && void 0 !== _c ? _c : null === (_d = null == chartSpec ? void 0 : chartSpec.series[0]) || void 0 === _d ? void 0 : _d.yField),
778
- dimensionKeys) : null;
779
- }
780
- getAxisConfigInPivotChart(col, row) {
781
- return (0, get_axis_config_1.getAxisConfigInPivotChart)(col, row, this);
782
- }
783
- getRawChartSpec(col, row) {
784
- return (0, get_chart_spec_1.getRawChartSpec)(col, row, this);
785
- }
786
- getChartSpec(col, row) {
787
- return (0, get_chart_spec_1.getChartSpec)(col, row, this);
788
- }
789
- getChartAxes(col, row) {
790
- return (0, get_chart_spec_1.getChartAxes)(col, row, this);
791
- }
792
- getChartDataId(col, row) {
793
- return (0, get_chart_spec_1.getChartDataId)(col, row, this);
794
- }
795
- isEmpty(col, row) {
796
- return !!this._table.isPivotChart() && (col > this.colCount - this.rightFrozenColCount - 1 || row > this.rowCount - this.bottomFrozenRowCount - 1 || !(!this.hasTwoIndicatorAxes || !this.indicatorsAsCol || row !== this.columnHeaderLevelCount - 1));
797
- }
798
- release() {
799
- const activeChartInstance = this._table._getActiveChartInstance();
800
- null == activeChartInstance || activeChartInstance.release(), this._indicatorObjects.forEach((indicatorObject => {
801
- var _a;
802
- null === (_a = indicatorObject.chartInstance) || void 0 === _a || _a.release();
803
- }));
804
- }
805
- clearCellRangeMap() {}
806
- }
807
-
808
- function scaleWholeRangeSize(count, bandwidth, paddingInner, paddingOuter) {
809
- 1 === paddingInner && (paddingInner = 0);
810
- return bandSpace(count, paddingInner, paddingOuter) * (bandwidth / (1 - paddingInner));
811
- }
812
-
813
- function bandSpace(count, paddingInner, paddingOuter) {
814
- let space;
815
- return space = 1 === count ? count + 2 * paddingOuter : count - paddingInner + 2 * paddingOuter,
816
- count ? space > 0 ? space : 1 : 0;
817
- }
818
-
819
1
  //# sourceMappingURL=pivot-layout.js.map
820
- exports.PivotLayoutMap = PivotLayoutMap;