@rowsncolumns/charts 28.0.0 → 28.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/cjs/atoms/pivot-chart.atom.d.ts +14 -0
  2. package/dist/cjs/atoms/pivot-chart.atom.d.ts.map +1 -0
  3. package/dist/cjs/atoms/pivot-chart.atom.js +9 -0
  4. package/dist/cjs/basic-chart/basic-chart.d.ts +1 -1
  5. package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
  6. package/dist/cjs/basic-chart/basic-chart.js +863 -371
  7. package/dist/cjs/components/dialogs/pivot-chart-dialog.d.ts +39 -0
  8. package/dist/cjs/components/dialogs/pivot-chart-dialog.d.ts.map +1 -0
  9. package/dist/cjs/components/dialogs/pivot-chart-dialog.js +100 -0
  10. package/dist/cjs/components/editors/chart-editor.d.ts +13 -1
  11. package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -1
  12. package/dist/cjs/components/editors/chart-editor.js +225 -59
  13. package/dist/cjs/config.d.ts.map +1 -1
  14. package/dist/cjs/config.js +149 -12
  15. package/dist/cjs/hooks/use-charts.d.ts +21 -6
  16. package/dist/cjs/hooks/use-charts.d.ts.map +1 -1
  17. package/dist/cjs/hooks/use-charts.js +13 -1
  18. package/dist/cjs/hooks/use-on-create-chart.d.ts.map +1 -1
  19. package/dist/cjs/hooks/use-on-create-chart.js +7 -1
  20. package/dist/cjs/hooks/use-on-move-chart-to-sheet.d.ts +12 -0
  21. package/dist/cjs/hooks/use-on-move-chart-to-sheet.d.ts.map +1 -0
  22. package/dist/cjs/hooks/use-on-move-chart-to-sheet.js +26 -0
  23. package/dist/cjs/hooks/use-on-move-chart.d.ts +1 -1
  24. package/dist/cjs/hooks/use-on-move-chart.d.ts.map +1 -1
  25. package/dist/cjs/hooks/use-on-move-chart.js +2 -2
  26. package/dist/cjs/hooks/use-on-resize-chart.d.ts +1 -1
  27. package/dist/cjs/hooks/use-on-resize-chart.d.ts.map +1 -1
  28. package/dist/cjs/hooks/use-on-resize-chart.js +2 -2
  29. package/dist/cjs/index.d.ts +11 -0
  30. package/dist/cjs/index.d.ts.map +1 -1
  31. package/dist/cjs/index.js +34 -1
  32. package/dist/cjs/interface/create-chart.d.ts.map +1 -1
  33. package/dist/cjs/interface/create-chart.js +33 -42
  34. package/dist/cjs/interface/delete-chart.d.ts.map +1 -1
  35. package/dist/cjs/interface/delete-chart.js +4 -0
  36. package/dist/cjs/interface/move-chart-to-sheet.d.ts +13 -0
  37. package/dist/cjs/interface/move-chart-to-sheet.d.ts.map +1 -0
  38. package/dist/cjs/interface/move-chart-to-sheet.js +136 -0
  39. package/dist/cjs/interface/move-chart.d.ts +2 -2
  40. package/dist/cjs/interface/move-chart.d.ts.map +1 -1
  41. package/dist/cjs/interface/move-chart.js +7 -1
  42. package/dist/cjs/interface/resize-chart.d.ts +2 -2
  43. package/dist/cjs/interface/resize-chart.d.ts.map +1 -1
  44. package/dist/cjs/interface/resize-chart.js +7 -1
  45. package/dist/cjs/interface/update-chart.d.ts.map +1 -1
  46. package/dist/cjs/interface/update-chart.js +4 -0
  47. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts +1 -1
  48. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  49. package/dist/cjs/plotly/basic-chart/basic-chart.js +970 -585
  50. package/dist/cjs/plotly/basic-chart/helpers.d.ts.map +1 -1
  51. package/dist/cjs/plotly/basic-chart/helpers.js +3 -0
  52. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  53. package/dist/cjs/types.d.ts +7 -0
  54. package/dist/cjs/types.d.ts.map +1 -1
  55. package/dist/cjs/utils/axis-number-format.d.ts +69 -0
  56. package/dist/cjs/utils/axis-number-format.d.ts.map +1 -0
  57. package/dist/cjs/utils/axis-number-format.js +217 -0
  58. package/dist/cjs/utils/category-levels.d.ts +27 -0
  59. package/dist/cjs/utils/category-levels.d.ts.map +1 -0
  60. package/dist/cjs/utils/category-levels.js +80 -0
  61. package/dist/cjs/utils/chart-image.d.ts +8 -0
  62. package/dist/cjs/utils/chart-image.d.ts.map +1 -0
  63. package/dist/cjs/utils/chart-image.js +28 -0
  64. package/dist/cjs/utils/chart-orientation.d.ts +67 -0
  65. package/dist/cjs/utils/chart-orientation.d.ts.map +1 -0
  66. package/dist/cjs/utils/chart-orientation.js +265 -0
  67. package/dist/cjs/utils/chart-spec-utils.d.ts +3 -0
  68. package/dist/cjs/utils/chart-spec-utils.d.ts.map +1 -1
  69. package/dist/cjs/utils/chart-spec-utils.js +12 -4
  70. package/dist/cjs/utils/chart-styles.d.ts +75 -0
  71. package/dist/cjs/utils/chart-styles.d.ts.map +1 -0
  72. package/dist/cjs/utils/chart-styles.js +283 -0
  73. package/dist/cjs/utils/empty-cells.d.ts +30 -0
  74. package/dist/cjs/utils/empty-cells.d.ts.map +1 -0
  75. package/dist/cjs/utils/empty-cells.js +91 -0
  76. package/dist/cjs/utils/overrides.d.ts +6 -1
  77. package/dist/cjs/utils/overrides.d.ts.map +1 -1
  78. package/dist/cjs/utils/overrides.js +19 -7
  79. package/dist/cjs/utils/pie-explosion.d.ts +30 -0
  80. package/dist/cjs/utils/pie-explosion.d.ts.map +1 -0
  81. package/dist/cjs/utils/pie-explosion.js +55 -0
  82. package/dist/cjs/utils/plotly-click.d.ts +34 -0
  83. package/dist/cjs/utils/plotly-click.d.ts.map +1 -0
  84. package/dist/cjs/utils/plotly-click.js +49 -0
  85. package/dist/cjs/utils/plotly-surface.d.ts +14 -0
  86. package/dist/cjs/utils/plotly-surface.d.ts.map +1 -0
  87. package/dist/cjs/utils/plotly-surface.js +64 -0
  88. package/dist/cjs/utils/plotly-title.d.ts +12 -0
  89. package/dist/cjs/utils/plotly-title.d.ts.map +1 -0
  90. package/dist/cjs/utils/plotly-title.js +24 -0
  91. package/dist/cjs/utils/series-click.d.ts +39 -0
  92. package/dist/cjs/utils/series-click.d.ts.map +1 -0
  93. package/dist/cjs/utils/series-click.js +75 -0
  94. package/dist/cjs/utils/three-d.d.ts +17 -1
  95. package/dist/cjs/utils/three-d.d.ts.map +1 -1
  96. package/dist/cjs/utils/three-d.js +32 -4
  97. package/dist/esm/atoms/pivot-chart.atom.d.ts +14 -0
  98. package/dist/esm/atoms/pivot-chart.atom.d.ts.map +1 -0
  99. package/dist/esm/atoms/pivot-chart.atom.js +4 -0
  100. package/dist/esm/basic-chart/basic-chart.d.ts +1 -1
  101. package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
  102. package/dist/esm/basic-chart/basic-chart.js +680 -178
  103. package/dist/esm/components/dialogs/pivot-chart-dialog.d.ts +39 -0
  104. package/dist/esm/components/dialogs/pivot-chart-dialog.d.ts.map +1 -0
  105. package/dist/esm/components/dialogs/pivot-chart-dialog.js +89 -0
  106. package/dist/esm/components/editors/chart-editor.d.ts +13 -1
  107. package/dist/esm/components/editors/chart-editor.d.ts.map +1 -1
  108. package/dist/esm/components/editors/chart-editor.js +164 -20
  109. package/dist/esm/config.d.ts.map +1 -1
  110. package/dist/esm/config.js +149 -12
  111. package/dist/esm/hooks/use-charts.d.ts +21 -6
  112. package/dist/esm/hooks/use-charts.d.ts.map +1 -1
  113. package/dist/esm/hooks/use-charts.js +13 -1
  114. package/dist/esm/hooks/use-on-create-chart.d.ts.map +1 -1
  115. package/dist/esm/hooks/use-on-create-chart.js +7 -1
  116. package/dist/esm/hooks/use-on-move-chart-to-sheet.d.ts +12 -0
  117. package/dist/esm/hooks/use-on-move-chart-to-sheet.d.ts.map +1 -0
  118. package/dist/esm/hooks/use-on-move-chart-to-sheet.js +19 -0
  119. package/dist/esm/hooks/use-on-move-chart.d.ts +1 -1
  120. package/dist/esm/hooks/use-on-move-chart.d.ts.map +1 -1
  121. package/dist/esm/hooks/use-on-move-chart.js +2 -2
  122. package/dist/esm/hooks/use-on-resize-chart.d.ts +1 -1
  123. package/dist/esm/hooks/use-on-resize-chart.d.ts.map +1 -1
  124. package/dist/esm/hooks/use-on-resize-chart.js +2 -2
  125. package/dist/esm/index.d.ts +11 -0
  126. package/dist/esm/index.d.ts.map +1 -1
  127. package/dist/esm/index.js +14 -0
  128. package/dist/esm/interface/create-chart.d.ts.map +1 -1
  129. package/dist/esm/interface/create-chart.js +36 -58
  130. package/dist/esm/interface/delete-chart.d.ts.map +1 -1
  131. package/dist/esm/interface/delete-chart.js +4 -0
  132. package/dist/esm/interface/move-chart-to-sheet.d.ts +13 -0
  133. package/dist/esm/interface/move-chart-to-sheet.d.ts.map +1 -0
  134. package/dist/esm/interface/move-chart-to-sheet.js +126 -0
  135. package/dist/esm/interface/move-chart.d.ts +2 -2
  136. package/dist/esm/interface/move-chart.d.ts.map +1 -1
  137. package/dist/esm/interface/move-chart.js +7 -1
  138. package/dist/esm/interface/resize-chart.d.ts +2 -2
  139. package/dist/esm/interface/resize-chart.d.ts.map +1 -1
  140. package/dist/esm/interface/resize-chart.js +7 -1
  141. package/dist/esm/interface/update-chart.d.ts.map +1 -1
  142. package/dist/esm/interface/update-chart.js +4 -0
  143. package/dist/esm/plotly/basic-chart/basic-chart.d.ts +1 -1
  144. package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  145. package/dist/esm/plotly/basic-chart/basic-chart.js +858 -463
  146. package/dist/esm/plotly/basic-chart/helpers.d.ts.map +1 -1
  147. package/dist/esm/plotly/basic-chart/helpers.js +3 -0
  148. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  149. package/dist/esm/types.d.ts +7 -0
  150. package/dist/esm/types.d.ts.map +1 -1
  151. package/dist/esm/utils/axis-number-format.d.ts +69 -0
  152. package/dist/esm/utils/axis-number-format.d.ts.map +1 -0
  153. package/dist/esm/utils/axis-number-format.js +170 -0
  154. package/dist/esm/utils/category-levels.d.ts +27 -0
  155. package/dist/esm/utils/category-levels.d.ts.map +1 -0
  156. package/dist/esm/utils/category-levels.js +65 -0
  157. package/dist/esm/utils/chart-image.d.ts +8 -0
  158. package/dist/esm/utils/chart-image.d.ts.map +1 -0
  159. package/dist/esm/utils/chart-image.js +24 -0
  160. package/dist/esm/utils/chart-orientation.d.ts +67 -0
  161. package/dist/esm/utils/chart-orientation.d.ts.map +1 -0
  162. package/dist/esm/utils/chart-orientation.js +234 -0
  163. package/dist/esm/utils/chart-spec-utils.d.ts +3 -0
  164. package/dist/esm/utils/chart-spec-utils.d.ts.map +1 -1
  165. package/dist/esm/utils/chart-spec-utils.js +10 -2
  166. package/dist/esm/utils/chart-styles.d.ts +75 -0
  167. package/dist/esm/utils/chart-styles.d.ts.map +1 -0
  168. package/dist/esm/utils/chart-styles.js +357 -0
  169. package/dist/esm/utils/empty-cells.d.ts +30 -0
  170. package/dist/esm/utils/empty-cells.d.ts.map +1 -0
  171. package/dist/esm/utils/empty-cells.js +67 -0
  172. package/dist/esm/utils/overrides.d.ts +6 -1
  173. package/dist/esm/utils/overrides.d.ts.map +1 -1
  174. package/dist/esm/utils/overrides.js +14 -2
  175. package/dist/esm/utils/pie-explosion.d.ts +30 -0
  176. package/dist/esm/utils/pie-explosion.d.ts.map +1 -0
  177. package/dist/esm/utils/pie-explosion.js +43 -0
  178. package/dist/esm/utils/plotly-click.d.ts +34 -0
  179. package/dist/esm/utils/plotly-click.d.ts.map +1 -0
  180. package/dist/esm/utils/plotly-click.js +44 -0
  181. package/dist/esm/utils/plotly-surface.d.ts +14 -0
  182. package/dist/esm/utils/plotly-surface.d.ts.map +1 -0
  183. package/dist/esm/utils/plotly-surface.js +45 -0
  184. package/dist/esm/utils/plotly-title.d.ts +12 -0
  185. package/dist/esm/utils/plotly-title.d.ts.map +1 -0
  186. package/dist/esm/utils/plotly-title.js +20 -0
  187. package/dist/esm/utils/series-click.d.ts +39 -0
  188. package/dist/esm/utils/series-click.d.ts.map +1 -0
  189. package/dist/esm/utils/series-click.js +66 -0
  190. package/dist/esm/utils/three-d.d.ts +17 -1
  191. package/dist/esm/utils/three-d.d.ts.map +1 -1
  192. package/dist/esm/utils/three-d.js +29 -3
  193. package/package.json +10 -6
@@ -14,12 +14,18 @@ var echarts = tslib_1.__importStar(require("echarts/core"));
14
14
  var renderers_1 = require("echarts/renderers");
15
15
  var react_1 = tslib_1.__importStar(require("react"));
16
16
  var aggregation_1 = require("../utils/aggregation");
17
+ var axis_number_format_1 = require("../utils/axis-number-format");
17
18
  var bar_layout_1 = require("../utils/bar-layout");
18
19
  var boxplot_1 = require("../utils/boxplot");
19
20
  var bubble_1 = require("../utils/bubble");
20
21
  var chart_spec_utils_1 = require("../utils/chart-spec-utils");
22
+ var chart_orientation_1 = require("../utils/chart-orientation");
23
+ var chart_image_1 = require("../utils/chart-image");
24
+ var chart_styles_1 = require("../utils/chart-styles");
25
+ var empty_cells_1 = require("../utils/empty-cells");
21
26
  var echarts_gl_loader_1 = require("../utils/echarts-gl-loader");
22
27
  var error_bars_1 = require("../utils/error-bars");
28
+ var category_levels_1 = require("../utils/category-levels");
23
29
  var gradient_1 = require("../utils/gradient");
24
30
  var hierarchy_1 = require("../utils/hierarchy");
25
31
  var histogram_1 = require("../utils/histogram");
@@ -29,6 +35,8 @@ var radar_1 = require("../utils/radar");
29
35
  var region_map_1 = require("../utils/region-map");
30
36
  var region_map_loader_1 = require("../utils/region-map-loader");
31
37
  var stock_1 = require("../utils/stock");
38
+ var pie_explosion_1 = require("../utils/pie-explosion");
39
+ var series_click_1 = require("../utils/series-click");
32
40
  var three_d_1 = require("../utils/three-d");
33
41
  var trendline_1 = require("../utils/trendline");
34
42
  var waterfall_1 = require("../utils/waterfall");
@@ -172,6 +180,8 @@ var buildHierarchyLevels = function (maxDepth) {
172
180
  }
173
181
  return levels;
174
182
  };
183
+ /** Series whose tooltip value is one number on a value axis. */
184
+ var VALUE_TOOLTIP_SERIES_TYPES = new Set(["bar", "line", "scatter", "funnel"]);
175
185
  var defaultLegendConfig = {
176
186
  padding: 10,
177
187
  itemWidth: 10,
@@ -180,7 +190,7 @@ var defaultLegendConfig = {
180
190
  };
181
191
  var BasicChart = function (_a) {
182
192
  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;
193
+ 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, getFormattingFromRange = _a.getFormattingFromRange, onDeleteChart = _a.onDeleteChart, onUpdateChart = _a.onUpdateChart, onRequestEdit = _a.onRequestEdit, onRequestCalculate = _a.onRequestCalculate, isSelected = _a.isSelected, fieldButtons = _a.fieldButtons;
184
194
  var spec = chart.spec;
185
195
  var explicitChartTitle = (_b = chart.spec.title) !== null && _b !== void 0 ? _b : undefined;
186
196
  var hierarchyTitleRef = (0, react_1.useRef)(explicitChartTitle);
@@ -188,6 +198,45 @@ var BasicChart = function (_a) {
188
198
  var el = (0, react_1.useRef)(null);
189
199
  var chartRef = (0, react_1.useRef)(undefined);
190
200
  var focusSheet = (0, spreadsheet_1.useFocusSheet)();
201
+ // Excel selects a data series when it is clicked inside the chart and
202
+ // the grid highlights that series' source range; clicking empty chart
203
+ // area steps back to the whole chart. Published for the grid to draw.
204
+ var setSelectedChartSeries = (0, spreadsheet_1.useSetSelectedChartSeries)();
205
+ var chartForClickRef = (0, react_1.useRef)(chart);
206
+ chartForClickRef.current = chart;
207
+ // An exploded pie draws every slice in echarts' `select` state (the only
208
+ // per-slice offset it has); echarts unselects a slice on click, so that
209
+ // click is folded back into a select to keep the slice out.
210
+ var explodedRef = (0, react_1.useRef)(false);
211
+ var bindSeriesSelection = function (instance) {
212
+ instance.on("click", function (params) {
213
+ var _a, _b;
214
+ var current = chartForClickRef.current;
215
+ var clickParams = params;
216
+ var seriesIndex = (0, series_click_1.resolveClickedSeriesIndex)(clickParams, (_b = (_a = current.spec.series) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);
217
+ if (seriesIndex === undefined)
218
+ return;
219
+ var dataIndex = (0, series_click_1.resolveClickedDataIndex)(clickParams);
220
+ setSelectedChartSeries(tslib_1.__assign({ chartId: current.chartId, seriesIndex: seriesIndex }, (dataIndex === undefined ? {} : { dataIndex: dataIndex })));
221
+ });
222
+ instance.on("selectchanged", function (event) {
223
+ var _a;
224
+ var _b = event, fromAction = _b.fromAction, isFromClick = _b.isFromClick, fromActionPayload = _b.fromActionPayload;
225
+ if (!explodedRef.current || !isFromClick || fromAction !== "unselect") {
226
+ return;
227
+ }
228
+ instance.dispatchAction({
229
+ type: "select",
230
+ seriesIndex: fromActionPayload === null || fromActionPayload === void 0 ? void 0 : fromActionPayload.seriesIndex,
231
+ dataIndex: (_a = fromActionPayload === null || fromActionPayload === void 0 ? void 0 : fromActionPayload.dataIndexInside) !== null && _a !== void 0 ? _a : fromActionPayload === null || fromActionPayload === void 0 ? void 0 : fromActionPayload.dataIndex,
232
+ });
233
+ });
234
+ instance.getZr().on("click", function (event) {
235
+ if (!event.target) {
236
+ setSelectedChartSeries(undefined);
237
+ }
238
+ });
239
+ };
191
240
  var shouldFocusSheetRef = (0, react_1.useRef)(false);
192
241
  var previousChartType = (0, react_1.useRef)(undefined);
193
242
  var previousSeriesCount = (0, react_1.useRef)(undefined);
@@ -201,11 +250,16 @@ var BasicChart = function (_a) {
201
250
  // visualMap) doesn't merge back into a cartesian one, so the instance
202
251
  // is re-initialized when entering/leaving the region-map rendering.
203
252
  var renderedAsRegionMap = (0, react_1.useRef)(false);
253
+ // Contour (Excel's flat Surface view) renders as a heatmap with a
254
+ // visualMap; that component doesn't merge back into a plain cartesian
255
+ // option, so the instance is re-initialized when entering/leaving it.
256
+ var renderedAsContour = (0, react_1.useRef)(false);
204
257
  // Initialize line chart
205
258
  var initializeChart = function () {
206
259
  var _a, _b;
207
260
  if (el.current && !chartRef.current) {
208
261
  chartRef.current = echarts.init(el.current);
262
+ bindSeriesSelection(chartRef.current);
209
263
  chartRef.current.setOption({
210
264
  title: {
211
265
  left: "top",
@@ -275,6 +329,16 @@ var BasicChart = function (_a) {
275
329
  }
276
330
  var numericValues = seriesValues;
277
331
  if (spec.chartType === "pie") {
332
+ if (options.pieLabels) {
333
+ var _b = options.pieLabels, domainLabels = _b.domainLabels, offset = _b.offset;
334
+ var labels = offset === undefined
335
+ ? domainLabels
336
+ : domainLabels.slice(offset, offset + numericValues.length);
337
+ return labels.map(function (name, idx) { return ({
338
+ value: numericValues[idx],
339
+ name: name,
340
+ }); });
341
+ }
278
342
  var domainSheetRange = (_a = spec.domains[0]) === null || _a === void 0 ? void 0 : _a.sources[0];
279
343
  if (!domainSheetRange) {
280
344
  return [];
@@ -285,7 +349,9 @@ var BasicChart = function (_a) {
285
349
  name: name,
286
350
  }); });
287
351
  }
288
- return numericValues;
352
+ // Excel's "Hidden and Empty Cells": gaps / zero / connect, and
353
+ // whether #N/A counts as empty.
354
+ return (0, empty_cells_1.applyEmptyCellsPolicy)(numericValues, rawSeriesValues, spec, options.lineLike);
289
355
  }, [getSeriesValuesFromRange, getDomainValuesFromRange]);
290
356
  // Resize a chart
291
357
  var resizeChart = function () {
@@ -296,11 +362,11 @@ var BasicChart = function (_a) {
296
362
  * Triggers a chart update
297
363
  */
298
364
  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) {
365
+ 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, sizeNumberFormat_1, tooltipFormatter, hierarchyDataLabels, hierarchySeriesLabel, isContour, categories_2, contourSeriesInputs, _d, _e, seriesEntry, dataLabel, _f, _g, values, e_1_1, seriesNames_1, contourPoints, _h, zMin, zMax, contourFormats_1, contourLabel, categories_3, threeDSeriesInputs, _j, _k, seriesEntry, dataLabel, _l, _m, values, e_2_1, seriesNames_2, threeDPalette_1, seriesColorAt_1, categoryAxisLabel, seriesAxisLabel, stackedBar3D_1, threeDFormats_1, threeDTooltipFormatter, threeDSeries, visualMap, xAxis3D, yAxis3D, categoryCount, categoryTotals_1, threeDSeriesInputs_1, threeDSeriesInputs_1_1, entry, isPercent_1, surfacePoints, _o, zMin, zMax, skipHeaders, categories, radarSeriesInputs, _p, _q, seriesEntry, label, values, indicators_1, radarData, radarStyle_1, radarColors_1, radarFormats_1, radarDataLabels_1, radarSeriesLabelFor_1, radarTooltipFormatter, variant_1, categories, seriesValues, stockFormats_1, stockRoleIndex_1, stockFormatFor_1, stockDataLabels_1, stockSeriesLabelFor_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, categoryLevels, pushSeriesOverlays, sideBySideBarCount, specBarGap, specBarCategoryGap, _loop_1, _r, _s, _t, specSeriesIndex, series, e_3_1, labels, seriesEntry, rawValues, _u, 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, _v, _w, seriesEntry, label, rawValues, summary, boxIndex, lo, hi, _x, _y, outlier, boxSeries, boxColor, rawValues, _z, labels, counts, isPareto_1, cumulativePercents, pareto, histogramSeries, histogramColor, renderedSeriesCount, replaceMerge, gridConfig, valueAxisBase, isPareto, hasSecondaryAxis, isPercentStackedBars, primaryAxisNumberFormat, secondaryAxisNumberFormat, axisNumberFormatFor, seriesNumberFormats, seriesNumberFormatFor, tooltipConfig, finalLegend, dataLabelOptions, seriesLabelOptionFor, isDoughnut, doughnutHoleSize, explosion, explosionOffset, barSeries, len, categoryTotals_2, barSeries_1, barSeries_1_1, s, i, raw, n, barSeries_2, barSeries_2_1, s, seriesWithLabels;
366
+ var e_1, _0, e_2, _1, e_4, _2, e_5, _3, e_3, _4, e_6, _5, e_7, _6, e_8, _7, e_9, _8;
367
+ var _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, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128;
368
+ return tslib_1.__generator(this, function (_129) {
369
+ switch (_129.label) {
304
370
  case 0:
305
371
  (0, utils_1.debug)("Updating chart", chart);
306
372
  threeDRenderKind = (0, three_d_1.resolve3DRenderKind)(spec.sourceChartType);
@@ -324,7 +390,7 @@ var BasicChart = function (_a) {
324
390
  // Leaving 3-D (spec edit) — the grid3D option doesn't merge back
325
391
  // into a cartesian one, so re-initialize from a clean slate and
326
392
  // let the normal 2-D flow below do a full structural render.
327
- (_6 = chartRef.current) === null || _6 === void 0 ? void 0 : _6.dispose();
393
+ (_9 = chartRef.current) === null || _9 === void 0 ? void 0 : _9.dispose();
328
394
  chartRef.current = undefined;
329
395
  renderedIn3D.current = false;
330
396
  previousChartType.current = undefined;
@@ -338,7 +404,7 @@ var BasicChart = function (_a) {
338
404
  // doesn't merge back into a cartesian one, so re-initialize from
339
405
  // a clean slate and let the normal flow below do a full
340
406
  // structural render.
341
- (_7 = chartRef.current) === null || _7 === void 0 ? void 0 : _7.dispose();
407
+ (_10 = chartRef.current) === null || _10 === void 0 ? void 0 : _10.dispose();
342
408
  chartRef.current = undefined;
343
409
  renderedAsRegionMap.current = false;
344
410
  previousChartType.current = undefined;
@@ -351,7 +417,7 @@ var BasicChart = function (_a) {
351
417
  geoScope = (0, region_map_1.resolveGeoScope)(regionSpec.geoScope);
352
418
  return [4 /*yield*/, (0, region_map_loader_1.loadRegionMapGeo)(geoScope)];
353
419
  case 1:
354
- geo = _104.sent();
420
+ geo = _129.sent();
355
421
  // Entering the region map from a cartesian render: the previous
356
422
  // grid/axis option doesn't merge into the map one, so start from
357
423
  // a bare instance (theme options are re-applied after setOption).
@@ -361,11 +427,12 @@ var BasicChart = function (_a) {
361
427
  }
362
428
  if (el.current && !chartRef.current) {
363
429
  chartRef.current = echarts.init(el.current);
430
+ bindSeriesSelection(chartRef.current);
364
431
  }
365
432
  if (!geo) {
366
433
  // Map asset failed to load (or unknown scope) — the loader
367
434
  // 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"] });
435
+ (_11 = chartRef.current) === null || _11 === void 0 ? void 0 : _11.setOption({ series: [] }, { replaceMerge: ["series", "visualMap"] });
369
436
  renderedAsRegionMap.current = true;
370
437
  applyThemeOptions();
371
438
  previousChartType.current = spec.chartType;
@@ -373,7 +440,7 @@ var BasicChart = function (_a) {
373
440
  return [2 /*return*/];
374
441
  }
375
442
  labels = flattenChartDataValues(regionSpec.domains, getDomainValuesFromRange, regionSpec.hiddenDimensionStrategy, false);
376
- seriesEntry = (_9 = regionSpec.series) === null || _9 === void 0 ? void 0 : _9[0];
443
+ seriesEntry = (_12 = regionSpec.series) === null || _12 === void 0 ? void 0 : _12[0];
377
444
  values = seriesEntry
378
445
  ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, regionSpec.hiddenDimensionStrategy)
379
446
  : [];
@@ -389,7 +456,7 @@ var BasicChart = function (_a) {
389
456
  seriesName = (seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) && !(0, utils_1.isAFormula)(seriesEntry.dataLabel)
390
457
  ? seriesEntry.dataLabel
391
458
  : "";
392
- (_10 = chartRef.current) === null || _10 === void 0 ? void 0 : _10.setOption({
459
+ (_13 = chartRef.current) === null || _13 === void 0 ? void 0 : _13.setOption({
393
460
  // The visualMap color scale is the value legend; the series
394
461
  // legend stays hidden unless an authored override turns it on.
395
462
  legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { show: false }), spec.legend),
@@ -457,36 +524,36 @@ var BasicChart = function (_a) {
457
524
  hierarchyTitleRef.current = explicitChartTitle;
458
525
  skipHeaders_1 = spec.useFirstRowAsHeaders !== false;
459
526
  labelValues = flattenChartDataValues(spec.bubbleLabels, getDomainValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders_1);
460
- perSeriesX = ((_11 = spec.domains) !== null && _11 !== void 0 ? _11 : []).map(function (dom) {
527
+ perSeriesX = ((_14 = spec.domains) !== null && _14 !== void 0 ? _14 : []).map(function (dom) {
461
528
  return flattenChartDataValues([dom], getSeriesValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders_1);
462
529
  });
463
- perSeriesSize = ((_12 = spec.bubbleSizes) !== null && _12 !== void 0 ? _12 : []).map(function (sz) {
530
+ perSeriesSize = ((_15 = spec.bubbleSizes) !== null && _15 !== void 0 ? _15 : []).map(function (sz) {
464
531
  return flattenChartDataValues([sz], getSeriesValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders_1);
465
532
  });
466
533
  seriesInputs = [];
467
534
  i = 0;
468
- _104.label = 3;
535
+ _129.label = 3;
469
536
  case 3:
470
537
  if (!(i < spec.series.length)) return [3 /*break*/, 7];
471
538
  seriesEntry = spec.series[i];
472
- resolvedLabel = (_13 = seriesEntry.dataLabel) !== null && _13 !== void 0 ? _13 : "";
539
+ resolvedLabel = (_16 = seriesEntry.dataLabel) !== null && _16 !== void 0 ? _16 : "";
473
540
  if (!(resolvedLabel && (0, utils_1.isAFormula)(resolvedLabel))) return [3 /*break*/, 5];
474
541
  _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)];
542
+ return [4 /*yield*/, onRequestCalculate(resolvedLabel, (_17 = position.sheetId) !== null && _17 !== void 0 ? _17 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
476
543
  case 4:
477
- resolvedLabel = _b.apply(void 0, [_104.sent()]);
478
- _104.label = 5;
544
+ resolvedLabel = _b.apply(void 0, [_129.sent()]);
545
+ _129.label = 5;
479
546
  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];
547
+ xValues = (_18 = perSeriesX[i]) !== null && _18 !== void 0 ? _18 : perSeriesX[0];
548
+ sizeValues_1 = (_19 = perSeriesSize[i]) !== null && _19 !== void 0 ? _19 : perSeriesSize[0];
482
549
  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;
550
+ _129.label = 6;
484
551
  case 6:
485
552
  i++;
486
553
  return [3 /*break*/, 3];
487
554
  case 7:
488
- sharedXValues = (_17 = perSeriesX[0]) !== null && _17 !== void 0 ? _17 : [];
489
- sharedSizeValues = (_18 = perSeriesSize[0]) !== null && _18 !== void 0 ? _18 : [];
555
+ sharedXValues = (_20 = perSeriesX[0]) !== null && _20 !== void 0 ? _20 : [];
556
+ sharedSizeValues = (_21 = perSeriesSize[0]) !== null && _21 !== void 0 ? _21 : [];
490
557
  _c = (0, bubble_1.prepareBubbleSeriesData)({
491
558
  xValues: sharedXValues,
492
559
  labelValues: labelValues,
@@ -498,13 +565,13 @@ var BasicChart = function (_a) {
498
565
  ? {
499
566
  type: "category",
500
567
  data: categories_1,
501
- name: (_19 = spec.horizontalAxisTitle) !== null && _19 !== void 0 ? _19 : "",
568
+ name: (_22 = spec.horizontalAxisTitle) !== null && _22 !== void 0 ? _22 : "",
502
569
  nameLocation: "middle",
503
570
  nameGap: 30,
504
571
  }
505
572
  : {
506
573
  type: "value",
507
- name: (_20 = spec.horizontalAxisTitle) !== null && _20 !== void 0 ? _20 : "",
574
+ name: (_23 = spec.horizontalAxisTitle) !== null && _23 !== void 0 ? _23 : "",
508
575
  nameLocation: "middle",
509
576
  nameGap: 30,
510
577
  };
@@ -519,14 +586,14 @@ var BasicChart = function (_a) {
519
586
  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
587
  };
521
588
  bubbleSeriesLabel_1 = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
522
- (_21 = chartRef.current) === null || _21 === void 0 ? void 0 : _21.setOption({
589
+ (_24 = chartRef.current) === null || _24 === void 0 ? void 0 : _24.setOption({
523
590
  xAxis: [
524
591
  (0, overrides_1.applyAxisOverrides)(tslib_1.__assign({}, xAxisConfig), spec.categoryAxisOptions),
525
592
  ],
526
593
  yAxis: [
527
594
  (0, overrides_1.applyAxisOverrides)({
528
595
  type: "value",
529
- name: (_22 = spec.verticalAxisTitle) !== null && _22 !== void 0 ? _22 : "",
596
+ name: (_25 = spec.verticalAxisTitle) !== null && _25 !== void 0 ? _25 : "",
530
597
  nameLocation: "middle",
531
598
  nameGap: 45,
532
599
  }, spec.valueAxisOptions),
@@ -613,19 +680,22 @@ var BasicChart = function (_a) {
613
680
  });
614
681
  hierarchyTitleRef.current = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle;
615
682
  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 : "";
683
+ rootName = hierarchyData.length === 1 ? (_27 = (_26 = hierarchyData[0]) === null || _26 === void 0 ? void 0 : _26.name) !== null && _27 !== void 0 ? _27 : "" : "";
684
+ seriesDisplayName = (_29 = (_28 = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle) !== null && _28 !== void 0 ? _28 : rootName) !== null && _29 !== void 0 ? _29 : "";
618
685
  hierarchyDepth = getHierarchyDepth(hierarchyData);
619
686
  levels = buildHierarchyLevels(hierarchyDepth);
687
+ sizeNumberFormat_1 = (0, axis_number_format_1.resolveSourceNumberFormat)((_31 = (_30 = spec.sizeData) === null || _30 === void 0 ? void 0 : _30[0]) === null || _31 === void 0 ? void 0 : _31.sources, getFormattingFromRange, spec.hiddenDimensionStrategy);
620
688
  tooltipFormatter = function (params) {
621
689
  var _a;
622
690
  var value = Array.isArray(params.value)
623
691
  ? params.value[params.value.length - 1]
624
692
  : (_a = params.value) !== null && _a !== void 0 ? _a : "";
625
- return "".concat(params.name, ": ").concat(value);
693
+ return "".concat(params.name, ": ").concat((0, axis_number_format_1.formatAxisValue)(sizeNumberFormat_1, value));
626
694
  };
627
- hierarchySeriesLabel = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
628
- (_27 = chartRef.current) === null || _27 === void 0 ? void 0 : _27.setOption({
695
+ hierarchyDataLabels = spec.dataLabels;
696
+ hierarchySeriesLabel = (0, overrides_1.buildSeriesLabelOption)(hierarchyDataLabels && !hierarchyDataLabels.numberFormatPattern
697
+ ? tslib_1.__assign(tslib_1.__assign({}, hierarchyDataLabels), { numberFormatPattern: sizeNumberFormat_1 }) : hierarchyDataLabels);
698
+ (_32 = chartRef.current) === null || _32 === void 0 ? void 0 : _32.setOption({
629
699
  xAxis: [
630
700
  {
631
701
  type: "category",
@@ -687,55 +757,200 @@ var BasicChart = function (_a) {
687
757
  (0, utils_1.debug)("Unsupported chart type", spec.chartType);
688
758
  return [2 /*return*/];
689
759
  }
690
- if (!(willRender3D && threeDRenderKind)) return [3 /*break*/, 19];
760
+ isContour = (0, three_d_1.isContourSpec)(spec);
761
+ if (renderedAsContour.current && !isContour) {
762
+ (_33 = chartRef.current) === null || _33 === void 0 ? void 0 : _33.dispose();
763
+ chartRef.current = undefined;
764
+ renderedAsContour.current = false;
765
+ previousChartType.current = undefined;
766
+ previousSeriesCount.current = undefined;
767
+ initializeChart();
768
+ applyThemeOptions();
769
+ }
770
+ if (!isContour) return [3 /*break*/, 19];
691
771
  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;
772
+ contourSeriesInputs = [];
773
+ _129.label = 9;
694
774
  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;
775
+ _129.trys.push([9, 16, 17, 18]);
776
+ _d = tslib_1.__values((_34 = spec.series) !== null && _34 !== void 0 ? _34 : []), _e = _d.next();
777
+ _129.label = 10;
698
778
  case 10:
699
779
  if (!!_e.done) return [3 /*break*/, 15];
700
780
  seriesEntry = _e.value;
701
781
  if (!(!(0, utils_1.isNil)(seriesEntry.dataLabel) && (0, utils_1.isAFormula)(seriesEntry.dataLabel))) return [3 /*break*/, 12];
702
782
  _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)];
783
+ return [4 /*yield*/, onRequestCalculate(seriesEntry.dataLabel, (_35 = position.sheetId) !== null && _35 !== void 0 ? _35 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
704
784
  case 11:
705
- _f = _g.apply(void 0, [_104.sent()]);
785
+ _f = _g.apply(void 0, [_129.sent()]);
706
786
  return [3 /*break*/, 13];
707
787
  case 12:
708
- _f = (_30 = seriesEntry.dataLabel) !== null && _30 !== void 0 ? _30 : "";
709
- _104.label = 13;
788
+ _f = (_36 = seriesEntry.dataLabel) !== null && _36 !== void 0 ? _36 : "";
789
+ _129.label = 13;
710
790
  case 13:
711
791
  dataLabel = _f;
712
792
  values = flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(sanitizeChartValue);
713
- threeDSeriesInputs.push({ name: dataLabel, values: values });
714
- _104.label = 14;
793
+ contourSeriesInputs.push({ name: dataLabel, values: values });
794
+ _129.label = 14;
715
795
  case 14:
716
796
  _e = _d.next();
717
797
  return [3 /*break*/, 10];
718
798
  case 15: return [3 /*break*/, 18];
719
799
  case 16:
720
- e_1_1 = _104.sent();
800
+ e_1_1 = _129.sent();
721
801
  e_1 = { error: e_1_1 };
722
802
  return [3 /*break*/, 18];
723
803
  case 17:
724
804
  try {
725
- if (_e && !_e.done && (_y = _d.return)) _y.call(_d);
805
+ if (_e && !_e.done && (_0 = _d.return)) _0.call(_d);
726
806
  }
727
807
  finally { if (e_1) throw e_1.error; }
728
808
  return [7 /*endfinally*/];
729
809
  case 18:
730
- seriesNames_1 = threeDSeriesInputs.map(function (entry, index) { return entry.name || "Series ".concat(index + 1); });
731
- threeDPalette_1 = [
810
+ seriesNames_1 = contourSeriesInputs.map(function (entry, index) { return entry.name || "Series ".concat(index + 1); });
811
+ contourPoints = (0, three_d_1.buildContourData)(contourSeriesInputs);
812
+ _h = tslib_1.__read((0, three_d_1.getValueExtent)(contourPoints.filter(function (point) {
813
+ return typeof point[2] === "number";
814
+ })), 2), zMin = _h[0], zMax = _h[1];
815
+ contourFormats_1 = (0, axis_number_format_1.resolveSeriesNumberFormats)(spec.series, getFormattingFromRange, spec.hiddenDimensionStrategy);
816
+ contourLabel = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
817
+ if (!renderedAsContour.current && chartRef.current) {
818
+ chartRef.current.dispose();
819
+ chartRef.current = undefined;
820
+ }
821
+ if (el.current && !chartRef.current) {
822
+ chartRef.current = echarts.init(el.current);
823
+ bindSeriesSelection(chartRef.current);
824
+ }
825
+ (_37 = chartRef.current) === null || _37 === void 0 ? void 0 : _37.setOption({
826
+ tooltip: {
827
+ textStyle: { fontSize: 12 },
828
+ trigger: "item",
829
+ formatter: function (params) {
830
+ var _a, _b, _c;
831
+ var _d = tslib_1.__read(((_a = params === null || params === void 0 ? void 0 : params.value) !== null && _a !== void 0 ? _a : []), 3), x = _d[0], y = _d[1], z = _d[2];
832
+ var value = z === "-" || z === undefined
833
+ ? ""
834
+ : (0, axis_number_format_1.formatAxisValue)(contourFormats_1[y], z);
835
+ return "".concat((_b = seriesNames_1[y]) !== null && _b !== void 0 ? _b : "", "<br/>").concat((_c = categories_2[x]) !== null && _c !== void 0 ? _c : "", ": ").concat(value);
836
+ },
837
+ },
838
+ legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { show: false }), spec.legend),
839
+ grid: { left: "3%", right: "12%", bottom: "3%", containLabel: true },
840
+ xAxis: [
841
+ (0, overrides_1.applyAxisOverrides)({
842
+ type: "category",
843
+ data: categories_2,
844
+ splitArea: { show: true },
845
+ name: (_38 = spec.horizontalAxisTitle) !== null && _38 !== void 0 ? _38 : "",
846
+ nameLocation: "middle",
847
+ nameGap: 30,
848
+ }, spec.categoryAxisOptions),
849
+ ],
850
+ yAxis: [
851
+ {
852
+ type: "category",
853
+ data: seriesNames_1,
854
+ splitArea: { show: true },
855
+ name: (_39 = spec.verticalAxisTitle) !== null && _39 !== void 0 ? _39 : "",
856
+ nameLocation: "middle",
857
+ nameGap: 50,
858
+ },
859
+ ],
860
+ visualMap: [
861
+ {
862
+ type: "continuous",
863
+ min: zMin,
864
+ max: zMax,
865
+ calculable: false,
866
+ orient: "vertical",
867
+ right: 0,
868
+ top: "center",
869
+ inRange: { color: tslib_1.__spreadArray([], tslib_1.__read(three_d_1.SURFACE_COLOR_RAMP), false) },
870
+ formatter: function (value) {
871
+ return (0, axis_number_format_1.formatAxisValue)(contourFormats_1[0], value);
872
+ },
873
+ },
874
+ ],
875
+ series: [
876
+ tslib_1.__assign({ type: "heatmap", id: (0, series_click_1.chartSeriesId)(0, 0), data: contourPoints }, (contourLabel
877
+ ? {
878
+ label: tslib_1.__assign(tslib_1.__assign({}, contourLabel), { position: "inside", formatter: function (params) {
879
+ var _a;
880
+ var _b = tslib_1.__read(((_a = params === null || params === void 0 ? void 0 : params.value) !== null && _a !== void 0 ? _a : []), 3), y = _b[1], z = _b[2];
881
+ return z === "-" || z === undefined
882
+ ? ""
883
+ : (0, axis_number_format_1.formatAxisValue)(contourFormats_1[y], z);
884
+ } }),
885
+ }
886
+ : {})),
887
+ ],
888
+ }, {
889
+ replaceMerge: [
890
+ "series",
891
+ "xAxis",
892
+ "yAxis",
893
+ "visualMap",
894
+ "legend",
895
+ "grid",
896
+ "tooltip",
897
+ ],
898
+ });
899
+ renderedAsContour.current = true;
900
+ applyThemeOptions();
901
+ previousChartType.current = spec.chartType;
902
+ previousSeriesCount.current = 1;
903
+ return [2 /*return*/];
904
+ case 19:
905
+ if (!(willRender3D && threeDRenderKind)) return [3 /*break*/, 30];
906
+ categories_3 = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
907
+ threeDSeriesInputs = [];
908
+ _129.label = 20;
909
+ case 20:
910
+ _129.trys.push([20, 27, 28, 29]);
911
+ _j = tslib_1.__values((_40 = spec.series) !== null && _40 !== void 0 ? _40 : []), _k = _j.next();
912
+ _129.label = 21;
913
+ case 21:
914
+ if (!!_k.done) return [3 /*break*/, 26];
915
+ seriesEntry = _k.value;
916
+ if (!(!(0, utils_1.isNil)(seriesEntry.dataLabel) && (0, utils_1.isAFormula)(seriesEntry.dataLabel))) return [3 /*break*/, 23];
917
+ _m = chart_spec_utils_1.coerceCalculatedLabel;
918
+ return [4 /*yield*/, onRequestCalculate(seriesEntry.dataLabel, (_41 = position.sheetId) !== null && _41 !== void 0 ? _41 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
919
+ case 22:
920
+ _l = _m.apply(void 0, [_129.sent()]);
921
+ return [3 /*break*/, 24];
922
+ case 23:
923
+ _l = (_42 = seriesEntry.dataLabel) !== null && _42 !== void 0 ? _42 : "";
924
+ _129.label = 24;
925
+ case 24:
926
+ dataLabel = _l;
927
+ values = flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(sanitizeChartValue);
928
+ threeDSeriesInputs.push({ name: dataLabel, values: values });
929
+ _129.label = 25;
930
+ case 25:
931
+ _k = _j.next();
932
+ return [3 /*break*/, 21];
933
+ case 26: return [3 /*break*/, 29];
934
+ case 27:
935
+ e_2_1 = _129.sent();
936
+ e_2 = { error: e_2_1 };
937
+ return [3 /*break*/, 29];
938
+ case 28:
939
+ try {
940
+ if (_k && !_k.done && (_1 = _j.return)) _1.call(_j);
941
+ }
942
+ finally { if (e_2) throw e_2.error; }
943
+ return [7 /*endfinally*/];
944
+ case 29:
945
+ seriesNames_2 = threeDSeriesInputs.map(function (entry, index) { return entry.name || "Series ".concat(index + 1); });
946
+ threeDPalette_1 = (0, chart_styles_1.getChartPalette)(spec, [
732
947
  theme.themeColors.accent1,
733
948
  theme.themeColors.accent2,
734
949
  theme.themeColors.accent3,
735
950
  theme.themeColors.accent4,
736
951
  theme.themeColors.accent5,
737
952
  theme.themeColors.accent6,
738
- ];
953
+ ]);
739
954
  seriesColorAt_1 = function (index) {
740
955
  var _a, _b, _c;
741
956
  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];
@@ -749,23 +964,77 @@ var BasicChart = function (_a) {
749
964
  }
750
965
  if (el.current && !chartRef.current) {
751
966
  chartRef.current = echarts.init(el.current);
967
+ bindSeriesSelection(chartRef.current);
752
968
  }
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 : "" : ""; };
969
+ categoryAxisLabel = function (value) { var _a; return Number.isInteger(value) ? (_a = categories_3[value]) !== null && _a !== void 0 ? _a : "" : ""; };
970
+ seriesAxisLabel = function (value) { var _a; return Number.isInteger(value) ? (_a = seriesNames_2[value]) !== null && _a !== void 0 ? _a : "" : ""; };
971
+ stackedBar3D_1 = threeDRenderKind === "bar3D" &&
972
+ (spec.stackedType === "STACKED" ||
973
+ spec.stackedType === "PERCENT_STACKED");
974
+ threeDFormats_1 = (0, axis_number_format_1.resolveSeriesNumberFormats)(spec.series, getFormattingFromRange, spec.hiddenDimensionStrategy);
755
975
  threeDTooltipFormatter = function (params) {
756
- var _a, _b, _c, _d, _e, _f, _g, _h;
976
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
757
977
  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 : "");
978
+ var categoryLabel = (_c = categories_3[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 : "");
979
+ // Stacked bars and line3D are one echarts series per spec series;
980
+ // a single bar3D / surface series carries the spec index on y.
981
+ var seriesIndex = stackedBar3D_1 || threeDRenderKind === "line3D"
982
+ ? params === null || params === void 0 ? void 0 : params.seriesIndex
983
+ : Math.round((_e = value[1]) !== null && _e !== void 0 ? _e : 0);
984
+ var seriesLabel = stackedBar3D_1
985
+ ? (_f = params === null || params === void 0 ? void 0 : params.seriesName) !== null && _f !== void 0 ? _f : ""
986
+ : (_j = (_h = seriesNames_2[Math.round((_g = value[1]) !== null && _g !== void 0 ? _g : 0)]) !== null && _h !== void 0 ? _h : params === null || params === void 0 ? void 0 : params.seriesName) !== null && _j !== void 0 ? _j : "";
987
+ var valueLabel = spec.stackedType === "PERCENT_STACKED" && stackedBar3D_1
988
+ ? "".concat(Math.round(((_k = value[2]) !== null && _k !== void 0 ? _k : 0) * 10) / 10, "%")
989
+ : (0, axis_number_format_1.formatAxisValue)(threeDFormats_1[seriesIndex], value[2]);
990
+ return "".concat(seriesLabel ? "".concat(seriesLabel, "<br/>") : "").concat(categoryLabel, ": ").concat(valueLabel);
761
991
  };
762
992
  threeDSeries = void 0;
763
993
  visualMap = void 0;
764
994
  xAxis3D = void 0;
765
995
  yAxis3D = void 0;
766
- if (threeDRenderKind === "bar3D") {
767
- xAxis3D = { type: "category", data: categories_2 };
768
- yAxis3D = { type: "category", data: seriesNames_1 };
996
+ if (stackedBar3D_1) {
997
+ xAxis3D = { type: "category", data: categories_3 };
998
+ yAxis3D = { type: "category", data: [""] };
999
+ categoryCount = (0, three_d_1.getCategoryCount)(threeDSeriesInputs);
1000
+ categoryTotals_1 = new Array(categoryCount).fill(0);
1001
+ try {
1002
+ for (threeDSeriesInputs_1 = tslib_1.__values(threeDSeriesInputs), threeDSeriesInputs_1_1 = threeDSeriesInputs_1.next(); !threeDSeriesInputs_1_1.done; threeDSeriesInputs_1_1 = threeDSeriesInputs_1.next()) {
1003
+ entry = threeDSeriesInputs_1_1.value;
1004
+ entry.values.forEach(function (value, categoryIndex) {
1005
+ if (typeof value === "number" && Number.isFinite(value)) {
1006
+ categoryTotals_1[categoryIndex] += value;
1007
+ }
1008
+ });
1009
+ }
1010
+ }
1011
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1012
+ finally {
1013
+ try {
1014
+ if (threeDSeriesInputs_1_1 && !threeDSeriesInputs_1_1.done && (_2 = threeDSeriesInputs_1.return)) _2.call(threeDSeriesInputs_1);
1015
+ }
1016
+ finally { if (e_4) throw e_4.error; }
1017
+ }
1018
+ isPercent_1 = spec.stackedType === "PERCENT_STACKED";
1019
+ threeDSeries = threeDSeriesInputs.map(function (entry, index) { return ({
1020
+ type: "bar3D",
1021
+ name: seriesNames_2[index],
1022
+ stack: "total",
1023
+ shading: "lambert",
1024
+ itemStyle: { color: seriesColorAt_1(index) },
1025
+ data: entry.values.flatMap(function (value, categoryIndex) {
1026
+ if (typeof value !== "number" || !Number.isFinite(value)) {
1027
+ return [];
1028
+ }
1029
+ var total = categoryTotals_1[categoryIndex];
1030
+ var z = isPercent_1 ? (total === 0 ? 0 : (value / total) * 100) : value;
1031
+ return [{ value: [categoryIndex, 0, z] }];
1032
+ }),
1033
+ }); });
1034
+ }
1035
+ else if (threeDRenderKind === "bar3D") {
1036
+ xAxis3D = { type: "category", data: categories_3 };
1037
+ yAxis3D = { type: "category", data: seriesNames_2 };
769
1038
  threeDSeries = [
770
1039
  {
771
1040
  type: "bar3D",
@@ -785,35 +1054,35 @@ var BasicChart = function (_a) {
785
1054
  type: "value",
786
1055
  axisLabel: { formatter: categoryAxisLabel },
787
1056
  min: 0,
788
- max: Math.max(categories_2.length - 1, 1),
1057
+ max: Math.max(categories_3.length - 1, 1),
789
1058
  };
790
1059
  yAxis3D = {
791
1060
  type: "value",
792
1061
  axisLabel: { formatter: seriesAxisLabel },
793
1062
  min: 0,
794
- max: Math.max(seriesNames_1.length - 1, 1),
1063
+ max: Math.max(seriesNames_2.length - 1, 1),
795
1064
  };
796
1065
  threeDSeries = (0, three_d_1.buildLine3DSeries)(threeDSeriesInputs).map(function (entry, index) { return ({
797
1066
  type: "line3D",
798
- name: seriesNames_1[index],
1067
+ name: seriesNames_2[index],
799
1068
  data: entry.data,
800
1069
  lineStyle: { width: 3, color: seriesColorAt_1(index) },
801
1070
  }); });
802
1071
  }
803
1072
  else {
804
1073
  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];
1074
+ _o = tslib_1.__read((0, three_d_1.getValueExtent)(surfacePoints), 2), zMin = _o[0], zMax = _o[1];
806
1075
  xAxis3D = {
807
1076
  type: "value",
808
1077
  axisLabel: { formatter: categoryAxisLabel },
809
1078
  min: 0,
810
- max: Math.max(categories_2.length - 1, 1),
1079
+ max: Math.max(categories_3.length - 1, 1),
811
1080
  };
812
1081
  yAxis3D = {
813
1082
  type: "value",
814
1083
  axisLabel: { formatter: seriesAxisLabel },
815
1084
  min: 0,
816
- max: Math.max(seriesNames_1.length - 1, 1),
1085
+ max: Math.max(seriesNames_2.length - 1, 1),
817
1086
  };
818
1087
  threeDSeries = [
819
1088
  {
@@ -832,13 +1101,13 @@ var BasicChart = function (_a) {
832
1101
  inRange: { color: tslib_1.__spreadArray([], tslib_1.__read(three_d_1.SURFACE_COLOR_RAMP), false) },
833
1102
  };
834
1103
  }
835
- (_31 = chartRef.current) === null || _31 === void 0 ? void 0 : _31.setOption(tslib_1.__assign(tslib_1.__assign({ tooltip: {
1104
+ (_43 = chartRef.current) === null || _43 === void 0 ? void 0 : _43.setOption(tslib_1.__assign(tslib_1.__assign({ tooltip: {
836
1105
  textStyle: { fontSize: 12 },
837
1106
  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)),
1107
+ }, legend: threeDRenderKind === "line3D" || stackedBar3D_1
1108
+ ? (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { show: seriesNames_2.length > 1, data: seriesNames_2 }), spec.legend)
1109
+ : { show: false }, xAxis3D: tslib_1.__assign(tslib_1.__assign({}, xAxis3D), { name: (_44 = spec.horizontalAxisTitle) !== null && _44 !== void 0 ? _44 : "" }), yAxis3D: tslib_1.__assign(tslib_1.__assign({}, yAxis3D), { name: "" }), zAxis3D: { type: "value", name: (_45 = spec.verticalAxisTitle) !== null && _45 !== void 0 ? _45 : "" }, grid3D: {
1110
+ boxDepth: Math.max(20, Math.min(100, seriesNames_2.length * 20)),
842
1111
  viewControl: { autoRotate: false },
843
1112
  } }, (visualMap ? { visualMap: [visualMap] } : {})), { series: threeDSeries }), {
844
1113
  replaceMerge: [
@@ -858,7 +1127,7 @@ var BasicChart = function (_a) {
858
1127
  previousChartType.current = spec.chartType;
859
1128
  previousSeriesCount.current = threeDSeries.length;
860
1129
  return [2 /*return*/];
861
- case 19:
1130
+ case 30:
862
1131
  // ---------------------------- Radar ----------------------------
863
1132
  // Radar is polar: a top-level `radar.indicator` list (one axis per
864
1133
  // category) plus one `radar`-type series carrying every data series'
@@ -868,8 +1137,8 @@ var BasicChart = function (_a) {
868
1137
  categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders);
869
1138
  radarSeriesInputs = [];
870
1139
  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;
1140
+ for (_p = tslib_1.__values((_46 = spec.series) !== null && _46 !== void 0 ? _46 : []), _q = _p.next(); !_q.done; _q = _p.next()) {
1141
+ seriesEntry = _q.value;
873
1142
  label = seriesEntry.dataLabel && !(0, utils_1.isAFormula)(seriesEntry.dataLabel)
874
1143
  ? seriesEntry.dataLabel
875
1144
  : "";
@@ -877,33 +1146,53 @@ var BasicChart = function (_a) {
877
1146
  radarSeriesInputs.push({ name: label, values: values });
878
1147
  }
879
1148
  }
880
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1149
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
881
1150
  finally {
882
1151
  try {
883
- if (_k && !_k.done && (_z = _j.return)) _z.call(_j);
1152
+ if (_q && !_q.done && (_3 = _p.return)) _3.call(_p);
884
1153
  }
885
- finally { if (e_3) throw e_3.error; }
1154
+ finally { if (e_5) throw e_5.error; }
886
1155
  }
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";
1156
+ indicators_1 = (0, radar_1.buildRadarIndicators)(categories, radarSeriesInputs);
1157
+ radarData = (0, radar_1.buildRadarSeriesData)(radarSeriesInputs, indicators_1.length);
1158
+ radarStyle_1 = (_47 = spec.radarStyle) !== null && _47 !== void 0 ? _47 : "standard";
890
1159
  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({
1160
+ radarFormats_1 = (0, axis_number_format_1.resolveSeriesNumberFormats)(spec.series, getFormattingFromRange, spec.hiddenDimensionStrategy);
1161
+ radarDataLabels_1 = spec.dataLabels;
1162
+ radarSeriesLabelFor_1 = function (seriesIndex) {
1163
+ return (0, overrides_1.buildSeriesLabelOption)(radarDataLabels_1 && !radarDataLabels_1.numberFormatPattern
1164
+ ? tslib_1.__assign(tslib_1.__assign({}, radarDataLabels_1), { numberFormatPattern: radarFormats_1[seriesIndex] }) : radarDataLabels_1);
1165
+ };
1166
+ radarTooltipFormatter = function (params) {
1167
+ var _a, _b;
1168
+ var values = Array.isArray(params === null || params === void 0 ? void 0 : params.value) ? params.value : [];
1169
+ var pattern = radarFormats_1[(_a = params === null || params === void 0 ? void 0 : params.dataIndex) !== null && _a !== void 0 ? _a : 0];
1170
+ var lines = indicators_1.map(function (indicator, i) {
1171
+ return "".concat(indicator.name, ": ").concat((0, axis_number_format_1.formatAxisValue)(pattern, values[i]));
1172
+ });
1173
+ return tslib_1.__spreadArray([(_b = params === null || params === void 0 ? void 0 : params.name) !== null && _b !== void 0 ? _b : ""], tslib_1.__read(lines), false).filter(Boolean).join("<br/>");
1174
+ };
1175
+ (_48 = chartRef.current) === null || _48 === void 0 ? void 0 : _48.setOption({
893
1176
  radar: {
894
- indicator: indicators.length
895
- ? indicators
1177
+ indicator: indicators_1.length
1178
+ ? indicators_1
896
1179
  : [{ name: "", max: 1 }],
897
1180
  },
898
1181
  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" },
1182
+ tooltip: { trigger: "item", formatter: radarTooltipFormatter },
900
1183
  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]
1184
+ {
1185
+ type: "radar",
1186
+ symbol: radarStyle_1 === "standard" ? "none" : "circle",
1187
+ data: radarData.map(function (d, i) { return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ value: d.value, name: d.name }, (radarSeriesLabelFor_1(i)
1188
+ ? { label: radarSeriesLabelFor_1(i) }
1189
+ : {})), (radarStyle_1 === "filled" ? { areaStyle: {} } : {})), (radarColors_1[i]
902
1190
  ? {
903
1191
  itemStyle: { color: radarColors_1[i] },
904
1192
  lineStyle: { color: radarColors_1[i] },
905
1193
  }
906
- : {}))); }) }),
1194
+ : {}))); }),
1195
+ },
907
1196
  ],
908
1197
  }, {
909
1198
  replaceMerge: [
@@ -926,16 +1215,27 @@ var BasicChart = function (_a) {
926
1215
  // V-variants additionally get a volume column sub-pane below the
927
1216
  // price plot.
928
1217
  if (spec.chartType === "stock") {
929
- variant = ((_37 = spec.stockVariant) !== null && _37 !== void 0 ? _37 : "HLC");
1218
+ variant_1 = ((_49 = spec.stockVariant) !== null && _49 !== void 0 ? _49 : "HLC");
930
1219
  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) {
1220
+ seriesValues = ((_50 = spec.series) !== null && _50 !== void 0 ? _50 : []).map(function (seriesEntry) {
932
1221
  return flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
933
1222
  });
934
- stockSeriesLabel_1 = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
1223
+ stockFormats_1 = (0, axis_number_format_1.resolveSeriesNumberFormats)(spec.series, getFormattingFromRange, spec.hiddenDimensionStrategy);
1224
+ stockRoleIndex_1 = function (role) {
1225
+ return stock_1.STOCK_ROLES[variant_1].indexOf(role);
1226
+ };
1227
+ stockFormatFor_1 = function (role) {
1228
+ return stockFormats_1[stockRoleIndex_1(role)];
1229
+ };
1230
+ stockDataLabels_1 = spec.dataLabels;
1231
+ stockSeriesLabelFor_1 = function (role) {
1232
+ return (0, overrides_1.buildSeriesLabelOption)(stockDataLabels_1 && !stockDataLabels_1.numberFormatPattern
1233
+ ? tslib_1.__assign(tslib_1.__assign({}, stockDataLabels_1), { numberFormatPattern: stockFormatFor_1(role) }) : stockDataLabels_1);
1234
+ };
935
1235
  upColor_1 = theme.themeColors.accent1;
936
1236
  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;
1237
+ volumePoints = (0, stock_1.toVolumeSeries)(seriesValues, variant_1);
1238
+ hasVolume = ((_51 = volumePoints === null || volumePoints === void 0 ? void 0 : volumePoints.length) !== null && _51 !== void 0 ? _51 : 0) > 0;
939
1239
  stockGrid = hasVolume
940
1240
  ? [
941
1241
  { left: "10%", right: "4%", top: "8%", height: "56%" },
@@ -949,7 +1249,7 @@ var BasicChart = function (_a) {
949
1249
  axisLine: { show: true },
950
1250
  axisTick: { show: true },
951
1251
  splitLine: { show: false },
952
- name: (_40 = spec.horizontalAxisTitle) !== null && _40 !== void 0 ? _40 : "",
1252
+ name: (_52 = spec.horizontalAxisTitle) !== null && _52 !== void 0 ? _52 : "",
953
1253
  nameLocation: "middle",
954
1254
  nameGap: 30,
955
1255
  }, spec.categoryAxisOptions);
@@ -971,16 +1271,16 @@ var BasicChart = function (_a) {
971
1271
  };
972
1272
  volumeSeries = hasVolume
973
1273
  ? [
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 ({
1274
+ tslib_1.__assign({ type: "bar", name: "Volume", xAxisIndex: 1, yAxisIndex: 1, data: (volumePoints !== null && volumePoints !== void 0 ? volumePoints : []).map(function (p) { return ({
980
1275
  value: p.value,
981
1276
  itemStyle: { color: p.up ? upColor_1 : downColor_1 },
982
- }); }),
983
- },
1277
+ }); }) }, ((0, axis_number_format_1.tooltipValueFormatter)(stockFormatFor_1("volume"))
1278
+ ? {
1279
+ tooltip: {
1280
+ valueFormatter: (0, axis_number_format_1.tooltipValueFormatter)(stockFormatFor_1("volume")),
1281
+ },
1282
+ }
1283
+ : {})),
984
1284
  ]
985
1285
  : [];
986
1286
  stockAxisPointer = {
@@ -989,16 +1289,16 @@ var BasicChart = function (_a) {
989
1289
  // OHLC / VOHLC variants carry an `open`, so they render as a
990
1290
  // candlestick (Excel's open-high-low-close stock chart). HLC / VHLC
991
1291
  // (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({
1292
+ if (variant_1 === "OHLC" || variant_1 === "VOHLC") {
1293
+ candleData = (0, stock_1.toCandlestick)(seriesValues, variant_1);
1294
+ (_53 = chartRef.current) === null || _53 === void 0 ? void 0 : _53.setOption({
995
1295
  xAxis: stockXAxis,
996
1296
  yAxis: tslib_1.__spreadArray([
997
1297
  (0, overrides_1.applyAxisOverrides)({
998
1298
  type: "value",
999
1299
  show: true,
1000
1300
  scale: true,
1001
- name: (_42 = spec.verticalAxisTitle) !== null && _42 !== void 0 ? _42 : "",
1301
+ name: (_54 = spec.verticalAxisTitle) !== null && _54 !== void 0 ? _54 : "",
1002
1302
  nameLocation: "middle",
1003
1303
  nameGap: 50,
1004
1304
  gridIndex: 0,
@@ -1009,17 +1309,18 @@ var BasicChart = function (_a) {
1009
1309
  tooltip: { trigger: "axis" },
1010
1310
  axisPointer: stockAxisPointer,
1011
1311
  series: tslib_1.__spreadArray([
1012
- {
1013
- type: "candlestick",
1014
- name: spec.title || "Stock",
1015
- data: candleData,
1016
- itemStyle: {
1312
+ tslib_1.__assign({ type: "candlestick", name: spec.title || "Stock", data: candleData, itemStyle: {
1017
1313
  color: upColor_1,
1018
1314
  color0: downColor_1,
1019
1315
  borderColor: upColor_1,
1020
1316
  borderColor0: downColor_1,
1021
- },
1022
- }
1317
+ } }, ((0, axis_number_format_1.tooltipValueFormatter)(stockFormatFor_1("close"))
1318
+ ? {
1319
+ tooltip: {
1320
+ valueFormatter: (0, axis_number_format_1.tooltipValueFormatter)(stockFormatFor_1("close")),
1321
+ },
1322
+ }
1323
+ : {}))
1023
1324
  ], tslib_1.__read(volumeSeries), false),
1024
1325
  }, {
1025
1326
  replaceMerge: [
@@ -1035,20 +1336,20 @@ var BasicChart = function (_a) {
1035
1336
  previousSeriesCount.current = 1 + volumeSeries.length;
1036
1337
  return [2 /*return*/];
1037
1338
  }
1038
- lineSeries = (0, stock_1.toLineSeries)(seriesValues, variant);
1039
- stockColors_1 = [
1339
+ lineSeries = (0, stock_1.toLineSeries)(seriesValues, variant_1);
1340
+ stockColors_1 = (0, chart_styles_1.getChartPalette)(spec, [
1040
1341
  theme.themeColors.accent1,
1041
1342
  theme.themeColors.accent2,
1042
1343
  theme.themeColors.accent3,
1043
1344
  theme.themeColors.accent4,
1044
- ];
1045
- (_43 = chartRef.current) === null || _43 === void 0 ? void 0 : _43.setOption({
1345
+ ]);
1346
+ (_55 = chartRef.current) === null || _55 === void 0 ? void 0 : _55.setOption({
1046
1347
  xAxis: stockXAxis,
1047
1348
  yAxis: tslib_1.__spreadArray([
1048
1349
  (0, overrides_1.applyAxisOverrides)({
1049
1350
  type: "value",
1050
1351
  show: true,
1051
- name: (_44 = spec.verticalAxisTitle) !== null && _44 !== void 0 ? _44 : "",
1352
+ name: (_56 = spec.verticalAxisTitle) !== null && _56 !== void 0 ? _56 : "",
1052
1353
  nameLocation: "middle",
1053
1354
  nameGap: 50,
1054
1355
  gridIndex: 0,
@@ -1058,7 +1359,15 @@ var BasicChart = function (_a) {
1058
1359
  grid: stockGrid,
1059
1360
  tooltip: { trigger: "axis" },
1060
1361
  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),
1362
+ series: tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(lineSeries.map(function (s, i) { return (tslib_1.__assign(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] } }, (stockSeriesLabelFor_1(s.role)
1363
+ ? { label: stockSeriesLabelFor_1(s.role) }
1364
+ : {})), ((0, axis_number_format_1.tooltipValueFormatter)(stockFormatFor_1(s.role))
1365
+ ? {
1366
+ tooltip: {
1367
+ valueFormatter: (0, axis_number_format_1.tooltipValueFormatter)(stockFormatFor_1(s.role)),
1368
+ },
1369
+ }
1370
+ : {}))); })), false), tslib_1.__read(volumeSeries), false),
1062
1371
  }, {
1063
1372
  replaceMerge: [
1064
1373
  "series",
@@ -1079,38 +1388,57 @@ var BasicChart = function (_a) {
1079
1388
  ofPieLayout = null;
1080
1389
  isHorizontalBarChart = spec.chartType === "bar";
1081
1390
  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];
1391
+ primaryDomainSource = (_59 = (_58 = (_57 = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _57 === void 0 ? void 0 : _57[0]) === null || _58 === void 0 ? void 0 : _58.sources) === null || _59 === void 0 ? void 0 : _59[0];
1083
1392
  rawPrimaryDomainValues = primaryDomainSource
1084
- ? (0, aggregation_1.sanitizeDomainValues)((_48 = getDomainValuesFromRange(primaryDomainSource, spec.hiddenDimensionStrategy)) !== null && _48 !== void 0 ? _48 : [])
1393
+ ? (0, aggregation_1.sanitizeDomainValues)((_60 = getDomainValuesFromRange(primaryDomainSource, spec.hiddenDimensionStrategy)) !== null && _60 !== void 0 ? _60 : [])
1085
1394
  : [];
1086
1395
  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 = [];
1396
+ categoryLevels = isCircularChart
1397
+ ? undefined
1398
+ : (0, category_levels_1.resolveCategoryLevels)((_61 = spec.categoryLevels) === null || _61 === void 0 ? void 0 : _61.map(function (level) {
1399
+ return flattenChartDataValues([level], getDomainValuesFromRange, spec.hiddenDimensionStrategy, false);
1400
+ }));
1401
+ if (categoryLevels) {
1402
+ chartDomains.push.apply(chartDomains, tslib_1.__spreadArray([], tslib_1.__read((0, category_levels_1.echartsGroupedCategoryAxes)(categoryLevels, {
1403
+ type: "category",
1404
+ show: showAxis,
1405
+ axisLine: { show: true },
1406
+ axisTick: { show: true },
1407
+ splitLine: { show: true },
1408
+ name: isHorizontalBarChart
1409
+ ? (_62 = spec.verticalAxisTitle) !== null && _62 !== void 0 ? _62 : ""
1410
+ : (_63 = spec.horizontalAxisTitle) !== null && _63 !== void 0 ? _63 : "",
1411
+ nameLocation: "middle",
1412
+ nameGap: 30 + 24 * categoryLevels.outer.length,
1413
+ })), false));
1414
+ }
1415
+ // One category axis per domain (Excel): a domain drawn from several
1416
+ // ranges lists their categories in sequence on that single axis.
1417
+ (categoryLevels ? [] : (_64 = spec.domains) !== null && _64 !== void 0 ? _64 : []).forEach(function (domain, domainIndex) {
1418
+ var _a, _b;
1419
+ var axisData = domain.sources.flatMap(function (sheetRange, sourceIndex) {
1420
+ var _a;
1091
1421
  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);
1422
+ return aggregateDomainValues;
1097
1423
  }
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
- });
1424
+ var rawValues = (0, aggregation_1.sanitizeDomainValues)((_a = getDomainValuesFromRange(sheetRange, spec.hiddenDimensionStrategy)) !== null && _a !== void 0 ? _a : []);
1425
+ return (0, aggregation_1.getDomainValuesForAxis)(rawValues, shouldAggregate);
1426
+ });
1427
+ var axisTitle = domainIndex === 0 && !isCircularChart
1428
+ ? isHorizontalBarChart
1429
+ ? (_a = spec.verticalAxisTitle) !== null && _a !== void 0 ? _a : ""
1430
+ : (_b = spec.horizontalAxisTitle) !== null && _b !== void 0 ? _b : ""
1431
+ : undefined;
1432
+ chartDomains.push({
1433
+ type: "category",
1434
+ data: axisData,
1435
+ show: showAxis && !isCircularChart,
1436
+ axisLine: { show: !isCircularChart },
1437
+ axisTick: { show: !isCircularChart },
1438
+ splitLine: { show: !isCircularChart },
1439
+ name: axisTitle,
1440
+ nameLocation: "middle",
1441
+ nameGap: 30,
1114
1442
  });
1115
1443
  });
1116
1444
  if (chartDomains.length === 0 && !isCircularChart) {
@@ -1122,14 +1450,14 @@ var BasicChart = function (_a) {
1122
1450
  splitLine: { show: true },
1123
1451
  gridIndex: 0,
1124
1452
  name: isHorizontalBarChart
1125
- ? (_50 = spec.verticalAxisTitle) !== null && _50 !== void 0 ? _50 : ""
1126
- : (_51 = spec.horizontalAxisTitle) !== null && _51 !== void 0 ? _51 : "",
1453
+ ? (_65 = spec.verticalAxisTitle) !== null && _65 !== void 0 ? _65 : ""
1454
+ : (_66 = spec.horizontalAxisTitle) !== null && _66 !== void 0 ? _66 : "",
1127
1455
  nameLocation: "middle",
1128
1456
  nameGap: 30,
1129
1457
  });
1130
1458
  }
1131
1459
  pushSeriesOverlays = function (series, data, dataLabel) {
1132
- var e_9, _a;
1460
+ var e_10, _a;
1133
1461
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1134
1462
  var numericValues = Array.isArray(data)
1135
1463
  ? data.map(function (v) {
@@ -1168,12 +1496,12 @@ var BasicChart = function (_a) {
1168
1496
  }, itemStyle: { color: (_g = tl.color) !== null && _g !== void 0 ? _g : seriesColor }, tooltip: { show: false }, z: 5 }, useSecondary));
1169
1497
  }
1170
1498
  }
1171
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
1499
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1172
1500
  finally {
1173
1501
  try {
1174
1502
  if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
1175
1503
  }
1176
- finally { if (e_9) throw e_9.error; }
1504
+ finally { if (e_10) throw e_10.error; }
1177
1505
  }
1178
1506
  // Error bars — drawn as a custom series of vertical/horizontal
1179
1507
  // whiskers. valueType "custom" reads per-point magnitudes from the
@@ -1270,11 +1598,11 @@ var BasicChart = function (_a) {
1270
1598
  };
1271
1599
  sideBySideBarCount = isStacked
1272
1600
  ? 1
1273
- : ((_52 = spec.series) !== null && _52 !== void 0 ? _52 : []).reduce(function (count, s) {
1274
- var _a, _b, _c;
1601
+ : ((_67 = spec.series) !== null && _67 !== void 0 ? _67 : []).reduce(function (count, s) {
1602
+ var _a;
1275
1603
  var seriesType = (_a = s.seriesChartType) !== null && _a !== void 0 ? _a : spec.chartType;
1276
1604
  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)
1605
+ ? count + 1
1278
1606
  : count;
1279
1607
  }, 0);
1280
1608
  specBarGap = (0, bar_layout_1.overlapToBarGap)(spec.overlap);
@@ -1282,174 +1610,230 @@ var BasicChart = function (_a) {
1282
1610
  seriesCount: sideBySideBarCount,
1283
1611
  overlap: isStacked ? 0 : spec.overlap,
1284
1612
  });
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);
1613
+ _loop_1 = function (specSeriesIndex, series) {
1614
+ var dataLabel, _130, _131, effectiveChartType, lineLike, domainSources, pieDomainLabels, piePointOffset, data, seriesEchartsType, seriesStyleAttrs, seriesEntry, isBarOrColumn, seriesAny, markerSymbol, wantsMarkers, gradientArgs, gradient, overrides_2, _132, _133, dp, fallback_1, overrides_3, _134, _135, dp, slicePalette_1, positiveColor_1, negativeColor_1;
1615
+ var e_11, _136, e_12, _137;
1616
+ return tslib_1.__generator(this, function (_138) {
1617
+ switch (_138.label) {
1618
+ case 0:
1619
+ if (!(!(0, utils_1.isNil)(series.dataLabel) && (0, utils_1.isAFormula)(series.dataLabel))) return [3 /*break*/, 2];
1620
+ _131 = chart_spec_utils_1.coerceCalculatedLabel;
1621
+ return [4 /*yield*/, onRequestCalculate(series.dataLabel, (_69 = position.sheetId) !== null && _69 !== void 0 ? _69 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
1622
+ case 1:
1623
+ _130 = _131.apply(void 0, [_138.sent()]);
1624
+ return [3 /*break*/, 3];
1625
+ case 2:
1626
+ _130 = (_70 = series.dataLabel) !== null && _70 !== void 0 ? _70 : "";
1627
+ _138.label = 3;
1628
+ case 3:
1629
+ dataLabel = _130;
1630
+ // Label
1631
+ if (dataLabel) {
1632
+ (_71 = legend.data) === null || _71 === void 0 ? void 0 : _71.push(dataLabel);
1377
1633
  }
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 });
1634
+ effectiveChartType = (_72 = series.seriesChartType) !== null && _72 !== void 0 ? _72 : spec.chartType;
1635
+ lineLike = (0, empty_cells_1.isLineLikeChartType)(effectiveChartType);
1636
+ domainSources = (_75 = (_74 = (_73 = spec.domains) === null || _73 === void 0 ? void 0 : _73[0]) === null || _74 === void 0 ? void 0 : _74.sources) !== null && _75 !== void 0 ? _75 : [];
1637
+ pieDomainLabels = spec.chartType === "pie" &&
1638
+ (domainSources.length > 1 || series.sources.length > 1)
1639
+ ? domainSources.flatMap(function (sheetRange) {
1640
+ var _a;
1641
+ return (_a = getDomainValuesFromRange(sheetRange, spec.hiddenDimensionStrategy)) !== null && _a !== void 0 ? _a : [];
1642
+ })
1643
+ : undefined;
1644
+ piePointOffset = 0;
1645
+ data = series.sources.flatMap(function (sheetRange) {
1646
+ var part = getSeriesData(spec, sheetRange, {
1647
+ aggregateEnabled: shouldAggregate,
1648
+ aggregateType: series.aggregateType,
1649
+ rawDomainValues: rawPrimaryDomainValues,
1650
+ orderedDomainValues: aggregateDomainValues,
1651
+ lineLike: lineLike,
1652
+ pieLabels: pieDomainLabels
1653
+ ? {
1654
+ domainLabels: pieDomainLabels,
1655
+ offset: series.sources.length > 1 ? piePointOffset : undefined,
1656
+ }
1657
+ : undefined,
1658
+ });
1659
+ if (pieDomainLabels)
1660
+ piePointOffset += part.length;
1661
+ return part;
1662
+ });
1663
+ seriesEchartsType = (0, helpers_1.chartTypeToEchartsType)(effectiveChartType);
1664
+ seriesStyleAttrs = (0, helpers_1.getEchartsSeriesStyle)(effectiveChartType);
1665
+ seriesEntry = tslib_1.__assign(tslib_1.__assign({ type: seriesEchartsType,
1666
+ // Ties the rendered series back to spec.series for click selection
1667
+ // One rendered series per spec series (source index 0).
1668
+ id: (0, series_click_1.chartSeriesId)(specSeriesIndex, 0), name: dataLabel, data: data, stack: isStacked ? "dataLabel" : undefined, smooth: (_76 = spec.smooth) !== null && _76 !== void 0 ? _76 : undefined, radius: (_77 = spec.radius) !== null && _77 !== void 0 ? _77 : (isCircularChart ? [0, "75%"] : undefined) }, ((0, empty_cells_1.connectsAcrossEmptyCells)(spec, lineLike)
1669
+ ? { connectNulls: true }
1670
+ : {})), seriesStyleAttrs);
1671
+ // Plot this series against a secondary value axis. The 2nd
1672
+ // yAxis element is appended below (when any series opts in);
1673
+ // here we point the series at index 1.
1674
+ if (series.useSecondaryAxis) {
1675
+ seriesEntry.yAxisIndex = 1;
1676
+ }
1677
+ isBarOrColumn = effectiveChartType === "bar" || effectiveChartType === "column";
1678
+ // Bar layout (overlap/gapWidth) — echarts reads barGap /
1679
+ // barCategoryGap from bar series (the last bar series wins for
1680
+ // the whole coordinate system), so apply them to every
1681
+ // bar/column series. Set before the gradient/noFill branches so
1682
+ // every push path carries them.
1683
+ if (isBarOrColumn) {
1684
+ if (specBarGap !== undefined) {
1685
+ seriesEntry.barGap = specBarGap;
1686
+ }
1687
+ if (specBarCategoryGap !== undefined) {
1688
+ seriesEntry.barCategoryGap = specBarCategoryGap;
1689
+ }
1690
+ }
1691
+ seriesAny = series;
1692
+ if (effectiveChartType === "line") {
1693
+ markerSymbol = (_78 = seriesAny.marker) === null || _78 === void 0 ? void 0 : _78.symbol;
1694
+ wantsMarkers = markerSymbol === "none"
1695
+ ? false
1696
+ : Boolean(spec.showMarkers) || !(0, utils_1.isNil)(markerSymbol);
1697
+ seriesEntry.showSymbol = wantsMarkers;
1698
+ if (wantsMarkers) {
1699
+ seriesEntry.symbol =
1700
+ (_79 = (0, helpers_1.mapMarkerSymbolToEcharts)(markerSymbol)) !== null && _79 !== void 0 ? _79 : "circle";
1701
+ seriesEntry.symbolSize = (_81 = (_80 = seriesAny.marker) === null || _80 === void 0 ? void 0 : _80.size) !== null && _81 !== void 0 ? _81 : 6;
1702
+ }
1703
+ }
1704
+ gradientArgs = (0, gradient_1.gradientToEcharts)(series.gradient);
1705
+ if (gradientArgs && !seriesAny.noFill) {
1706
+ gradient = new echarts.graphic.LinearGradient(gradientArgs.x, gradientArgs.y, gradientArgs.x2, gradientArgs.y2, gradientArgs.colorStops);
1707
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_82 = seriesEntry.itemStyle) !== null && _82 !== void 0 ? _82 : {})), { color: gradient });
1708
+ if (effectiveChartType === "area") {
1709
+ seriesEntry.areaStyle = tslib_1.__assign(tslib_1.__assign({}, ((_83 = seriesEntry.areaStyle) !== null && _83 !== void 0 ? _83 : {})), { color: gradient });
1710
+ }
1711
+ }
1712
+ else if (seriesAny.noFill) {
1713
+ // Transparent series (Gantt lag offset, etc.) — fill it
1714
+ // with `transparent` so layout is preserved but nothing
1715
+ // paints. Legend entries are also suppressed via `name: ""`
1716
+ // since the series carries no semantic information.
1717
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_84 = seriesEntry.itemStyle) !== null && _84 !== void 0 ? _84 : {})), { color: "transparent", borderColor: "transparent" });
1718
+ }
1719
+ else if (isBarOrColumn &&
1720
+ Array.isArray(seriesAny.dataPointColors) &&
1721
+ seriesAny.dataPointColors.length) {
1722
+ overrides_2 = new Map();
1723
+ try {
1724
+ for (_132 = (e_11 = void 0, tslib_1.__values(seriesAny.dataPointColors)), _133 = _132.next(); !_133.done; _133 = _132.next()) {
1725
+ dp = _133.value;
1726
+ if (typeof dp.idx === "number" && typeof dp.color === "string") {
1727
+ overrides_2.set(dp.idx, dp.color);
1728
+ }
1729
+ }
1730
+ }
1731
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1732
+ finally {
1733
+ try {
1734
+ if (_133 && !_133.done && (_136 = _132.return)) _136.call(_132);
1735
+ }
1736
+ finally { if (e_11) throw e_11.error; }
1737
+ }
1738
+ fallback_1 = (_85 = series.color) !== null && _85 !== void 0 ? _85 : theme.themeColors.accent1;
1739
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_86 = seriesEntry.itemStyle) !== null && _86 !== void 0 ? _86 : {})), { color: function (params) { var _a; return (_a = overrides_2.get(params.dataIndex)) !== null && _a !== void 0 ? _a : fallback_1; } });
1740
+ }
1741
+ else if (isCircularChart &&
1742
+ Array.isArray(seriesAny.dataPointColors) &&
1743
+ seriesAny.dataPointColors.length) {
1744
+ overrides_3 = new Map();
1745
+ try {
1746
+ for (_134 = (e_12 = void 0, tslib_1.__values(seriesAny.dataPointColors)), _135 = _134.next(); !_135.done; _135 = _134.next()) {
1747
+ dp = _135.value;
1748
+ if (typeof dp.idx === "number" && typeof dp.color === "string") {
1749
+ overrides_3.set(dp.idx, dp.color);
1750
+ }
1751
+ }
1752
+ }
1753
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1754
+ finally {
1755
+ try {
1756
+ if (_135 && !_135.done && (_137 = _134.return)) _137.call(_134);
1757
+ }
1758
+ finally { if (e_12) throw e_12.error; }
1759
+ }
1760
+ slicePalette_1 = (0, chart_styles_1.getChartPalette)(spec, [
1761
+ theme.themeColors.accent1,
1762
+ theme.themeColors.accent2,
1763
+ theme.themeColors.accent3,
1764
+ theme.themeColors.accent4,
1765
+ theme.themeColors.accent5,
1766
+ theme.themeColors.accent6,
1767
+ ]);
1768
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_87 = seriesEntry.itemStyle) !== null && _87 !== void 0 ? _87 : {})), { color: function (params) {
1769
+ var _a, _b;
1770
+ return (_b = (_a = overrides_3.get(params.dataIndex)) !== null && _a !== void 0 ? _a : series.color) !== null && _b !== void 0 ? _b : slicePalette_1[params.dataIndex % slicePalette_1.length];
1771
+ } });
1772
+ }
1773
+ else if (isBarOrColumn && series.invertIfNegative) {
1774
+ positiveColor_1 = (_88 = series.color) !== null && _88 !== void 0 ? _88 : theme.themeColors.accent1;
1775
+ negativeColor_1 = (_89 = series.negativeColor) !== null && _89 !== void 0 ? _89 : "#FF0000";
1776
+ // Use a color function that returns different colors based on value
1777
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_90 = seriesEntry.itemStyle) !== null && _90 !== void 0 ? _90 : {})), { color: function (params) {
1778
+ var _a, _b;
1779
+ var value = Array.isArray(params.data)
1780
+ ? params.data[1]
1781
+ : (_b = (_a = params.data) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : params.data;
1782
+ return typeof value === "number" && value < 0
1783
+ ? negativeColor_1
1784
+ : positiveColor_1;
1785
+ } });
1786
+ }
1787
+ else if (series.color) {
1788
+ seriesEntry.itemStyle = tslib_1.__assign(tslib_1.__assign({}, ((_91 = seriesEntry.itemStyle) !== null && _91 !== void 0 ? _91 : {})), { color: series.color });
1789
+ seriesEntry.lineStyle = tslib_1.__assign(tslib_1.__assign({}, ((_92 = seriesEntry.lineStyle) !== null && _92 !== void 0 ? _92 : {})), { color: series.color });
1790
+ if (effectiveChartType === "area") {
1791
+ seriesEntry.areaStyle = tslib_1.__assign(tslib_1.__assign({}, ((_93 = seriesEntry.areaStyle) !== null && _93 !== void 0 ? _93 : {})), { color: series.color });
1792
+ }
1793
+ }
1794
+ chartSeries.push(seriesEntry);
1795
+ pushSeriesOverlays(series, data, dataLabel);
1796
+ return [2 /*return*/];
1409
1797
  }
1410
- }
1411
- chartSeries.push(seriesEntry);
1412
- pushSeriesOverlays(series, data, dataLabel);
1798
+ });
1413
1799
  };
1800
+ _129.label = 31;
1801
+ case 31:
1802
+ _129.trys.push([31, 36, 37, 38]);
1803
+ _r = tslib_1.__values(((_68 = spec.series) !== null && _68 !== void 0 ? _68 : []).entries()), _s = _r.next();
1804
+ _129.label = 32;
1805
+ case 32:
1806
+ if (!!_s.done) return [3 /*break*/, 35];
1807
+ _t = tslib_1.__read(_s.value, 2), specSeriesIndex = _t[0], series = _t[1];
1808
+ return [5 /*yield**/, _loop_1(specSeriesIndex, series)];
1809
+ case 33:
1810
+ _129.sent();
1811
+ _129.label = 34;
1812
+ case 34:
1813
+ _s = _r.next();
1814
+ return [3 /*break*/, 32];
1815
+ case 35: return [3 /*break*/, 38];
1816
+ case 36:
1817
+ e_3_1 = _129.sent();
1818
+ e_3 = { error: e_3_1 };
1819
+ return [3 /*break*/, 38];
1820
+ case 37:
1414
1821
  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);
1822
+ if (_s && !_s.done && (_4 = _r.return)) _4.call(_r);
1439
1823
  }
1440
- finally { if (e_2) throw e_2.error; }
1824
+ finally { if (e_3) throw e_3.error; }
1441
1825
  return [7 /*endfinally*/];
1442
- case 29:
1826
+ case 38:
1443
1827
  if (isOfPie) {
1444
1828
  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];
1829
+ seriesEntry = (_94 = spec.series) === null || _94 === void 0 ? void 0 : _94[0];
1446
1830
  rawValues = seriesEntry
1447
1831
  ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); })
1448
1832
  : [];
1449
- _s = (0, of_pie_1.splitOfPie)(rawValues, labels, {
1833
+ _u = (0, of_pie_1.splitOfPie)(rawValues, labels, {
1450
1834
  splitType: spec.splitType,
1451
1835
  splitPos: spec.splitPos,
1452
- }), main_1 = _s.main, secondary = _s.secondary, otherTotal = _s.otherTotal, total = _s.total;
1836
+ }), main_1 = _u.main, secondary = _u.secondary, otherTotal = _u.otherTotal, total = _u.total;
1453
1837
  ofPieType_1 = (0, of_pie_1.resolveOfPieType)(spec.ofPieType);
1454
1838
  secondScale = (0, of_pie_1.clampSecondPieSize)(spec.secondPieSize) / 100;
1455
1839
  halfAngle_1 = (0, of_pie_1.otherSliceHalfAngle)(otherTotal, total);
@@ -1476,20 +1860,20 @@ var BasicChart = function (_a) {
1476
1860
  };
1477
1861
  chartDomains.length = 0;
1478
1862
  chartSeries.length = 0;
1479
- ofPiePalette_1 = [
1863
+ ofPiePalette_1 = (0, chart_styles_1.getChartPalette)(spec, [
1480
1864
  theme.themeColors.accent1,
1481
1865
  theme.themeColors.accent2,
1482
1866
  theme.themeColors.accent3,
1483
1867
  theme.themeColors.accent4,
1484
1868
  theme.themeColors.accent5,
1485
1869
  theme.themeColors.accent6,
1486
- ];
1870
+ ]);
1487
1871
  paletteAt_1 = function (index) {
1488
1872
  return ofPiePalette_1[index % ofPiePalette_1.length];
1489
1873
  };
1490
1874
  chartSeries.push({
1491
1875
  type: "pie",
1492
- name: (_72 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _72 !== void 0 ? _72 : "",
1876
+ name: (_95 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _95 !== void 0 ? _95 : "",
1493
1877
  center: ["".concat(MAIN_CX_1 * 100, "%"), "".concat(CY_1 * 100, "%")],
1494
1878
  radius: [0, "".concat(MAIN_RADIUS_PCT_1, "%")],
1495
1879
  // Rotate the pie so the "Other" slice's angular midpoint faces
@@ -1507,7 +1891,7 @@ var BasicChart = function (_a) {
1507
1891
  if (ofPieType_1 === "pie") {
1508
1892
  chartSeries.push({
1509
1893
  type: "pie",
1510
- name: (_73 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _73 !== void 0 ? _73 : "",
1894
+ name: (_96 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _96 !== void 0 ? _96 : "",
1511
1895
  center: ["".concat(SECONDARY_CX_1 * 100, "%"), "".concat(CY_1 * 100, "%")],
1512
1896
  radius: [0, "".concat(secondaryRadiusPct_1, "%")],
1513
1897
  data: secondary.map(function (s, i) { return ({
@@ -1602,16 +1986,16 @@ var BasicChart = function (_a) {
1602
1986
  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
1987
  }
1604
1988
  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];
1989
+ primaryDomainSource_1 = (_99 = (_98 = (_97 = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _97 === void 0 ? void 0 : _97[0]) === null || _98 === void 0 ? void 0 : _98.sources) === null || _99 === void 0 ? void 0 : _99[0];
1606
1990
  rawDomainValues = primaryDomainSource_1
1607
- ? (0, aggregation_1.sanitizeDomainValues)((_77 = getDomainValuesFromRange(primaryDomainSource_1, spec.hiddenDimensionStrategy)) !== null && _77 !== void 0 ? _77 : [])
1991
+ ? (0, aggregation_1.sanitizeDomainValues)((_100 = getDomainValuesFromRange(primaryDomainSource_1, spec.hiddenDimensionStrategy)) !== null && _100 !== void 0 ? _100 : [])
1608
1992
  : [];
1609
1993
  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];
1994
+ seriesEntry = (_101 = spec.series) === null || _101 === void 0 ? void 0 : _101[0];
1611
1995
  rawValues_1 = seriesEntry
1612
1996
  ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); })
1613
1997
  : [];
1614
- totalIndices = new Set((_79 = spec.totalIndices) !== null && _79 !== void 0 ? _79 : []);
1998
+ totalIndices = new Set((_102 = spec.totalIndices) !== null && _102 !== void 0 ? _102 : []);
1615
1999
  steps = (0, waterfall_1.computeWaterfall)(rawValues_1, labels, totalIndices);
1616
2000
  chartDomains.length = 0;
1617
2001
  chartDomains.push({
@@ -1621,7 +2005,7 @@ var BasicChart = function (_a) {
1621
2005
  axisLine: { show: true },
1622
2006
  axisTick: { show: true },
1623
2007
  splitLine: { show: false },
1624
- name: (_80 = spec.horizontalAxisTitle) !== null && _80 !== void 0 ? _80 : "",
2008
+ name: (_103 = spec.horizontalAxisTitle) !== null && _103 !== void 0 ? _103 : "",
1625
2009
  nameLocation: "middle",
1626
2010
  nameGap: 30,
1627
2011
  });
@@ -1634,9 +2018,9 @@ var BasicChart = function (_a) {
1634
2018
  data: steps.map(function (s) { return s.placeholder; }),
1635
2019
  silent: true,
1636
2020
  });
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;
2021
+ accent_1 = (_104 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.color) !== null && _104 !== void 0 ? _104 : theme.themeColors.accent1;
2022
+ decreaseColor_1 = (_106 = (_105 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.negativeColor) !== null && _105 !== void 0 ? _105 : theme.themeColors.accent2) !== null && _106 !== void 0 ? _106 : accent_1;
2023
+ totalColor_1 = (_107 = theme.themeColors.accent3) !== null && _107 !== void 0 ? _107 : accent_1;
1640
2024
  connectors = steps.slice(0, -1).map(function (s, i) { return [
1641
2025
  { coord: [i, s.cumulative] },
1642
2026
  { coord: [i + 1, s.cumulative] },
@@ -1644,7 +2028,7 @@ var BasicChart = function (_a) {
1644
2028
  chartSeries.push({
1645
2029
  type: "bar",
1646
2030
  stack: "waterfall",
1647
- name: (_85 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _85 !== void 0 ? _85 : "",
2031
+ name: (_108 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _108 !== void 0 ? _108 : "",
1648
2032
  data: steps.map(function (s, i) { return ({
1649
2033
  value: s.value,
1650
2034
  itemStyle: {
@@ -1671,12 +2055,12 @@ var BasicChart = function (_a) {
1671
2055
  legend.data = [];
1672
2056
  }
1673
2057
  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];
2058
+ primaryDomainSource_2 = (_111 = (_110 = (_109 = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _109 === void 0 ? void 0 : _109[0]) === null || _110 === void 0 ? void 0 : _110.sources) === null || _111 === void 0 ? void 0 : _111[0];
1675
2059
  rawDomainValues = primaryDomainSource_2
1676
- ? (0, aggregation_1.sanitizeDomainValues)((_89 = getDomainValuesFromRange(primaryDomainSource_2, spec.hiddenDimensionStrategy)) !== null && _89 !== void 0 ? _89 : [])
2060
+ ? (0, aggregation_1.sanitizeDomainValues)((_112 = getDomainValuesFromRange(primaryDomainSource_2, spec.hiddenDimensionStrategy)) !== null && _112 !== void 0 ? _112 : [])
1677
2061
  : [];
1678
2062
  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];
2063
+ seriesEntry = (_113 = spec.series) === null || _113 === void 0 ? void 0 : _113[0];
1680
2064
  rawValues = seriesEntry
1681
2065
  ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : 0); })
1682
2066
  : [];
@@ -1684,7 +2068,7 @@ var BasicChart = function (_a) {
1684
2068
  chartSeries.length = 0;
1685
2069
  chartSeries.push({
1686
2070
  type: "funnel",
1687
- name: (_91 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _91 !== void 0 ? _91 : "",
2071
+ name: (_114 = seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.dataLabel) !== null && _114 !== void 0 ? _114 : "",
1688
2072
  data: rawValues.map(function (value, i) {
1689
2073
  var _a;
1690
2074
  return ({
@@ -1705,8 +2089,8 @@ var BasicChart = function (_a) {
1705
2089
  outlierPoints = [];
1706
2090
  meanPoints = [];
1707
2091
  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;
2092
+ for (_v = tslib_1.__values((_115 = spec.series) !== null && _115 !== void 0 ? _115 : []), _w = _v.next(); !_w.done; _w = _v.next()) {
2093
+ seriesEntry = _w.value;
1710
2094
  label = seriesEntry.dataLabel && !(0, utils_1.isAFormula)(seriesEntry.dataLabel)
1711
2095
  ? seriesEntry.dataLabel
1712
2096
  : "";
@@ -1720,17 +2104,17 @@ var BasicChart = function (_a) {
1720
2104
  boxLabels.push(label);
1721
2105
  if (showOutliers === true) {
1722
2106
  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;
2107
+ for (_x = (e_7 = void 0, tslib_1.__values(summary.outliers)), _y = _x.next(); !_y.done; _y = _x.next()) {
2108
+ outlier = _y.value;
1725
2109
  outlierPoints.push([boxIndex, outlier]);
1726
2110
  }
1727
2111
  }
1728
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
2112
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1729
2113
  finally {
1730
2114
  try {
1731
- if (_w && !_w.done && (_3 = _v.return)) _3.call(_v);
2115
+ if (_y && !_y.done && (_6 = _x.return)) _6.call(_x);
1732
2116
  }
1733
- finally { if (e_6) throw e_6.error; }
2117
+ finally { if (e_7) throw e_7.error; }
1734
2118
  }
1735
2119
  }
1736
2120
  if (showMeanMarker) {
@@ -1739,12 +2123,12 @@ var BasicChart = function (_a) {
1739
2123
  }
1740
2124
  }
1741
2125
  }
1742
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
2126
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1743
2127
  finally {
1744
2128
  try {
1745
- if (_u && !_u.done && (_2 = _t.return)) _2.call(_t);
2129
+ if (_w && !_w.done && (_5 = _v.return)) _5.call(_v);
1746
2130
  }
1747
- finally { if (e_5) throw e_5.error; }
2131
+ finally { if (e_6) throw e_6.error; }
1748
2132
  }
1749
2133
  chartDomains.length = 0;
1750
2134
  chartDomains.push({
@@ -1754,7 +2138,7 @@ var BasicChart = function (_a) {
1754
2138
  axisLine: { show: true },
1755
2139
  axisTick: { show: true },
1756
2140
  splitLine: { show: false },
1757
- name: (_93 = spec.horizontalAxisTitle) !== null && _93 !== void 0 ? _93 : "",
2141
+ name: (_116 = spec.horizontalAxisTitle) !== null && _116 !== void 0 ? _116 : "",
1758
2142
  nameLocation: "middle",
1759
2143
  nameGap: 30,
1760
2144
  });
@@ -1764,7 +2148,7 @@ var BasicChart = function (_a) {
1764
2148
  name: "",
1765
2149
  data: boxStats,
1766
2150
  };
1767
- boxColor = (_95 = (_94 = spec.series) === null || _94 === void 0 ? void 0 : _94[0]) === null || _95 === void 0 ? void 0 : _95.color;
2151
+ boxColor = (_118 = (_117 = spec.series) === null || _117 === void 0 ? void 0 : _117[0]) === null || _118 === void 0 ? void 0 : _118.color;
1768
2152
  if (boxColor) {
1769
2153
  boxSeries.itemStyle = { color: boxColor, borderColor: boxColor };
1770
2154
  }
@@ -1779,7 +2163,7 @@ var BasicChart = function (_a) {
1779
2163
  }
1780
2164
  else if (spec.chartType === "histogram") {
1781
2165
  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;
2166
+ _z = (0, histogram_1.binHistogram)(rawValues, spec.binCount), labels = _z.labels, counts = _z.counts;
1783
2167
  isPareto_1 = (0, histogram_1.isParetoSpec)(spec);
1784
2168
  cumulativePercents = [];
1785
2169
  if (isPareto_1) {
@@ -1796,18 +2180,18 @@ var BasicChart = function (_a) {
1796
2180
  axisLine: { show: true },
1797
2181
  axisTick: { show: true },
1798
2182
  splitLine: { show: false },
1799
- name: (_96 = spec.horizontalAxisTitle) !== null && _96 !== void 0 ? _96 : "",
2183
+ name: (_119 = spec.horizontalAxisTitle) !== null && _119 !== void 0 ? _119 : "",
1800
2184
  nameLocation: "middle",
1801
2185
  nameGap: 30,
1802
2186
  });
1803
2187
  chartSeries.length = 0;
1804
2188
  histogramSeries = {
1805
2189
  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 : "",
2190
+ name: (_122 = (_121 = (_120 = spec.series) === null || _120 === void 0 ? void 0 : _120[0]) === null || _121 === void 0 ? void 0 : _121.dataLabel) !== null && _122 !== void 0 ? _122 : "",
1807
2191
  data: counts,
1808
2192
  barCategoryGap: "1%",
1809
2193
  };
1810
- histogramColor = (_101 = (_100 = spec.series) === null || _100 === void 0 ? void 0 : _100[0]) === null || _101 === void 0 ? void 0 : _101.color;
2194
+ histogramColor = (_124 = (_123 = spec.series) === null || _123 === void 0 ? void 0 : _123[0]) === null || _124 === void 0 ? void 0 : _124.color;
1811
2195
  if (histogramColor) {
1812
2196
  histogramSeries.itemStyle = { color: histogramColor };
1813
2197
  }
@@ -1861,29 +2245,73 @@ var BasicChart = function (_a) {
1861
2245
  isPareto = spec.chartType === "histogram" && (0, histogram_1.isParetoSpec)(spec);
1862
2246
  hasSecondaryAxis = !isCircularChart &&
1863
2247
  !isHorizontalBarChart &&
1864
- (((_102 = spec.series) !== null && _102 !== void 0 ? _102 : []).some(function (s) { return s.useSecondaryAxis; }) || isPareto);
2248
+ (((_125 = spec.series) !== null && _125 !== void 0 ? _125 : []).some(function (s) { return s.useSecondaryAxis; }) || isPareto);
2249
+ isPercentStackedBars = spec.stackedType === "PERCENT_STACKED" &&
2250
+ (spec.chartType === "bar" || spec.chartType === "column");
2251
+ primaryAxisNumberFormat = isPercentStackedBars
2252
+ ? undefined
2253
+ : (0, axis_number_format_1.resolveValueAxisNumberFormat)({
2254
+ axisOptions: spec.valueAxisOptions,
2255
+ series: ((_126 = spec.series) !== null && _126 !== void 0 ? _126 : []).filter(function (s) { return !s.useSecondaryAxis; }),
2256
+ getFormattingFromRange: getFormattingFromRange,
2257
+ hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
2258
+ });
2259
+ secondaryAxisNumberFormat = (0, axis_number_format_1.resolveValueAxisNumberFormat)({
2260
+ axisOptions: spec.secondaryValueAxisOptions,
2261
+ series: ((_127 = spec.series) !== null && _127 !== void 0 ? _127 : []).filter(function (s) { return s.useSecondaryAxis; }),
2262
+ getFormattingFromRange: getFormattingFromRange,
2263
+ hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
2264
+ });
2265
+ axisNumberFormatFor = function (s) {
2266
+ return (s === null || s === void 0 ? void 0 : s.yAxisIndex) === 1
2267
+ ? secondaryAxisNumberFormat
2268
+ : primaryAxisNumberFormat;
2269
+ };
2270
+ seriesNumberFormats = (0, axis_number_format_1.resolveSeriesNumberFormats)(spec.series, getFormattingFromRange, spec.hiddenDimensionStrategy);
2271
+ seriesNumberFormatFor = function (s) {
2272
+ var _a;
2273
+ var specIndex = (0, series_click_1.chartSeriesSpecIndex)(s === null || s === void 0 ? void 0 : s.id);
2274
+ return ((_a = (specIndex === undefined ? undefined : seriesNumberFormats[specIndex])) !== null && _a !== void 0 ? _a : axisNumberFormatFor(s));
2275
+ };
1865
2276
  tooltipConfig = {
1866
2277
  textStyle: {
1867
2278
  fontSize: 12,
1868
2279
  },
1869
2280
  trigger: isCircularChart ? "item" : "axis",
1870
- formatter: isCircularChart ? "{b}: {c} ({d}%)" : undefined,
2281
+ formatter: isCircularChart
2282
+ ? primaryAxisNumberFormat
2283
+ ? (0, axis_number_format_1.circularTooltipFormatter)(primaryAxisNumberFormat)
2284
+ : "{b}: {c} ({d}%)"
2285
+ : undefined,
1871
2286
  };
1872
2287
  finalLegend = (0, overrides_1.applyLegendOverrides)(legend, spec.legend);
1873
- seriesLabelOption = (0, overrides_1.buildSeriesLabelOption)(spec.dataLabels);
2288
+ dataLabelOptions = spec.dataLabels;
2289
+ seriesLabelOptionFor = function (s) {
2290
+ return (0, overrides_1.buildSeriesLabelOption)(dataLabelOptions && !dataLabelOptions.numberFormatPattern
2291
+ ? tslib_1.__assign(tslib_1.__assign({}, dataLabelOptions), { numberFormatPattern: seriesNumberFormatFor(s) }) : dataLabelOptions);
2292
+ };
1874
2293
  isDoughnut = spec.chartType === "doughnut";
1875
2294
  doughnutHoleSize = spec.doughnutHoleSize;
2295
+ explosion = isCircularChart && !isOfPie ? (0, pie_explosion_1.resolveExplosion)(spec) : 0;
2296
+ explodedRef.current = explosion > 0;
2297
+ explosionOffset = (0, pie_explosion_1.explosionOffsetPx)(explosion, (0, pie_explosion_1.pieRadiusPx)(isDoughnut ? [0, "75%"] : spec.radius, width !== null && width !== void 0 ? width : 0, height !== null && height !== void 0 ? height : 0));
1876
2298
  // PERCENT_STACKED — echarts has no built-in `barnorm: 'percent'`,
1877
2299
  // so we normalize per category here: each cell becomes
1878
2300
  // (value / category_total) * 100, while the original value is
1879
2301
  // 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.
2302
+ // surface the dollar amount. Touches only the stacked base series
2303
+ // (bar/column, and the line series of 100% stacked line / area
2304
+ // charts); overlays and other charts pass through unchanged.
1882
2305
  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"; });
2306
+ (spec.chartType === "bar" ||
2307
+ spec.chartType === "column" ||
2308
+ spec.chartType === "line" ||
2309
+ spec.chartType === "area")) {
2310
+ barSeries = chartSeries.filter(function (s) {
2311
+ return (s === null || s === void 0 ? void 0 : s.stack) !== undefined && ((s === null || s === void 0 ? void 0 : s.type) === "bar" || (s === null || s === void 0 ? void 0 : s.type) === "line");
2312
+ });
1885
2313
  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);
2314
+ categoryTotals_2 = new Array(len).fill(0);
1887
2315
  try {
1888
2316
  for (barSeries_1 = tslib_1.__values(barSeries), barSeries_1_1 = barSeries_1.next(); !barSeries_1_1.done; barSeries_1_1 = barSeries_1.next()) {
1889
2317
  s = barSeries_1_1.value;
@@ -1893,16 +2321,16 @@ var BasicChart = function (_a) {
1893
2321
  raw = s.data[i];
1894
2322
  n = typeof raw === "number" ? raw : Number(raw);
1895
2323
  if (Number.isFinite(n))
1896
- categoryTotals_1[i] += n;
2324
+ categoryTotals_2[i] += n;
1897
2325
  }
1898
2326
  }
1899
2327
  }
1900
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
2328
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1901
2329
  finally {
1902
2330
  try {
1903
- if (barSeries_1_1 && !barSeries_1_1.done && (_4 = barSeries_1.return)) _4.call(barSeries_1);
2331
+ if (barSeries_1_1 && !barSeries_1_1.done && (_7 = barSeries_1.return)) _7.call(barSeries_1);
1904
2332
  }
1905
- finally { if (e_7) throw e_7.error; }
2333
+ finally { if (e_8) throw e_8.error; }
1906
2334
  }
1907
2335
  try {
1908
2336
  for (barSeries_2 = tslib_1.__values(barSeries), barSeries_2_1 = barSeries_2.next(); !barSeries_2_1.done; barSeries_2_1 = barSeries_2.next()) {
@@ -1911,7 +2339,7 @@ var BasicChart = function (_a) {
1911
2339
  continue;
1912
2340
  s.data = s.data.map(function (raw, i) {
1913
2341
  var n = typeof raw === "number" ? raw : Number(raw);
1914
- var total = categoryTotals_1[i];
2342
+ var total = categoryTotals_2[i];
1915
2343
  if (!Number.isFinite(n) || total === 0) {
1916
2344
  return { value: 0, originalValue: raw };
1917
2345
  }
@@ -1919,20 +2347,43 @@ var BasicChart = function (_a) {
1919
2347
  });
1920
2348
  }
1921
2349
  }
1922
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
2350
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
1923
2351
  finally {
1924
2352
  try {
1925
- if (barSeries_2_1 && !barSeries_2_1.done && (_5 = barSeries_2.return)) _5.call(barSeries_2);
2353
+ if (barSeries_2_1 && !barSeries_2_1.done && (_8 = barSeries_2.return)) _8.call(barSeries_2);
1926
2354
  }
1927
- finally { if (e_8) throw e_8.error; }
2355
+ finally { if (e_9) throw e_9.error; }
1928
2356
  }
1929
2357
  }
1930
2358
  seriesWithLabels = chartSeries.map(function (s) {
1931
- var _a;
2359
+ var _a, _b, _c, _d, _e;
1932
2360
  var next = tslib_1.__assign({}, s);
2361
+ var seriesLabelOption = seriesLabelOptionFor(s);
1933
2362
  if (seriesLabelOption) {
1934
2363
  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
2364
  }
2365
+ // Tooltip values of the value-axis series (a boxplot / candlestick
2366
+ // tooltip lists its own statistics and keeps echarts' default).
2367
+ var seriesTooltipValueFormatter = VALUE_TOOLTIP_SERIES_TYPES.has(s === null || s === void 0 ? void 0 : s.type)
2368
+ ? (0, axis_number_format_1.valueAxisLabelFormatter)(seriesNumberFormatFor(s))
2369
+ : undefined;
2370
+ if (seriesTooltipValueFormatter && ((_b = s === null || s === void 0 ? void 0 : s.tooltip) === null || _b === void 0 ? void 0 : _b.show) !== false) {
2371
+ next.tooltip = tslib_1.__assign(tslib_1.__assign({}, ((_c = s === null || s === void 0 ? void 0 : s.tooltip) !== null && _c !== void 0 ? _c : {})), { valueFormatter: seriesTooltipValueFormatter });
2372
+ }
2373
+ if (next.type === "pie") {
2374
+ var pieNumberFormat = seriesNumberFormatFor(s);
2375
+ if (pieNumberFormat && ((_d = s === null || s === void 0 ? void 0 : s.tooltip) === null || _d === void 0 ? void 0 : _d.show) !== false) {
2376
+ next.tooltip = tslib_1.__assign(tslib_1.__assign({}, ((_e = s === null || s === void 0 ? void 0 : s.tooltip) !== null && _e !== void 0 ? _e : {})), { formatter: (0, axis_number_format_1.circularTooltipFormatter)(pieNumberFormat) });
2377
+ }
2378
+ if (explosionOffset > 0 && Array.isArray(next.data)) {
2379
+ next.selectedMode = "multiple";
2380
+ next.selectedOffset = explosionOffset;
2381
+ next.data = next.data.map(function (item) {
2382
+ return item !== null && typeof item === "object"
2383
+ ? tslib_1.__assign(tslib_1.__assign({}, item), { selected: true }) : { value: item, selected: true };
2384
+ });
2385
+ }
2386
+ }
1936
2387
  if (isDoughnut && next.type === "pie") {
1937
2388
  var inner = typeof doughnutHoleSize === "number"
1938
2389
  ? Math.round(Math.max(0, Math.min(0.9, doughnutHoleSize)) * 100)
@@ -1942,7 +2393,7 @@ var BasicChart = function (_a) {
1942
2393
  return next;
1943
2394
  });
1944
2395
  // Update charts
1945
- (_103 = chartRef.current) === null || _103 === void 0 ? void 0 : _103.setOption({
2396
+ (_128 = chartRef.current) === null || _128 === void 0 ? void 0 : _128.setOption({
1946
2397
  xAxis: (function () {
1947
2398
  var _a, _b;
1948
2399
  if (isOfPie) {
@@ -1986,7 +2437,7 @@ var BasicChart = function (_a) {
1986
2437
  }
1987
2438
  if (isHorizontalBarChart) {
1988
2439
  return [
1989
- (0, overrides_1.applyAxisOverrides)(tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { name: (_a = spec.horizontalAxisTitle) !== null && _a !== void 0 ? _a : "" }), spec.valueAxisOptions),
2440
+ (0, overrides_1.applyAxisOverrides)(tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { name: (_a = spec.horizontalAxisTitle) !== null && _a !== void 0 ? _a : "" }), spec.valueAxisOptions, primaryAxisNumberFormat),
1990
2441
  ];
1991
2442
  }
1992
2443
  var base = chartDomains.length > 0
@@ -2050,7 +2501,7 @@ var BasicChart = function (_a) {
2050
2501
  });
2051
2502
  }
2052
2503
  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),
2504
+ (0, overrides_1.applyAxisOverrides)(tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { name: (_b = spec.verticalAxisTitle) !== null && _b !== void 0 ? _b : "" }), spec.valueAxisOptions, primaryAxisNumberFormat),
2054
2505
  ];
2055
2506
  if (hasSecondaryAxis) {
2056
2507
  axes.push((0, overrides_1.applyAxisOverrides)(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, valueAxisBase), { name: "", splitLine: { show: false } }), (isPareto
@@ -2059,7 +2510,7 @@ var BasicChart = function (_a) {
2059
2510
  max: 100,
2060
2511
  axisLabel: { formatter: "{value}%" },
2061
2512
  }
2062
- : {})), spec.secondaryValueAxisOptions));
2513
+ : {})), spec.secondaryValueAxisOptions, secondaryAxisNumberFormat));
2063
2514
  }
2064
2515
  return axes;
2065
2516
  })(),
@@ -2086,6 +2537,7 @@ var BasicChart = function (_a) {
2086
2537
  charts_1.CandlestickChart,
2087
2538
  charts_1.CustomChart,
2088
2539
  charts_1.FunnelChart,
2540
+ charts_1.HeatmapChart,
2089
2541
  charts_1.LineChart,
2090
2542
  charts_1.PieChart,
2091
2543
  charts_1.RadarChart,
@@ -2094,6 +2546,7 @@ var BasicChart = function (_a) {
2094
2546
  charts_1.SunburstChart,
2095
2547
  renderers_1.CanvasRenderer,
2096
2548
  components_1.DatasetComponent,
2549
+ components_1.VisualMapComponent,
2097
2550
  ]);
2098
2551
  initializeChart();
2099
2552
  }, []);
@@ -2106,7 +2559,7 @@ var BasicChart = function (_a) {
2106
2559
  // between the cartesian 2-D option and the grid3D / map one and must
2107
2560
  // re-apply these.
2108
2561
  var applyThemeOptions = function () {
2109
- var _a, _b, _c, _d, _e;
2562
+ var _a, _b, _c, _d, _e, _f;
2110
2563
  if (chartRef.current) {
2111
2564
  var textColor = (0, spreadsheet_1.getStringifiedColor)({
2112
2565
  theme: 1,
@@ -2146,14 +2599,17 @@ var BasicChart = function (_a) {
2146
2599
  color: textColor,
2147
2600
  },
2148
2601
  },
2149
- color: [
2602
+ color: (0, chart_styles_1.getChartPalette)(chart.spec, [
2150
2603
  theme.themeColors.accent1,
2151
2604
  theme.themeColors.accent2,
2152
2605
  theme.themeColors.accent3,
2153
2606
  theme.themeColors.accent4,
2154
2607
  theme.themeColors.accent5,
2155
2608
  theme.themeColors.accent6,
2156
- ],
2609
+ ]),
2610
+ // Excel's Format Chart Area fill; `transparent` (echarts' own
2611
+ // default) so clearing the fill undoes an earlier setOption.
2612
+ backgroundColor: (_f = chart.spec.backgroundColor) !== null && _f !== void 0 ? _f : "transparent",
2157
2613
  };
2158
2614
  // Skip when rendering 3-D or a region map: merging a cartesian
2159
2615
  // yAxis into a grid3D / map option would create a stray empty
@@ -2175,7 +2631,14 @@ var BasicChart = function (_a) {
2175
2631
  // Update chart properties
2176
2632
  (0, ui_1.useIsomorphicLayoutEffect)(function () {
2177
2633
  applyThemeOptions();
2178
- }, [theme, title, isDarkMode, chart.spec.chartType]);
2634
+ }, [
2635
+ theme,
2636
+ title,
2637
+ isDarkMode,
2638
+ chart.spec.chartType,
2639
+ chart.spec.palette,
2640
+ chart.spec.backgroundColor,
2641
+ ]);
2179
2642
  // Draw chart. `glUpgradeTick` re-runs the draw when the lazily loaded
2180
2643
  // echarts-gl module resolves, upgrading a 3-D spec's immediate 2-D
2181
2644
  // fallback to the true 3-D rendering.
@@ -2185,6 +2648,7 @@ var BasicChart = function (_a) {
2185
2648
  chart.spec,
2186
2649
  getDomainValuesFromRange,
2187
2650
  getSeriesValuesFromRange,
2651
+ getFormattingFromRange,
2188
2652
  glUpgradeTick,
2189
2653
  ]);
2190
2654
  // Resize chart
@@ -2202,16 +2666,43 @@ var BasicChart = function (_a) {
2202
2666
  var _a;
2203
2667
  (_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.resize({ silent: true });
2204
2668
  }, [width, height]);
2669
+ var chartPngDataUrl = function () {
2670
+ var _a, _b;
2671
+ return (_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.getDataURL({
2672
+ type: "png",
2673
+ pixelRatio: 2,
2674
+ backgroundColor: (_b = chart.spec.backgroundColor) !== null && _b !== void 0 ? _b : (0, spreadsheet_1.getStringifiedColor)({ theme: 0, tint: isDarkMode ? -1 : 1 }, theme),
2675
+ });
2676
+ };
2205
2677
  var onDownloadChart = function () {
2206
2678
  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
- });
2679
+ var url = chartPngDataUrl();
2680
+ if (url) {
2212
2681
  (0, toolkit_1.createDownloadableFile)((_a = chart.spec.title) !== null && _a !== void 0 ? _a : "Chart", url);
2213
2682
  }
2214
2683
  };
2684
+ // Copy as Picture / print preview — the same raster as the download.
2685
+ var exportChartPng = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
2686
+ return [2 /*return*/, (0, chart_image_1.dataUrlToBlob)(chartPngDataUrl())];
2687
+ }); }); };
2688
+ // Excel's "Switch Row/Column" — offered to the grid's right-click menu
2689
+ // when the host can persist the chart and the sources transpose.
2690
+ var switchRowColumnAction = onUpdateChart && !readonly && (0, chart_orientation_1.canSwitchRowColumn)(spec)
2691
+ ? function () {
2692
+ var next = (0, chart_orientation_1.switchRowColumn)(spec, {
2693
+ getFormattedValue: (0, chart_orientation_1.cellLabelGetterFromRangeReader)(getDomainValuesFromRange),
2694
+ });
2695
+ if (next)
2696
+ onUpdateChart(tslib_1.__assign(tslib_1.__assign({}, chart), { spec: next }));
2697
+ }
2698
+ : undefined;
2699
+ // The grid's right-click menu offers these without knowing the renderer.
2700
+ (0, spreadsheet_1.useRegisterChartActions)(chart.chartId, {
2701
+ requestEdit: onRequestEdit ? function () { return onRequestEdit(chart); } : undefined,
2702
+ downloadPng: onDownloadChart,
2703
+ exportPng: exportChartPng,
2704
+ switchRowColumn: switchRowColumnAction,
2705
+ });
2215
2706
  // Excel's "Rounded Corners" chart style (`<c:roundedCorners val="1"/>`
2216
2707
  // at the chartSpace root). Default per OOXML §21.2.2.183 is square,
2217
2708
  // so only opt in when the workbook explicitly set the flag — otherwise
@@ -2220,6 +2711,7 @@ var BasicChart = function (_a) {
2220
2711
  ? { borderRadius: 8, overflow: "hidden" }
2221
2712
  : undefined;
2222
2713
  return (react_1.default.createElement("div", { className: "flex flex-1", style: roundedCornersStyle },
2714
+ fieldButtons,
2223
2715
  isSelected ? (react_1.default.createElement(ui_1.DropdownMenu, null,
2224
2716
  react_1.default.createElement(ui_1.DropdownMenuTrigger, { asChild: true },
2225
2717
  react_1.default.createElement(ui_1.IconButton, { className: "absolute right-1 top-1 z-10" },