@rowsncolumns/charts 27.0.30

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 (281) hide show
  1. package/LICENSE.md +100 -0
  2. package/Readme.md +81 -0
  3. package/dist/cjs/atoms/editing-chart.atom.d.ts +13 -0
  4. package/dist/cjs/atoms/editing-chart.atom.d.ts.map +1 -0
  5. package/dist/cjs/atoms/editing-chart.atom.js +26 -0
  6. package/dist/cjs/basic-chart/basic-chart.d.ts +5 -0
  7. package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -0
  8. package/dist/cjs/basic-chart/basic-chart.js +2250 -0
  9. package/dist/cjs/basic-chart/helpers.d.ts +12 -0
  10. package/dist/cjs/basic-chart/helpers.d.ts.map +1 -0
  11. package/dist/cjs/basic-chart/helpers.js +105 -0
  12. package/dist/cjs/basic-chart/index.d.ts +5 -0
  13. package/dist/cjs/basic-chart/index.d.ts.map +1 -0
  14. package/dist/cjs/basic-chart/index.js +12 -0
  15. package/dist/cjs/components/dialogs/chart-editor-dialog.d.ts +5 -0
  16. package/dist/cjs/components/dialogs/chart-editor-dialog.d.ts.map +1 -0
  17. package/dist/cjs/components/dialogs/chart-editor-dialog.js +25 -0
  18. package/dist/cjs/components/editors/chart-editor.d.ts +10 -0
  19. package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -0
  20. package/dist/cjs/components/editors/chart-editor.js +631 -0
  21. package/dist/cjs/components/editors/chart-range-input.d.ts +17 -0
  22. package/dist/cjs/components/editors/chart-range-input.d.ts.map +1 -0
  23. package/dist/cjs/components/editors/chart-range-input.js +16 -0
  24. package/dist/cjs/config.d.ts +19 -0
  25. package/dist/cjs/config.d.ts.map +1 -0
  26. package/dist/cjs/config.js +196 -0
  27. package/dist/cjs/hooks/use-chart-editor.d.ts +8 -0
  28. package/dist/cjs/hooks/use-chart-editor.d.ts.map +1 -0
  29. package/dist/cjs/hooks/use-chart-editor.js +29 -0
  30. package/dist/cjs/hooks/use-charts.d.ts +35 -0
  31. package/dist/cjs/hooks/use-charts.d.ts.map +1 -0
  32. package/dist/cjs/hooks/use-charts.js +67 -0
  33. package/dist/cjs/hooks/use-on-create-chart.d.ts +13 -0
  34. package/dist/cjs/hooks/use-on-create-chart.d.ts.map +1 -0
  35. package/dist/cjs/hooks/use-on-create-chart.js +24 -0
  36. package/dist/cjs/hooks/use-on-delete-chart.d.ts +8 -0
  37. package/dist/cjs/hooks/use-on-delete-chart.d.ts.map +1 -0
  38. package/dist/cjs/hooks/use-on-delete-chart.js +19 -0
  39. package/dist/cjs/hooks/use-on-move-chart.d.ts +8 -0
  40. package/dist/cjs/hooks/use-on-move-chart.d.ts.map +1 -0
  41. package/dist/cjs/hooks/use-on-move-chart.js +15 -0
  42. package/dist/cjs/hooks/use-on-resize-chart.d.ts +8 -0
  43. package/dist/cjs/hooks/use-on-resize-chart.d.ts.map +1 -0
  44. package/dist/cjs/hooks/use-on-resize-chart.js +15 -0
  45. package/dist/cjs/hooks/use-on-update-chart.d.ts +9 -0
  46. package/dist/cjs/hooks/use-on-update-chart.d.ts.map +1 -0
  47. package/dist/cjs/hooks/use-on-update-chart.js +15 -0
  48. package/dist/cjs/index.d.ts +11 -0
  49. package/dist/cjs/index.d.ts.map +1 -0
  50. package/dist/cjs/index.js +18 -0
  51. package/dist/cjs/interface/create-chart.d.ts +9 -0
  52. package/dist/cjs/interface/create-chart.d.ts.map +1 -0
  53. package/dist/cjs/interface/create-chart.js +110 -0
  54. package/dist/cjs/interface/delete-chart.d.ts +4 -0
  55. package/dist/cjs/interface/delete-chart.d.ts.map +1 -0
  56. package/dist/cjs/interface/delete-chart.js +26 -0
  57. package/dist/cjs/interface/move-chart.d.ts +5 -0
  58. package/dist/cjs/interface/move-chart.d.ts.map +1 -0
  59. package/dist/cjs/interface/move-chart.js +28 -0
  60. package/dist/cjs/interface/resize-chart.d.ts +5 -0
  61. package/dist/cjs/interface/resize-chart.d.ts.map +1 -0
  62. package/dist/cjs/interface/resize-chart.js +30 -0
  63. package/dist/cjs/interface/update-chart.d.ts +4 -0
  64. package/dist/cjs/interface/update-chart.d.ts.map +1 -0
  65. package/dist/cjs/interface/update-chart.js +29 -0
  66. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts +5 -0
  67. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -0
  68. package/dist/cjs/plotly/basic-chart/basic-chart.js +1586 -0
  69. package/dist/cjs/plotly/basic-chart/helpers.d.ts +20 -0
  70. package/dist/cjs/plotly/basic-chart/helpers.d.ts.map +1 -0
  71. package/dist/cjs/plotly/basic-chart/helpers.js +114 -0
  72. package/dist/cjs/plotly/basic-chart/index.d.ts +5 -0
  73. package/dist/cjs/plotly/basic-chart/index.d.ts.map +1 -0
  74. package/dist/cjs/plotly/basic-chart/index.js +12 -0
  75. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  76. package/dist/cjs/types.d.ts +27 -0
  77. package/dist/cjs/types.d.ts.map +1 -0
  78. package/dist/cjs/types.js +2 -0
  79. package/dist/cjs/utils/aggregation.d.ts +6 -0
  80. package/dist/cjs/utils/aggregation.d.ts.map +1 -0
  81. package/dist/cjs/utils/aggregation.js +127 -0
  82. package/dist/cjs/utils/bar-layout.d.ts +57 -0
  83. package/dist/cjs/utils/bar-layout.d.ts.map +1 -0
  84. package/dist/cjs/utils/bar-layout.js +81 -0
  85. package/dist/cjs/utils/boxplot.d.ts +62 -0
  86. package/dist/cjs/utils/boxplot.d.ts.map +1 -0
  87. package/dist/cjs/utils/boxplot.js +105 -0
  88. package/dist/cjs/utils/bubble.d.ts +52 -0
  89. package/dist/cjs/utils/bubble.d.ts.map +1 -0
  90. package/dist/cjs/utils/bubble.js +139 -0
  91. package/dist/cjs/utils/chart-spec-utils.d.ts +67 -0
  92. package/dist/cjs/utils/chart-spec-utils.d.ts.map +1 -0
  93. package/dist/cjs/utils/chart-spec-utils.js +355 -0
  94. package/dist/cjs/utils/echarts-gl-loader.d.ts +11 -0
  95. package/dist/cjs/utils/echarts-gl-loader.d.ts.map +1 -0
  96. package/dist/cjs/utils/echarts-gl-loader.js +59 -0
  97. package/dist/cjs/utils/error-bars.d.ts +58 -0
  98. package/dist/cjs/utils/error-bars.d.ts.map +1 -0
  99. package/dist/cjs/utils/error-bars.js +154 -0
  100. package/dist/cjs/utils/gradient.d.ts +52 -0
  101. package/dist/cjs/utils/gradient.d.ts.map +1 -0
  102. package/dist/cjs/utils/gradient.js +93 -0
  103. package/dist/cjs/utils/hierarchy.d.ts +28 -0
  104. package/dist/cjs/utils/hierarchy.d.ts.map +1 -0
  105. package/dist/cjs/utils/hierarchy.js +186 -0
  106. package/dist/cjs/utils/histogram.d.ts +46 -0
  107. package/dist/cjs/utils/histogram.d.ts.map +1 -0
  108. package/dist/cjs/utils/histogram.js +125 -0
  109. package/dist/cjs/utils/of-pie.d.ts +101 -0
  110. package/dist/cjs/utils/of-pie.d.ts.map +1 -0
  111. package/dist/cjs/utils/of-pie.js +159 -0
  112. package/dist/cjs/utils/overrides.d.ts +12 -0
  113. package/dist/cjs/utils/overrides.d.ts.map +1 -0
  114. package/dist/cjs/utils/overrides.js +171 -0
  115. package/dist/cjs/utils/radar.d.ts +37 -0
  116. package/dist/cjs/utils/radar.d.ts.map +1 -0
  117. package/dist/cjs/utils/radar.js +70 -0
  118. package/dist/cjs/utils/region-map-loader.d.ts +22 -0
  119. package/dist/cjs/utils/region-map-loader.d.ts.map +1 -0
  120. package/dist/cjs/utils/region-map-loader.js +174 -0
  121. package/dist/cjs/utils/region-map.d.ts +100 -0
  122. package/dist/cjs/utils/region-map.d.ts.map +1 -0
  123. package/dist/cjs/utils/region-map.js +327 -0
  124. package/dist/cjs/utils/stock.d.ts +64 -0
  125. package/dist/cjs/utils/stock.d.ts.map +1 -0
  126. package/dist/cjs/utils/stock.js +153 -0
  127. package/dist/cjs/utils/three-d.d.ts +96 -0
  128. package/dist/cjs/utils/three-d.d.ts.map +1 -0
  129. package/dist/cjs/utils/three-d.js +191 -0
  130. package/dist/cjs/utils/trendline.d.ts +41 -0
  131. package/dist/cjs/utils/trendline.d.ts.map +1 -0
  132. package/dist/cjs/utils/trendline.js +303 -0
  133. package/dist/cjs/utils/waterfall.d.ts +24 -0
  134. package/dist/cjs/utils/waterfall.d.ts.map +1 -0
  135. package/dist/cjs/utils/waterfall.js +61 -0
  136. package/dist/cjs/utils/webgl.d.ts +12 -0
  137. package/dist/cjs/utils/webgl.d.ts.map +1 -0
  138. package/dist/cjs/utils/webgl.js +36 -0
  139. package/dist/cjs/vitest.config.d.ts +3 -0
  140. package/dist/cjs/vitest.config.d.ts.map +1 -0
  141. package/dist/cjs/vitest.config.js +9 -0
  142. package/dist/esm/atoms/editing-chart.atom.d.ts +13 -0
  143. package/dist/esm/atoms/editing-chart.atom.d.ts.map +1 -0
  144. package/dist/esm/atoms/editing-chart.atom.js +12 -0
  145. package/dist/esm/basic-chart/basic-chart.d.ts +5 -0
  146. package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -0
  147. package/dist/esm/basic-chart/basic-chart.js +2343 -0
  148. package/dist/esm/basic-chart/helpers.d.ts +12 -0
  149. package/dist/esm/basic-chart/helpers.d.ts.map +1 -0
  150. package/dist/esm/basic-chart/helpers.js +98 -0
  151. package/dist/esm/basic-chart/index.d.ts +5 -0
  152. package/dist/esm/basic-chart/index.d.ts.map +1 -0
  153. package/dist/esm/basic-chart/index.js +7 -0
  154. package/dist/esm/components/dialogs/chart-editor-dialog.d.ts +5 -0
  155. package/dist/esm/components/dialogs/chart-editor-dialog.d.ts.map +1 -0
  156. package/dist/esm/components/dialogs/chart-editor-dialog.js +19 -0
  157. package/dist/esm/components/editors/chart-editor.d.ts +10 -0
  158. package/dist/esm/components/editors/chart-editor.d.ts.map +1 -0
  159. package/dist/esm/components/editors/chart-editor.js +550 -0
  160. package/dist/esm/components/editors/chart-range-input.d.ts +17 -0
  161. package/dist/esm/components/editors/chart-range-input.d.ts.map +1 -0
  162. package/dist/esm/components/editors/chart-range-input.js +10 -0
  163. package/dist/esm/config.d.ts +19 -0
  164. package/dist/esm/config.d.ts.map +1 -0
  165. package/dist/esm/config.js +161 -0
  166. package/dist/esm/hooks/use-chart-editor.d.ts +8 -0
  167. package/dist/esm/hooks/use-chart-editor.d.ts.map +1 -0
  168. package/dist/esm/hooks/use-chart-editor.js +32 -0
  169. package/dist/esm/hooks/use-charts.d.ts +35 -0
  170. package/dist/esm/hooks/use-charts.d.ts.map +1 -0
  171. package/dist/esm/hooks/use-charts.js +62 -0
  172. package/dist/esm/hooks/use-on-create-chart.d.ts +13 -0
  173. package/dist/esm/hooks/use-on-create-chart.d.ts.map +1 -0
  174. package/dist/esm/hooks/use-on-create-chart.js +19 -0
  175. package/dist/esm/hooks/use-on-delete-chart.d.ts +8 -0
  176. package/dist/esm/hooks/use-on-delete-chart.d.ts.map +1 -0
  177. package/dist/esm/hooks/use-on-delete-chart.js +14 -0
  178. package/dist/esm/hooks/use-on-move-chart.d.ts +8 -0
  179. package/dist/esm/hooks/use-on-move-chart.d.ts.map +1 -0
  180. package/dist/esm/hooks/use-on-move-chart.js +10 -0
  181. package/dist/esm/hooks/use-on-resize-chart.d.ts +8 -0
  182. package/dist/esm/hooks/use-on-resize-chart.d.ts.map +1 -0
  183. package/dist/esm/hooks/use-on-resize-chart.js +10 -0
  184. package/dist/esm/hooks/use-on-update-chart.d.ts +9 -0
  185. package/dist/esm/hooks/use-on-update-chart.d.ts.map +1 -0
  186. package/dist/esm/hooks/use-on-update-chart.js +10 -0
  187. package/dist/esm/index.d.ts +11 -0
  188. package/dist/esm/index.d.ts.map +1 -0
  189. package/dist/esm/index.js +13 -0
  190. package/dist/esm/interface/create-chart.d.ts +9 -0
  191. package/dist/esm/interface/create-chart.d.ts.map +1 -0
  192. package/dist/esm/interface/create-chart.js +126 -0
  193. package/dist/esm/interface/delete-chart.d.ts +4 -0
  194. package/dist/esm/interface/delete-chart.d.ts.map +1 -0
  195. package/dist/esm/interface/delete-chart.js +20 -0
  196. package/dist/esm/interface/move-chart.d.ts +5 -0
  197. package/dist/esm/interface/move-chart.d.ts.map +1 -0
  198. package/dist/esm/interface/move-chart.js +22 -0
  199. package/dist/esm/interface/resize-chart.d.ts +5 -0
  200. package/dist/esm/interface/resize-chart.d.ts.map +1 -0
  201. package/dist/esm/interface/resize-chart.js +24 -0
  202. package/dist/esm/interface/update-chart.d.ts +4 -0
  203. package/dist/esm/interface/update-chart.d.ts.map +1 -0
  204. package/dist/esm/interface/update-chart.js +26 -0
  205. package/dist/esm/plotly/basic-chart/basic-chart.d.ts +5 -0
  206. package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -0
  207. package/dist/esm/plotly/basic-chart/basic-chart.js +1682 -0
  208. package/dist/esm/plotly/basic-chart/helpers.d.ts +20 -0
  209. package/dist/esm/plotly/basic-chart/helpers.d.ts.map +1 -0
  210. package/dist/esm/plotly/basic-chart/helpers.js +107 -0
  211. package/dist/esm/plotly/basic-chart/index.d.ts +5 -0
  212. package/dist/esm/plotly/basic-chart/index.d.ts.map +1 -0
  213. package/dist/esm/plotly/basic-chart/index.js +7 -0
  214. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  215. package/dist/esm/types.d.ts +27 -0
  216. package/dist/esm/types.d.ts.map +1 -0
  217. package/dist/esm/types.js +1 -0
  218. package/dist/esm/utils/aggregation.d.ts +6 -0
  219. package/dist/esm/utils/aggregation.d.ts.map +1 -0
  220. package/dist/esm/utils/aggregation.js +96 -0
  221. package/dist/esm/utils/bar-layout.d.ts +57 -0
  222. package/dist/esm/utils/bar-layout.d.ts.map +1 -0
  223. package/dist/esm/utils/bar-layout.js +70 -0
  224. package/dist/esm/utils/boxplot.d.ts +62 -0
  225. package/dist/esm/utils/boxplot.d.ts.map +1 -0
  226. package/dist/esm/utils/boxplot.js +91 -0
  227. package/dist/esm/utils/bubble.d.ts +52 -0
  228. package/dist/esm/utils/bubble.d.ts.map +1 -0
  229. package/dist/esm/utils/bubble.js +122 -0
  230. package/dist/esm/utils/chart-spec-utils.d.ts +67 -0
  231. package/dist/esm/utils/chart-spec-utils.d.ts.map +1 -0
  232. package/dist/esm/utils/chart-spec-utils.js +270 -0
  233. package/dist/esm/utils/echarts-gl-loader.d.ts +11 -0
  234. package/dist/esm/utils/echarts-gl-loader.d.ts.map +1 -0
  235. package/dist/esm/utils/echarts-gl-loader.js +51 -0
  236. package/dist/esm/utils/error-bars.d.ts +58 -0
  237. package/dist/esm/utils/error-bars.d.ts.map +1 -0
  238. package/dist/esm/utils/error-bars.js +134 -0
  239. package/dist/esm/utils/gradient.d.ts +52 -0
  240. package/dist/esm/utils/gradient.d.ts.map +1 -0
  241. package/dist/esm/utils/gradient.js +84 -0
  242. package/dist/esm/utils/hierarchy.d.ts +28 -0
  243. package/dist/esm/utils/hierarchy.d.ts.map +1 -0
  244. package/dist/esm/utils/hierarchy.js +150 -0
  245. package/dist/esm/utils/histogram.d.ts +46 -0
  246. package/dist/esm/utils/histogram.d.ts.map +1 -0
  247. package/dist/esm/utils/histogram.js +95 -0
  248. package/dist/esm/utils/of-pie.d.ts +101 -0
  249. package/dist/esm/utils/of-pie.d.ts.map +1 -0
  250. package/dist/esm/utils/of-pie.js +141 -0
  251. package/dist/esm/utils/overrides.d.ts +12 -0
  252. package/dist/esm/utils/overrides.d.ts.map +1 -0
  253. package/dist/esm/utils/overrides.js +159 -0
  254. package/dist/esm/utils/radar.d.ts +37 -0
  255. package/dist/esm/utils/radar.d.ts.map +1 -0
  256. package/dist/esm/utils/radar.js +49 -0
  257. package/dist/esm/utils/region-map-loader.d.ts +22 -0
  258. package/dist/esm/utils/region-map-loader.d.ts.map +1 -0
  259. package/dist/esm/utils/region-map-loader.js +141 -0
  260. package/dist/esm/utils/region-map.d.ts +100 -0
  261. package/dist/esm/utils/region-map.d.ts.map +1 -0
  262. package/dist/esm/utils/region-map.js +266 -0
  263. package/dist/esm/utils/stock.d.ts +64 -0
  264. package/dist/esm/utils/stock.d.ts.map +1 -0
  265. package/dist/esm/utils/stock.js +123 -0
  266. package/dist/esm/utils/three-d.d.ts +96 -0
  267. package/dist/esm/utils/three-d.d.ts.map +1 -0
  268. package/dist/esm/utils/three-d.js +162 -0
  269. package/dist/esm/utils/trendline.d.ts +41 -0
  270. package/dist/esm/utils/trendline.d.ts.map +1 -0
  271. package/dist/esm/utils/trendline.js +257 -0
  272. package/dist/esm/utils/waterfall.d.ts +24 -0
  273. package/dist/esm/utils/waterfall.d.ts.map +1 -0
  274. package/dist/esm/utils/waterfall.js +55 -0
  275. package/dist/esm/utils/webgl.d.ts +12 -0
  276. package/dist/esm/utils/webgl.d.ts.map +1 -0
  277. package/dist/esm/utils/webgl.js +30 -0
  278. package/dist/esm/vitest.config.d.ts +3 -0
  279. package/dist/esm/vitest.config.d.ts.map +1 -0
  280. package/dist/esm/vitest.config.js +7 -0
  281. package/package.json +96 -0
@@ -0,0 +1,2250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BasicChart = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var icons_1 = require("@rowsncolumns/icons");
6
+ var spreadsheet_1 = require("@rowsncolumns/spreadsheet");
7
+ var spreadsheet_state_1 = require("@rowsncolumns/spreadsheet-state");
8
+ var toolkit_1 = require("@rowsncolumns/toolkit");
9
+ var ui_1 = require("@rowsncolumns/ui");
10
+ var utils_1 = require("@rowsncolumns/utils");
11
+ var charts_1 = require("echarts/charts");
12
+ var components_1 = require("echarts/components");
13
+ var echarts = tslib_1.__importStar(require("echarts/core"));
14
+ var renderers_1 = require("echarts/renderers");
15
+ var react_1 = tslib_1.__importStar(require("react"));
16
+ var aggregation_1 = require("../utils/aggregation");
17
+ var bar_layout_1 = require("../utils/bar-layout");
18
+ var boxplot_1 = require("../utils/boxplot");
19
+ var bubble_1 = require("../utils/bubble");
20
+ var chart_spec_utils_1 = require("../utils/chart-spec-utils");
21
+ var echarts_gl_loader_1 = require("../utils/echarts-gl-loader");
22
+ var error_bars_1 = require("../utils/error-bars");
23
+ var gradient_1 = require("../utils/gradient");
24
+ var hierarchy_1 = require("../utils/hierarchy");
25
+ var histogram_1 = require("../utils/histogram");
26
+ var of_pie_1 = require("../utils/of-pie");
27
+ var overrides_1 = require("../utils/overrides");
28
+ var radar_1 = require("../utils/radar");
29
+ var region_map_1 = require("../utils/region-map");
30
+ var region_map_loader_1 = require("../utils/region-map-loader");
31
+ var stock_1 = require("../utils/stock");
32
+ var three_d_1 = require("../utils/three-d");
33
+ var trendline_1 = require("../utils/trendline");
34
+ var waterfall_1 = require("../utils/waterfall");
35
+ var webgl_1 = require("../utils/webgl");
36
+ var helpers_1 = require("./helpers");
37
+ // Excel error values that should be treated as null in charts
38
+ var EXCEL_ERROR_VALUES = new Set([
39
+ "#N/A",
40
+ "#REF!",
41
+ "#VALUE!",
42
+ "#DIV/0!",
43
+ "#NAME?",
44
+ "#NULL!",
45
+ "#NUM!",
46
+ "#ERROR!",
47
+ "#GETTING_DATA",
48
+ ]);
49
+ /**
50
+ * Check if a value is an Excel error string
51
+ */
52
+ var isErrorValue = function (value) {
53
+ if (typeof value !== "string")
54
+ return false;
55
+ return EXCEL_ERROR_VALUES.has(value.toUpperCase());
56
+ };
57
+ /**
58
+ * Sanitize a value for chart display - convert errors to undefined
59
+ */
60
+ var sanitizeChartValue = function (value) {
61
+ if (value === null || value === undefined)
62
+ return undefined;
63
+ if (isErrorValue(value))
64
+ return undefined;
65
+ if (typeof value === "number" && !isNaN(value))
66
+ return value;
67
+ if (typeof value === "string") {
68
+ var num = parseFloat(value);
69
+ return isNaN(num) ? undefined : num;
70
+ }
71
+ return undefined;
72
+ };
73
+ var BASIC_CHART_TYPES = new Set([
74
+ "bar",
75
+ "column",
76
+ "line",
77
+ "pie",
78
+ "area",
79
+ "doughnut",
80
+ "radar",
81
+ "stock",
82
+ "histogram",
83
+ "boxplot",
84
+ "waterfall",
85
+ "funnel",
86
+ "combo",
87
+ "regionMap",
88
+ ]);
89
+ var BUBBLE_CHART_TYPES = new Set([
90
+ "bubble",
91
+ "scatter",
92
+ ]);
93
+ var HIERARCHY_CHART_TYPES = new Set([
94
+ "treemap",
95
+ "sunburst",
96
+ ]);
97
+ var isBasicChartSpec = function (spec) {
98
+ return BASIC_CHART_TYPES.has(spec.chartType);
99
+ };
100
+ var isBubbleChartSpec = function (spec) {
101
+ return BUBBLE_CHART_TYPES.has(spec.chartType);
102
+ };
103
+ var isHierarchyChartSpec = function (spec) {
104
+ return HIERARCHY_CHART_TYPES.has(spec.chartType);
105
+ };
106
+ var HIERARCHY_LEVEL_STYLES = [
107
+ {
108
+ itemStyle: {
109
+ gapWidth: 1,
110
+ borderColorSaturation: 0.6,
111
+ },
112
+ upperLabel: { show: false },
113
+ },
114
+ {
115
+ colorSaturation: [0.35, 0.65],
116
+ itemStyle: {
117
+ gapWidth: 1,
118
+ borderColorSaturation: 0.6,
119
+ },
120
+ },
121
+ {
122
+ colorSaturation: [0.45, 0.75],
123
+ itemStyle: {
124
+ gapWidth: 1,
125
+ borderColorSaturation: 0.6,
126
+ },
127
+ },
128
+ ];
129
+ var getHierarchyDepth = function (nodes, depth) {
130
+ if (depth === void 0) { depth = 1; }
131
+ var maxDepth = depth;
132
+ nodes.forEach(function (node) {
133
+ if (node.children && node.children.length > 0) {
134
+ maxDepth = Math.max(maxDepth, getHierarchyDepth(node.children, depth + 1));
135
+ }
136
+ });
137
+ return maxDepth;
138
+ };
139
+ var flattenChartDataValues = function (chartData, extractor, hiddenStrategy, skipFirstRow) {
140
+ if (skipFirstRow === void 0) { skipFirstRow = false; }
141
+ if (!chartData || chartData.length === 0)
142
+ return [];
143
+ var values = [];
144
+ chartData.forEach(function (entry) {
145
+ // Inline values (`<c:strLit>` / `<c:numLit>` embedded in the chart
146
+ // XML) take precedence over cell-range sources — by spec only one
147
+ // is populated, but if both happen to exist the inline value is
148
+ // the authored "ground truth".
149
+ var inline = entry
150
+ .inlineValues;
151
+ if (inline && inline.length) {
152
+ var trimmed = skipFirstRow ? inline.slice(1) : inline;
153
+ values.push.apply(values, tslib_1.__spreadArray([], tslib_1.__read(trimmed), false));
154
+ return;
155
+ }
156
+ entry.sources.forEach(function (source) {
157
+ var _a;
158
+ var extracted = (_a = extractor(source, hiddenStrategy)) !== null && _a !== void 0 ? _a : [];
159
+ var trimmed = skipFirstRow && extracted.length > 0 ? extracted.slice(1) : extracted;
160
+ values.push.apply(values, tslib_1.__spreadArray([], tslib_1.__read(trimmed), false));
161
+ });
162
+ });
163
+ return values;
164
+ };
165
+ var buildHierarchyLevels = function (maxDepth) {
166
+ if (maxDepth <= 0)
167
+ return undefined;
168
+ var levels = [];
169
+ for (var i = 0; i < maxDepth; i++) {
170
+ var baseStyle = HIERARCHY_LEVEL_STYLES[Math.min(i, HIERARCHY_LEVEL_STYLES.length - 1)];
171
+ levels.push(tslib_1.__assign(tslib_1.__assign({}, baseStyle), { itemStyle: tslib_1.__assign({}, baseStyle.itemStyle) }));
172
+ }
173
+ return levels;
174
+ };
175
+ var defaultLegendConfig = {
176
+ padding: 10,
177
+ itemWidth: 10,
178
+ itemHeight: 4,
179
+ top: 20,
180
+ };
181
+ var BasicChart = function (_a) {
182
+ var _b;
183
+ var width = _a.width, height = _a.height, chart = _a.chart, theme = _a.theme, isDarkMode = _a.isDarkMode, sheetId = _a.sheetId, readonly = _a.readonly, getDomainValuesFromRange = _a.getDomainValuesFromRange, getSeriesValuesFromRange = _a.getSeriesValuesFromRange, onDeleteChart = _a.onDeleteChart, onRequestEdit = _a.onRequestEdit, onRequestCalculate = _a.onRequestCalculate, isSelected = _a.isSelected;
184
+ var spec = chart.spec;
185
+ var explicitChartTitle = (_b = chart.spec.title) !== null && _b !== void 0 ? _b : undefined;
186
+ var hierarchyTitleRef = (0, react_1.useRef)(explicitChartTitle);
187
+ var title = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : hierarchyTitleRef.current;
188
+ var el = (0, react_1.useRef)(null);
189
+ var chartRef = (0, react_1.useRef)(undefined);
190
+ var focusSheet = (0, spreadsheet_1.useFocusSheet)();
191
+ var shouldFocusSheetRef = (0, react_1.useRef)(false);
192
+ var previousChartType = (0, react_1.useRef)(undefined);
193
+ var previousSeriesCount = (0, react_1.useRef)(undefined);
194
+ // 3-D pipeline state. echarts-gl is lazy-loaded the first time a 3-D
195
+ // spec renders; the tick re-runs updateChart when the module lands so
196
+ // the chart upgrades from the immediate 2-D fallback to true 3-D.
197
+ var renderedIn3D = (0, react_1.useRef)(false);
198
+ var glUpgradeRequested = (0, react_1.useRef)(false);
199
+ var _c = tslib_1.__read((0, react_1.useState)(0), 2), glUpgradeTick = _c[0], setGlUpgradeTick = _c[1];
200
+ // Region-map (choropleth) pipeline state. The map option (geo +
201
+ // visualMap) doesn't merge back into a cartesian one, so the instance
202
+ // is re-initialized when entering/leaving the region-map rendering.
203
+ var renderedAsRegionMap = (0, react_1.useRef)(false);
204
+ // Initialize line chart
205
+ var initializeChart = function () {
206
+ var _a, _b;
207
+ if (el.current && !chartRef.current) {
208
+ chartRef.current = echarts.init(el.current);
209
+ chartRef.current.setOption({
210
+ title: {
211
+ left: "top",
212
+ padding: 10,
213
+ textStyle: {
214
+ fontSize: 16,
215
+ fontWeight: "normal",
216
+ fontFamily: "Untitled Sans, apple-system, sans-serif",
217
+ },
218
+ },
219
+ tooltip: {
220
+ textStyle: {
221
+ fontSize: 12,
222
+ },
223
+ trigger: "axis",
224
+ },
225
+ legend: defaultLegendConfig,
226
+ grid: {
227
+ left: "3%",
228
+ right: "4%",
229
+ bottom: "3%",
230
+ containLabel: true,
231
+ },
232
+ xAxis: [
233
+ {
234
+ type: "category",
235
+ name: (_a = spec.horizontalAxisTitle) !== null && _a !== void 0 ? _a : "", // Set your x-axis title here
236
+ nameLocation: "middle",
237
+ nameGap: 30,
238
+ },
239
+ ],
240
+ yAxis: [
241
+ {
242
+ type: "value",
243
+ name: (_b = spec.verticalAxisTitle) !== null && _b !== void 0 ? _b : "", // Set your y-axis title here
244
+ nameLocation: "middle",
245
+ nameGap: 50,
246
+ },
247
+ ],
248
+ series: [],
249
+ });
250
+ }
251
+ };
252
+ var getSeriesData = (0, react_1.useCallback)(function (spec, sheetRange, options) {
253
+ var _a;
254
+ var rawSeriesValues = getSeriesValuesFromRange(sheetRange, spec.hiddenDimensionStrategy);
255
+ // Sanitize values - convert error strings like #N/A to null
256
+ var seriesValues = rawSeriesValues.map(sanitizeChartValue);
257
+ var aggregateEnabled = options.aggregateEnabled, aggregateType = options.aggregateType, rawDomainValues = options.rawDomainValues, orderedDomainValues = options.orderedDomainValues;
258
+ var canAggregate = aggregateEnabled &&
259
+ !!aggregateType &&
260
+ rawDomainValues.length > 0 &&
261
+ orderedDomainValues.length > 0 &&
262
+ rawDomainValues.length === seriesValues.length;
263
+ if (canAggregate) {
264
+ var aggregatedValues_1 = (0, aggregation_1.aggregateSeriesByDomain)(rawDomainValues, seriesValues, aggregateType, orderedDomainValues);
265
+ if (spec.chartType === "pie") {
266
+ return orderedDomainValues.map(function (name, idx) {
267
+ var _a;
268
+ return ({
269
+ value: (_a = aggregatedValues_1[idx]) !== null && _a !== void 0 ? _a : 0,
270
+ name: name,
271
+ });
272
+ });
273
+ }
274
+ return aggregatedValues_1;
275
+ }
276
+ var numericValues = seriesValues;
277
+ if (spec.chartType === "pie") {
278
+ var domainSheetRange = (_a = spec.domains[0]) === null || _a === void 0 ? void 0 : _a.sources[0];
279
+ if (!domainSheetRange) {
280
+ return [];
281
+ }
282
+ var domainValues = getDomainValuesFromRange(domainSheetRange, spec.hiddenDimensionStrategy);
283
+ return domainValues.map(function (name, idx) { return ({
284
+ value: numericValues[idx],
285
+ name: name,
286
+ }); });
287
+ }
288
+ return numericValues;
289
+ }, [getSeriesValuesFromRange, getDomainValuesFromRange]);
290
+ // Resize a chart
291
+ var resizeChart = function () {
292
+ var _a;
293
+ (_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.resize();
294
+ };
295
+ /**
296
+ * Triggers a chart update
297
+ */
298
+ var updateChart = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
299
+ var threeDRenderKind, canRender3D, willRender3D, isRegionMap, regionSpec, geoScope, geo, labels, seriesEntry, values, _a, data, unmatched, min, max, textColor, ramp, noDataColor, borderColor, regionSeriesLabel, seriesName, chartDomains, chartSeries, legend, chartType, position, showAxis, isBubble, isHierarchy, skipHeaders_1, labelValues, perSeriesX, perSeriesSize, seriesInputs, i, seriesEntry, resolvedLabel, _b, xValues, sizeValues_1, sharedXValues, sharedSizeValues, _c, categories_1, preparedSeries, sizeValues, sizeScale_1, xAxisConfig, tooltipFormatter, bubbleSeriesLabel_1, hierarchyRows, headerTitle, hierarchyData, rootName, seriesDisplayName, hierarchyDepth, levels, tooltipFormatter, hierarchySeriesLabel, categories_2, threeDSeriesInputs, _d, _e, seriesEntry, dataLabel, _f, _g, values, e_1_1, seriesNames_1, threeDPalette_1, seriesColorAt_1, categoryAxisLabel, seriesAxisLabel, threeDTooltipFormatter, threeDSeries, visualMap, xAxis3D, yAxis3D, surfacePoints, _h, zMin, zMax, skipHeaders, categories, radarSeriesInputs, _j, _k, seriesEntry, label, values, indicators, radarData, radarStyle_1, radarColors_1, radarSeriesLabel, variant, categories, seriesValues, stockSeriesLabel_1, upColor_1, downColor_1, volumePoints, hasVolume, stockGrid, baseStockXAxis, stockXAxis, volumeYAxis, volumeSeries, stockAxisPointer, candleData, lineSeries, stockColors_1, isStacked, isCircularChart, isOfPie, ofPieLayout, isHorizontalBarChart, shouldAggregate, primaryDomainSource, rawPrimaryDomainValues, aggregateDomainValues, pushSeriesOverlays, sideBySideBarCount, specBarGap, specBarCategoryGap, _l, _m, series, dataLabel, _o, _p, _loop_1, _q, _r, sheetRange, e_2_1, labels, seriesEntry, rawValues, _s, main_1, secondary, otherTotal, total, ofPieType_1, secondScale, halfAngle_1, hasSecondary, MAIN_CX_1, CY_1, MAIN_RADIUS_PCT_1, SECONDARY_CX_1, secondaryRadiusPct_1, BAR_LEFT_1, BAR_RIGHT, barHalfFrac_1, ofPiePalette_1, paletteAt_1, connectorColor_1, primaryDomainSource_1, rawDomainValues, labels, seriesEntry, rawValues_1, totalIndices, steps, accent_1, decreaseColor_1, totalColor_1, connectors, primaryDomainSource_2, rawDomainValues, labels_1, seriesEntry, rawValues, quartileMethod, showOutliers, showMeanMarker, boxStats, boxLabels, outlierPoints, meanPoints, _t, _u, seriesEntry, label, rawValues, summary, boxIndex, lo, hi, _v, _w, outlier, boxSeries, boxColor, rawValues, _x, labels, counts, isPareto_1, cumulativePercents, pareto, histogramSeries, histogramColor, renderedSeriesCount, replaceMerge, gridConfig, valueAxisBase, isPareto, hasSecondaryAxis, tooltipConfig, finalLegend, seriesLabelOption, isDoughnut, doughnutHoleSize, barSeries, len, categoryTotals_1, barSeries_1, barSeries_1_1, s, i, raw, n, barSeries_2, barSeries_2_1, s, seriesWithLabels;
300
+ var e_1, _y, e_3, _z, e_2, _0, e_4, _1, e_5, _2, e_6, _3, e_7, _4, e_8, _5;
301
+ var _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103;
302
+ return tslib_1.__generator(this, function (_104) {
303
+ switch (_104.label) {
304
+ case 0:
305
+ (0, utils_1.debug)("Updating chart", chart);
306
+ threeDRenderKind = (0, three_d_1.resolve3DRenderKind)(spec.sourceChartType);
307
+ canRender3D = threeDRenderKind !== null && (0, webgl_1.isWebGLAvailable)();
308
+ willRender3D = canRender3D && (0, echarts_gl_loader_1.getEchartsGlState)() === "ready";
309
+ if (canRender3D && !willRender3D && (0, echarts_gl_loader_1.getEchartsGlState)() !== "failed") {
310
+ // Kick off the echarts-gl load in the background (once). The 2-D
311
+ // fallback renders immediately; the tick re-runs updateChart to
312
+ // upgrade to 3-D when the module resolves. A failed load latches
313
+ // and the chart simply stays 2-D.
314
+ if (!glUpgradeRequested.current) {
315
+ glUpgradeRequested.current = true;
316
+ (0, echarts_gl_loader_1.loadEchartsGl)().then(function (loaded) {
317
+ if (loaded) {
318
+ setGlUpgradeTick(function (tick) { return tick + 1; });
319
+ }
320
+ });
321
+ }
322
+ }
323
+ if (renderedIn3D.current && !willRender3D) {
324
+ // Leaving 3-D (spec edit) — the grid3D option doesn't merge back
325
+ // into a cartesian one, so re-initialize from a clean slate and
326
+ // let the normal 2-D flow below do a full structural render.
327
+ (_6 = chartRef.current) === null || _6 === void 0 ? void 0 : _6.dispose();
328
+ chartRef.current = undefined;
329
+ renderedIn3D.current = false;
330
+ previousChartType.current = undefined;
331
+ previousSeriesCount.current = undefined;
332
+ initializeChart();
333
+ applyThemeOptions();
334
+ }
335
+ isRegionMap = (0, region_map_1.isRegionMapSpec)(spec);
336
+ if (renderedAsRegionMap.current && !isRegionMap) {
337
+ // Leaving the region map (spec edit) — the geo/visualMap option
338
+ // doesn't merge back into a cartesian one, so re-initialize from
339
+ // a clean slate and let the normal flow below do a full
340
+ // structural render.
341
+ (_7 = chartRef.current) === null || _7 === void 0 ? void 0 : _7.dispose();
342
+ chartRef.current = undefined;
343
+ renderedAsRegionMap.current = false;
344
+ previousChartType.current = undefined;
345
+ previousSeriesCount.current = undefined;
346
+ initializeChart();
347
+ applyThemeOptions();
348
+ }
349
+ if (!isRegionMap) return [3 /*break*/, 2];
350
+ regionSpec = spec;
351
+ geoScope = (0, region_map_1.resolveGeoScope)(regionSpec.geoScope);
352
+ return [4 /*yield*/, (0, region_map_loader_1.loadRegionMapGeo)(geoScope)];
353
+ case 1:
354
+ geo = _104.sent();
355
+ // Entering the region map from a cartesian render: the previous
356
+ // grid/axis option doesn't merge into the map one, so start from
357
+ // a bare instance (theme options are re-applied after setOption).
358
+ if (!renderedAsRegionMap.current && chartRef.current) {
359
+ chartRef.current.dispose();
360
+ chartRef.current = undefined;
361
+ }
362
+ if (el.current && !chartRef.current) {
363
+ chartRef.current = echarts.init(el.current);
364
+ }
365
+ if (!geo) {
366
+ // Map asset failed to load (or unknown scope) — the loader
367
+ // already warned once; render an empty chart, never crash.
368
+ (_8 = chartRef.current) === null || _8 === void 0 ? void 0 : _8.setOption({ series: [] }, { replaceMerge: ["series", "visualMap"] });
369
+ renderedAsRegionMap.current = true;
370
+ applyThemeOptions();
371
+ previousChartType.current = spec.chartType;
372
+ previousSeriesCount.current = 0;
373
+ return [2 /*return*/];
374
+ }
375
+ labels = flattenChartDataValues(regionSpec.domains, getDomainValuesFromRange, regionSpec.hiddenDimensionStrategy, false);
376
+ seriesEntry = (_9 = regionSpec.series) === null || _9 === void 0 ? void 0 : _9[0];
377
+ values = seriesEntry
378
+ ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, regionSpec.hiddenDimensionStrategy)
379
+ : [];
380
+ _a = (0, region_map_1.buildRegionMapData)(labels, values, geo.regionNames), data = _a.data, unmatched = _a.unmatched, min = _a.min, max = _a.max;
381
+ (0, region_map_1.warnOnceForUnmatchedRegions)(geoScope, unmatched);
382
+ textColor = (0, spreadsheet_1.getStringifiedColor)({ theme: 1, tint: isDarkMode ? 1 : 0 }, theme);
383
+ ramp = (0, region_map_1.buildSequentialColorRamp)(theme.themeColors.accent1, !!isDarkMode);
384
+ noDataColor = isDarkMode
385
+ ? "rgba(255,255,255,0.08)"
386
+ : "rgba(0,0,0,0.06)";
387
+ borderColor = isDarkMode ? "rgba(255,255,255,0.3)" : "#FFFFFF";
388
+ regionSeriesLabel = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
389
+ seriesName = (seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) && !(0, utils_1.isAFormula)(seriesEntry.dataLabel)
390
+ ? seriesEntry.dataLabel
391
+ : "";
392
+ (_10 = chartRef.current) === null || _10 === void 0 ? void 0 : _10.setOption({
393
+ // The visualMap color scale is the value legend; the series
394
+ // legend stays hidden unless an authored override turns it on.
395
+ legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { show: false }), spec.legend),
396
+ tooltip: {
397
+ textStyle: { fontSize: 12 },
398
+ trigger: "item",
399
+ formatter: function (params) {
400
+ var _a;
401
+ var value = Array.isArray(params === null || params === void 0 ? void 0 : params.value)
402
+ ? params.value[params.value.length - 1]
403
+ : params === null || params === void 0 ? void 0 : params.value;
404
+ return typeof value === "number" && Number.isFinite(value)
405
+ ? "".concat(params === null || params === void 0 ? void 0 : params.name, ": ").concat(value)
406
+ : "".concat((_a = params === null || params === void 0 ? void 0 : params.name) !== null && _a !== void 0 ? _a : "");
407
+ },
408
+ },
409
+ visualMap: [
410
+ {
411
+ type: "continuous",
412
+ min: min,
413
+ max: max,
414
+ left: "left",
415
+ bottom: 10,
416
+ inRange: { color: ramp },
417
+ textStyle: { color: textColor, fontSize: 12 },
418
+ },
419
+ ],
420
+ series: [
421
+ {
422
+ type: "map",
423
+ map: geoScope,
424
+ name: seriesName,
425
+ data: data,
426
+ roam: false,
427
+ // Region names label the shapes only when the authored
428
+ // dataLabels override asks for them.
429
+ label: tslib_1.__assign({ show: false }, (regionSeriesLabel !== null && regionSeriesLabel !== void 0 ? regionSeriesLabel : {})),
430
+ emphasis: { label: { show: false } },
431
+ select: { disabled: true },
432
+ itemStyle: {
433
+ areaColor: noDataColor,
434
+ borderColor: borderColor,
435
+ borderWidth: 0.5,
436
+ },
437
+ },
438
+ ],
439
+ }, { replaceMerge: ["series", "visualMap", "legend", "tooltip"] });
440
+ // Re-apply theme-derived title / palette / tooltip colors — lost
441
+ // when the instance was re-initialized on entry.
442
+ renderedAsRegionMap.current = true;
443
+ applyThemeOptions();
444
+ previousChartType.current = spec.chartType;
445
+ previousSeriesCount.current = 1;
446
+ return [2 /*return*/];
447
+ case 2:
448
+ chartDomains = [];
449
+ chartSeries = [];
450
+ legend = tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { data: [] });
451
+ chartType = (0, helpers_1.chartTypeToEchartsType)(spec === null || spec === void 0 ? void 0 : spec.chartType);
452
+ position = chart.position;
453
+ showAxis = (0, helpers_1.showXAxis)(spec === null || spec === void 0 ? void 0 : spec.chartType);
454
+ isBubble = isBubbleChartSpec(spec);
455
+ isHierarchy = isHierarchyChartSpec(spec);
456
+ if (!isBubble) return [3 /*break*/, 8];
457
+ hierarchyTitleRef.current = explicitChartTitle;
458
+ skipHeaders_1 = spec.useFirstRowAsHeaders !== false;
459
+ labelValues = flattenChartDataValues(spec.bubbleLabels, getDomainValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders_1);
460
+ perSeriesX = ((_11 = spec.domains) !== null && _11 !== void 0 ? _11 : []).map(function (dom) {
461
+ return flattenChartDataValues([dom], getSeriesValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders_1);
462
+ });
463
+ perSeriesSize = ((_12 = spec.bubbleSizes) !== null && _12 !== void 0 ? _12 : []).map(function (sz) {
464
+ return flattenChartDataValues([sz], getSeriesValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders_1);
465
+ });
466
+ seriesInputs = [];
467
+ i = 0;
468
+ _104.label = 3;
469
+ case 3:
470
+ if (!(i < spec.series.length)) return [3 /*break*/, 7];
471
+ seriesEntry = spec.series[i];
472
+ resolvedLabel = (_13 = seriesEntry.dataLabel) !== null && _13 !== void 0 ? _13 : "";
473
+ if (!(resolvedLabel && (0, utils_1.isAFormula)(resolvedLabel))) return [3 /*break*/, 5];
474
+ _b = chart_spec_utils_1.coerceCalculatedLabel;
475
+ return [4 /*yield*/, onRequestCalculate(resolvedLabel, (_14 = position.sheetId) !== null && _14 !== void 0 ? _14 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
476
+ case 4:
477
+ resolvedLabel = _b.apply(void 0, [_104.sent()]);
478
+ _104.label = 5;
479
+ case 5:
480
+ xValues = (_15 = perSeriesX[i]) !== null && _15 !== void 0 ? _15 : perSeriesX[0];
481
+ sizeValues_1 = (_16 = perSeriesSize[i]) !== null && _16 !== void 0 ? _16 : perSeriesSize[0];
482
+ seriesInputs.push(tslib_1.__assign(tslib_1.__assign({ name: resolvedLabel, values: flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders_1) }, (xValues ? { xValues: xValues } : {})), (sizeValues_1 ? { sizeValues: sizeValues_1 } : {})));
483
+ _104.label = 6;
484
+ case 6:
485
+ i++;
486
+ return [3 /*break*/, 3];
487
+ case 7:
488
+ sharedXValues = (_17 = perSeriesX[0]) !== null && _17 !== void 0 ? _17 : [];
489
+ sharedSizeValues = (_18 = perSeriesSize[0]) !== null && _18 !== void 0 ? _18 : [];
490
+ _c = (0, bubble_1.prepareBubbleSeriesData)({
491
+ xValues: sharedXValues,
492
+ labelValues: labelValues,
493
+ sizeValues: sharedSizeValues,
494
+ series: seriesInputs,
495
+ }), categories_1 = _c.categories, preparedSeries = _c.series, sizeValues = _c.sizeValues;
496
+ sizeScale_1 = (0, bubble_1.createBubbleSizeScale)(sizeValues);
497
+ xAxisConfig = categories_1.length > 0
498
+ ? {
499
+ type: "category",
500
+ data: categories_1,
501
+ name: (_19 = spec.horizontalAxisTitle) !== null && _19 !== void 0 ? _19 : "",
502
+ nameLocation: "middle",
503
+ nameGap: 30,
504
+ }
505
+ : {
506
+ type: "value",
507
+ name: (_20 = spec.horizontalAxisTitle) !== null && _20 !== void 0 ? _20 : "",
508
+ nameLocation: "middle",
509
+ nameGap: 30,
510
+ };
511
+ tooltipFormatter = function (params) {
512
+ var _a, _b, _c, _d;
513
+ var _e = tslib_1.__read(((_a = params.value) !== null && _a !== void 0 ? _a : []), 3), rawX = _e[0], y = _e[1], size = _e[2];
514
+ var label = categories_1.length > 0
515
+ ? (_d = (_c = (_b = params.data) === null || _b === void 0 ? void 0 : _b.xLabel) !== null && _c !== void 0 ? _c : categories_1[Math.round(rawX)]) !== null && _d !== void 0 ? _d : rawX
516
+ : rawX;
517
+ var bubbleName = params.name ? "".concat(params.name, "<br/>") : "";
518
+ var seriesName = params.seriesName ? "".concat(params.seriesName, "<br/>") : "";
519
+ return "".concat(seriesName).concat(bubbleName, "X: ").concat(label !== null && label !== void 0 ? label : "", "<br/>Y: ").concat(y !== null && y !== void 0 ? y : "", "<br/>Size: ").concat(size !== null && size !== void 0 ? size : "");
520
+ };
521
+ bubbleSeriesLabel_1 = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
522
+ (_21 = chartRef.current) === null || _21 === void 0 ? void 0 : _21.setOption({
523
+ xAxis: [
524
+ (0, overrides_1.applyAxisOverrides)(tslib_1.__assign({}, xAxisConfig), spec.categoryAxisOptions),
525
+ ],
526
+ yAxis: [
527
+ (0, overrides_1.applyAxisOverrides)({
528
+ type: "value",
529
+ name: (_22 = spec.verticalAxisTitle) !== null && _22 !== void 0 ? _22 : "",
530
+ nameLocation: "middle",
531
+ nameGap: 45,
532
+ }, spec.valueAxisOptions),
533
+ ],
534
+ legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, legend), { show: preparedSeries.length > 1, data: preparedSeries.map(function (entry) { return entry.name; }) }), spec.legend),
535
+ grid: {
536
+ left: "3%",
537
+ right: "4%",
538
+ bottom: "3%",
539
+ containLabel: true,
540
+ },
541
+ tooltip: {
542
+ trigger: "item",
543
+ formatter: tooltipFormatter,
544
+ },
545
+ // Scatter vs bubble — scatter uses small fixed markers
546
+ // (optionally connected with a line per scatterStyle); bubble
547
+ // applies a size scale on the 3rd dimension. Pre-fix scatter
548
+ // routed through the bubble code, producing Y-scaled giant
549
+ // circles instead of Excel's small dots.
550
+ series: preparedSeries.map(function (entry, index) {
551
+ var _a, _b, _c, _d, _e, _f;
552
+ var isScatter = spec.chartType === "scatter";
553
+ var scatterStyle = (_a = spec.scatterStyle) !== null && _a !== void 0 ? _a : (isScatter ? "lineMarker" : undefined);
554
+ var seriesEntry = (_b = spec.series) === null || _b === void 0 ? void 0 : _b[index];
555
+ var seriesColor = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.color;
556
+ var perMarker = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.marker;
557
+ if (isScatter) {
558
+ var symbol = perMarker === null || perMarker === void 0 ? void 0 : perMarker.symbol;
559
+ var noMarkers = symbol === "none";
560
+ var wantsLine = scatterStyle === "line" ||
561
+ scatterStyle === "lineMarker" ||
562
+ scatterStyle === "smooth" ||
563
+ scatterStyle === "smoothMarker";
564
+ var wantsMarkers = !noMarkers &&
565
+ (scatterStyle === "marker" ||
566
+ scatterStyle === "lineMarker" ||
567
+ scatterStyle === "smoothMarker" ||
568
+ !scatterStyle);
569
+ var smooth = scatterStyle === "smooth" || scatterStyle === "smoothMarker";
570
+ return wantsLine
571
+ ? tslib_1.__assign({ type: "line", name: entry.name, data: entry.points, showSymbol: wantsMarkers, smooth: smooth, symbol: (_c = (0, helpers_1.mapMarkerSymbolToEcharts)(symbol)) !== null && _c !== void 0 ? _c : "circle", symbolSize: (_d = perMarker === null || perMarker === void 0 ? void 0 : perMarker.size) !== null && _d !== void 0 ? _d : 6 }, (seriesColor
572
+ ? {
573
+ itemStyle: { color: seriesColor },
574
+ lineStyle: { color: seriesColor },
575
+ }
576
+ : {})) : tslib_1.__assign({ type: "scatter", name: entry.name, data: entry.points, symbol: (_e = (0, helpers_1.mapMarkerSymbolToEcharts)(symbol)) !== null && _e !== void 0 ? _e : "circle", symbolSize: (_f = perMarker === null || perMarker === void 0 ? void 0 : perMarker.size) !== null && _f !== void 0 ? _f : 6 }, (seriesColor
577
+ ? { itemStyle: { color: seriesColor } }
578
+ : {}));
579
+ }
580
+ return tslib_1.__assign({ type: chartType, name: entry.name, data: entry.points, symbolSize: function (data) { var _a; return sizeScale_1((_a = data === null || data === void 0 ? void 0 : data[2]) !== null && _a !== void 0 ? _a : 0); }, label: {
581
+ show: true,
582
+ formatter: function (params) { var _a; return (_a = params.name) !== null && _a !== void 0 ? _a : ""; },
583
+ } }, (seriesColor ? { itemStyle: { color: seriesColor } } : {}));
584
+ }).map(function (s) {
585
+ var _a;
586
+ return bubbleSeriesLabel_1
587
+ ? tslib_1.__assign(tslib_1.__assign({}, s), { label: tslib_1.__assign(tslib_1.__assign({}, ((_a = s.label) !== null && _a !== void 0 ? _a : {})), bubbleSeriesLabel_1) }) : s;
588
+ }),
589
+ }, {
590
+ replaceMerge: [
591
+ "series",
592
+ "xAxis",
593
+ "yAxis",
594
+ "legend",
595
+ "grid",
596
+ "tooltip",
597
+ ],
598
+ });
599
+ previousChartType.current = spec.chartType;
600
+ previousSeriesCount.current = preparedSeries.length;
601
+ return [2 /*return*/];
602
+ case 8:
603
+ if (isHierarchy) {
604
+ hierarchyRows = (0, hierarchy_1.extractHierarchyRows)(spec, {
605
+ getDomainValuesFromRange: getDomainValuesFromRange,
606
+ getSeriesValuesFromRange: getSeriesValuesFromRange,
607
+ hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
608
+ });
609
+ headerTitle = (0, hierarchy_1.getHierarchyHeaderTitle)(spec, {
610
+ getDomainValuesFromRange: getDomainValuesFromRange,
611
+ getSeriesValuesFromRange: getSeriesValuesFromRange,
612
+ hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
613
+ });
614
+ hierarchyTitleRef.current = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle;
615
+ hierarchyData = (0, hierarchy_1.buildHierarchyTree)(hierarchyRows);
616
+ rootName = hierarchyData.length === 1 ? (_24 = (_23 = hierarchyData[0]) === null || _23 === void 0 ? void 0 : _23.name) !== null && _24 !== void 0 ? _24 : "" : "";
617
+ seriesDisplayName = (_26 = (_25 = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle) !== null && _25 !== void 0 ? _25 : rootName) !== null && _26 !== void 0 ? _26 : "";
618
+ hierarchyDepth = getHierarchyDepth(hierarchyData);
619
+ levels = buildHierarchyLevels(hierarchyDepth);
620
+ tooltipFormatter = function (params) {
621
+ var _a;
622
+ var value = Array.isArray(params.value)
623
+ ? params.value[params.value.length - 1]
624
+ : (_a = params.value) !== null && _a !== void 0 ? _a : "";
625
+ return "".concat(params.name, ": ").concat(value);
626
+ };
627
+ hierarchySeriesLabel = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
628
+ (_27 = chartRef.current) === null || _27 === void 0 ? void 0 : _27.setOption({
629
+ xAxis: [
630
+ {
631
+ type: "category",
632
+ show: false,
633
+ },
634
+ ],
635
+ yAxis: [
636
+ {
637
+ type: "value",
638
+ show: false,
639
+ },
640
+ ],
641
+ legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { show: false }), spec.legend),
642
+ grid: {
643
+ left: 0,
644
+ right: 0,
645
+ top: 0,
646
+ bottom: 0,
647
+ },
648
+ tooltip: {
649
+ trigger: "item",
650
+ formatter: tooltipFormatter,
651
+ },
652
+ series: [
653
+ {
654
+ type: chartType,
655
+ name: seriesDisplayName,
656
+ rootName: rootName || seriesDisplayName || "",
657
+ data: hierarchyData,
658
+ label: tslib_1.__assign({ show: true, formatter: "{b}" }, (hierarchySeriesLabel !== null && hierarchySeriesLabel !== void 0 ? hierarchySeriesLabel : {})),
659
+ upperLabel: spec.chartType === "treemap"
660
+ ? {
661
+ show: true,
662
+ padding: [0, 0, 0, 4],
663
+ }
664
+ : undefined,
665
+ levels: levels,
666
+ colorMappingBy: "index",
667
+ },
668
+ ],
669
+ }, {
670
+ replaceMerge: [
671
+ "series",
672
+ "xAxis",
673
+ "yAxis",
674
+ "legend",
675
+ "grid",
676
+ "tooltip",
677
+ ],
678
+ });
679
+ previousChartType.current = spec.chartType;
680
+ previousSeriesCount.current = 1;
681
+ return [2 /*return*/];
682
+ }
683
+ else {
684
+ hierarchyTitleRef.current = explicitChartTitle;
685
+ }
686
+ if (!isBasicChartSpec(spec)) {
687
+ (0, utils_1.debug)("Unsupported chart type", spec.chartType);
688
+ return [2 /*return*/];
689
+ }
690
+ if (!(willRender3D && threeDRenderKind)) return [3 /*break*/, 19];
691
+ categories_2 = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
692
+ threeDSeriesInputs = [];
693
+ _104.label = 9;
694
+ case 9:
695
+ _104.trys.push([9, 16, 17, 18]);
696
+ _d = tslib_1.__values((_28 = spec.series) !== null && _28 !== void 0 ? _28 : []), _e = _d.next();
697
+ _104.label = 10;
698
+ case 10:
699
+ if (!!_e.done) return [3 /*break*/, 15];
700
+ seriesEntry = _e.value;
701
+ if (!(!(0, utils_1.isNil)(seriesEntry.dataLabel) && (0, utils_1.isAFormula)(seriesEntry.dataLabel))) return [3 /*break*/, 12];
702
+ _g = chart_spec_utils_1.coerceCalculatedLabel;
703
+ return [4 /*yield*/, onRequestCalculate(seriesEntry.dataLabel, (_29 = position.sheetId) !== null && _29 !== void 0 ? _29 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
704
+ case 11:
705
+ _f = _g.apply(void 0, [_104.sent()]);
706
+ return [3 /*break*/, 13];
707
+ case 12:
708
+ _f = (_30 = seriesEntry.dataLabel) !== null && _30 !== void 0 ? _30 : "";
709
+ _104.label = 13;
710
+ case 13:
711
+ dataLabel = _f;
712
+ values = flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(sanitizeChartValue);
713
+ threeDSeriesInputs.push({ name: dataLabel, values: values });
714
+ _104.label = 14;
715
+ case 14:
716
+ _e = _d.next();
717
+ return [3 /*break*/, 10];
718
+ case 15: return [3 /*break*/, 18];
719
+ case 16:
720
+ e_1_1 = _104.sent();
721
+ e_1 = { error: e_1_1 };
722
+ return [3 /*break*/, 18];
723
+ case 17:
724
+ try {
725
+ if (_e && !_e.done && (_y = _d.return)) _y.call(_d);
726
+ }
727
+ finally { if (e_1) throw e_1.error; }
728
+ return [7 /*endfinally*/];
729
+ case 18:
730
+ seriesNames_1 = threeDSeriesInputs.map(function (entry, index) { return entry.name || "Series ".concat(index + 1); });
731
+ threeDPalette_1 = [
732
+ theme.themeColors.accent1,
733
+ theme.themeColors.accent2,
734
+ theme.themeColors.accent3,
735
+ theme.themeColors.accent4,
736
+ theme.themeColors.accent5,
737
+ theme.themeColors.accent6,
738
+ ];
739
+ seriesColorAt_1 = function (index) {
740
+ var _a, _b, _c;
741
+ return (_c = (_b = (_a = spec.series) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.color) !== null && _c !== void 0 ? _c : threeDPalette_1[index % threeDPalette_1.length];
742
+ };
743
+ // Entering 3-D from a 2-D render: the cartesian option doesn't
744
+ // merge into a grid3D one, so re-initialize the echarts instance
745
+ // from scratch (theme options are re-applied after setOption).
746
+ if (!renderedIn3D.current && chartRef.current) {
747
+ chartRef.current.dispose();
748
+ chartRef.current = undefined;
749
+ }
750
+ if (el.current && !chartRef.current) {
751
+ chartRef.current = echarts.init(el.current);
752
+ }
753
+ categoryAxisLabel = function (value) { var _a; return Number.isInteger(value) ? (_a = categories_2[value]) !== null && _a !== void 0 ? _a : "" : ""; };
754
+ seriesAxisLabel = function (value) { var _a; return Number.isInteger(value) ? (_a = seriesNames_1[value]) !== null && _a !== void 0 ? _a : "" : ""; };
755
+ threeDTooltipFormatter = function (params) {
756
+ var _a, _b, _c, _d, _e, _f, _g, _h;
757
+ var value = ((_a = params === null || params === void 0 ? void 0 : params.value) !== null && _a !== void 0 ? _a : []);
758
+ var categoryLabel = (_c = categories_2[Math.round((_b = value[0]) !== null && _b !== void 0 ? _b : 0)]) !== null && _c !== void 0 ? _c : String((_d = value[0]) !== null && _d !== void 0 ? _d : "");
759
+ var seriesLabel = (_g = (_f = seriesNames_1[Math.round((_e = value[1]) !== null && _e !== void 0 ? _e : 0)]) !== null && _f !== void 0 ? _f : params === null || params === void 0 ? void 0 : params.seriesName) !== null && _g !== void 0 ? _g : "";
760
+ return "".concat(seriesLabel ? "".concat(seriesLabel, "<br/>") : "").concat(categoryLabel, ": ").concat((_h = value[2]) !== null && _h !== void 0 ? _h : "");
761
+ };
762
+ threeDSeries = void 0;
763
+ visualMap = void 0;
764
+ xAxis3D = void 0;
765
+ yAxis3D = void 0;
766
+ if (threeDRenderKind === "bar3D") {
767
+ xAxis3D = { type: "category", data: categories_2 };
768
+ yAxis3D = { type: "category", data: seriesNames_1 };
769
+ threeDSeries = [
770
+ {
771
+ type: "bar3D",
772
+ shading: "lambert",
773
+ data: (0, three_d_1.buildBar3DData)(threeDSeriesInputs).map(function (_a) {
774
+ var _b = tslib_1.__read(_a, 3), x = _b[0], y = _b[1], z = _b[2];
775
+ return ({
776
+ value: [x, y, z],
777
+ itemStyle: { color: seriesColorAt_1(y) },
778
+ });
779
+ }),
780
+ },
781
+ ];
782
+ }
783
+ else if (threeDRenderKind === "line3D") {
784
+ xAxis3D = {
785
+ type: "value",
786
+ axisLabel: { formatter: categoryAxisLabel },
787
+ min: 0,
788
+ max: Math.max(categories_2.length - 1, 1),
789
+ };
790
+ yAxis3D = {
791
+ type: "value",
792
+ axisLabel: { formatter: seriesAxisLabel },
793
+ min: 0,
794
+ max: Math.max(seriesNames_1.length - 1, 1),
795
+ };
796
+ threeDSeries = (0, three_d_1.buildLine3DSeries)(threeDSeriesInputs).map(function (entry, index) { return ({
797
+ type: "line3D",
798
+ name: seriesNames_1[index],
799
+ data: entry.data,
800
+ lineStyle: { width: 3, color: seriesColorAt_1(index) },
801
+ }); });
802
+ }
803
+ else {
804
+ surfacePoints = (0, three_d_1.buildSurfaceData)(threeDSeriesInputs);
805
+ _h = tslib_1.__read((0, three_d_1.getValueExtent)(surfacePoints), 2), zMin = _h[0], zMax = _h[1];
806
+ xAxis3D = {
807
+ type: "value",
808
+ axisLabel: { formatter: categoryAxisLabel },
809
+ min: 0,
810
+ max: Math.max(categories_2.length - 1, 1),
811
+ };
812
+ yAxis3D = {
813
+ type: "value",
814
+ axisLabel: { formatter: seriesAxisLabel },
815
+ min: 0,
816
+ max: Math.max(seriesNames_1.length - 1, 1),
817
+ };
818
+ threeDSeries = [
819
+ {
820
+ type: "surface",
821
+ data: surfacePoints,
822
+ wireframe: { show: true },
823
+ shading: "color",
824
+ },
825
+ ];
826
+ visualMap = {
827
+ show: false,
828
+ dimension: 2,
829
+ min: zMin,
830
+ max: zMax,
831
+ seriesIndex: 0,
832
+ inRange: { color: tslib_1.__spreadArray([], tslib_1.__read(three_d_1.SURFACE_COLOR_RAMP), false) },
833
+ };
834
+ }
835
+ (_31 = chartRef.current) === null || _31 === void 0 ? void 0 : _31.setOption(tslib_1.__assign(tslib_1.__assign({ tooltip: {
836
+ textStyle: { fontSize: 12 },
837
+ formatter: threeDTooltipFormatter,
838
+ }, legend: threeDRenderKind === "line3D"
839
+ ? (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { show: seriesNames_1.length > 1, data: seriesNames_1 }), spec.legend)
840
+ : { show: false }, xAxis3D: tslib_1.__assign(tslib_1.__assign({}, xAxis3D), { name: (_32 = spec.horizontalAxisTitle) !== null && _32 !== void 0 ? _32 : "" }), yAxis3D: tslib_1.__assign(tslib_1.__assign({}, yAxis3D), { name: "" }), zAxis3D: { type: "value", name: (_33 = spec.verticalAxisTitle) !== null && _33 !== void 0 ? _33 : "" }, grid3D: {
841
+ boxDepth: Math.max(20, Math.min(100, seriesNames_1.length * 20)),
842
+ viewControl: { autoRotate: false },
843
+ } }, (visualMap ? { visualMap: [visualMap] } : {})), { series: threeDSeries }), {
844
+ replaceMerge: [
845
+ "series",
846
+ "xAxis3D",
847
+ "yAxis3D",
848
+ "zAxis3D",
849
+ "visualMap",
850
+ "legend",
851
+ "tooltip",
852
+ ],
853
+ });
854
+ // Re-apply theme-derived title / palette / tooltip colors — lost
855
+ // when the instance was re-initialized on entry into 3-D.
856
+ renderedIn3D.current = true;
857
+ applyThemeOptions();
858
+ previousChartType.current = spec.chartType;
859
+ previousSeriesCount.current = threeDSeries.length;
860
+ return [2 /*return*/];
861
+ case 19:
862
+ // ---------------------------- Radar ----------------------------
863
+ // Radar is polar: a top-level `radar.indicator` list (one axis per
864
+ // category) plus one `radar`-type series carrying every data series'
865
+ // value vector. radarStyle controls markers / filled area.
866
+ if (spec.chartType === "radar") {
867
+ skipHeaders = false;
868
+ categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders);
869
+ radarSeriesInputs = [];
870
+ try {
871
+ for (_j = tslib_1.__values((_34 = spec.series) !== null && _34 !== void 0 ? _34 : []), _k = _j.next(); !_k.done; _k = _j.next()) {
872
+ seriesEntry = _k.value;
873
+ label = seriesEntry.dataLabel && !(0, utils_1.isAFormula)(seriesEntry.dataLabel)
874
+ ? seriesEntry.dataLabel
875
+ : "";
876
+ values = flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
877
+ radarSeriesInputs.push({ name: label, values: values });
878
+ }
879
+ }
880
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
881
+ finally {
882
+ try {
883
+ if (_k && !_k.done && (_z = _j.return)) _z.call(_j);
884
+ }
885
+ finally { if (e_3) throw e_3.error; }
886
+ }
887
+ indicators = (0, radar_1.buildRadarIndicators)(categories, radarSeriesInputs);
888
+ radarData = (0, radar_1.buildRadarSeriesData)(radarSeriesInputs, indicators.length);
889
+ radarStyle_1 = (_35 = spec.radarStyle) !== null && _35 !== void 0 ? _35 : "standard";
890
+ radarColors_1 = radarSeriesInputs.map(function (_, i) { var _a, _b; return (_b = (_a = spec.series) === null || _a === void 0 ? void 0 : _a[i]) === null || _b === void 0 ? void 0 : _b.color; });
891
+ radarSeriesLabel = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
892
+ (_36 = chartRef.current) === null || _36 === void 0 ? void 0 : _36.setOption({
893
+ radar: {
894
+ indicator: indicators.length
895
+ ? indicators
896
+ : [{ name: "", max: 1 }],
897
+ },
898
+ legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, legend), { show: radarData.length > 1, data: radarData.map(function (d) { return d.name; }) }), spec.legend),
899
+ tooltip: { trigger: "item" },
900
+ series: [
901
+ tslib_1.__assign(tslib_1.__assign({ type: "radar", symbol: radarStyle_1 === "standard" ? "none" : "circle" }, (radarSeriesLabel ? { label: radarSeriesLabel } : {})), { data: radarData.map(function (d, i) { return (tslib_1.__assign(tslib_1.__assign({ value: d.value, name: d.name }, (radarStyle_1 === "filled" ? { areaStyle: {} } : {})), (radarColors_1[i]
902
+ ? {
903
+ itemStyle: { color: radarColors_1[i] },
904
+ lineStyle: { color: radarColors_1[i] },
905
+ }
906
+ : {}))); }) }),
907
+ ],
908
+ }, {
909
+ replaceMerge: [
910
+ "series",
911
+ "xAxis",
912
+ "yAxis",
913
+ "radar",
914
+ "legend",
915
+ "grid",
916
+ "tooltip",
917
+ ],
918
+ });
919
+ previousChartType.current = spec.chartType;
920
+ previousSeriesCount.current = radarData.length;
921
+ return [2 /*return*/];
922
+ }
923
+ // ---------------------------- Stock ----------------------------
924
+ // Line-derived stock: fan the price-role series (open/high/low/close)
925
+ // out into separate line series over the category (date) domain. The
926
+ // V-variants additionally get a volume column sub-pane below the
927
+ // price plot.
928
+ if (spec.chartType === "stock") {
929
+ variant = ((_37 = spec.stockVariant) !== null && _37 !== void 0 ? _37 : "HLC");
930
+ categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
931
+ seriesValues = ((_38 = spec.series) !== null && _38 !== void 0 ? _38 : []).map(function (seriesEntry) {
932
+ return flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
933
+ });
934
+ stockSeriesLabel_1 = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
935
+ upColor_1 = theme.themeColors.accent1;
936
+ downColor_1 = theme.themeColors.accent2;
937
+ volumePoints = (0, stock_1.toVolumeSeries)(seriesValues, variant);
938
+ hasVolume = ((_39 = volumePoints === null || volumePoints === void 0 ? void 0 : volumePoints.length) !== null && _39 !== void 0 ? _39 : 0) > 0;
939
+ stockGrid = hasVolume
940
+ ? [
941
+ { left: "10%", right: "4%", top: "8%", height: "56%" },
942
+ { left: "10%", right: "4%", top: "74%", height: "18%" },
943
+ ]
944
+ : [{ left: "3%", right: "4%", bottom: "3%", containLabel: true }];
945
+ baseStockXAxis = (0, overrides_1.applyAxisOverrides)({
946
+ type: "category",
947
+ data: categories,
948
+ show: true,
949
+ axisLine: { show: true },
950
+ axisTick: { show: true },
951
+ splitLine: { show: false },
952
+ name: (_40 = spec.horizontalAxisTitle) !== null && _40 !== void 0 ? _40 : "",
953
+ nameLocation: "middle",
954
+ nameGap: 30,
955
+ }, spec.categoryAxisOptions);
956
+ stockXAxis = hasVolume
957
+ ? [
958
+ tslib_1.__assign(tslib_1.__assign({}, baseStockXAxis), { gridIndex: 0, axisLabel: { show: false }, axisTick: { show: false }, name: "" }),
959
+ tslib_1.__assign(tslib_1.__assign({}, baseStockXAxis), { gridIndex: 1 }),
960
+ ]
961
+ : [baseStockXAxis];
962
+ volumeYAxis = {
963
+ type: "value",
964
+ gridIndex: 1,
965
+ scale: true,
966
+ splitNumber: 2,
967
+ axisLabel: { show: false },
968
+ axisLine: { show: false },
969
+ axisTick: { show: false },
970
+ splitLine: { show: false },
971
+ };
972
+ volumeSeries = hasVolume
973
+ ? [
974
+ {
975
+ type: "bar",
976
+ name: "Volume",
977
+ xAxisIndex: 1,
978
+ yAxisIndex: 1,
979
+ data: (volumePoints !== null && volumePoints !== void 0 ? volumePoints : []).map(function (p) { return ({
980
+ value: p.value,
981
+ itemStyle: { color: p.up ? upColor_1 : downColor_1 },
982
+ }); }),
983
+ },
984
+ ]
985
+ : [];
986
+ stockAxisPointer = {
987
+ link: hasVolume ? [{ xAxisIndex: "all" }] : [],
988
+ };
989
+ // OHLC / VOHLC variants carry an `open`, so they render as a
990
+ // candlestick (Excel's open-high-low-close stock chart). HLC / VHLC
991
+ // (no open) fall through to the line-derived rendering below.
992
+ if (variant === "OHLC" || variant === "VOHLC") {
993
+ candleData = (0, stock_1.toCandlestick)(seriesValues, variant);
994
+ (_41 = chartRef.current) === null || _41 === void 0 ? void 0 : _41.setOption({
995
+ xAxis: stockXAxis,
996
+ yAxis: tslib_1.__spreadArray([
997
+ (0, overrides_1.applyAxisOverrides)({
998
+ type: "value",
999
+ show: true,
1000
+ scale: true,
1001
+ name: (_42 = spec.verticalAxisTitle) !== null && _42 !== void 0 ? _42 : "",
1002
+ nameLocation: "middle",
1003
+ nameGap: 50,
1004
+ gridIndex: 0,
1005
+ }, spec.valueAxisOptions)
1006
+ ], tslib_1.__read((hasVolume ? [volumeYAxis] : [])), false),
1007
+ legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, legend), { show: false }), spec.legend),
1008
+ grid: stockGrid,
1009
+ tooltip: { trigger: "axis" },
1010
+ axisPointer: stockAxisPointer,
1011
+ series: tslib_1.__spreadArray([
1012
+ {
1013
+ type: "candlestick",
1014
+ name: spec.title || "Stock",
1015
+ data: candleData,
1016
+ itemStyle: {
1017
+ color: upColor_1,
1018
+ color0: downColor_1,
1019
+ borderColor: upColor_1,
1020
+ borderColor0: downColor_1,
1021
+ },
1022
+ }
1023
+ ], tslib_1.__read(volumeSeries), false),
1024
+ }, {
1025
+ replaceMerge: [
1026
+ "series",
1027
+ "xAxis",
1028
+ "yAxis",
1029
+ "legend",
1030
+ "grid",
1031
+ "tooltip",
1032
+ ],
1033
+ });
1034
+ previousChartType.current = spec.chartType;
1035
+ previousSeriesCount.current = 1 + volumeSeries.length;
1036
+ return [2 /*return*/];
1037
+ }
1038
+ lineSeries = (0, stock_1.toLineSeries)(seriesValues, variant);
1039
+ stockColors_1 = [
1040
+ theme.themeColors.accent1,
1041
+ theme.themeColors.accent2,
1042
+ theme.themeColors.accent3,
1043
+ theme.themeColors.accent4,
1044
+ ];
1045
+ (_43 = chartRef.current) === null || _43 === void 0 ? void 0 : _43.setOption({
1046
+ xAxis: stockXAxis,
1047
+ yAxis: tslib_1.__spreadArray([
1048
+ (0, overrides_1.applyAxisOverrides)({
1049
+ type: "value",
1050
+ show: true,
1051
+ name: (_44 = spec.verticalAxisTitle) !== null && _44 !== void 0 ? _44 : "",
1052
+ nameLocation: "middle",
1053
+ nameGap: 50,
1054
+ gridIndex: 0,
1055
+ }, spec.valueAxisOptions)
1056
+ ], tslib_1.__read((hasVolume ? [volumeYAxis] : [])), false),
1057
+ legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, legend), { show: lineSeries.length > 1, data: lineSeries.map(function (s) { return s.name; }) }), spec.legend),
1058
+ grid: stockGrid,
1059
+ tooltip: { trigger: "axis" },
1060
+ axisPointer: stockAxisPointer,
1061
+ series: tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(lineSeries.map(function (s, i) { return (tslib_1.__assign({ type: "line", name: s.name, data: s.values, showSymbol: false, itemStyle: { color: stockColors_1[i % stockColors_1.length] }, lineStyle: { color: stockColors_1[i % stockColors_1.length] } }, (stockSeriesLabel_1 ? { label: stockSeriesLabel_1 } : {}))); })), false), tslib_1.__read(volumeSeries), false),
1062
+ }, {
1063
+ replaceMerge: [
1064
+ "series",
1065
+ "xAxis",
1066
+ "yAxis",
1067
+ "legend",
1068
+ "grid",
1069
+ "tooltip",
1070
+ ],
1071
+ });
1072
+ previousChartType.current = spec.chartType;
1073
+ previousSeriesCount.current = lineSeries.length + volumeSeries.length;
1074
+ return [2 /*return*/];
1075
+ }
1076
+ isStacked = spec.stackedType && spec.stackedType !== "UNSTACKED";
1077
+ isCircularChart = spec.chartType === "pie" || spec.chartType === "doughnut";
1078
+ isOfPie = isCircularChart && (0, of_pie_1.isOfPieChartSpec)(spec);
1079
+ ofPieLayout = null;
1080
+ isHorizontalBarChart = spec.chartType === "bar";
1081
+ shouldAggregate = (0, aggregation_1.shouldAggregateSeries)(spec.series);
1082
+ primaryDomainSource = (_47 = (_46 = (_45 = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _45 === void 0 ? void 0 : _45[0]) === null || _46 === void 0 ? void 0 : _46.sources) === null || _47 === void 0 ? void 0 : _47[0];
1083
+ rawPrimaryDomainValues = primaryDomainSource
1084
+ ? (0, aggregation_1.sanitizeDomainValues)((_48 = getDomainValuesFromRange(primaryDomainSource, spec.hiddenDimensionStrategy)) !== null && _48 !== void 0 ? _48 : [])
1085
+ : [];
1086
+ aggregateDomainValues = (0, aggregation_1.getDomainValuesForAxis)(rawPrimaryDomainValues, shouldAggregate);
1087
+ (_49 = spec.domains) === null || _49 === void 0 ? void 0 : _49.forEach(function (domain, domainIndex) {
1088
+ domain.sources.forEach(function (sheetRange, sourceIndex) {
1089
+ var _a, _b, _c;
1090
+ var axisData = [];
1091
+ if (domainIndex === 0 && sourceIndex === 0) {
1092
+ axisData = aggregateDomainValues;
1093
+ }
1094
+ else {
1095
+ var rawValues = (0, aggregation_1.sanitizeDomainValues)((_a = getDomainValuesFromRange(sheetRange, spec.hiddenDimensionStrategy)) !== null && _a !== void 0 ? _a : []);
1096
+ axisData = (0, aggregation_1.getDomainValuesForAxis)(rawValues, shouldAggregate);
1097
+ }
1098
+ var axisTitle = domainIndex === 0 && sourceIndex === 0 && !isCircularChart
1099
+ ? isHorizontalBarChart
1100
+ ? (_b = spec.verticalAxisTitle) !== null && _b !== void 0 ? _b : ""
1101
+ : (_c = spec.horizontalAxisTitle) !== null && _c !== void 0 ? _c : ""
1102
+ : undefined;
1103
+ chartDomains.push({
1104
+ type: "category",
1105
+ data: axisData,
1106
+ show: showAxis && !isCircularChart,
1107
+ axisLine: { show: !isCircularChart },
1108
+ axisTick: { show: !isCircularChart },
1109
+ splitLine: { show: !isCircularChart },
1110
+ name: axisTitle,
1111
+ nameLocation: "middle",
1112
+ nameGap: 30,
1113
+ });
1114
+ });
1115
+ });
1116
+ if (chartDomains.length === 0 && !isCircularChart) {
1117
+ chartDomains.push({
1118
+ type: "category",
1119
+ show: showAxis,
1120
+ axisLine: { show: true },
1121
+ axisTick: { show: true },
1122
+ splitLine: { show: true },
1123
+ gridIndex: 0,
1124
+ name: isHorizontalBarChart
1125
+ ? (_50 = spec.verticalAxisTitle) !== null && _50 !== void 0 ? _50 : ""
1126
+ : (_51 = spec.horizontalAxisTitle) !== null && _51 !== void 0 ? _51 : "",
1127
+ nameLocation: "middle",
1128
+ nameGap: 30,
1129
+ });
1130
+ }
1131
+ pushSeriesOverlays = function (series, data, dataLabel) {
1132
+ var e_9, _a;
1133
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1134
+ var numericValues = Array.isArray(data)
1135
+ ? data.map(function (v) {
1136
+ return typeof v === "number"
1137
+ ? v
1138
+ : v && typeof v === "object" && "value" in v
1139
+ ? v.value
1140
+ : Number(v);
1141
+ })
1142
+ : [];
1143
+ if (numericValues.length === 0)
1144
+ return;
1145
+ var seriesColor = (_b = series.color) !== null && _b !== void 0 ? _b : theme.themeColors.accent1;
1146
+ var useSecondary = series.useSecondaryAxis ? { yAxisIndex: 1 } : {};
1147
+ try {
1148
+ // Trendlines — one overlay line series per spec.
1149
+ for (var _m = tslib_1.__values((_c = series.trendlines) !== null && _c !== void 0 ? _c : []), _o = _m.next(); !_o.done; _o = _m.next()) {
1150
+ var tl = _o.value;
1151
+ var result = (0, trendline_1.computeTrendline)(numericValues, {
1152
+ type: tl.type,
1153
+ order: tl.order,
1154
+ period: tl.period,
1155
+ forecastForward: tl.forecastForward,
1156
+ forecastBackward: tl.forecastBackward,
1157
+ });
1158
+ if (!result || result.points.length < 2)
1159
+ continue;
1160
+ var tlName = (_d = tl.name) !== null && _d !== void 0 ? _d : "".concat(dataLabel ? dataLabel + " " : "").concat((_e = tl.type) !== null && _e !== void 0 ? _e : "linear", " trend");
1161
+ chartSeries.push(tslib_1.__assign({ type: "line", name: tlName,
1162
+ // Index x lets the trendline overlay the category axis even
1163
+ // when forecasting extends beyond the data range.
1164
+ data: result.points.map(function (p) { return [p.x, p.y]; }), showSymbol: false, smooth: tl.type === "poly", lineStyle: {
1165
+ color: (_f = tl.color) !== null && _f !== void 0 ? _f : seriesColor,
1166
+ type: "dashed",
1167
+ width: 2,
1168
+ }, itemStyle: { color: (_g = tl.color) !== null && _g !== void 0 ? _g : seriesColor }, tooltip: { show: false }, z: 5 }, useSecondary));
1169
+ }
1170
+ }
1171
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
1172
+ finally {
1173
+ try {
1174
+ if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
1175
+ }
1176
+ finally { if (e_9) throw e_9.error; }
1177
+ }
1178
+ // Error bars — drawn as a custom series of vertical/horizontal
1179
+ // whiskers. valueType "custom" reads per-point magnitudes from the
1180
+ // spec's plus/minus ranges, resolved through the same extractor
1181
+ // the series values use.
1182
+ var magnitudes = (0, error_bars_1.computeErrorBars)(numericValues, (0, error_bars_1.resolveCustomErrorBarValues)(series.errorBars, function (range) {
1183
+ return getSeriesValuesFromRange(range, spec.hiddenDimensionStrategy);
1184
+ }));
1185
+ if (magnitudes) {
1186
+ var direction_1 = (_j = (_h = series.errorBars) === null || _h === void 0 ? void 0 : _h.direction) !== null && _j !== void 0 ? _j : "y";
1187
+ var noEndCap_1 = (_l = (_k = series.errorBars) === null || _k === void 0 ? void 0 : _k.noEndCap) !== null && _l !== void 0 ? _l : false;
1188
+ var errorData = numericValues.map(function (v, i) {
1189
+ var _a, _b;
1190
+ return [
1191
+ i,
1192
+ typeof v === "number" ? v : 0,
1193
+ (_a = magnitudes.plus[i]) !== null && _a !== void 0 ? _a : 0,
1194
+ (_b = magnitudes.minus[i]) !== null && _b !== void 0 ? _b : 0,
1195
+ ];
1196
+ });
1197
+ chartSeries.push(tslib_1.__assign(tslib_1.__assign({ type: "custom", name: "".concat(dataLabel ? dataLabel + " " : "", "error"), data: errorData, z: 6, tooltip: { show: false } }, useSecondary), { renderItem: function (_params, api) {
1198
+ var value = api.value(1);
1199
+ var plus = api.value(2);
1200
+ var minus = api.value(3);
1201
+ var capHalf = 5;
1202
+ if (direction_1 === "x") {
1203
+ var center_1 = api.coord([value, api.value(0)]);
1204
+ var hi_1 = api.coord([value + plus, api.value(0)]);
1205
+ var lo_1 = api.coord([value - minus, api.value(0)]);
1206
+ var children_1 = [
1207
+ {
1208
+ type: "line",
1209
+ shape: { x1: lo_1[0], y1: center_1[1], x2: hi_1[0], y2: center_1[1] },
1210
+ style: { stroke: seriesColor, lineWidth: 1 },
1211
+ },
1212
+ ];
1213
+ if (!noEndCap_1) {
1214
+ children_1.push({
1215
+ type: "line",
1216
+ shape: {
1217
+ x1: hi_1[0],
1218
+ y1: center_1[1] - capHalf,
1219
+ x2: hi_1[0],
1220
+ y2: center_1[1] + capHalf,
1221
+ },
1222
+ style: { stroke: seriesColor, lineWidth: 1 },
1223
+ }, {
1224
+ type: "line",
1225
+ shape: {
1226
+ x1: lo_1[0],
1227
+ y1: center_1[1] - capHalf,
1228
+ x2: lo_1[0],
1229
+ y2: center_1[1] + capHalf,
1230
+ },
1231
+ style: { stroke: seriesColor, lineWidth: 1 },
1232
+ });
1233
+ }
1234
+ return { type: "group", children: children_1 };
1235
+ }
1236
+ var center = api.coord([api.value(0), value]);
1237
+ var hi = api.coord([api.value(0), value + plus]);
1238
+ var lo = api.coord([api.value(0), value - minus]);
1239
+ var children = [
1240
+ {
1241
+ type: "line",
1242
+ shape: { x1: center[0], y1: lo[1], x2: center[0], y2: hi[1] },
1243
+ style: { stroke: seriesColor, lineWidth: 1 },
1244
+ },
1245
+ ];
1246
+ if (!noEndCap_1) {
1247
+ children.push({
1248
+ type: "line",
1249
+ shape: {
1250
+ x1: center[0] - capHalf,
1251
+ y1: hi[1],
1252
+ x2: center[0] + capHalf,
1253
+ y2: hi[1],
1254
+ },
1255
+ style: { stroke: seriesColor, lineWidth: 1 },
1256
+ }, {
1257
+ type: "line",
1258
+ shape: {
1259
+ x1: center[0] - capHalf,
1260
+ y1: lo[1],
1261
+ x2: center[0] + capHalf,
1262
+ y2: lo[1],
1263
+ },
1264
+ style: { stroke: seriesColor, lineWidth: 1 },
1265
+ });
1266
+ }
1267
+ return { type: "group", children: children };
1268
+ } }));
1269
+ }
1270
+ };
1271
+ sideBySideBarCount = isStacked
1272
+ ? 1
1273
+ : ((_52 = spec.series) !== null && _52 !== void 0 ? _52 : []).reduce(function (count, s) {
1274
+ var _a, _b, _c;
1275
+ var seriesType = (_a = s.seriesChartType) !== null && _a !== void 0 ? _a : spec.chartType;
1276
+ return seriesType === "bar" || seriesType === "column"
1277
+ ? count + Math.max(1, (_c = (_b = s.sources) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0)
1278
+ : count;
1279
+ }, 0);
1280
+ specBarGap = (0, bar_layout_1.overlapToBarGap)(spec.overlap);
1281
+ specBarCategoryGap = (0, bar_layout_1.gapWidthToBarCategoryGap)(spec.gapWidth, {
1282
+ seriesCount: sideBySideBarCount,
1283
+ overlap: isStacked ? 0 : spec.overlap,
1284
+ });
1285
+ _104.label = 20;
1286
+ case 20:
1287
+ _104.trys.push([20, 27, 28, 29]);
1288
+ _l = tslib_1.__values((_53 = spec.series) !== null && _53 !== void 0 ? _53 : []), _m = _l.next();
1289
+ _104.label = 21;
1290
+ case 21:
1291
+ if (!!_m.done) return [3 /*break*/, 26];
1292
+ series = _m.value;
1293
+ if (!(!(0, utils_1.isNil)(series.dataLabel) && (0, utils_1.isAFormula)(series.dataLabel))) return [3 /*break*/, 23];
1294
+ _p = chart_spec_utils_1.coerceCalculatedLabel;
1295
+ return [4 /*yield*/, onRequestCalculate(series.dataLabel, (_54 = position.sheetId) !== null && _54 !== void 0 ? _54 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
1296
+ case 22:
1297
+ _o = _p.apply(void 0, [_104.sent()]);
1298
+ return [3 /*break*/, 24];
1299
+ case 23:
1300
+ _o = (_55 = series.dataLabel) !== null && _55 !== void 0 ? _55 : "";
1301
+ _104.label = 24;
1302
+ case 24:
1303
+ dataLabel = _o;
1304
+ // Label
1305
+ if (dataLabel) {
1306
+ (_56 = legend.data) === null || _56 === void 0 ? void 0 : _56.push(dataLabel);
1307
+ }
1308
+ _loop_1 = function (sheetRange) {
1309
+ var e_10, _105;
1310
+ var data = getSeriesData(spec, sheetRange, {
1311
+ aggregateEnabled: shouldAggregate,
1312
+ aggregateType: series.aggregateType,
1313
+ rawDomainValues: rawPrimaryDomainValues,
1314
+ orderedDomainValues: aggregateDomainValues,
1315
+ });
1316
+ // Support per-series chart type for combo charts
1317
+ var effectiveChartType = (_57 = series.seriesChartType) !== null && _57 !== void 0 ? _57 : spec.chartType;
1318
+ var seriesEchartsType = (0, helpers_1.chartTypeToEchartsType)(effectiveChartType);
1319
+ var seriesStyleAttrs = (0, helpers_1.getEchartsSeriesStyle)(effectiveChartType);
1320
+ var seriesEntry = tslib_1.__assign({ type: seriesEchartsType, name: dataLabel, data: data, stack: isStacked ? "dataLabel" : undefined, smooth: (_58 = spec.smooth) !== null && _58 !== void 0 ? _58 : undefined, radius: (_59 = spec.radius) !== null && _59 !== void 0 ? _59 : (isCircularChart ? [0, "75%"] : undefined) }, seriesStyleAttrs);
1321
+ // Plot this series against a secondary value axis. The 2nd
1322
+ // yAxis element is appended below (when any series opts in);
1323
+ // here we point the series at index 1.
1324
+ if (series.useSecondaryAxis) {
1325
+ seriesEntry.yAxisIndex = 1;
1326
+ }
1327
+ // Handle invertIfNegative for bar/column charts
1328
+ var isBarOrColumn = effectiveChartType === "bar" || effectiveChartType === "column";
1329
+ // Bar layout (overlap/gapWidth) — echarts reads barGap /
1330
+ // barCategoryGap from bar series (the last bar series wins for
1331
+ // the whole coordinate system), so apply them to every
1332
+ // bar/column series. Set before the gradient/noFill branches so
1333
+ // every push path carries them.
1334
+ if (isBarOrColumn) {
1335
+ if (specBarGap !== undefined) {
1336
+ seriesEntry.barGap = specBarGap;
1337
+ }
1338
+ if (specBarCategoryGap !== undefined) {
1339
+ seriesEntry.barCategoryGap = specBarCategoryGap;
1340
+ }
1341
+ }
1342
+ var seriesAny = series;
1343
+ // Gradient fill — overrides solid color when present. echarts
1344
+ // paints it natively via a LinearGradient on itemStyle.color
1345
+ // (and areaStyle for area series / lineStyle for lines).
1346
+ var gradientArgs = (0, gradient_1.gradientToEcharts)(series.gradient);
1347
+ if (gradientArgs && !seriesAny.noFill) {
1348
+ var gradient = new echarts.graphic.LinearGradient(gradientArgs.x, gradientArgs.y, gradientArgs.x2, gradientArgs.y2, gradientArgs.colorStops);
1349
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_60 = seriesEntry.itemStyle) !== null && _60 !== void 0 ? _60 : {})), { color: gradient });
1350
+ if (effectiveChartType === "area") {
1351
+ seriesEntry.areaStyle = tslib_1.__assign(tslib_1.__assign({}, ((_61 = seriesEntry.areaStyle) !== null && _61 !== void 0 ? _61 : {})), { color: gradient });
1352
+ }
1353
+ chartSeries.push(seriesEntry);
1354
+ pushSeriesOverlays(series, data, dataLabel);
1355
+ return "continue";
1356
+ }
1357
+ if (seriesAny.noFill) {
1358
+ // Transparent series (Gantt lag offset, etc.) — fill it
1359
+ // with `transparent` so layout is preserved but nothing
1360
+ // paints. Legend entries are also suppressed via `name: ""`
1361
+ // since the series carries no semantic information.
1362
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_62 = seriesEntry.itemStyle) !== null && _62 !== void 0 ? _62 : {})), { color: "transparent", borderColor: "transparent" });
1363
+ }
1364
+ else if (isBarOrColumn &&
1365
+ Array.isArray(seriesAny.dataPointColors) &&
1366
+ seriesAny.dataPointColors.length) {
1367
+ // Per-data-point color overrides — Gantt-style charts colour
1368
+ // each task differently via `<c:dPt>`. Echarts accepts an
1369
+ // `itemStyle.color` function that receives the data index;
1370
+ // we look up the override or fall back to the series color.
1371
+ var overrides_2 = new Map();
1372
+ try {
1373
+ for (var _106 = (e_10 = void 0, tslib_1.__values(seriesAny.dataPointColors)), _107 = _106.next(); !_107.done; _107 = _106.next()) {
1374
+ var dp = _107.value;
1375
+ if (typeof dp.idx === "number" && typeof dp.color === "string") {
1376
+ overrides_2.set(dp.idx, dp.color);
1377
+ }
1378
+ }
1379
+ }
1380
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1381
+ finally {
1382
+ try {
1383
+ if (_107 && !_107.done && (_105 = _106.return)) _105.call(_106);
1384
+ }
1385
+ finally { if (e_10) throw e_10.error; }
1386
+ }
1387
+ var fallback_1 = (_63 = series.color) !== null && _63 !== void 0 ? _63 : theme.themeColors.accent1;
1388
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_64 = seriesEntry.itemStyle) !== null && _64 !== void 0 ? _64 : {})), { color: function (params) { var _a; return (_a = overrides_2.get(params.dataIndex)) !== null && _a !== void 0 ? _a : fallback_1; } });
1389
+ }
1390
+ else if (isBarOrColumn && series.invertIfNegative) {
1391
+ var positiveColor_1 = (_65 = series.color) !== null && _65 !== void 0 ? _65 : theme.themeColors.accent1;
1392
+ var negativeColor_1 = (_66 = series.negativeColor) !== null && _66 !== void 0 ? _66 : "#FF0000";
1393
+ // Use a color function that returns different colors based on value
1394
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_67 = seriesEntry.itemStyle) !== null && _67 !== void 0 ? _67 : {})), { color: function (params) {
1395
+ var _a, _b;
1396
+ var value = Array.isArray(params.data)
1397
+ ? params.data[1]
1398
+ : (_b = (_a = params.data) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : params.data;
1399
+ return typeof value === "number" && value < 0
1400
+ ? negativeColor_1
1401
+ : positiveColor_1;
1402
+ } });
1403
+ }
1404
+ else if (series.color) {
1405
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_68 = seriesEntry.itemStyle) !== null && _68 !== void 0 ? _68 : {})), { color: series.color });
1406
+ seriesEntry.lineStyle = tslib_1.__assign(tslib_1.__assign({}, ((_69 = seriesEntry.lineStyle) !== null && _69 !== void 0 ? _69 : {})), { color: series.color });
1407
+ if (effectiveChartType === "area") {
1408
+ seriesEntry.areaStyle = tslib_1.__assign(tslib_1.__assign({}, ((_70 = seriesEntry.areaStyle) !== null && _70 !== void 0 ? _70 : {})), { color: series.color });
1409
+ }
1410
+ }
1411
+ chartSeries.push(seriesEntry);
1412
+ pushSeriesOverlays(series, data, dataLabel);
1413
+ };
1414
+ try {
1415
+ for (_q = (e_4 = void 0, tslib_1.__values(series.sources)), _r = _q.next(); !_r.done; _r = _q.next()) {
1416
+ sheetRange = _r.value;
1417
+ _loop_1(sheetRange);
1418
+ }
1419
+ }
1420
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1421
+ finally {
1422
+ try {
1423
+ if (_r && !_r.done && (_1 = _q.return)) _1.call(_q);
1424
+ }
1425
+ finally { if (e_4) throw e_4.error; }
1426
+ }
1427
+ _104.label = 25;
1428
+ case 25:
1429
+ _m = _l.next();
1430
+ return [3 /*break*/, 21];
1431
+ case 26: return [3 /*break*/, 29];
1432
+ case 27:
1433
+ e_2_1 = _104.sent();
1434
+ e_2 = { error: e_2_1 };
1435
+ return [3 /*break*/, 29];
1436
+ case 28:
1437
+ try {
1438
+ if (_m && !_m.done && (_0 = _l.return)) _0.call(_l);
1439
+ }
1440
+ finally { if (e_2) throw e_2.error; }
1441
+ return [7 /*endfinally*/];
1442
+ case 29:
1443
+ if (isOfPie) {
1444
+ labels = rawPrimaryDomainValues.map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
1445
+ seriesEntry = (_71 = spec.series) === null || _71 === void 0 ? void 0 : _71[0];
1446
+ rawValues = seriesEntry
1447
+ ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); })
1448
+ : [];
1449
+ _s = (0, of_pie_1.splitOfPie)(rawValues, labels, {
1450
+ splitType: spec.splitType,
1451
+ splitPos: spec.splitPos,
1452
+ }), main_1 = _s.main, secondary = _s.secondary, otherTotal = _s.otherTotal, total = _s.total;
1453
+ ofPieType_1 = (0, of_pie_1.resolveOfPieType)(spec.ofPieType);
1454
+ secondScale = (0, of_pie_1.clampSecondPieSize)(spec.secondPieSize) / 100;
1455
+ halfAngle_1 = (0, of_pie_1.otherSliceHalfAngle)(otherTotal, total);
1456
+ hasSecondary = secondary.length > 0;
1457
+ MAIN_CX_1 = 0.3;
1458
+ CY_1 = 0.5;
1459
+ MAIN_RADIUS_PCT_1 = 55;
1460
+ SECONDARY_CX_1 = 0.78;
1461
+ secondaryRadiusPct_1 = Math.min(80, MAIN_RADIUS_PCT_1 * secondScale);
1462
+ BAR_LEFT_1 = 0.68;
1463
+ BAR_RIGHT = 0.88;
1464
+ barHalfFrac_1 = Math.min(0.45, Math.max(0.08, 0.28 * secondScale));
1465
+ ofPieLayout = {
1466
+ ofPieType: ofPieType_1,
1467
+ hasSecondary: hasSecondary,
1468
+ barGrid: ofPieType_1 === "bar" && hasSecondary
1469
+ ? {
1470
+ left: "".concat(BAR_LEFT_1 * 100, "%"),
1471
+ right: "".concat((1 - BAR_RIGHT) * 100, "%"),
1472
+ top: "".concat((CY_1 - barHalfFrac_1) * 100, "%"),
1473
+ bottom: "".concat((1 - CY_1 - barHalfFrac_1) * 100, "%"),
1474
+ }
1475
+ : undefined,
1476
+ };
1477
+ chartDomains.length = 0;
1478
+ chartSeries.length = 0;
1479
+ ofPiePalette_1 = [
1480
+ theme.themeColors.accent1,
1481
+ theme.themeColors.accent2,
1482
+ theme.themeColors.accent3,
1483
+ theme.themeColors.accent4,
1484
+ theme.themeColors.accent5,
1485
+ theme.themeColors.accent6,
1486
+ ];
1487
+ paletteAt_1 = function (index) {
1488
+ return ofPiePalette_1[index % ofPiePalette_1.length];
1489
+ };
1490
+ chartSeries.push({
1491
+ type: "pie",
1492
+ name: (_72 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _72 !== void 0 ? _72 : "",
1493
+ center: ["".concat(MAIN_CX_1 * 100, "%"), "".concat(CY_1 * 100, "%")],
1494
+ radius: [0, "".concat(MAIN_RADIUS_PCT_1, "%")],
1495
+ // Rotate the pie so the "Other" slice's angular midpoint faces
1496
+ // the secondary plot (Excel's layout). Slices sweep clockwise
1497
+ // and Other is last, ending the sweep at startAngle; putting
1498
+ // the midpoint at 0° (3 o'clock) needs startAngle 360 - 180f.
1499
+ startAngle: 360 - (halfAngle_1 * 180) / Math.PI,
1500
+ data: main_1.map(function (s, i) { return ({
1501
+ name: s.label,
1502
+ value: s.value,
1503
+ itemStyle: { color: paletteAt_1(i) },
1504
+ }); }),
1505
+ });
1506
+ if (hasSecondary) {
1507
+ if (ofPieType_1 === "pie") {
1508
+ chartSeries.push({
1509
+ type: "pie",
1510
+ name: (_73 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _73 !== void 0 ? _73 : "",
1511
+ center: ["".concat(SECONDARY_CX_1 * 100, "%"), "".concat(CY_1 * 100, "%")],
1512
+ radius: [0, "".concat(secondaryRadiusPct_1, "%")],
1513
+ data: secondary.map(function (s, i) { return ({
1514
+ name: s.label,
1515
+ value: s.value,
1516
+ itemStyle: { color: paletteAt_1(main_1.length + i) },
1517
+ }); }),
1518
+ });
1519
+ }
1520
+ else {
1521
+ // Bar-of-pie — a single-category stacked bar on the second
1522
+ // grid, one series per point so each segment keeps its own
1523
+ // color, legend entry and tooltip.
1524
+ secondary.forEach(function (s, i) {
1525
+ chartSeries.push({
1526
+ type: "bar",
1527
+ name: s.label,
1528
+ stack: "rnc-of-pie-secondary",
1529
+ xAxisIndex: 1,
1530
+ yAxisIndex: 1,
1531
+ barWidth: "75%",
1532
+ data: [s.value],
1533
+ itemStyle: { color: paletteAt_1(main_1.length + i) },
1534
+ tooltip: { formatter: "{a}: {c}" },
1535
+ });
1536
+ });
1537
+ }
1538
+ connectorColor_1 = isDarkMode
1539
+ ? "rgba(255,255,255,0.45)"
1540
+ : "#999999";
1541
+ chartSeries.push({
1542
+ type: "custom",
1543
+ name: "",
1544
+ silent: true,
1545
+ animation: false,
1546
+ tooltip: { show: false },
1547
+ z: 1,
1548
+ data: [[0, 0]],
1549
+ renderItem: function (params) {
1550
+ var _a, _b, _c, _d, _e;
1551
+ var cs = (_a = params === null || params === void 0 ? void 0 : params.coordSys) !== null && _a !== void 0 ? _a : {};
1552
+ var width = (_b = cs.width) !== null && _b !== void 0 ? _b : 0;
1553
+ var height = (_c = cs.height) !== null && _c !== void 0 ? _c : 0;
1554
+ if (!(width > 0) || !(height > 0)) {
1555
+ return { type: "group", children: [] };
1556
+ }
1557
+ var x0 = (_d = cs.x) !== null && _d !== void 0 ? _d : 0;
1558
+ var y0 = (_e = cs.y) !== null && _e !== void 0 ? _e : 0;
1559
+ var r = ((MAIN_RADIUS_PCT_1 / 100) * Math.min(width, height)) / 2;
1560
+ var cx = x0 + MAIN_CX_1 * width;
1561
+ var cy = y0 + CY_1 * height;
1562
+ // Boundary points of the Other slice on the main circle —
1563
+ // ±halfAngle around 3 o'clock (screen y grows downwards).
1564
+ var px = cx + r * Math.cos(halfAngle_1);
1565
+ var pyTop = cy - r * Math.sin(halfAngle_1);
1566
+ var pyBottom = cy + r * Math.sin(halfAngle_1);
1567
+ var tx;
1568
+ var tyTop;
1569
+ var tyBottom;
1570
+ if (ofPieType_1 === "pie") {
1571
+ var r2 = ((secondaryRadiusPct_1 / 100) * Math.min(width, height)) / 2;
1572
+ tx = x0 + SECONDARY_CX_1 * width;
1573
+ tyTop = cy - r2;
1574
+ tyBottom = cy + r2;
1575
+ }
1576
+ else {
1577
+ tx = x0 + BAR_LEFT_1 * width;
1578
+ tyTop = y0 + (CY_1 - barHalfFrac_1) * height;
1579
+ tyBottom = y0 + (CY_1 + barHalfFrac_1) * height;
1580
+ }
1581
+ var style = { stroke: connectorColor_1, lineWidth: 1 };
1582
+ return {
1583
+ type: "group",
1584
+ children: [
1585
+ {
1586
+ type: "line",
1587
+ shape: { x1: px, y1: pyTop, x2: tx, y2: tyTop },
1588
+ style: style,
1589
+ },
1590
+ {
1591
+ type: "line",
1592
+ shape: { x1: px, y1: pyBottom, x2: tx, y2: tyBottom },
1593
+ style: style,
1594
+ },
1595
+ ],
1596
+ };
1597
+ },
1598
+ });
1599
+ }
1600
+ // Legend lists every category (main + secondary); the Other slice
1601
+ // only exists in the main pie.
1602
+ legend.data = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(main_1.map(function (s) { return s.label; })), false), tslib_1.__read(secondary.map(function (s) { return s.label; })), false);
1603
+ }
1604
+ else if (spec.chartType === "waterfall") {
1605
+ primaryDomainSource_1 = (_76 = (_75 = (_74 = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _74 === void 0 ? void 0 : _74[0]) === null || _75 === void 0 ? void 0 : _75.sources) === null || _76 === void 0 ? void 0 : _76[0];
1606
+ rawDomainValues = primaryDomainSource_1
1607
+ ? (0, aggregation_1.sanitizeDomainValues)((_77 = getDomainValuesFromRange(primaryDomainSource_1, spec.hiddenDimensionStrategy)) !== null && _77 !== void 0 ? _77 : [])
1608
+ : [];
1609
+ labels = rawDomainValues.map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
1610
+ seriesEntry = (_78 = spec.series) === null || _78 === void 0 ? void 0 : _78[0];
1611
+ rawValues_1 = seriesEntry
1612
+ ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); })
1613
+ : [];
1614
+ totalIndices = new Set((_79 = spec.totalIndices) !== null && _79 !== void 0 ? _79 : []);
1615
+ steps = (0, waterfall_1.computeWaterfall)(rawValues_1, labels, totalIndices);
1616
+ chartDomains.length = 0;
1617
+ chartDomains.push({
1618
+ type: "category",
1619
+ data: steps.map(function (s) { return s.label; }),
1620
+ show: showAxis,
1621
+ axisLine: { show: true },
1622
+ axisTick: { show: true },
1623
+ splitLine: { show: false },
1624
+ name: (_80 = spec.horizontalAxisTitle) !== null && _80 !== void 0 ? _80 : "",
1625
+ nameLocation: "middle",
1626
+ nameGap: 30,
1627
+ });
1628
+ chartSeries.length = 0;
1629
+ chartSeries.push({
1630
+ type: "bar",
1631
+ stack: "waterfall",
1632
+ itemStyle: { color: "transparent" },
1633
+ emphasis: { itemStyle: { color: "transparent" } },
1634
+ data: steps.map(function (s) { return s.placeholder; }),
1635
+ silent: true,
1636
+ });
1637
+ accent_1 = (_81 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.color) !== null && _81 !== void 0 ? _81 : theme.themeColors.accent1;
1638
+ decreaseColor_1 = (_83 = (_82 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.negativeColor) !== null && _82 !== void 0 ? _82 : theme.themeColors.accent2) !== null && _83 !== void 0 ? _83 : accent_1;
1639
+ totalColor_1 = (_84 = theme.themeColors.accent3) !== null && _84 !== void 0 ? _84 : accent_1;
1640
+ connectors = steps.slice(0, -1).map(function (s, i) { return [
1641
+ { coord: [i, s.cumulative] },
1642
+ { coord: [i + 1, s.cumulative] },
1643
+ ]; });
1644
+ chartSeries.push({
1645
+ type: "bar",
1646
+ stack: "waterfall",
1647
+ name: (_85 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _85 !== void 0 ? _85 : "",
1648
+ data: steps.map(function (s, i) { return ({
1649
+ value: s.value,
1650
+ itemStyle: {
1651
+ color: s.isTotal
1652
+ ? totalColor_1
1653
+ : rawValues_1[i] < 0
1654
+ ? decreaseColor_1
1655
+ : accent_1,
1656
+ },
1657
+ }); }),
1658
+ markLine: {
1659
+ silent: true,
1660
+ symbol: "none",
1661
+ animation: false,
1662
+ label: { show: false },
1663
+ lineStyle: {
1664
+ color: isDarkMode ? "rgba(255,255,255,0.45)" : "#999999",
1665
+ width: 1,
1666
+ type: "solid",
1667
+ },
1668
+ data: connectors,
1669
+ },
1670
+ });
1671
+ legend.data = [];
1672
+ }
1673
+ else if (spec.chartType === "funnel") {
1674
+ primaryDomainSource_2 = (_88 = (_87 = (_86 = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _86 === void 0 ? void 0 : _86[0]) === null || _87 === void 0 ? void 0 : _87.sources) === null || _88 === void 0 ? void 0 : _88[0];
1675
+ rawDomainValues = primaryDomainSource_2
1676
+ ? (0, aggregation_1.sanitizeDomainValues)((_89 = getDomainValuesFromRange(primaryDomainSource_2, spec.hiddenDimensionStrategy)) !== null && _89 !== void 0 ? _89 : [])
1677
+ : [];
1678
+ labels_1 = rawDomainValues.map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
1679
+ seriesEntry = (_90 = spec.series) === null || _90 === void 0 ? void 0 : _90[0];
1680
+ rawValues = seriesEntry
1681
+ ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : 0); })
1682
+ : [];
1683
+ chartDomains.length = 0;
1684
+ chartSeries.length = 0;
1685
+ chartSeries.push({
1686
+ type: "funnel",
1687
+ name: (_91 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _91 !== void 0 ? _91 : "",
1688
+ data: rawValues.map(function (value, i) {
1689
+ var _a;
1690
+ return ({
1691
+ name: (_a = labels_1[i]) !== null && _a !== void 0 ? _a : String(i),
1692
+ value: value,
1693
+ });
1694
+ }),
1695
+ label: { show: true, position: "inside" },
1696
+ });
1697
+ legend.data = [];
1698
+ }
1699
+ else if (spec.chartType === "boxplot") {
1700
+ quartileMethod = spec.quartileMethod;
1701
+ showOutliers = spec.showOutliers;
1702
+ showMeanMarker = spec.showMeanMarker === true;
1703
+ boxStats = [];
1704
+ boxLabels = [];
1705
+ outlierPoints = [];
1706
+ meanPoints = [];
1707
+ try {
1708
+ for (_t = tslib_1.__values((_92 = spec.series) !== null && _92 !== void 0 ? _92 : []), _u = _t.next(); !_u.done; _u = _t.next()) {
1709
+ seriesEntry = _u.value;
1710
+ label = seriesEntry.dataLabel && !(0, utils_1.isAFormula)(seriesEntry.dataLabel)
1711
+ ? seriesEntry.dataLabel
1712
+ : "";
1713
+ rawValues = flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
1714
+ summary = (0, boxplot_1.computeBoxplotSummary)(rawValues, { quartileMethod: quartileMethod });
1715
+ if (summary) {
1716
+ boxIndex = boxStats.length;
1717
+ lo = showOutliers === true ? summary.lowerWhisker : summary.min;
1718
+ hi = showOutliers === true ? summary.upperWhisker : summary.max;
1719
+ boxStats.push([lo, summary.q1, summary.median, summary.q3, hi]);
1720
+ boxLabels.push(label);
1721
+ if (showOutliers === true) {
1722
+ try {
1723
+ for (_v = (e_6 = void 0, tslib_1.__values(summary.outliers)), _w = _v.next(); !_w.done; _w = _v.next()) {
1724
+ outlier = _w.value;
1725
+ outlierPoints.push([boxIndex, outlier]);
1726
+ }
1727
+ }
1728
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1729
+ finally {
1730
+ try {
1731
+ if (_w && !_w.done && (_3 = _v.return)) _3.call(_v);
1732
+ }
1733
+ finally { if (e_6) throw e_6.error; }
1734
+ }
1735
+ }
1736
+ if (showMeanMarker) {
1737
+ meanPoints.push([boxIndex, summary.mean]);
1738
+ }
1739
+ }
1740
+ }
1741
+ }
1742
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1743
+ finally {
1744
+ try {
1745
+ if (_u && !_u.done && (_2 = _t.return)) _2.call(_t);
1746
+ }
1747
+ finally { if (e_5) throw e_5.error; }
1748
+ }
1749
+ chartDomains.length = 0;
1750
+ chartDomains.push({
1751
+ type: "category",
1752
+ data: boxLabels,
1753
+ show: showAxis,
1754
+ axisLine: { show: true },
1755
+ axisTick: { show: true },
1756
+ splitLine: { show: false },
1757
+ name: (_93 = spec.horizontalAxisTitle) !== null && _93 !== void 0 ? _93 : "",
1758
+ nameLocation: "middle",
1759
+ nameGap: 30,
1760
+ });
1761
+ chartSeries.length = 0;
1762
+ boxSeries = {
1763
+ type: "boxplot",
1764
+ name: "",
1765
+ data: boxStats,
1766
+ };
1767
+ boxColor = (_95 = (_94 = spec.series) === null || _94 === void 0 ? void 0 : _94[0]) === null || _95 === void 0 ? void 0 : _95.color;
1768
+ if (boxColor) {
1769
+ boxSeries.itemStyle = { color: boxColor, borderColor: boxColor };
1770
+ }
1771
+ chartSeries.push(boxSeries);
1772
+ if (outlierPoints.length > 0) {
1773
+ chartSeries.push(tslib_1.__assign(tslib_1.__assign({ type: "scatter", name: "", data: outlierPoints, symbolSize: 6 }, (boxColor ? { itemStyle: { color: boxColor } } : {})), { tooltip: { show: false } }));
1774
+ }
1775
+ if (meanPoints.length > 0) {
1776
+ chartSeries.push(tslib_1.__assign(tslib_1.__assign({ type: "scatter", name: "", data: meanPoints, symbol: "diamond", symbolSize: 9 }, (boxColor ? { itemStyle: { color: boxColor } } : {})), { tooltip: { show: false } }));
1777
+ }
1778
+ legend.data = [];
1779
+ }
1780
+ else if (spec.chartType === "histogram") {
1781
+ rawValues = flattenChartDataValues(spec.series, getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
1782
+ _x = (0, histogram_1.binHistogram)(rawValues, spec.binCount), labels = _x.labels, counts = _x.counts;
1783
+ isPareto_1 = (0, histogram_1.isParetoSpec)(spec);
1784
+ cumulativePercents = [];
1785
+ if (isPareto_1) {
1786
+ pareto = (0, histogram_1.computePareto)({ labels: labels, counts: counts });
1787
+ labels = pareto.labels;
1788
+ counts = pareto.counts;
1789
+ cumulativePercents = pareto.cumulativePercents;
1790
+ }
1791
+ chartDomains.length = 0;
1792
+ chartDomains.push({
1793
+ type: "category",
1794
+ data: labels,
1795
+ show: showAxis,
1796
+ axisLine: { show: true },
1797
+ axisTick: { show: true },
1798
+ splitLine: { show: false },
1799
+ name: (_96 = spec.horizontalAxisTitle) !== null && _96 !== void 0 ? _96 : "",
1800
+ nameLocation: "middle",
1801
+ nameGap: 30,
1802
+ });
1803
+ chartSeries.length = 0;
1804
+ histogramSeries = {
1805
+ type: "bar",
1806
+ name: (_99 = (_98 = (_97 = spec.series) === null || _97 === void 0 ? void 0 : _97[0]) === null || _98 === void 0 ? void 0 : _98.dataLabel) !== null && _99 !== void 0 ? _99 : "",
1807
+ data: counts,
1808
+ barCategoryGap: "1%",
1809
+ };
1810
+ histogramColor = (_101 = (_100 = spec.series) === null || _100 === void 0 ? void 0 : _100[0]) === null || _101 === void 0 ? void 0 : _101.color;
1811
+ if (histogramColor) {
1812
+ histogramSeries.itemStyle = { color: histogramColor };
1813
+ }
1814
+ chartSeries.push(histogramSeries);
1815
+ if (isPareto_1) {
1816
+ // Cumulative-% overlay on the secondary axis (yAxisIndex 1);
1817
+ // the matching 0-100% axis element is appended with the other
1818
+ // value axes below.
1819
+ chartSeries.push({
1820
+ type: "line",
1821
+ name: "Cumulative %",
1822
+ data: cumulativePercents,
1823
+ yAxisIndex: 1,
1824
+ symbol: "circle",
1825
+ symbolSize: 6,
1826
+ });
1827
+ }
1828
+ legend.data = [];
1829
+ }
1830
+ renderedSeriesCount = chartSeries.length;
1831
+ replaceMerge = previousChartType.current !== spec.chartType ||
1832
+ previousSeriesCount.current !== renderedSeriesCount
1833
+ ? ["series", "xAxis", "yAxis", "legend", "grid", "tooltip"]
1834
+ : [];
1835
+ gridConfig = isOfPie
1836
+ ? tslib_1.__spreadArray([
1837
+ { left: 0, right: 0, top: 0, bottom: 0 }
1838
+ ], tslib_1.__read(((ofPieLayout === null || ofPieLayout === void 0 ? void 0 : ofPieLayout.barGrid) ? [ofPieLayout.barGrid] : [])), false)
1839
+ : isCircularChart
1840
+ ? {
1841
+ left: 0,
1842
+ right: 0,
1843
+ top: 0,
1844
+ bottom: 0,
1845
+ }
1846
+ : {
1847
+ left: "3%",
1848
+ right: "4%",
1849
+ bottom: "3%",
1850
+ containLabel: true,
1851
+ };
1852
+ valueAxisBase = {
1853
+ type: "value",
1854
+ show: !isCircularChart,
1855
+ axisLine: { show: !isCircularChart },
1856
+ axisTick: { show: !isCircularChart },
1857
+ splitLine: { show: !isCircularChart },
1858
+ nameLocation: "middle",
1859
+ nameGap: 50,
1860
+ };
1861
+ isPareto = spec.chartType === "histogram" && (0, histogram_1.isParetoSpec)(spec);
1862
+ hasSecondaryAxis = !isCircularChart &&
1863
+ !isHorizontalBarChart &&
1864
+ (((_102 = spec.series) !== null && _102 !== void 0 ? _102 : []).some(function (s) { return s.useSecondaryAxis; }) || isPareto);
1865
+ tooltipConfig = {
1866
+ textStyle: {
1867
+ fontSize: 12,
1868
+ },
1869
+ trigger: isCircularChart ? "item" : "axis",
1870
+ formatter: isCircularChart ? "{b}: {c} ({d}%)" : undefined,
1871
+ };
1872
+ finalLegend = (0, overrides_1.applyLegendOverrides)(legend, spec.legend);
1873
+ seriesLabelOption = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
1874
+ isDoughnut = spec.chartType === "doughnut";
1875
+ doughnutHoleSize = spec.doughnutHoleSize;
1876
+ // PERCENT_STACKED — echarts has no built-in `barnorm: 'percent'`,
1877
+ // so we normalize per category here: each cell becomes
1878
+ // (value / category_total) * 100, while the original value is
1879
+ // tucked into a sibling field so the label formatter can still
1880
+ // surface the dollar amount. Touches only bar/column series in
1881
+ // the percent-stacked spec; other charts pass through unchanged.
1882
+ if (spec.stackedType === "PERCENT_STACKED" &&
1883
+ (spec.chartType === "bar" || spec.chartType === "column")) {
1884
+ barSeries = chartSeries.filter(function (s) { return (s === null || s === void 0 ? void 0 : s.type) === "bar"; });
1885
+ len = barSeries.reduce(function (m, s) { return Math.max(m, Array.isArray(s.data) ? s.data.length : 0); }, 0);
1886
+ categoryTotals_1 = new Array(len).fill(0);
1887
+ try {
1888
+ for (barSeries_1 = tslib_1.__values(barSeries), barSeries_1_1 = barSeries_1.next(); !barSeries_1_1.done; barSeries_1_1 = barSeries_1.next()) {
1889
+ s = barSeries_1_1.value;
1890
+ if (!Array.isArray(s.data))
1891
+ continue;
1892
+ for (i = 0; i < s.data.length; i++) {
1893
+ raw = s.data[i];
1894
+ n = typeof raw === "number" ? raw : Number(raw);
1895
+ if (Number.isFinite(n))
1896
+ categoryTotals_1[i] += n;
1897
+ }
1898
+ }
1899
+ }
1900
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1901
+ finally {
1902
+ try {
1903
+ if (barSeries_1_1 && !barSeries_1_1.done && (_4 = barSeries_1.return)) _4.call(barSeries_1);
1904
+ }
1905
+ finally { if (e_7) throw e_7.error; }
1906
+ }
1907
+ try {
1908
+ for (barSeries_2 = tslib_1.__values(barSeries), barSeries_2_1 = barSeries_2.next(); !barSeries_2_1.done; barSeries_2_1 = barSeries_2.next()) {
1909
+ s = barSeries_2_1.value;
1910
+ if (!Array.isArray(s.data))
1911
+ continue;
1912
+ s.data = s.data.map(function (raw, i) {
1913
+ var n = typeof raw === "number" ? raw : Number(raw);
1914
+ var total = categoryTotals_1[i];
1915
+ if (!Number.isFinite(n) || total === 0) {
1916
+ return { value: 0, originalValue: raw };
1917
+ }
1918
+ return { value: (n / total) * 100, originalValue: n };
1919
+ });
1920
+ }
1921
+ }
1922
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1923
+ finally {
1924
+ try {
1925
+ if (barSeries_2_1 && !barSeries_2_1.done && (_5 = barSeries_2.return)) _5.call(barSeries_2);
1926
+ }
1927
+ finally { if (e_8) throw e_8.error; }
1928
+ }
1929
+ }
1930
+ seriesWithLabels = chartSeries.map(function (s) {
1931
+ var _a;
1932
+ var next = tslib_1.__assign({}, s);
1933
+ if (seriesLabelOption) {
1934
+ next.label = tslib_1.__assign(tslib_1.__assign({}, ((_a = s === null || s === void 0 ? void 0 : s.label) !== null && _a !== void 0 ? _a : {})), seriesLabelOption);
1935
+ }
1936
+ if (isDoughnut && next.type === "pie") {
1937
+ var inner = typeof doughnutHoleSize === "number"
1938
+ ? Math.round(Math.max(0, Math.min(0.9, doughnutHoleSize)) * 100)
1939
+ : 50;
1940
+ next.radius = ["".concat(inner, "%"), "75%"];
1941
+ }
1942
+ return next;
1943
+ });
1944
+ // Update charts
1945
+ (_103 = chartRef.current) === null || _103 === void 0 ? void 0 : _103.setOption({
1946
+ xAxis: (function () {
1947
+ var _a, _b;
1948
+ if (isOfPie) {
1949
+ // Hidden 0-1 value axis on the full-container grid for the
1950
+ // connector overlay, plus a hidden single-category axis on
1951
+ // the secondary grid for bar-of-pie.
1952
+ var axes = [
1953
+ {
1954
+ type: "value",
1955
+ min: 0,
1956
+ max: 1,
1957
+ show: false,
1958
+ axisLine: { show: false },
1959
+ axisTick: { show: false },
1960
+ splitLine: { show: false },
1961
+ },
1962
+ ];
1963
+ if (ofPieLayout === null || ofPieLayout === void 0 ? void 0 : ofPieLayout.barGrid) {
1964
+ axes.push({
1965
+ type: "category",
1966
+ data: [""],
1967
+ gridIndex: 1,
1968
+ show: false,
1969
+ axisLine: { show: false },
1970
+ axisTick: { show: false },
1971
+ splitLine: { show: false },
1972
+ });
1973
+ }
1974
+ return axes;
1975
+ }
1976
+ if (isCircularChart) {
1977
+ return [
1978
+ {
1979
+ type: "category",
1980
+ show: false,
1981
+ axisLine: { show: false },
1982
+ axisTick: { show: false },
1983
+ splitLine: { show: false },
1984
+ },
1985
+ ];
1986
+ }
1987
+ if (isHorizontalBarChart) {
1988
+ return [
1989
+ (0, overrides_1.applyAxisOverrides)(tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { name: (_a = spec.horizontalAxisTitle) !== null && _a !== void 0 ? _a : "" }), spec.valueAxisOptions),
1990
+ ];
1991
+ }
1992
+ var base = chartDomains.length > 0
1993
+ ? chartDomains
1994
+ : [
1995
+ {
1996
+ type: "category",
1997
+ show: showAxis,
1998
+ axisLine: { show: true },
1999
+ axisTick: { show: true },
2000
+ splitLine: { show: true },
2001
+ name: (_b = spec.horizontalAxisTitle) !== null && _b !== void 0 ? _b : "",
2002
+ nameLocation: "middle",
2003
+ nameGap: 30,
2004
+ },
2005
+ ];
2006
+ return base.map(function (axis) {
2007
+ return (0, overrides_1.applyAxisOverrides)(axis, spec.categoryAxisOptions);
2008
+ });
2009
+ })(),
2010
+ yAxis: (function () {
2011
+ var _a, _b;
2012
+ if (isOfPie) {
2013
+ var axes_1 = [
2014
+ tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { min: 0, max: 1, show: false, axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: false }, name: undefined }),
2015
+ ];
2016
+ if (ofPieLayout === null || ofPieLayout === void 0 ? void 0 : ofPieLayout.barGrid) {
2017
+ axes_1.push({
2018
+ type: "value",
2019
+ gridIndex: 1,
2020
+ show: false,
2021
+ axisLine: { show: false },
2022
+ axisTick: { show: false },
2023
+ splitLine: { show: false },
2024
+ });
2025
+ }
2026
+ return axes_1;
2027
+ }
2028
+ if (isCircularChart) {
2029
+ return [
2030
+ tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { show: false, axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: false }, name: undefined }),
2031
+ ];
2032
+ }
2033
+ if (isHorizontalBarChart) {
2034
+ var base = chartDomains.length > 0
2035
+ ? chartDomains
2036
+ : [
2037
+ {
2038
+ type: "category",
2039
+ show: showAxis,
2040
+ axisLine: { show: true },
2041
+ axisTick: { show: true },
2042
+ splitLine: { show: true },
2043
+ name: (_a = spec.verticalAxisTitle) !== null && _a !== void 0 ? _a : "",
2044
+ nameLocation: "middle",
2045
+ nameGap: 30,
2046
+ },
2047
+ ];
2048
+ return base.map(function (axis) {
2049
+ return (0, overrides_1.applyAxisOverrides)(axis, spec.categoryAxisOptions);
2050
+ });
2051
+ }
2052
+ var axes = [
2053
+ (0, overrides_1.applyAxisOverrides)(tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { name: (_b = spec.verticalAxisTitle) !== null && _b !== void 0 ? _b : "" }), spec.valueAxisOptions),
2054
+ ];
2055
+ if (hasSecondaryAxis) {
2056
+ axes.push((0, overrides_1.applyAxisOverrides)(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { name: "", splitLine: { show: false } }), (isPareto
2057
+ ? {
2058
+ min: 0,
2059
+ max: 100,
2060
+ axisLabel: { formatter: "{value}%" },
2061
+ }
2062
+ : {})), spec.secondaryValueAxisOptions));
2063
+ }
2064
+ return axes;
2065
+ })(),
2066
+ series: seriesWithLabels,
2067
+ legend: finalLegend,
2068
+ grid: gridConfig,
2069
+ tooltip: tooltipConfig,
2070
+ }, { replaceMerge: replaceMerge, lazyUpdate: true });
2071
+ previousChartType.current = spec.chartType;
2072
+ previousSeriesCount.current = renderedSeriesCount;
2073
+ return [2 /*return*/];
2074
+ }
2075
+ });
2076
+ }); };
2077
+ (0, ui_1.useIsomorphicLayoutEffect)(function () {
2078
+ echarts.use([
2079
+ components_1.TitleComponent,
2080
+ components_1.TooltipComponent,
2081
+ components_1.GridComponent,
2082
+ components_1.LegendComponent,
2083
+ components_1.RadarComponent,
2084
+ charts_1.BarChart,
2085
+ charts_1.BoxplotChart,
2086
+ charts_1.CandlestickChart,
2087
+ charts_1.CustomChart,
2088
+ charts_1.FunnelChart,
2089
+ charts_1.LineChart,
2090
+ charts_1.PieChart,
2091
+ charts_1.RadarChart,
2092
+ charts_1.ScatterChart,
2093
+ charts_1.TreemapChart,
2094
+ charts_1.SunburstChart,
2095
+ renderers_1.CanvasRenderer,
2096
+ components_1.DatasetComponent,
2097
+ ]);
2098
+ initializeChart();
2099
+ }, []);
2100
+ // Subscribe to all chart data sources (domains, series, etc.)
2101
+ var chartDataRanges = (0, react_1.useMemo)(function () { return (0, chart_spec_utils_1.getChartDataRanges)(chart.spec); }, [chart.spec]);
2102
+ (0, spreadsheet_state_1.useSubscribeToMultipleRanges)(chart.chartId, chartDataRanges, updateChart);
2103
+ // Theme-derived chart properties (title/legend/tooltip colors, series
2104
+ // palette). Shared by the theme effect below and the 3-D / region-map
2105
+ // pipelines, which re-initialize the echarts instance when switching
2106
+ // between the cartesian 2-D option and the grid3D / map one and must
2107
+ // re-apply these.
2108
+ var applyThemeOptions = function () {
2109
+ var _a, _b, _c, _d, _e;
2110
+ if (chartRef.current) {
2111
+ var textColor = (0, spreadsheet_1.getStringifiedColor)({
2112
+ theme: 1,
2113
+ tint: isDarkMode ? 1 : 0,
2114
+ }, theme);
2115
+ var bgColor = (0, spreadsheet_1.getStringifiedColor)({ theme: 0, tint: isDarkMode ? -1 : 1 }, theme);
2116
+ var showAxis = (0, helpers_1.showXAxis)(chart.spec.chartType);
2117
+ // Authored chart-level text formats override the theme-derived
2118
+ // defaults. Title, legend, and data-label colors flow through
2119
+ // here; per-axis label colors land on each axis via
2120
+ // `applyAxisOverrides` later in the layout build.
2121
+ var authoredTitleFmt = chart.spec.titleTextFormat;
2122
+ var authoredLegendFmt = (_a = chart.spec.legend) === null || _a === void 0 ? void 0 : _a.textFormat;
2123
+ var authoredDataLabelFmt = (_b = chart.spec.dataLabels) === null || _b === void 0 ? void 0 : _b.textFormat;
2124
+ var options = {
2125
+ title: {
2126
+ text: title !== null && title !== void 0 ? title : undefined,
2127
+ textStyle: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ color: (_c = authoredTitleFmt === null || authoredTitleFmt === void 0 ? void 0 : authoredTitleFmt.color) !== null && _c !== void 0 ? _c : textColor }, ((authoredTitleFmt === null || authoredTitleFmt === void 0 ? void 0 : authoredTitleFmt.fontFamily)
2128
+ ? { fontFamily: authoredTitleFmt.fontFamily }
2129
+ : {})), (typeof (authoredTitleFmt === null || authoredTitleFmt === void 0 ? void 0 : authoredTitleFmt.fontSize) === "number"
2130
+ ? { fontSize: authoredTitleFmt.fontSize }
2131
+ : {})), ((authoredTitleFmt === null || authoredTitleFmt === void 0 ? void 0 : authoredTitleFmt.bold) ? { fontWeight: "bold" } : {})), ((authoredTitleFmt === null || authoredTitleFmt === void 0 ? void 0 : authoredTitleFmt.italic) ? { fontStyle: "italic" } : {})),
2132
+ },
2133
+ legend: {
2134
+ textStyle: tslib_1.__assign(tslib_1.__assign({ color: (_d = authoredLegendFmt === null || authoredLegendFmt === void 0 ? void 0 : authoredLegendFmt.color) !== null && _d !== void 0 ? _d : textColor }, ((authoredLegendFmt === null || authoredLegendFmt === void 0 ? void 0 : authoredLegendFmt.fontFamily)
2135
+ ? { fontFamily: authoredLegendFmt.fontFamily }
2136
+ : {})), (typeof (authoredLegendFmt === null || authoredLegendFmt === void 0 ? void 0 : authoredLegendFmt.fontSize) === "number"
2137
+ ? { fontSize: authoredLegendFmt.fontSize }
2138
+ : {})),
2139
+ },
2140
+ axisLabel: {
2141
+ color: (_e = authoredDataLabelFmt === null || authoredDataLabelFmt === void 0 ? void 0 : authoredDataLabelFmt.color) !== null && _e !== void 0 ? _e : textColor,
2142
+ },
2143
+ tooltip: {
2144
+ backgroundColor: bgColor,
2145
+ textStyle: {
2146
+ color: textColor,
2147
+ },
2148
+ },
2149
+ color: [
2150
+ theme.themeColors.accent1,
2151
+ theme.themeColors.accent2,
2152
+ theme.themeColors.accent3,
2153
+ theme.themeColors.accent4,
2154
+ theme.themeColors.accent5,
2155
+ theme.themeColors.accent6,
2156
+ ],
2157
+ };
2158
+ // Skip when rendering 3-D or a region map: merging a cartesian
2159
+ // yAxis into a grid3D / map option would create a stray empty
2160
+ // 2-D axis over the WebGL scene / choropleth.
2161
+ if (showAxis &&
2162
+ !renderedIn3D.current &&
2163
+ !renderedAsRegionMap.current) {
2164
+ options.yAxis = {
2165
+ splitLine: {
2166
+ lineStyle: {
2167
+ color: isDarkMode ? "rgba(255,255,255,0.3)" : "#CCCCCC",
2168
+ },
2169
+ },
2170
+ };
2171
+ }
2172
+ chartRef.current.setOption(options);
2173
+ }
2174
+ };
2175
+ // Update chart properties
2176
+ (0, ui_1.useIsomorphicLayoutEffect)(function () {
2177
+ applyThemeOptions();
2178
+ }, [theme, title, isDarkMode, chart.spec.chartType]);
2179
+ // Draw chart. `glUpgradeTick` re-runs the draw when the lazily loaded
2180
+ // echarts-gl module resolves, upgrading a 3-D spec's immediate 2-D
2181
+ // fallback to the true 3-D rendering.
2182
+ (0, ui_1.useIsomorphicLayoutEffect)(function () {
2183
+ updateChart();
2184
+ }, [
2185
+ chart.spec,
2186
+ getDomainValuesFromRange,
2187
+ getSeriesValuesFromRange,
2188
+ glUpgradeTick,
2189
+ ]);
2190
+ // Resize chart
2191
+ (0, ui_1.useIsomorphicLayoutEffect)(function () {
2192
+ resizeChart();
2193
+ }, [
2194
+ chart.position.overlayPosition.widthPixels,
2195
+ chart.position.overlayPosition.heightPixels,
2196
+ ]);
2197
+ // Chrome bug
2198
+ (0, ui_1.useOnVisibilityChange)(function (state) {
2199
+ return state === "visible" ? resizeChart() : null;
2200
+ });
2201
+ (0, ui_1.useIsomorphicLayoutEffect)(function () {
2202
+ var _a;
2203
+ (_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.resize({ silent: true });
2204
+ }, [width, height]);
2205
+ var onDownloadChart = function () {
2206
+ var _a;
2207
+ if (chartRef.current) {
2208
+ var url = chartRef.current.getDataURL({
2209
+ type: "png",
2210
+ backgroundColor: (0, spreadsheet_1.getStringifiedColor)({ theme: 0, tint: isDarkMode ? -1 : 1 }, theme),
2211
+ });
2212
+ (0, toolkit_1.createDownloadableFile)((_a = chart.spec.title) !== null && _a !== void 0 ? _a : "Chart", url);
2213
+ }
2214
+ };
2215
+ // Excel's "Rounded Corners" chart style (`<c:roundedCorners val="1"/>`
2216
+ // at the chartSpace root). Default per OOXML §21.2.2.183 is square,
2217
+ // so only opt in when the workbook explicitly set the flag — otherwise
2218
+ // every imported chart would silently gain a radius.
2219
+ var roundedCornersStyle = spec.roundedCorners
2220
+ ? { borderRadius: 8, overflow: "hidden" }
2221
+ : undefined;
2222
+ return (react_1.default.createElement("div", { className: "flex flex-1", style: roundedCornersStyle },
2223
+ isSelected ? (react_1.default.createElement(ui_1.DropdownMenu, null,
2224
+ react_1.default.createElement(ui_1.DropdownMenuTrigger, { asChild: true },
2225
+ react_1.default.createElement(ui_1.IconButton, { className: "absolute right-1 top-1 z-10" },
2226
+ react_1.default.createElement(icons_1.DotsVerticalIcon, null))),
2227
+ react_1.default.createElement(ui_1.DropdownMenuPortal, null,
2228
+ react_1.default.createElement(ui_1.DropdownMenuContent, { align: "start", onCloseAutoFocus: function (event) {
2229
+ event.preventDefault();
2230
+ if (shouldFocusSheetRef.current) {
2231
+ focusSheet === null || focusSheet === void 0 ? void 0 : focusSheet();
2232
+ }
2233
+ }, onInteractOutside: function () {
2234
+ shouldFocusSheetRef.current = false;
2235
+ } },
2236
+ readonly ? null : (react_1.default.createElement(ui_1.DropdownMenuItem, { onClick: function () { return onRequestEdit === null || onRequestEdit === void 0 ? void 0 : onRequestEdit(chart); } }, "Edit chart")),
2237
+ readonly ? null : (react_1.default.createElement(ui_1.DropdownMenuItem, { onClick: function () {
2238
+ shouldFocusSheetRef.current = true;
2239
+ onDeleteChart === null || onDeleteChart === void 0 ? void 0 : onDeleteChart(chart.chartId);
2240
+ } }, "Delete chart")),
2241
+ react_1.default.createElement(ui_1.DropdownMenuSub, null,
2242
+ react_1.default.createElement(ui_1.DropdownMenuSubTrigger, null,
2243
+ "Download chart",
2244
+ react_1.default.createElement(ui_1.DropdownRightSlot, null,
2245
+ react_1.default.createElement(icons_1.ChevronRightIcon, null))),
2246
+ react_1.default.createElement(ui_1.DropdownMenuSubContent, null,
2247
+ react_1.default.createElement(ui_1.DropdownMenuItem, { onClick: function () { return onDownloadChart === null || onDownloadChart === void 0 ? void 0 : onDownloadChart(); } }, "PNG Image (.png)"))))))) : null,
2248
+ react_1.default.createElement("div", { className: "flex-1", ref: el })));
2249
+ };
2250
+ exports.BasicChart = BasicChart;