apexcharts 8.0.1 → 8.2.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 (267) hide show
  1. package/README.md +14 -8
  2. package/dist/apexcharts.common.js +2 -2
  3. package/dist/apexcharts.core.js +2310 -2274
  4. package/dist/apexcharts.core.min.js +2 -2
  5. package/dist/apexcharts.esm.js +1367 -1110
  6. package/dist/apexcharts.full.js +3880 -3531
  7. package/dist/apexcharts.full.min.js +2 -2
  8. package/dist/apexcharts.js +3676 -3409
  9. package/dist/apexcharts.min.js +2 -2
  10. package/dist/apexcharts.ssr.common.js +2 -2
  11. package/dist/apexcharts.ssr.esm.js +4114 -3591
  12. package/dist/area.common.js +2 -2
  13. package/dist/area.esm.js +25 -67
  14. package/dist/bar.common.js +2 -2
  15. package/dist/bar.esm.js +159 -163
  16. package/dist/bar.js +2 -2
  17. package/dist/boxPlot.common.js +2 -2
  18. package/dist/boxPlot.esm.js +125 -106
  19. package/dist/bubble.common.js +2 -2
  20. package/dist/bubble.esm.js +25 -67
  21. package/dist/candlestick.common.js +2 -2
  22. package/dist/candlestick.esm.js +125 -106
  23. package/dist/candlestick.js +2 -2
  24. package/dist/column.common.js +2 -2
  25. package/dist/column.esm.js +159 -163
  26. package/dist/core.common.js +2 -2
  27. package/dist/core.esm.js +2310 -2274
  28. package/dist/donut.common.js +2 -2
  29. package/dist/donut.esm.js +100 -78
  30. package/dist/dumbbell.common.js +2 -2
  31. package/dist/dumbbell.esm.js +192 -167
  32. package/dist/features/all.common.js +2 -2
  33. package/dist/features/all.esm.js +945 -640
  34. package/dist/features/annotations.common.js +2 -2
  35. package/dist/features/annotations.esm.js +46 -21
  36. package/dist/features/annotations.js +2 -2
  37. package/dist/features/context-menu.common.js +1 -1
  38. package/dist/features/context-menu.esm.js +1 -1
  39. package/dist/features/context-menu.js +1 -1
  40. package/dist/features/drilldown.common.js +2 -2
  41. package/dist/features/drilldown.esm.js +22 -2
  42. package/dist/features/drilldown.js +2 -2
  43. package/dist/features/dumbbell.common.js +2 -2
  44. package/dist/features/dumbbell.esm.js +34 -5
  45. package/dist/features/dumbbell.js +2 -2
  46. package/dist/features/exports.common.js +2 -2
  47. package/dist/features/exports.esm.js +203 -204
  48. package/dist/features/exports.js +2 -2
  49. package/dist/features/facet.common.js +1 -1
  50. package/dist/features/facet.esm.js +1 -1
  51. package/dist/features/facet.js +1 -1
  52. package/dist/features/highlight-filter.common.js +2 -2
  53. package/dist/features/highlight-filter.esm.js +97 -41
  54. package/dist/features/highlight-filter.js +2 -2
  55. package/dist/features/history.common.js +2 -2
  56. package/dist/features/history.esm.js +4 -3
  57. package/dist/features/history.js +2 -2
  58. package/dist/features/ink.common.js +1 -1
  59. package/dist/features/ink.esm.js +1 -1
  60. package/dist/features/ink.js +1 -1
  61. package/dist/features/keyboard.common.js +2 -2
  62. package/dist/features/keyboard.esm.js +20 -23
  63. package/dist/features/keyboard.js +2 -2
  64. package/dist/features/legend.common.js +2 -2
  65. package/dist/features/legend.esm.js +61 -41
  66. package/dist/features/legend.js +2 -2
  67. package/dist/features/link.common.js +2 -2
  68. package/dist/features/link.esm.js +8 -8
  69. package/dist/features/link.js +2 -2
  70. package/dist/features/marks.common.js +2 -2
  71. package/dist/features/marks.esm.js +1 -1
  72. package/dist/features/marks.js +1 -1
  73. package/dist/features/measure.common.js +1 -1
  74. package/dist/features/measure.esm.js +1 -1
  75. package/dist/features/measure.js +1 -1
  76. package/dist/features/morph.common.js +2 -2
  77. package/dist/features/morph.esm.js +260 -279
  78. package/dist/features/morph.js +2 -2
  79. package/dist/features/perspectives.common.js +2 -2
  80. package/dist/features/perspectives.esm.js +28 -19
  81. package/dist/features/perspectives.js +2 -2
  82. package/dist/features/raincloud.common.js +2 -2
  83. package/dist/features/raincloud.esm.js +54 -36
  84. package/dist/features/raincloud.js +2 -2
  85. package/dist/features/renderer-canvas.common.js +1 -1
  86. package/dist/features/renderer-canvas.esm.js +1 -1
  87. package/dist/features/renderer-canvas.js +1 -1
  88. package/dist/features/stats.common.js +2 -2
  89. package/dist/features/stats.esm.js +66 -18
  90. package/dist/features/stats.js +2 -2
  91. package/dist/features/storyboard.common.js +2 -2
  92. package/dist/features/storyboard.esm.js +24 -15
  93. package/dist/features/storyboard.js +2 -2
  94. package/dist/features/streamgraph.common.js +2 -2
  95. package/dist/features/streamgraph.esm.js +34 -5
  96. package/dist/features/streamgraph.js +2 -2
  97. package/dist/features/toolbar.common.js +2 -2
  98. package/dist/features/toolbar.esm.js +211 -217
  99. package/dist/features/toolbar.js +2 -2
  100. package/dist/features/trellis.common.js +2 -2
  101. package/dist/features/trellis.esm.js +31 -19
  102. package/dist/features/trellis.js +2 -2
  103. package/dist/features/waterfall.common.js +2 -2
  104. package/dist/features/waterfall.esm.js +34 -5
  105. package/dist/features/waterfall.js +2 -2
  106. package/dist/features/weave.common.js +2 -2
  107. package/dist/features/weave.esm.js +290 -48
  108. package/dist/features/weave.js +2 -2
  109. package/dist/full.common.js +2 -2
  110. package/dist/full.esm.js +289 -150
  111. package/dist/heatmap.common.js +2 -2
  112. package/dist/heatmap.esm.js +48 -17
  113. package/dist/heatmap.js +2 -2
  114. package/dist/histogram.common.js +2 -2
  115. package/dist/histogram.esm.js +224 -180
  116. package/dist/icicle.common.js +2 -2
  117. package/dist/icicle.esm.js +1 -1
  118. package/dist/icicle.js +1 -1
  119. package/dist/line.common.js +2 -2
  120. package/dist/line.esm.js +25 -67
  121. package/dist/line.js +2 -2
  122. package/dist/pictograms.common.js +1 -1
  123. package/dist/pictograms.esm.js +1 -1
  124. package/dist/pictograms.js +1 -1
  125. package/dist/pie.common.js +2 -2
  126. package/dist/pie.esm.js +100 -78
  127. package/dist/pie.js +2 -2
  128. package/dist/polarArea.common.js +2 -2
  129. package/dist/polarArea.esm.js +100 -78
  130. package/dist/radar.common.js +2 -2
  131. package/dist/radar.esm.js +8 -5
  132. package/dist/radar.js +2 -2
  133. package/dist/radialBar.common.js +2 -2
  134. package/dist/radialBar.esm.js +166 -133
  135. package/dist/radialBar.js +2 -2
  136. package/dist/raincloud.common.js +2 -2
  137. package/dist/raincloud.esm.js +55 -42
  138. package/dist/rangeArea.common.js +2 -2
  139. package/dist/rangeArea.esm.js +25 -67
  140. package/dist/rangeBar.common.js +2 -2
  141. package/dist/rangeBar.esm.js +159 -163
  142. package/dist/scatter.common.js +2 -2
  143. package/dist/scatter.esm.js +25 -67
  144. package/dist/streamgraph.common.js +2 -2
  145. package/dist/streamgraph.esm.js +58 -71
  146. package/dist/sunburst.common.js +2 -2
  147. package/dist/sunburst.esm.js +1 -1
  148. package/dist/sunburst.js +1 -1
  149. package/dist/treemap.common.js +2 -2
  150. package/dist/treemap.esm.js +28 -90
  151. package/dist/treemap.js +2 -2
  152. package/dist/unit-shapes.common.js +2 -2
  153. package/dist/unit-shapes.esm.js +1 -1
  154. package/dist/unit-shapes.js +1 -1
  155. package/dist/unit.common.js +2 -2
  156. package/dist/unit.esm.js +30 -6
  157. package/dist/unit.js +2 -2
  158. package/dist/violin.common.js +2 -2
  159. package/dist/violin.esm.js +2 -7
  160. package/dist/violin.js +2 -2
  161. package/dist/waterfall.common.js +2 -2
  162. package/dist/waterfall.esm.js +192 -167
  163. package/package.json +3 -1
  164. package/src/apexcharts.js +260 -201
  165. package/src/charts/Bar.js +16 -5
  166. package/src/charts/BarStacked.js +42 -88
  167. package/src/charts/BoxCandleStick.js +1 -7
  168. package/src/charts/HeatMap.js +73 -16
  169. package/src/charts/Line.js +21 -71
  170. package/src/charts/Pie.js +142 -89
  171. package/src/charts/Radar.js +4 -1
  172. package/src/charts/Radial.js +91 -63
  173. package/src/charts/RangeBar.js +1 -7
  174. package/src/charts/Treemap.js +25 -78
  175. package/src/charts/Unit.js +28 -10
  176. package/src/charts/Violin.js +1 -7
  177. package/src/charts/common/Hierarchy.js +0 -22
  178. package/src/charts/common/OuterLabels.js +12 -5
  179. package/src/charts/common/Stats.js +55 -28
  180. package/src/charts/common/bar/DataLabels.js +94 -83
  181. package/src/charts/common/bar/Helpers.js +34 -57
  182. package/src/charts/common/circle/Helpers.js +5 -2
  183. package/src/charts/common/treemap/Helpers.js +1 -1
  184. package/src/entries/full.js +0 -17
  185. package/src/features/link.js +9 -10
  186. package/src/features/perspectives.js +20 -19
  187. package/src/features/raincloud.js +51 -53
  188. package/src/features/stats.js +23 -35
  189. package/src/libs/Treemap-squared.js +7 -47
  190. package/src/modules/Animations.js +55 -73
  191. package/src/modules/Base.js +3 -2
  192. package/src/modules/ChartFactory.js +6 -1
  193. package/src/modules/Core.js +57 -30
  194. package/src/modules/CoreUtils.js +32 -33
  195. package/src/modules/Crosshairs.js +29 -11
  196. package/src/modules/Data.js +279 -153
  197. package/src/modules/DataLabels.js +18 -2
  198. package/src/modules/Events.js +1 -4
  199. package/src/modules/Exports.js +284 -305
  200. package/src/modules/Fill.js +23 -10
  201. package/src/modules/Formatters.js +14 -3
  202. package/src/modules/Graphics.js +8 -14
  203. package/src/modules/MorphPieces.js +4 -2
  204. package/src/modules/MorphTypeChange.js +332 -316
  205. package/src/modules/Range.js +56 -99
  206. package/src/modules/Responsive.js +186 -61
  207. package/src/modules/Scales.js +4 -47
  208. package/src/modules/Series.js +14 -45
  209. package/src/modules/Theme.js +108 -57
  210. package/src/modules/Toolbar.js +7 -13
  211. package/src/modules/accessibility/KeyboardNavigation.js +29 -28
  212. package/src/modules/animations/AxisTransition.js +54 -16
  213. package/src/modules/animations/CircleTransition.js +1 -4
  214. package/src/modules/animations/DataLabelTransition.js +15 -10
  215. package/src/modules/animations/StreamScroll.js +6 -4
  216. package/src/modules/annotations/Annotations.js +18 -17
  217. package/src/modules/annotations/Helpers.js +41 -17
  218. package/src/modules/axes/XAxis.js +4 -4
  219. package/src/modules/axes/YAxis.js +1 -6
  220. package/src/modules/dimensions/Dimensions.js +12 -7
  221. package/src/modules/dimensions/Grid.js +15 -3
  222. package/src/modules/dimensions/YAxis.js +7 -6
  223. package/src/modules/drilldown/Drilldown.js +22 -1
  224. package/src/modules/dumbbell/DumbbellData.js +3 -5
  225. package/src/modules/helpers/Destroy.js +10 -1
  226. package/src/modules/helpers/InitCtxVariables.js +19 -16
  227. package/src/modules/helpers/RawStash.js +51 -0
  228. package/src/modules/helpers/UpdateHelpers.js +95 -30
  229. package/src/modules/highlightFilter/HighlightFilter.js +107 -52
  230. package/src/modules/highlightFilter/PiePart.js +1 -1
  231. package/src/modules/highlightFilter/RadialPart.js +1 -1
  232. package/src/modules/history/History.js +7 -2
  233. package/src/modules/legend/Legend.js +100 -62
  234. package/src/modules/license/LicenseEnforcer.js +6 -1
  235. package/src/modules/settings/Config.js +60 -153
  236. package/src/modules/settings/Defaults.js +352 -58
  237. package/src/modules/settings/Globals.js +23 -5
  238. package/src/modules/settings/Options.js +19 -5
  239. package/src/modules/settings/TypeAliases.js +3 -6
  240. package/src/modules/streamgraph/StreamData.js +3 -5
  241. package/src/modules/tooltip/AxesTooltip.js +33 -41
  242. package/src/modules/tooltip/Intersect.js +50 -43
  243. package/src/modules/tooltip/Labels.js +62 -23
  244. package/src/modules/tooltip/Marker.js +6 -7
  245. package/src/modules/tooltip/Position.js +31 -35
  246. package/src/modules/tooltip/Tooltip.js +107 -119
  247. package/src/modules/tooltip/Utils.js +94 -159
  248. package/src/modules/trellis/TrellisExports.js +21 -9
  249. package/src/modules/trellis/TrellisTooltip.js +18 -8
  250. package/src/modules/waterfall/WaterfallData.js +3 -5
  251. package/src/modules/weave/Claims.js +14 -3
  252. package/src/modules/weave/Highlights.js +209 -0
  253. package/src/modules/weave/PluginAPI.js +64 -3
  254. package/src/modules/weave/WeaveHost.js +215 -51
  255. package/src/ssr/BrowserAPIs.js +5 -3
  256. package/src/ssr/DOMShim.js +6 -30
  257. package/src/ssr/Hydration.js +5 -36
  258. package/src/ssr/RenderShim.js +333 -0
  259. package/src/ssr/SSRRenderer.js +81 -36
  260. package/src/svg/SVGAnimation.js +10 -7
  261. package/src/types/internal.d.ts +37 -7
  262. package/src/utils/Constants.js +7 -8
  263. package/src/utils/DateTime.js +21 -195
  264. package/src/utils/MissingFeature.js +7 -9
  265. package/src/utils/Resize.js +4 -0
  266. package/src/utils/Utils.js +102 -171
  267. package/types/apexcharts.d.ts +57 -7
@@ -17,9 +17,21 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
20
32
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
33
  /*!
22
- * ApexCharts v8.0.1
34
+ * ApexCharts v8.2.0
23
35
  * (c) 2018-2026 ApexCharts
24
36
  */
25
37
  import * as _core from "apexcharts/core";
@@ -507,48 +519,58 @@ class Exports {
507
519
  return families;
508
520
  }
509
521
  /**
510
- * Every `@font-face` rule reachable from the document, as `{ family, css }`.
522
+ * Every `@font-face` rule reachable from the document, as
523
+ * `{ family, css, base }`, where `base` is the URL the rule's relative
524
+ * `url()`s resolve against: its stylesheet, not the page.
511
525
  *
512
- * Same-origin sheets are read through `cssRules`. A cross-origin sheet throws
513
- * on that access, so it is re-fetched by href and its `@font-face` blocks are
514
- * pulled out of the text: that is the path that matters in practice, since
515
- * hosted webfonts (the subject of #3617) are exactly the cross-origin case.
516
- * @returns {Promise<Array<{family: string, css: string}>>}
526
+ * Same-origin sheets are read through `cssRules`, descending into `@import`
527
+ * and grouping rules (`@media`, `@supports`, `@layer`). A cross-origin sheet
528
+ * throws on that access, so it is re-fetched by href and its `@font-face`
529
+ * blocks are pulled out of the text: that is the path that matters in
530
+ * practice, since hosted webfonts (the subject of #3617) are exactly the
531
+ * cross-origin case.
532
+ * @returns {Promise<Array<{family: string, css: string, base: string}>>}
517
533
  */
518
534
  collectFontFaceRules() {
519
535
  if (!Environment.isBrowser()) return Promise.resolve([]);
520
536
  const found = [];
521
537
  const remote = [];
522
- const pushFromText = (cssText) => {
538
+ const pushFromText = (cssText, base) => {
523
539
  const blocks = cssText.match(/@font-face\s*\{[^}]*\}/gi) || [];
524
540
  blocks.forEach((css) => {
525
541
  const m = css.match(/font-family\s*:\s*([^;}]+)/i);
526
542
  if (!m) return;
527
543
  const family = m[1].trim().replace(/^['"]|['"]$/g, "");
528
- found.push({ family: family.toLowerCase(), css });
544
+ found.push({ family: family.toLowerCase(), css, base });
545
+ });
546
+ };
547
+ const walkRules = (rules, base) => {
548
+ Array.from(rules).forEach((rule) => {
549
+ if (rule.type === 5) {
550
+ if (rule.cssText) pushFromText(rule.cssText, base);
551
+ } else if (rule.styleSheet) {
552
+ walkSheet(rule.styleSheet);
553
+ } else if (rule.cssRules) {
554
+ walkRules(rule.cssRules, base);
555
+ }
529
556
  });
530
557
  };
531
- const sheets = Array.from(document.styleSheets || []);
532
- sheets.forEach((sheet) => {
558
+ const walkSheet = (sheet) => {
533
559
  let rules = null;
534
560
  try {
535
561
  rules = sheet.cssRules;
536
562
  } catch (e) {
537
- rules = null;
538
563
  }
539
564
  if (rules) {
540
- Array.from(rules).forEach((rule) => {
541
- if (rule.type === 5 && rule.cssText) pushFromText(rule.cssText);
542
- });
543
- return;
544
- }
545
- if (sheet.href) {
565
+ walkRules(rules, sheet.href || document.baseURI);
566
+ } else if (sheet.href) {
546
567
  remote.push(
547
- fetch(sheet.href).then((r) => r.ok ? r.text() : "").then(pushFromText).catch(() => {
568
+ fetch(sheet.href).then((r) => r.ok ? r.text() : "").then((text) => pushFromText(text, sheet.href)).catch(() => {
548
569
  })
549
570
  );
550
571
  }
551
- });
572
+ };
573
+ Array.from(document.styleSheets || []).forEach(walkSheet);
552
574
  return Promise.all(remote).then(() => found);
553
575
  }
554
576
  /**
@@ -581,7 +603,7 @@ class Exports {
581
603
  if (!wanted.length) return Promise.resolve([]);
582
604
  return Promise.all(
583
605
  wanted.map(
584
- (face) => this.inlineFontFaceUrls(face.css).catch(() => null)
606
+ (face) => this.inlineFontFaceUrls(face.css, face.base).catch(() => null)
585
607
  )
586
608
  );
587
609
  }).then((cssBlocks) => {
@@ -598,9 +620,10 @@ class Exports {
598
620
  * data URI. Resolves to null if no url could be fetched, so the caller can
599
621
  * drop a block that would only reference unreachable files.
600
622
  * @param {string} css
623
+ * @param {string} [base] the URL relative `url()`s resolve against
601
624
  * @returns {Promise<string | null>}
602
625
  */
603
- inlineFontFaceUrls(css) {
626
+ inlineFontFaceUrls(css, base) {
604
627
  const urls = [];
605
628
  const re = /url\(\s*(['"]?)([^'")]+)\1\s*\)/gi;
606
629
  let m;
@@ -610,7 +633,7 @@ class Exports {
610
633
  if (!urls.length) return Promise.resolve(css.includes("data:") ? css : null);
611
634
  return Promise.all(
612
635
  urls.map(
613
- (url) => this.fetchAsDataUri(url).then((dataUri) => ({ url, dataUri })).catch(() => ({ url, dataUri: null }))
636
+ (url) => this.fetchAsDataUri(base ? new URL(url, base).href : url).then((dataUri) => ({ url, dataUri })).catch(() => ({ url, dataUri: null }))
614
637
  )
615
638
  ).then((results) => {
616
639
  let out = css;
@@ -671,6 +694,7 @@ class Exports {
671
694
  (_a = w.globals.layoutTween) == null ? void 0 : _a.finish();
672
695
  (_b = w.globals.circleTween) == null ? void 0 : _b.finish();
673
696
  (_c = w.globals.highlightTween) == null ? void 0 : _c.finish();
697
+ [...w.globals.chromeTweens || []].forEach((finish) => finish());
674
698
  const clonedNode = (
675
699
  /** @type {HTMLElement} */
676
700
  w.dom.elWrap.cloneNode(true)
@@ -777,19 +801,26 @@ class Exports {
777
801
  });
778
802
  }
779
803
  /**
804
+ * Resolves `{ imgURI: '' }` when the PNG cannot be made (no 2d context for
805
+ * a canvas that size, an SVG the browser will not decode, a tainted
806
+ * canvas), so a caller is never left waiting.
780
807
  * @param {Record<string, any> | undefined} options
781
808
  */
782
809
  dataURI(options) {
783
810
  if (Environment.isSSR()) return Promise.resolve({ imgURI: "" });
784
811
  return new Promise((resolve) => {
785
812
  const w = this.w;
813
+ const fail = () => {
814
+ console.warn("ApexCharts: the PNG export could not be rendered");
815
+ resolve({ imgURI: "" });
816
+ };
786
817
  const scale = options ? options.scale || options.width / w.globals.svgWidth : 1;
787
818
  const canvas = document.createElement("canvas");
788
819
  canvas.width = w.globals.svgWidth * scale;
789
820
  canvas.height = parseInt(w.dom.elWrap.style.height, 10) * scale;
790
821
  const canvasBg = this.resolveExportBackground();
791
822
  const ctx = canvas.getContext("2d");
792
- if (!ctx) return;
823
+ if (!ctx) return fail();
793
824
  ctx.fillStyle = canvasBg;
794
825
  ctx.fillRect(0, 0, canvas.width, canvas.height);
795
826
  this.getSvgString(scale).then((svgData) => {
@@ -797,18 +828,23 @@ class Exports {
797
828
  const img = new Image();
798
829
  img.crossOrigin = "anonymous";
799
830
  img.onload = () => {
800
- ctx.drawImage(img, 0, 0);
801
- const edgeCanvas = canvas;
802
- if (edgeCanvas.msToBlob) {
803
- const blob = edgeCanvas.msToBlob();
804
- resolve({ blob });
805
- } else {
806
- const imgURI = canvas.toDataURL("image/png");
807
- resolve({ imgURI });
831
+ try {
832
+ ctx.drawImage(img, 0, 0);
833
+ const edgeCanvas = canvas;
834
+ if (edgeCanvas.msToBlob) {
835
+ const blob = edgeCanvas.msToBlob();
836
+ resolve({ blob });
837
+ } else {
838
+ const imgURI = canvas.toDataURL("image/png");
839
+ resolve({ imgURI });
840
+ }
841
+ } catch (e) {
842
+ fail();
808
843
  }
809
844
  };
845
+ img.onerror = fail;
810
846
  img.src = svgUrl;
811
- });
847
+ }).catch(fail);
812
848
  });
813
849
  }
814
850
  exportToSVG() {
@@ -827,7 +863,7 @@ class Exports {
827
863
  this.dataURI(option).then(({ imgURI, blob }) => {
828
864
  if (blob) {
829
865
  navigator.msSaveOrOpenBlob(blob, this.w.globals.chartID + ".png");
830
- } else {
866
+ } else if (imgURI) {
831
867
  this.triggerDownload(
832
868
  imgURI,
833
869
  this.w.config.chart.toolbar.export.png.filename,
@@ -844,48 +880,54 @@ class Exports {
844
880
  lineDelimiter = "\n"
845
881
  }) {
846
882
  const w = this.w;
847
- if (!series) series = w.config.series;
848
- let columns = [];
883
+ const gl = w.globals;
884
+ const csvCfg = w.config.chart.toolbar.export.csv;
885
+ const raw = !series && (gl.streamgraphRawSeries || gl.waterfallRawSeries || gl.dumbbellRawSeries);
886
+ if (!series) series = raw || w.config.series;
887
+ const hidden = new Set(
888
+ raw && raw === gl.dumbbellRawSeries ? w.dumbbellData.hidden : gl.collapsedSeriesIndices
889
+ );
849
890
  const rows = [];
850
- let result = "";
851
- const universalBOM = "\uFEFF";
852
- const gSeries = w.seriesData.series.map((s, i) => {
853
- return w.globals.collapsedSeriesIndices.indexOf(i) === -1 ? s : [];
854
- });
891
+ const body = [];
892
+ const isDatetime = w.config.xaxis.type === "datetime";
893
+ const utc = w.config.xaxis.labels.datetimeUTC;
855
894
  const csvSafe = (val) => {
856
895
  if (val == null || Utils.isNumber(val)) return val;
857
896
  const s = String(val);
858
- return /^[=+\-@\t\r]/.test(s) ? `'${s}` : s;
897
+ return /^[=+\-@\t\r]/.test(s) && isNaN(+s) ? `'${s}` : s;
859
898
  };
860
- const getFormattedCategory = (cat) => {
861
- if (typeof w.config.chart.toolbar.export.csv.categoryFormatter === "function") {
862
- return w.config.chart.toolbar.export.csv.categoryFormatter(cat);
863
- }
864
- if (w.config.xaxis.type === "datetime" && String(cat).length >= 10) {
865
- return new Date(cat).toDateString();
899
+ const isDateCat = (cat) => isDatetime && String(cat).length >= 10 && !isNaN(new Date(cat).getTime());
900
+ const datetimeText = (cat, withTime2) => {
901
+ const d = new Date(cat);
902
+ if (!utc) d.setTime(d.getTime() - d.getTimezoneOffset() * 6e4);
903
+ if (withTime2) {
904
+ return d.toISOString().slice(0, 23).replace("T", " ").replace(".000", "");
905
+ }
906
+ const [day, date, month, year] = d.toUTCString().split(" ");
907
+ return `${day.slice(0, 3)} ${month} ${date} ${year}`;
908
+ };
909
+ const getFormattedCategory = (cat, withTime2) => {
910
+ if (typeof csvCfg.categoryFormatter === "function") {
911
+ return csvCfg.categoryFormatter(cat);
866
912
  }
867
- return Utils.isNumber(cat) ? cat : csvSafe(cat.split(columnDelimiter).join(""));
913
+ if (cat == null) return "";
914
+ if (isDateCat(cat)) return datetimeText(cat, withTime2);
915
+ return Utils.isNumber(cat) ? cat : csvSafe(String(cat).split(columnDelimiter).join(""));
868
916
  };
869
917
  const getFormattedValue = (value) => {
870
- return typeof w.config.chart.toolbar.export.csv.valueFormatter === "function" ? w.config.chart.toolbar.export.csv.valueFormatter(value) : csvSafe(value);
918
+ return typeof csvCfg.valueFormatter === "function" ? csvCfg.valueFormatter(value) : csvSafe(value);
871
919
  };
872
- const seriesMaxDataLength = Math.max(
873
- ...series.map((s) => {
874
- return s.data ? s.data.length : 0;
875
- })
876
- );
877
- const dataFormat = new Data(this.w);
878
920
  const axesUtils = new AxesUtils(this.w, {
879
921
  theme: this.ctx.theme,
880
922
  timeScale: this.ctx.timeScale
881
923
  });
882
924
  const getCat = (i) => {
883
925
  let cat = "";
884
- if (!w.globals.axisCharts) {
926
+ if (!gl.axisCharts) {
885
927
  cat = w.config.labels[i];
886
928
  } else {
887
929
  if (w.config.xaxis.type === "category" || w.config.xaxis.convertedCatToNumeric) {
888
- if (w.globals.isBarHorizontal) {
930
+ if (gl.isBarHorizontal) {
889
931
  const lbFormatter = w.formatters.yLabelFormatters[0];
890
932
  const sr = new Series(this.ctx.w);
891
933
  const activeSeries = sr.getActiveConfigSeriesIndex();
@@ -903,7 +945,7 @@ class Exports {
903
945
  ).text;
904
946
  }
905
947
  }
906
- if (w.config.xaxis.type === "datetime") {
948
+ if (isDatetime) {
907
949
  if (w.config.xaxis.categories.length) {
908
950
  cat = w.config.xaxis.categories[i];
909
951
  } else if (w.config.labels.length) {
@@ -911,159 +953,129 @@ class Exports {
911
953
  }
912
954
  }
913
955
  }
914
- if (cat === null) return "nullvalue";
915
- if (Array.isArray(cat)) {
916
- cat = cat.join(" ");
917
- }
918
- return Utils.isNumber(cat) ? cat : cat.split(columnDelimiter).join("");
919
- };
920
- const getEmptyDataForCsvColumn = () => {
921
- return [...Array(seriesMaxDataLength)].map(() => "");
956
+ return Array.isArray(cat) ? cat.join(" ") : cat;
922
957
  };
923
- const handleAxisRowsColumns = (s, sI) => {
924
- var _a, _b, _c, _d, _e, _f;
925
- if (columns.length && sI === 0) {
926
- rows.push(columns.join(columnDelimiter));
927
- }
928
- if (s.data) {
929
- const rowData = s.data.length ? s.data : getEmptyDataForCsvColumn();
930
- for (let i = 0; i < rowData.length; i++) {
931
- columns = [];
932
- let cat = getCat(i);
933
- if (cat === "nullvalue") continue;
934
- if (!cat) {
935
- if (dataFormat.isFormatXY()) {
936
- cat = series[sI].data[i].x;
937
- } else if (dataFormat.isFormat2DArray()) {
938
- cat = series[sI].data[i] ? series[sI].data[i][0] : "";
939
- }
940
- }
941
- if (sI === 0) {
942
- columns.push(getFormattedCategory(cat));
943
- for (let ci = 0; ci < w.seriesData.series.length; ci++) {
944
- const value = dataFormat.isFormatXY() ? (_a = series[ci].data[i]) == null ? void 0 : _a.y : gSeries[ci][i];
945
- columns.push(getFormattedValue(value));
946
- }
947
- }
948
- if (w.config.chart.type === "candlestick" || s.type && s.type === "candlestick") {
949
- columns.pop();
950
- columns.push(w.candleData.seriesCandleO[sI][i]);
951
- columns.push(w.candleData.seriesCandleH[sI][i]);
952
- columns.push(w.candleData.seriesCandleL[sI][i]);
953
- columns.push(w.candleData.seriesCandleC[sI][i]);
954
- }
955
- if (w.config.chart.type === "boxPlot" || s.type && s.type === "boxPlot") {
956
- columns.pop();
957
- columns.push(w.candleData.seriesCandleO[sI][i]);
958
- columns.push(w.candleData.seriesCandleH[sI][i]);
959
- columns.push(w.candleData.seriesCandleM[sI][i]);
960
- columns.push(w.candleData.seriesCandleL[sI][i]);
961
- columns.push(w.candleData.seriesCandleC[sI][i]);
962
- }
963
- if (w.config.chart.type === "rangeBar") {
964
- columns.pop();
965
- columns.push(w.rangeData.seriesRangeStart[sI][i]);
966
- columns.push(w.rangeData.seriesRangeEnd[sI][i]);
967
- }
968
- if (w.config.chart.type === "violin" || s.type && s.type === "violin") {
969
- columns.pop();
970
- columns.push((_b = w.violinData.seriesViolinMin[sI]) == null ? void 0 : _b[i]);
971
- columns.push((_c = w.violinData.seriesViolinMax[sI]) == null ? void 0 : _c[i]);
972
- columns.push((_f = (_e = (_d = w.violinData.seriesViolinPoints[sI]) == null ? void 0 : _d[i]) == null ? void 0 : _e.length) != null ? _f : 0);
973
- }
974
- if (columns.length) {
975
- rows.push(columns.join(columnDelimiter));
976
- }
977
- }
978
- }
979
- };
980
- const handleUnequalXValues = () => {
981
- const byCategory = /* @__PURE__ */ new Map();
982
- series.forEach((s, sI) => {
983
- s == null ? void 0 : s.data.forEach((dataItem) => {
984
- let cat, value;
985
- if (dataFormat.isFormatXY()) {
986
- cat = dataItem.x;
987
- value = dataItem.y;
988
- } else if (dataFormat.isFormat2DArray()) {
989
- cat = dataItem[0];
990
- value = dataItem[1];
991
- } else {
992
- return;
993
- }
994
- const key = String(cat);
995
- let row = byCategory.get(key);
996
- if (!row) {
997
- row = { cat, values: Array(series.length).fill("") };
998
- byCategory.set(key, row);
958
+ const cd = w.candleData;
959
+ const rd = w.rangeData;
960
+ const vd = w.violinData;
961
+ const multi = series.length > 1;
962
+ const cols = series.map((s, sI) => {
963
+ const type = raw ? "" : s.type || w.config.chart.type;
964
+ const fields = type === "candlestick" ? {
965
+ open: cd.seriesCandleO,
966
+ high: cd.seriesCandleH,
967
+ low: cd.seriesCandleL,
968
+ close: cd.seriesCandleC
969
+ } : type === "boxPlot" ? {
970
+ minimum: cd.seriesCandleO,
971
+ q1: cd.seriesCandleH,
972
+ median: cd.seriesCandleM,
973
+ q3: cd.seriesCandleL,
974
+ maximum: cd.seriesCandleC
975
+ } : type === "rangeBar" || type === "rangeArea" ? { minimum: rd.seriesRangeStart, maximum: rd.seriesRangeEnd } : type === "violin" ? {
976
+ minimum: vd.seriesViolinMin,
977
+ maximum: vd.seriesViolinMax,
978
+ observations: vd.seriesViolinPoints
979
+ } : null;
980
+ const name = String(s.name || `series-${sI}`).split(columnDelimiter).join("") || `series-${sI}`;
981
+ const keys = fields ? Object.keys(fields) : [name];
982
+ return {
983
+ head: fields && multi ? keys.map((k2) => `${name} ${k2}`) : keys,
984
+ /** @param {number} i */
985
+ cells: (i) => {
986
+ var _a;
987
+ const off = hidden.has(sI);
988
+ if (!fields) {
989
+ const d = off ? void 0 : (_a = s.data) == null ? void 0 : _a[i];
990
+ return [
991
+ getFormattedValue(
992
+ d && typeof d === "object" ? Array.isArray(d) ? d[1] : d.y : d
993
+ )
994
+ ];
999
995
  }
1000
- row.values[sI] = getFormattedValue(value);
1001
- });
1002
- });
1003
- if (columns.length) {
1004
- rows.push(columns.join(columnDelimiter));
1005
- }
1006
- Array.from(byCategory.values()).sort((a, b) => {
1007
- const aText = typeof a.cat === "string";
1008
- const bText = typeof b.cat === "string";
1009
- if (aText !== bText) return aText ? 1 : -1;
1010
- if (!aText) return a.cat - b.cat;
1011
- return a.cat < b.cat ? -1 : 1;
1012
- }).forEach(({ cat, values }) => {
1013
- rows.push([getFormattedCategory(cat), ...values].join(columnDelimiter));
1014
- });
1015
- };
1016
- columns.push(w.config.chart.toolbar.export.csv.headerCategory);
1017
- if (w.config.chart.type === "boxPlot") {
1018
- columns.push("minimum");
1019
- columns.push("q1");
1020
- columns.push("median");
1021
- columns.push("q3");
1022
- columns.push("maximum");
1023
- } else if (w.config.chart.type === "candlestick") {
1024
- columns.push("open");
1025
- columns.push("high");
1026
- columns.push("low");
1027
- columns.push("close");
1028
- } else if (w.config.chart.type === "rangeBar") {
1029
- columns.push("minimum");
1030
- columns.push("maximum");
1031
- } else if (w.config.chart.type === "violin") {
1032
- columns.push("minimum");
1033
- columns.push("maximum");
1034
- columns.push("observations");
1035
- } else {
1036
- series.map((s, sI) => {
1037
- const sname = (s.name ? s.name : `series-${sI}`) + "";
1038
- if (w.globals.axisCharts) {
1039
- columns.push(
1040
- sname.split(columnDelimiter).join("") ? sname.split(columnDelimiter).join("") : `series-${sI}`
1041
- );
996
+ return Object.values(fields).map((src) => {
997
+ var _a2;
998
+ const v = off ? void 0 : (_a2 = src == null ? void 0 : src[sI]) == null ? void 0 : _a2[i];
999
+ return getFormattedValue(Array.isArray(v) ? v.length : v);
1000
+ });
1042
1001
  }
1002
+ };
1003
+ });
1004
+ if (!gl.axisCharts) {
1005
+ rows.push(
1006
+ [csvCfg.headerCategory, csvCfg.headerValue].join(columnDelimiter)
1007
+ );
1008
+ series.forEach((_, sI) => {
1009
+ rows.push(
1010
+ [
1011
+ getFormattedCategory(w.labelData.labels[sI]),
1012
+ getFormattedValue(hidden.has(sI) ? "" : w.seriesData.series[sI])
1013
+ ].join(columnDelimiter)
1014
+ );
1043
1015
  });
1044
- }
1045
- if (!w.globals.axisCharts) {
1046
- columns.push(w.config.chart.toolbar.export.csv.headerValue);
1047
- rows.push(columns.join(columnDelimiter));
1048
- }
1049
- if (!w.globals.allSeriesHasEqualX && w.globals.axisCharts && !w.config.xaxis.categories.length && !w.config.labels.length) {
1050
- handleUnequalXValues();
1051
1016
  } else {
1052
- series.map((s, sI) => {
1053
- if (w.globals.axisCharts) {
1054
- handleAxisRowsColumns(s, sI);
1055
- } else {
1056
- columns = [];
1057
- columns.push(getFormattedCategory(w.labelData.labels[sI]));
1058
- columns.push(getFormattedValue(gSeries[sI]));
1059
- rows.push(columns.join(columnDelimiter));
1017
+ rows.push(
1018
+ [csvCfg.headerCategory, ...cols.flatMap((c) => c.head)].join(
1019
+ columnDelimiter
1020
+ )
1021
+ );
1022
+ if (!gl.allSeriesHasEqualX && !w.config.xaxis.categories.length && !w.config.labels.length) {
1023
+ const byCategory = /* @__PURE__ */ new Map();
1024
+ series.forEach((s, sI) => {
1025
+ var _a;
1026
+ (_a = s == null ? void 0 : s.data) == null ? void 0 : _a.forEach((d, i) => {
1027
+ if (!d || typeof d !== "object") return;
1028
+ const cat = Array.isArray(d) ? d[0] : d.x;
1029
+ const key = String(cat);
1030
+ let row = byCategory.get(key);
1031
+ if (!row) {
1032
+ row = { cat, values: cols.map((c) => c.head.map(() => "")) };
1033
+ byCategory.set(key, row);
1034
+ }
1035
+ row.values[sI] = cols[sI].cells(i);
1036
+ });
1037
+ });
1038
+ Array.from(byCategory.values()).sort((a, b) => {
1039
+ const aText = typeof a.cat === "string";
1040
+ const bText = typeof b.cat === "string";
1041
+ if (aText !== bText) return aText ? 1 : -1;
1042
+ if (!aText) return a.cat - b.cat;
1043
+ return w.axisFlags.isXNumeric ? a.cat < b.cat ? -1 : 1 : 0;
1044
+ }).forEach(({ cat, values }) => body.push([cat, ...values.flat()]));
1045
+ } else {
1046
+ const len = Math.max(
1047
+ 0,
1048
+ ...series.map((s) => {
1049
+ var _a;
1050
+ return ((_a = s.data) == null ? void 0 : _a.length) || 0;
1051
+ })
1052
+ );
1053
+ for (let i = 0; i < len; i++) {
1054
+ let cat = getCat(i);
1055
+ if (cat === null) continue;
1056
+ if (!cat) {
1057
+ const d = series.map((s) => {
1058
+ var _a;
1059
+ return (_a = s.data) == null ? void 0 : _a[i];
1060
+ }).find((d2) => d2 != null);
1061
+ cat = d == null ? "" : Array.isArray(d) ? d[0] : d.x;
1062
+ }
1063
+ body.push([cat, ...cols.flatMap((c) => c.cells(i))]);
1060
1064
  }
1061
- });
1065
+ }
1062
1066
  }
1063
- result += rows.join(lineDelimiter);
1067
+ const dates = body.map((r) => r[0]).filter(isDateCat);
1068
+ const withTime = new Set(dates.map((c) => datetimeText(c))).size < dates.length;
1069
+ body.forEach(
1070
+ (r) => rows.push(
1071
+ [getFormattedCategory(r[0], withTime), ...r.slice(1)].join(
1072
+ columnDelimiter
1073
+ )
1074
+ )
1075
+ );
1064
1076
  this.triggerDownload(
1065
- "data:text/csv; charset=utf-8," + encodeURIComponent(universalBOM + result),
1066
- fileName ? fileName : w.config.chart.toolbar.export.csv.filename,
1077
+ "data:text/csv; charset=utf-8," + encodeURIComponent("\uFEFF" + rows.join(lineDelimiter)),
1078
+ fileName ? fileName : csvCfg.filename,
1067
1079
  ".csv"
1068
1080
  );
1069
1081
  }
@@ -2317,6 +2329,9 @@ class HeatmapGradientLegend {
2317
2329
  return { min, max, stops, bands };
2318
2330
  }
2319
2331
  }
2332
+ function isLegendItem(el) {
2333
+ return el.classList.contains("apexcharts-legend-series") || el.classList.contains("apexcharts-legend-text") || el.classList.contains("apexcharts-legend-marker");
2334
+ }
2320
2335
  class Legend {
2321
2336
  /**
2322
2337
  * @param {import('../../types/internal').ChartStateW} w
@@ -2328,6 +2343,11 @@ class Legend {
2328
2343
  this.updateSeries = (...a) => ctx.updateHelpers._updateSeries(...a);
2329
2344
  this.onLegendClick = this.onLegendClick.bind(this);
2330
2345
  this.onLegendHovered = this.onLegendHovered.bind(this);
2346
+ this.onLegendClickEvent = this.onLegendClickEvent.bind(this);
2347
+ this.onLegendPointerDown = this.onLegendPointerDown.bind(this);
2348
+ this.onLegendPointerUp = this.onLegendPointerUp.bind(this);
2349
+ this.legendPress = null;
2350
+ this.recoveredRel = null;
2331
2351
  this.isBarsDistributed = this.w.config.chart.type === "bar" && this.w.config.plotOptions.bar.distributed && this.w.config.series.length === 1;
2332
2352
  this.legendHelpers = new Helpers$3(this);
2333
2353
  }
@@ -2417,16 +2437,7 @@ class Legend {
2417
2437
  pointFillColor: Array.isArray(fillcolor) ? fillcolor[i] : markerConfig.pointFillColor,
2418
2438
  shape
2419
2439
  }));
2420
- const shapesEls = w.dom.Paper.find(
2421
- ".apexcharts-legend-marker.apexcharts-marker"
2422
- );
2423
- shapesEls.forEach((shapeEl) => {
2424
- if (shapeEl.node.classList.contains("apexcharts-marker-triangle")) {
2425
- shapeEl.node.style.transform = "translate(50%, 45%)";
2426
- } else {
2427
- shapeEl.node.style.transform = "translate(50%, 50%)";
2428
- }
2429
- });
2440
+ marker.node.style.transform = shape === "triangle" ? "translate(50%, 45%)" : "translate(50%, 50%)";
2430
2441
  SVGMarker.add(marker);
2431
2442
  }
2432
2443
  return elMarker;
@@ -2541,20 +2552,9 @@ class Legend {
2541
2552
  elLegend.classList.add("apexcharts-hidden-null-series");
2542
2553
  }
2543
2554
  }
2544
- if (legendGroups.length) {
2545
- w.labelData.seriesGroups.forEach((group, gi) => {
2546
- var _a2, _b;
2547
- if (group.includes(
2548
- /** @type {Record<string,any>} */
2549
- (_b = (_a2 = w.config.series[i]) == null ? void 0 : _a2.name) != null ? _b : ""
2550
- )) {
2551
- elLegendWrap.appendChild(legendGroups[gi]);
2552
- legendGroups[gi].appendChild(elLegend);
2553
- }
2554
- });
2555
- } else {
2556
- elLegendWrap.appendChild(elLegend);
2557
- }
2555
+ const lg = legendGroups[w.labelData.seriesGroupIndex[i]];
2556
+ if (lg) elLegendWrap.appendChild(lg);
2557
+ (lg || elLegendWrap).appendChild(elLegend);
2558
2558
  elLegendWrap.classList.add(
2559
2559
  `apexcharts-align-${w.config.legend.horizontalAlign}`
2560
2560
  );
@@ -2577,7 +2577,9 @@ class Legend {
2577
2577
  elLegend.classList.add("apexcharts-no-click");
2578
2578
  }
2579
2579
  }
2580
- w.dom.elWrap.addEventListener("click", me.onLegendClick, true);
2580
+ w.dom.elWrap.addEventListener("click", me.onLegendClickEvent, true);
2581
+ w.dom.elWrap.addEventListener("pointerdown", me.onLegendPointerDown, true);
2582
+ w.dom.elWrap.addEventListener("pointerup", me.onLegendPointerUp, true);
2581
2583
  if (w.config.legend.onItemHover.highlightDataSeries && w.config.legend.customLegendItems.length === 0) {
2582
2584
  w.dom.elWrap.addEventListener("mousemove", me.onLegendHovered, true);
2583
2585
  w.dom.elWrap.addEventListener("mouseout", me.onLegendHovered, true);
@@ -2648,17 +2650,7 @@ class Legend {
2648
2650
  this.setLegendWrapXY(offsetX, offsetY);
2649
2651
  }
2650
2652
  legendAlignVertical() {
2651
- const w = this.w;
2652
- const lRect = this.legendHelpers.getLegendDimensions();
2653
- const offsetY = 20;
2654
- let offsetX = 0;
2655
- if (w.config.legend.position === "left") {
2656
- offsetX = 20;
2657
- }
2658
- if (w.config.legend.position === "right") {
2659
- offsetX = w.globals.svgWidth - lRect.clww - 10;
2660
- }
2661
- this.setLegendWrapXY(offsetX, offsetY);
2653
+ this.setLegendWrapXY(this.w.config.legend.position === "left" ? 20 : 0, 20);
2662
2654
  }
2663
2655
  /**
2664
2656
  * @param {MouseEvent} e
@@ -2670,7 +2662,7 @@ class Legend {
2670
2662
  /** @type {Element} */
2671
2663
  e.target
2672
2664
  );
2673
- const hoverOverLegend = target.classList.contains("apexcharts-legend-series") || target.classList.contains("apexcharts-legend-text") || target.classList.contains("apexcharts-legend-marker");
2665
+ const hoverOverLegend = isLegendItem(target);
2674
2666
  if (w.config.chart.type !== "heatmap" && !this.isBarsDistributed) {
2675
2667
  if (!target.classList.contains("apexcharts-inactive-legend") && hoverOverLegend) {
2676
2668
  const series = new Series(this.ctx.w);
@@ -2699,8 +2691,7 @@ class Legend {
2699
2691
  /** @type {Element} */
2700
2692
  e.target
2701
2693
  );
2702
- const isLegendItem = target.classList.contains("apexcharts-legend-series") || target.classList.contains("apexcharts-legend-text") || target.classList.contains("apexcharts-legend-marker");
2703
- if (!isLegendItem) return;
2694
+ if (!isLegendItem(target)) return;
2704
2695
  if (e.key === "Enter" || e.key === " ") {
2705
2696
  e.preventDefault();
2706
2697
  const rel = target.getAttribute("rel");
@@ -2715,6 +2706,47 @@ class Legend {
2715
2706
  }
2716
2707
  }
2717
2708
  }
2709
+ /**
2710
+ * @param {PointerEvent} e
2711
+ */
2712
+ onLegendPointerDown(e) {
2713
+ const target = (
2714
+ /** @type {Element} */
2715
+ e.target
2716
+ );
2717
+ this.recoveredRel = null;
2718
+ this.legendPress = e.button === 0 && isLegendItem(target) ? { el: target, rel: target.getAttribute("rel") } : null;
2719
+ }
2720
+ /**
2721
+ * @param {PointerEvent} e
2722
+ */
2723
+ onLegendPointerUp(e) {
2724
+ const press = this.legendPress;
2725
+ this.legendPress = null;
2726
+ const target = (
2727
+ /** @type {Element} */
2728
+ e.target
2729
+ );
2730
+ if (press && !press.el.isConnected && isLegendItem(target) && target.getAttribute("rel") === press.rel) {
2731
+ this.recoveredRel = press.rel;
2732
+ this.onLegendClick(e);
2733
+ }
2734
+ }
2735
+ /**
2736
+ * @param {MouseEvent} e
2737
+ */
2738
+ onLegendClickEvent(e) {
2739
+ const rel = this.recoveredRel;
2740
+ this.recoveredRel = null;
2741
+ const target = (
2742
+ /** @type {Element} */
2743
+ e.target
2744
+ );
2745
+ if (rel !== null && e.isTrusted && target.getAttribute("rel") === rel) {
2746
+ return;
2747
+ }
2748
+ this.onLegendClick(e);
2749
+ }
2718
2750
  /**
2719
2751
  * @param {Event} e
2720
2752
  */
@@ -2726,7 +2758,7 @@ class Legend {
2726
2758
  e.target
2727
2759
  );
2728
2760
  if (w.config.legend.customLegendItems.length) return;
2729
- if (target.classList.contains("apexcharts-legend-series") || target.classList.contains("apexcharts-legend-text") || target.classList.contains("apexcharts-legend-marker")) {
2761
+ if (isLegendItem(target)) {
2730
2762
  const seriesCnt = parseInt((_a = target.getAttribute("rel")) != null ? _a : "0", 10) - 1;
2731
2763
  const isHidden = target.getAttribute("data:collapsed") === "true";
2732
2764
  const legendClick = this.w.config.chart.events.legendClick;
@@ -2770,8 +2802,6 @@ class Toolbar {
2770
2802
  this.ev = this.w.config.chart.events;
2771
2803
  this.selectedClass = "apexcharts-selected";
2772
2804
  this.localeValues = this.w.globals.locale.toolbar;
2773
- this.minX = w.globals.minX;
2774
- this.maxX = w.globals.maxX;
2775
2805
  this.elZoom = null;
2776
2806
  this.elZoomIn = null;
2777
2807
  this.elZoomOut = null;
@@ -3151,14 +3181,14 @@ class Toolbar {
3151
3181
  charts.forEach((ch) => {
3152
3182
  const tb = ch.ctx.toolbar;
3153
3183
  const enabledType = type === "selection" ? "selectionEnabled" : "zoomEnabled";
3154
- const wasEnabled = !!ch.w.globals[enabledType];
3184
+ const wasEnabled = !!ch.w.interact[enabledType];
3155
3185
  tb.toggleOtherControls();
3156
3186
  const el = type === "selection" ? tb.elSelection : tb.elZoom;
3157
3187
  if (!wasEnabled) {
3158
- ch.w.globals[enabledType] = true;
3159
- el.classList.add(tb.selectedClass);
3188
+ ch.w.interact[enabledType] = true;
3189
+ el == null ? void 0 : el.classList.add(tb.selectedClass);
3160
3190
  }
3161
- el.setAttribute("aria-pressed", String(!!ch.w.globals[enabledType]));
3191
+ el == null ? void 0 : el.setAttribute("aria-pressed", String(!!ch.w.interact[enabledType]));
3162
3192
  });
3163
3193
  }
3164
3194
  /**
@@ -3216,14 +3246,15 @@ class Toolbar {
3216
3246
  togglePanning() {
3217
3247
  const charts = this.ctx.getSyncedCharts();
3218
3248
  charts.forEach((ch) => {
3249
+ var _a, _b;
3219
3250
  const tb = ch.ctx.toolbar;
3220
3251
  const wasEnabled = !!ch.w.interact.panEnabled;
3221
3252
  tb.toggleOtherControls();
3222
3253
  if (!wasEnabled) {
3223
3254
  ch.w.interact.panEnabled = true;
3224
- tb.elPan.classList.add(tb.selectedClass);
3255
+ (_a = tb.elPan) == null ? void 0 : _a.classList.add(tb.selectedClass);
3225
3256
  }
3226
- tb.elPan.setAttribute("aria-pressed", String(!!ch.w.interact.panEnabled));
3257
+ (_b = tb.elPan) == null ? void 0 : _b.setAttribute("aria-pressed", String(!!ch.w.interact.panEnabled));
3227
3258
  });
3228
3259
  }
3229
3260
  toggleOtherControls() {
@@ -3248,7 +3279,7 @@ class Toolbar {
3248
3279
  /**
3249
3280
  * Read the current x-range from globals at click time.
3250
3281
  * Toolbar instance is kept alive across updates (Phase 8 lazy
3251
- * instantiation), so cached this.minX/maxX go stale after a zoom.
3282
+ * instantiation), so a range cached on it would go stale after a zoom.
3252
3283
  * @returns {{minX: number, maxX: number}}
3253
3284
  */
3254
3285
  _currentXRange() {
@@ -3261,8 +3292,6 @@ class Toolbar {
3261
3292
  handleZoomIn() {
3262
3293
  const w = this.w;
3263
3294
  const { minX, maxX } = this._currentXRange();
3264
- this.minX = minX;
3265
- this.maxX = maxX;
3266
3295
  const centerX = (minX + maxX) / 2;
3267
3296
  const newMinX = (minX + centerX) / 2;
3268
3297
  const newMaxX = (maxX + centerX) / 2;
@@ -3274,8 +3303,6 @@ class Toolbar {
3274
3303
  handleZoomOut() {
3275
3304
  const w = this.w;
3276
3305
  const { minX, maxX } = this._currentXRange();
3277
- this.minX = minX;
3278
- this.maxX = maxX;
3279
3306
  if (w.config.xaxis.type === "datetime" && new Date(minX).getUTCFullYear() < 1e3) {
3280
3307
  return;
3281
3308
  }
@@ -4964,8 +4991,8 @@ let Helpers$2 = class Helpers2 {
4964
4991
  }
4965
4992
  /**
4966
4993
  * Does the x position take the category branch of `getX1X2` (a label lookup)
4967
- * rather than projecting through a numeric domain? Mirrors the conditions
4968
- * applied there, so the two cannot drift apart.
4994
+ * rather than projecting through a numeric domain? `getX1X2` and
4995
+ * `hasXDomain` both ask this, so the two cannot drift apart.
4969
4996
  *
4970
4997
  * @returns {boolean}
4971
4998
  */
@@ -5023,7 +5050,7 @@ let Helpers$2 = class Helpers2 {
5023
5050
  );
5024
5051
  yP = xLabel ? parseFloat((_a = xLabel.getAttribute("y")) != null ? _a : "0") : (w.layout.gridHeight / labels.length - 1) * (catIndex + 1) - w.globals.barHeight;
5025
5052
  if (anno.seriesIndex !== void 0 && w.globals.barHeight) {
5026
- yP -= w.globals.barHeight / 2 * (w.seriesData.series.length - 1) - w.globals.barHeight * anno.seriesIndex;
5053
+ yP += this.barSlotOffset(anno.seriesIndex, w.globals.barHeight);
5027
5054
  }
5028
5055
  } else {
5029
5056
  if (!w.config.yaxis[anno.yAxisIndex]) {
@@ -5076,10 +5103,8 @@ let Helpers$2 = class Helpers2 {
5076
5103
  return { x: 0, clipped: true };
5077
5104
  }
5078
5105
  let xP = this.annoCtx.inversedReversedAxis ? (max - x2) / (range / w.layout.gridWidth) : (x2 - min) / (range / w.layout.gridWidth);
5079
- if ((w.config.xaxis.type === "category" || w.config.xaxis.convertedCatToNumeric) && !this.annoCtx.invertAxis && !w.axisFlags.dataFormatXNumeric) {
5080
- if (!w.config.chart.sparkline.enabled) {
5081
- xP = this.getStringX(x2);
5082
- }
5106
+ if (this.usesCategoryX()) {
5107
+ xP = this.getStringX(x2);
5083
5108
  }
5084
5109
  if (typeof x2 === "string" && x2.includes("px")) {
5085
5110
  xP = parseFloat(x2);
@@ -5088,7 +5113,7 @@ let Helpers$2 = class Helpers2 {
5088
5113
  xP = w.layout.gridWidth;
5089
5114
  }
5090
5115
  if (anno.seriesIndex !== void 0 && w.globals.barWidth && !this.annoCtx.invertAxis) {
5091
- xP -= w.globals.barWidth / 2 * (w.seriesData.series.length - 1) - w.globals.barWidth * anno.seriesIndex;
5116
+ xP += this.barSlotOffset(anno.seriesIndex, w.globals.barWidth);
5092
5117
  }
5093
5118
  if (typeof xP !== "number") {
5094
5119
  xP = 0;
@@ -5103,6 +5128,34 @@ let Helpers$2 = class Helpers2 {
5103
5128
  }
5104
5129
  return { x: xP, clipped };
5105
5130
  }
5131
+ /**
5132
+ * Offset from a category's centre to the bar of series `i` in it. Bars
5133
+ * share the slot only among the series actually laid out side by side:
5134
+ * a stacked chart draws them all in one column, and a hidden series (empty
5135
+ * data) or a non-bar combo series takes no slot.
5136
+ * @param {number} i
5137
+ * @param {number} size bar width, or bar height when horizontal
5138
+ */
5139
+ barSlotOffset(i, size) {
5140
+ const w = this.w;
5141
+ if (w.config.chart.stacked) return 0;
5142
+ let n = 0;
5143
+ let ordinal = 0;
5144
+ w.seriesData.series.forEach(
5145
+ (s, si) => {
5146
+ var _a;
5147
+ const type = (
5148
+ /** @type {any} */
5149
+ (_a = w.config.series[si]) == null ? void 0 : _a.type
5150
+ );
5151
+ if (s.length && (!w.globals.comboCharts || type === "bar" || type === "column")) {
5152
+ if (si < i) ordinal++;
5153
+ n++;
5154
+ }
5155
+ }
5156
+ );
5157
+ return size * (ordinal - (n - 1) / 2);
5158
+ }
5106
5159
  /**
5107
5160
  * @param {number} x
5108
5161
  */
@@ -5124,6 +5177,8 @@ let Helpers$2 = class Helpers2 {
5124
5177
  );
5125
5178
  if (xLabel) {
5126
5179
  rX = parseFloat((_a = xLabel.getAttribute("x")) != null ? _a : "0");
5180
+ } else if (catIndex > -1) {
5181
+ rX = w.axisFlags.isXNumeric ? (x2 - w.globals.minX) / (w.globals.xRange / w.layout.gridWidth) : w.globals.padHorizontal + (catIndex + 0.5) * w.layout.gridWidth / w.globals.dataPoints;
5127
5182
  }
5128
5183
  return rX;
5129
5184
  }
@@ -5682,7 +5737,6 @@ class Annotations {
5682
5737
  if (this.w.globals.isBarHorizontal && this.w.config.yaxis[0].reversed) {
5683
5738
  this.inversedReversedAxis = true;
5684
5739
  }
5685
- this.xDivision = this.w.layout.gridWidth / this.w.globals.dataPoints;
5686
5740
  }
5687
5741
  drawAxesAnnotations() {
5688
5742
  const w = this.w;
@@ -5773,6 +5827,8 @@ class Annotations {
5773
5827
  paddingTop = 2
5774
5828
  } = params;
5775
5829
  const w = this.w;
5830
+ const parent = w.dom.baseEl.querySelector(appendTo);
5831
+ if (!parent) return;
5776
5832
  const elText = this.graphics.drawText({
5777
5833
  x: x2,
5778
5834
  y,
@@ -5782,12 +5838,9 @@ class Annotations {
5782
5838
  fontWeight: fontWeight || "regular",
5783
5839
  fontFamily: fontFamily || w.config.chart.fontFamily,
5784
5840
  foreColor: foreColor || w.config.chart.foreColor,
5785
- cssClass: "apexcharts-text " + cssClass ? cssClass : ""
5841
+ cssClass: cssClass || ""
5786
5842
  });
5787
- const parent = w.dom.baseEl.querySelector(appendTo);
5788
- if (parent) {
5789
- parent.appendChild(elText.node);
5790
- }
5843
+ parent.appendChild(elText.node);
5791
5844
  const textRect = elText.bbox();
5792
5845
  if (text) {
5793
5846
  const elRect = this.graphics.drawRect(
@@ -5883,10 +5936,11 @@ class Annotations {
5883
5936
  type,
5884
5937
  contextMethod
5885
5938
  }) {
5939
+ var _a;
5886
5940
  const me = context;
5887
5941
  const w = me.w;
5888
5942
  const parent = w.dom.baseEl.querySelector(`.apexcharts-${type}-annotations`);
5889
- const index = parent.childNodes.length + 1;
5943
+ const index = (((_a = w.config.annotations[type === "point" ? "points" : type]) == null ? void 0 : _a.length) || 0) + parent.childNodes.length;
5890
5944
  const options = new Options();
5891
5945
  const axesAnno = Object.assign(
5892
5946
  {},
@@ -5968,11 +6022,9 @@ class Annotations {
5968
6022
  this._removeAnnotationTooltip(w);
5969
6023
  const annos = w.dom.baseEl.querySelectorAll(`.${id}`);
5970
6024
  if (annos) {
5971
- w.globals.memory.methodsToExec.map((m, i) => {
5972
- if (m.id === id) {
5973
- w.globals.memory.methodsToExec.splice(i, 1);
5974
- }
5975
- });
6025
+ w.globals.memory.methodsToExec = w.globals.memory.methodsToExec.filter(
6026
+ (m) => m.id !== id
6027
+ );
5976
6028
  Object.keys(w.config.annotations).forEach((key) => {
5977
6029
  const annotationArray = w.config.annotations[key];
5978
6030
  if (Array.isArray(annotationArray)) {
@@ -5998,6 +6050,7 @@ class KeyboardNavigation {
5998
6050
  this.dataPointIndex = 0;
5999
6051
  this.active = false;
6000
6052
  this._tooltipDismissed = false;
6053
+ this._announceTimer = void 0;
6001
6054
  this._focusedEl = null;
6002
6055
  this._hoveredBarEl = null;
6003
6056
  this._enlargedScatterMarker = null;
@@ -6038,6 +6091,7 @@ class KeyboardNavigation {
6038
6091
  const w = this.w;
6039
6092
  const svgEl = w.dom.Paper && w.dom.Paper.node;
6040
6093
  this.ctx.events.removeEventListener("legendClick", this._onLegendClick);
6094
+ clearTimeout(this._announceTimer);
6041
6095
  if (!svgEl) return;
6042
6096
  svgEl.removeEventListener("focus", this._onFocus);
6043
6097
  svgEl.removeEventListener("blur", this._onBlur);
@@ -6081,15 +6135,6 @@ class KeyboardNavigation {
6081
6135
  notePointerFocus() {
6082
6136
  this._lastPointerDownAt = Date.now();
6083
6137
  }
6084
- /**
6085
- * Called from Events.js keydown handler. Navigation keys are already handled
6086
- * by the direct SVG listener (which can call preventDefault). This entry
6087
- * point is intentionally a no-op — Events.js still fires the public keyDown
6088
- * callback and fireEvent('keydown') independently.
6089
- * @param {Event} _e
6090
- */
6091
- handleKey(_e) {
6092
- }
6093
6138
  // ─── Focus / blur ─────────────────────────────────────────────────────────
6094
6139
  _onFocus() {
6095
6140
  if (!this._isNavEnabled()) return;
@@ -6198,9 +6243,11 @@ class KeyboardNavigation {
6198
6243
  }
6199
6244
  // ─── Zoom / pan (keyboard alternatives for drag gestures) ─────────────────
6200
6245
  _canZoom() {
6246
+ var _a, _b;
6201
6247
  const w = this.w;
6248
+ const r = (_a = this.ctx.toolbar) == null ? void 0 : _a._currentXRange();
6202
6249
  return Boolean(
6203
- w.globals.axisCharts && w.config.chart.zoom && w.config.chart.zoom.enabled
6250
+ w.globals.axisCharts && ((_b = w.config.chart.zoom) == null ? void 0 : _b.enabled) && (w.axisFlags.isXNumeric || w.config.xaxis.convertedCatToNumeric || w.axisFlags.isRangeBar) && (r == null ? void 0 : r.minX) < (r == null ? void 0 : r.maxX)
6204
6251
  );
6205
6252
  }
6206
6253
  _canPan() {
@@ -6211,11 +6258,11 @@ class KeyboardNavigation {
6211
6258
  * @param {number} direction +1 = right, -1 = left
6212
6259
  */
6213
6260
  _panBy(direction) {
6214
- const w = this.w;
6215
6261
  const toolbar = this.ctx.toolbar;
6216
6262
  if (!toolbar) return;
6217
- const minX = Number(w.globals.minX);
6218
- const maxX = Number(w.globals.maxX);
6263
+ const r = toolbar._currentXRange();
6264
+ const minX = Number(r.minX);
6265
+ const maxX = Number(r.maxX);
6219
6266
  if (!isFinite(minX) || !isFinite(maxX) || minX === maxX) return;
6220
6267
  const span = maxX - minX;
6221
6268
  const step = span * 0.1 * direction;
@@ -6244,14 +6291,15 @@ class KeyboardNavigation {
6244
6291
  dSeries = -dSeries;
6245
6292
  }
6246
6293
  const total = this._getSeriesCount();
6247
- let si = this.seriesIndex + dSeries;
6248
- let attempts = 0;
6249
- while (attempts < total) {
6250
- if (si < 0) si = wrapAround ? total - 1 : 0;
6251
- if (si >= total) si = wrapAround ? 0 : total - 1;
6252
- if (!w.globals.collapsedSeriesIndices.includes(si)) break;
6253
- si += dSeries;
6254
- attempts++;
6294
+ let si = this.seriesIndex;
6295
+ for (let k2 = 1; k2 < total; k2++) {
6296
+ let c = si + dSeries * k2;
6297
+ if (wrapAround) c = (c + total) % total;
6298
+ else if (c < 0 || c >= total) break;
6299
+ if (!w.globals.collapsedSeriesIndices.includes(c)) {
6300
+ si = c;
6301
+ break;
6302
+ }
6255
6303
  }
6256
6304
  this.seriesIndex = si;
6257
6305
  const dpCount = this._getDataPointCount(si);
@@ -7358,7 +7406,8 @@ class KeyboardNavigation {
7358
7406
  const region = baseEl.querySelector(".apexcharts-sr-status");
7359
7407
  if (!region) return;
7360
7408
  region.textContent = "";
7361
- setTimeout(() => {
7409
+ clearTimeout(this._announceTimer);
7410
+ this._announceTimer = setTimeout(() => {
7362
7411
  region.textContent = message;
7363
7412
  }, 0);
7364
7413
  }
@@ -7544,7 +7593,7 @@ function makeColorLerp(from, to) {
7544
7593
  function easeInOutCubic(t) {
7545
7594
  return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
7546
7595
  }
7547
- function runPieceTween({ pieces, duration, onPieceDone, onAllDone }) {
7596
+ function runPieceTween({ pieces, duration, onPieceDone, onAllDone, alive }) {
7548
7597
  let cancelled = false;
7549
7598
  const start = Date.now();
7550
7599
  const dur = Math.max(1, duration);
@@ -7561,7 +7610,7 @@ function runPieceTween({ pieces, duration, onPieceDone, onAllDone }) {
7561
7610
  else if (e >= 1 && p.fillEnd) el.setAttribute("fill", p.fillEnd);
7562
7611
  };
7563
7612
  const frame = () => {
7564
- if (cancelled) return;
7613
+ if (cancelled || alive && !alive()) return;
7565
7614
  const elapsed = Date.now() - start;
7566
7615
  let live = false;
7567
7616
  for (let k2 = 0; k2 < pieces.length; k2++) {
@@ -7594,8 +7643,13 @@ const UNIT_FAMILY = /* @__PURE__ */ new Set(["unit", "waffle"]);
7594
7643
  const PARTITION_FAMILY = /* @__PURE__ */ new Set(["treemap", "sunburst"]);
7595
7644
  const SUMMARY_FAMILY = /* @__PURE__ */ new Set(["boxPlot", "violin"]);
7596
7645
  const GHOST_FADE_FRACTION = 0.55;
7646
+ let ghostSeq = 0;
7597
7647
  const PIECE_BUDGET = 1500;
7598
7648
  const PIECE_STAGGER_MAX = 300;
7649
+ const reveal = (el) => {
7650
+ el.removeAttribute("opacity");
7651
+ el.removeAttribute("data-piece-hidden");
7652
+ };
7599
7653
  function familyOf(type) {
7600
7654
  if (BAR_FAMILY.has(type)) return "bar";
7601
7655
  if (RADIAL_FAMILY.has(type)) return "radial";
@@ -7617,6 +7671,7 @@ class MorphTypeChange {
7617
7671
  this._ghost = null;
7618
7672
  this._pieceLayer = null;
7619
7673
  this._pieceCancel = null;
7674
+ this._ghostTimer = void 0;
7620
7675
  }
7621
7676
  /**
7622
7677
  * @param {string} fromType
@@ -7723,7 +7778,9 @@ class MorphTypeChange {
7723
7778
  if (tf === "unit" && pieceFamilies) {
7724
7779
  const total = this._countUnitSeries(newSeries);
7725
7780
  this._snapshot.pieceOut = total > 0 && total <= PIECE_BUDGET;
7726
- } else if (ff === "unit" && (tf === "bar" || tf === "summary" || tf === "radial" && canShape)) {
7781
+ } else if (ff === "unit" && (tf === "bar" || tf === "summary" || // Only slices can be tiled: a radialBar ring is a stroked arc the
7782
+ // target collector does not read, so it keeps the ghost fade.
7783
+ tf === "radial" && canShape && !/^(radialBar|gauge)$/.test(toType))) {
7727
7784
  let total = 0;
7728
7785
  unitDots.forEach((list) => {
7729
7786
  total += list.length;
@@ -7731,24 +7788,7 @@ class MorphTypeChange {
7731
7788
  if (total > 0 && total <= PIECE_BUDGET) {
7732
7789
  this._snapshot.pieceIn = true;
7733
7790
  this._snapshot.sourceDots = unitDots;
7734
- const keyOrder = [];
7735
- if (tf === "radial") {
7736
- (Array.isArray(newSeries) ? newSeries : []).forEach(
7737
- (_v, i) => {
7738
- keyOrder.push(`${i}:0`);
7739
- }
7740
- );
7741
- } else {
7742
- (Array.isArray(newSeries) ? newSeries : []).forEach(
7743
- (s, seriesIdx) => {
7744
- const data = s && Array.isArray(s.data) ? s.data : [];
7745
- for (let j = 0; j < data.length; j++) {
7746
- keyOrder.push(`${seriesIdx}:${j}`);
7747
- }
7748
- }
7749
- );
7750
- }
7751
- this._snapshot.keyOrder = keyOrder;
7791
+ this._snapshot.keyOrder = this._targetKeys(tf, newSeries);
7752
7792
  }
7753
7793
  }
7754
7794
  if (this._needsGhost(fromType, toType) && !this._snapshot.pieceOut && !this._snapshot.pieceIn) {
@@ -7802,9 +7842,8 @@ class MorphTypeChange {
7802
7842
  const drop = [
7803
7843
  ".apexcharts-xaxis",
7804
7844
  ".apexcharts-yaxis",
7845
+ // (the gridlines go with it)
7805
7846
  ".apexcharts-grid",
7806
- ".apexcharts-gridlines-horizontal",
7807
- ".apexcharts-gridlines-vertical",
7808
7847
  ".apexcharts-legend",
7809
7848
  ".apexcharts-title-text",
7810
7849
  ".apexcharts-subtitle-text",
@@ -7817,13 +7856,25 @@ class MorphTypeChange {
7817
7856
  if (typeof clone.querySelectorAll === "function") {
7818
7857
  drop.forEach((sel) => {
7819
7858
  clone.querySelectorAll(sel).forEach((el) => {
7820
- if (el.parentNode) el.parentNode.removeChild(el);
7859
+ el.remove();
7821
7860
  });
7822
7861
  });
7823
7862
  }
7824
7863
  if (typeof clone.querySelectorAll === "function") {
7864
+ const tag = `-ghost${++ghostSeq}`;
7865
+ const ids = /* @__PURE__ */ new Set();
7825
7866
  clone.querySelectorAll("[id]").forEach((el) => {
7826
- el.removeAttribute("id");
7867
+ ids.add(el.id);
7868
+ el.id += tag;
7869
+ });
7870
+ clone.querySelectorAll("*").forEach((el) => {
7871
+ for (const a of el.attributes) {
7872
+ const v = a.value.replace(
7873
+ /(url\(['"]?#|^#)([^'")\s]+)/g,
7874
+ (m, pre, id) => ids.has(id) ? pre + id + tag : m
7875
+ );
7876
+ if (v !== a.value) a.value = v;
7877
+ }
7827
7878
  });
7828
7879
  }
7829
7880
  (_b = clone.removeAttribute) == null ? void 0 : _b.call(clone, "id");
@@ -7873,13 +7924,14 @@ class MorphTypeChange {
7873
7924
  style.transition = `opacity ${fade}ms ease-in`;
7874
7925
  style.opacity = "0";
7875
7926
  });
7876
- setTimeout(() => this._removeGhost(), fade + 60);
7927
+ this._ghostTimer = setTimeout(() => this._removeGhost(), fade + 60);
7877
7928
  }
7878
7929
  /** Detach the ghost if one is mounted. Safe to call at any time. */
7879
7930
  _removeGhost() {
7931
+ clearTimeout(this._ghostTimer);
7880
7932
  const ghost = this._ghost;
7881
7933
  this._ghost = null;
7882
- if (ghost && ghost.parentNode) ghost.parentNode.removeChild(ghost);
7934
+ ghost == null ? void 0 : ghost.remove();
7883
7935
  }
7884
7936
  /* ------------------------------------------------------------------ *
7885
7937
  * The piece layer (see MorphPieces for the geometry).
@@ -7959,12 +8011,7 @@ class MorphTypeChange {
7959
8011
  var _a;
7960
8012
  const baseEl = (_a = this.w.globals.dom) == null ? void 0 : _a.baseEl;
7961
8013
  if (!baseEl || typeof baseEl.querySelectorAll !== "function") return;
7962
- baseEl.querySelectorAll("[data-piece-hidden]").forEach(
7963
- (el) => {
7964
- el.removeAttribute("opacity");
7965
- el.removeAttribute("data-piece-hidden");
7966
- }
7967
- );
8014
+ baseEl.querySelectorAll("[data-piece-hidden]").forEach(reveal);
7968
8015
  }
7969
8016
  /** Stop the piece run, drop the overlay, and reveal anything still hidden. */
7970
8017
  _cancelPieces() {
@@ -7974,7 +8021,7 @@ class MorphTypeChange {
7974
8021
  }
7975
8022
  const layer = this._pieceLayer;
7976
8023
  this._pieceLayer = null;
7977
- if (layer && layer.parentNode) layer.parentNode.removeChild(layer);
8024
+ layer == null ? void 0 : layer.remove();
7978
8025
  this._revealPieceHidden();
7979
8026
  }
7980
8027
  /**
@@ -8100,7 +8147,7 @@ class MorphTypeChange {
8100
8147
  return {
8101
8148
  intervalsAt,
8102
8149
  dispose: () => {
8103
- if (probe.parentNode) probe.parentNode.removeChild(probe);
8150
+ probe.remove();
8104
8151
  }
8105
8152
  };
8106
8153
  }
@@ -8116,35 +8163,10 @@ class MorphTypeChange {
8116
8163
  const snap = this._snapshot;
8117
8164
  const baseEl = (_a = this.w.globals.dom) == null ? void 0 : _a.baseEl;
8118
8165
  if (!snap || !baseEl) return this._revealPieceHidden();
8119
- const byCluster = /* @__PURE__ */ new Map();
8166
+ const byCluster = this._readUnitDots(baseEl, /* @__PURE__ */ new Map());
8120
8167
  let total = 0;
8121
- baseEl.querySelectorAll(".apexcharts-unit-area").forEach((dot) => {
8122
- var _a2, _b, _c, _d, _e, _f, _g;
8123
- const i = parseInt((_a2 = dot.getAttribute("i")) != null ? _a2 : "", 10);
8124
- if (isNaN(i)) return;
8125
- const cxAttr = dot.getAttribute("cx");
8126
- let x2;
8127
- let y;
8128
- let r = 3;
8129
- if (cxAttr != null) {
8130
- x2 = parseFloat(cxAttr);
8131
- y = parseFloat((_b = dot.getAttribute("cy")) != null ? _b : "");
8132
- r = parseFloat((_c = dot.getAttribute("r")) != null ? _c : "3") || 3;
8133
- } else {
8134
- const wAttr = parseFloat((_d = dot.getAttribute("width")) != null ? _d : "0") || 0;
8135
- const hAttr = parseFloat((_e = dot.getAttribute("height")) != null ? _e : "0") || 0;
8136
- x2 = parseFloat((_f = dot.getAttribute("x")) != null ? _f : "") + wAttr / 2;
8137
- y = parseFloat((_g = dot.getAttribute("y")) != null ? _g : "") + hAttr / 2;
8138
- r = Math.max(wAttr, hAttr) / 2 || 3;
8139
- }
8140
- if (!isFinite(x2) || !isFinite(y)) return;
8141
- let list = byCluster.get(i);
8142
- if (!list) {
8143
- list = [];
8144
- byCluster.set(i, list);
8145
- }
8146
- list.push({ el: dot, x: x2, y, r, fill: dot.getAttribute("fill") });
8147
- total++;
8168
+ byCluster.forEach((list) => {
8169
+ total += list.length;
8148
8170
  });
8149
8171
  if (total === 0 || total > PIECE_BUDGET) return this._revealPieceHidden();
8150
8172
  const layer = this._makePieceLayer();
@@ -8162,10 +8184,7 @@ class MorphTypeChange {
8162
8184
  const box = this.getInitialBBoxFor(i);
8163
8185
  const entry = snap.mapping.get(`${i}:0`);
8164
8186
  if (!box || !entry) {
8165
- dots.forEach((d) => {
8166
- d.el.removeAttribute("opacity");
8167
- d.el.removeAttribute("data-piece-hidden");
8168
- });
8187
+ dots.forEach((d) => reveal(d.el));
8169
8188
  return;
8170
8189
  }
8171
8190
  const markFill = entry.fill && entry.fill.indexOf("url(") !== 0 ? entry.fill : ((_a2 = this.w.globals.colors) == null ? void 0 : _a2[i]) || dots[0].fill;
@@ -8186,6 +8205,7 @@ class MorphTypeChange {
8186
8205
  const dot = ordered[k2];
8187
8206
  const el = doc.createElementNS("http://www.w3.org/2000/svg", "rect");
8188
8207
  el.setAttribute("data-i", String(i));
8208
+ el.setAttribute("data-key", dot.el.getAttribute("data-key"));
8189
8209
  el.setAttribute("x", String(cell.x));
8190
8210
  el.setAttribute("y", String(cell.y));
8191
8211
  el.setAttribute("width", String(cell.width));
@@ -8212,12 +8232,36 @@ class MorphTypeChange {
8212
8232
  });
8213
8233
  if (!pieces.length) return this._cancelPieces();
8214
8234
  this._runPieces(pieces, (piece) => {
8215
- const dotEl = piece.meta.dotEl;
8216
- dotEl.removeAttribute("opacity");
8217
- dotEl.removeAttribute("data-piece-hidden");
8218
- if (piece.el.parentNode) piece.el.parentNode.removeChild(piece.el);
8235
+ reveal(piece.meta.dotEl);
8236
+ piece.el.remove();
8219
8237
  });
8220
8238
  }
8239
+ /**
8240
+ * The unit chart's dots, grouped by cluster index into `into`. Circles
8241
+ * carry cx/cy; square and image dots carry their top-left x/y.
8242
+ *
8243
+ * @param {any} baseEl
8244
+ * @param {Map<number, any[]>} into - each dot as {el, x, y, r, fill}
8245
+ */
8246
+ _readUnitDots(baseEl, into) {
8247
+ baseEl.querySelectorAll(".apexcharts-unit-area").forEach((dot) => {
8248
+ var _a;
8249
+ const i = parseInt((_a = dot.getAttribute("i")) != null ? _a : "", 10);
8250
+ if (isNaN(i)) return;
8251
+ const num = (a) => parseFloat(dot.getAttribute(a));
8252
+ const cx = dot.getAttribute("cx");
8253
+ const w = num("width") || 0;
8254
+ const h = num("height") || 0;
8255
+ const x2 = cx != null ? parseFloat(cx) : num("x") + w / 2;
8256
+ const y = cx != null ? num("cy") : num("y") + h / 2;
8257
+ const r = (cx != null ? num("r") : Math.max(w, h) / 2) || 3;
8258
+ if (!isFinite(x2) || !isFinite(y)) return;
8259
+ let list = into.get(i);
8260
+ if (!list) into.set(i, list = []);
8261
+ list.push({ el: dot, x: x2, y, r, fill: dot.getAttribute("fill") });
8262
+ });
8263
+ return into;
8264
+ }
8221
8265
  /**
8222
8266
  * objects -> mark. Each captured outgoing dot flies to one cell of the
8223
8267
  * incoming mark, squaring off and blending towards the mark's fill; the
@@ -8247,36 +8291,32 @@ class MorphTypeChange {
8247
8291
  /** @type {any[]} */
8248
8292
  snap.sourceDots.get(clusterIdx[k2])
8249
8293
  );
8250
- const key = snap.keyOrder[k2];
8251
- const target = key ? targets.get(key) : null;
8252
- if (!target || !dots || !dots.length) {
8253
- if (target) {
8254
- target.els.forEach((el) => {
8255
- el.removeAttribute("opacity");
8256
- el.removeAttribute("data-piece-hidden");
8257
- });
8258
- }
8294
+ const key = snap.keyOrder[clusterIdx[k2]];
8295
+ const target = (
8296
+ /** @type {any} */
8297
+ key ? targets.get(key) : null
8298
+ );
8299
+ const d = target && this._markD(target);
8300
+ const b = d && this._pathBBox(d);
8301
+ if (!b || !dots || !dots.length) {
8302
+ if (target) target.els.forEach(reveal);
8259
8303
  continue;
8260
8304
  }
8305
+ const bbox = { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY };
8261
8306
  const markFill = target.fill && target.fill.indexOf("url(") !== 0 ? target.fill : ((_b = this.w.globals.colors) == null ? void 0 : _b[target.realIndex]) || dots[0].fill;
8262
- let prober = null;
8263
- if (shapedTarget) {
8264
- const d = target.d || target.els.map(
8265
- (p) => p.getAttribute("pathTo") || p.getAttribute("d")
8266
- ).filter(Boolean).join(" ");
8267
- if (d) prober = this._makeExtentProber(d, target.bbox, layer);
8268
- }
8269
- const divided = prober ? gridDivideShape(target.bbox, dots.length, prober.intervalsAt) : gridDivideRect(target.bbox, dots.length);
8307
+ const prober = shapedTarget ? this._makeExtentProber(d, bbox, layer) : null;
8308
+ const divided = prober ? gridDivideShape(bbox, dots.length, prober.intervalsAt) : gridDivideRect(bbox, dots.length);
8270
8309
  if (prober) prober.dispose();
8271
8310
  const cells = sortByHilbert(divided, (c) => [
8272
8311
  c.x + c.width / 2,
8273
8312
  c.y + c.height / 2
8274
8313
  ]);
8275
- const ordered = sortByHilbert(dots, (d) => [d.x, d.y]);
8276
- const markState = { remaining: ordered.length, els: target.els, tiles: (
8277
- /** @type {any[]} */
8278
- []
8279
- ) };
8314
+ const ordered = sortByHilbert(dots, (d2) => [d2.x, d2.y]);
8315
+ const markState = {
8316
+ remaining: ordered.length,
8317
+ els: target.els,
8318
+ g: layer.appendChild(doc.createElementNS("http://www.w3.org/2000/svg", "g"))
8319
+ };
8280
8320
  for (let m = 0; m < ordered.length; m++) {
8281
8321
  const dot = ordered[m];
8282
8322
  const cell = cells[m];
@@ -8290,8 +8330,7 @@ class MorphTypeChange {
8290
8330
  el.setAttribute("height", String(dot.r * 2));
8291
8331
  el.setAttribute("rx", String(dot.r));
8292
8332
  el.setAttribute("fill", String(dot.fill || markFill));
8293
- layer.appendChild(el);
8294
- markState.tiles.push(el);
8333
+ markState.g.appendChild(el);
8295
8334
  pieces.push({
8296
8335
  el,
8297
8336
  from: { x: fx, y: fy, width: dot.r * 2, height: dot.r * 2, rx: dot.r },
@@ -8308,16 +8347,22 @@ class MorphTypeChange {
8308
8347
  const state = piece.meta.markState;
8309
8348
  state.remaining--;
8310
8349
  if (state.remaining === 0) {
8311
- state.els.forEach((el) => {
8312
- el.removeAttribute("opacity");
8313
- el.removeAttribute("data-piece-hidden");
8314
- });
8315
- state.tiles.forEach((t) => {
8316
- if (t.parentNode) t.parentNode.removeChild(t);
8317
- });
8350
+ state.els.forEach(reveal);
8351
+ state.g.remove();
8318
8352
  }
8319
8353
  });
8320
8354
  }
8355
+ /**
8356
+ * A collected target mark's final geometry as one path: the radial `d` it
8357
+ * carries, else every path that makes it up, joined.
8358
+ * @param {{ d?: string, els: any[] }} target
8359
+ * @returns {string}
8360
+ */
8361
+ _markD(target) {
8362
+ return target.d || target.els.map(
8363
+ (p) => p.getAttribute("pathTo") || p.getAttribute("d")
8364
+ ).filter(Boolean).join(" ");
8365
+ }
8321
8366
  /**
8322
8367
  * Stagger and start a piece run. Delays sweep the (already spatially
8323
8368
  * sorted) list front to back, and the last piece still lands within the
@@ -8337,6 +8382,8 @@ class MorphTypeChange {
8337
8382
  pieces,
8338
8383
  duration: flight,
8339
8384
  onPieceDone,
8385
+ // destroy() mid-flight: stop writing to the detached pieces.
8386
+ alive: () => !this.w.globals.isDestroyed,
8340
8387
  onAllDone: () => {
8341
8388
  this._pieceCancel = null;
8342
8389
  this._cancelPieces();
@@ -8345,12 +8392,12 @@ class MorphTypeChange {
8345
8392
  }
8346
8393
  /**
8347
8394
  * The incoming chart's marks, read live: every `path[pathTo]` grouped into
8348
- * one mark per (realIndex, j), with the union bbox of its final geometry.
8349
- * Bar marks are one path each; summary marks (boxPlot, violin) may be
8350
- * several, walked exactly like the capture branch walks the outgoing ones.
8395
+ * one mark per (realIndex, j); _markD reads its final geometry. Bar marks
8396
+ * are one path each; summary marks (boxPlot, violin) may be several,
8397
+ * walked exactly like the capture branch walks the outgoing ones.
8351
8398
  *
8352
8399
  * @param {string} toType
8353
- * @returns {Map<string, { realIndex: number, j: number, bbox: {x:number,y:number,width:number,height:number}, fill: string|null, els: any[], d?: string }>}
8400
+ * @returns {Map<string, { realIndex: number, fill: string|null, els: any[], d?: string }>}
8354
8401
  */
8355
8402
  _collectTargetMarks(toType) {
8356
8403
  var _a;
@@ -8361,22 +8408,9 @@ class MorphTypeChange {
8361
8408
  if (fam === "radial") {
8362
8409
  baseEl.querySelectorAll(".apexcharts-pie-series .apexcharts-pie-area").forEach((p, i) => {
8363
8410
  const d = p.getAttribute("data:pathFinal") || p.getAttribute("d");
8364
- if (!d || !d.trim()) return;
8365
- const box = this._pathBBox(d);
8366
- if (!box) return;
8367
- out.set(`${i}:0`, {
8368
- realIndex: i,
8369
- j: 0,
8370
- d,
8371
- bbox: {
8372
- x: box.minX,
8373
- y: box.minY,
8374
- width: box.maxX - box.minX,
8375
- height: box.maxY - box.minY
8376
- },
8377
- fill: p.getAttribute("fill"),
8378
- els: [p]
8379
- });
8411
+ if (d && d.trim()) {
8412
+ out.set(`${i}:0`, { realIndex: i, d, fill: p.getAttribute("fill"), els: [p] });
8413
+ }
8380
8414
  });
8381
8415
  return out;
8382
8416
  }
@@ -8391,32 +8425,10 @@ class MorphTypeChange {
8391
8425
  if (!d || !d.trim()) return;
8392
8426
  const jAttr = parseInt((_a3 = p.getAttribute("j")) != null ? _a3 : "", 10);
8393
8427
  const j = isNaN(jAttr) ? order++ : jAttr;
8394
- const box = this._pathBBox(d);
8395
- if (!box) return;
8396
8428
  const key = `${realIndex}:${j}`;
8397
8429
  const prev = out.get(key);
8398
- if (prev) {
8399
- prev.els.push(p);
8400
- prev.bbox = {
8401
- x: Math.min(prev.bbox.x, box.minX),
8402
- y: Math.min(prev.bbox.y, box.minY),
8403
- width: Math.max(prev.bbox.x + prev.bbox.width, box.maxX) - Math.min(prev.bbox.x, box.minX),
8404
- height: Math.max(prev.bbox.y + prev.bbox.height, box.maxY) - Math.min(prev.bbox.y, box.minY)
8405
- };
8406
- } else {
8407
- out.set(key, {
8408
- realIndex,
8409
- j,
8410
- bbox: {
8411
- x: box.minX,
8412
- y: box.minY,
8413
- width: box.maxX - box.minX,
8414
- height: box.maxY - box.minY
8415
- },
8416
- fill: p.getAttribute("fill"),
8417
- els: [p]
8418
- });
8419
- }
8430
+ if (prev) prev.els.push(p);
8431
+ else out.set(key, { realIndex, fill: p.getAttribute("fill"), els: [p] });
8420
8432
  });
8421
8433
  });
8422
8434
  return out;
@@ -8451,7 +8463,7 @@ class MorphTypeChange {
8451
8463
  "path[pathTo]:not(.apexcharts-highlight-part)"
8452
8464
  );
8453
8465
  paths.forEach((p, j) => {
8454
- const d = p.getAttribute("pathTo") || p.getAttribute("d");
8466
+ const d = p.getAttribute("d") || p.getAttribute("pathTo");
8455
8467
  if (!d) return;
8456
8468
  captured.push({
8457
8469
  realIndex,
@@ -8467,7 +8479,7 @@ class MorphTypeChange {
8467
8479
  var _a2, _b;
8468
8480
  const j = parseInt((_a2 = p.getAttribute("j")) != null ? _a2 : "", 10);
8469
8481
  if (isNaN(j)) return;
8470
- const d = p.getAttribute("pathTo") || p.getAttribute("d");
8482
+ const d = p.getAttribute("d") || p.getAttribute("pathTo");
8471
8483
  if (!d || !d.trim()) return;
8472
8484
  const group = typeof p.closest === "function" ? p.closest(".apexcharts-series") : null;
8473
8485
  const realIndex = parseInt((_b = group == null ? void 0 : group.getAttribute("data:realIndex")) != null ? _b : "0", 10) || 0;
@@ -8537,71 +8549,31 @@ class MorphTypeChange {
8537
8549
  });
8538
8550
  }
8539
8551
  } else if (fam === "unit") {
8540
- const dots = baseEl.querySelectorAll(".apexcharts-unit-area");
8541
- const boxes = /* @__PURE__ */ new Map();
8542
- dots.forEach((dot) => {
8543
- var _a2, _b, _c, _d, _e, _f, _g;
8544
- const i = parseInt((_a2 = dot.getAttribute("i")) != null ? _a2 : "", 10);
8545
- if (isNaN(i)) return;
8546
- const cxAttr = dot.getAttribute("cx");
8547
- let x2;
8548
- let y;
8549
- let r = 3;
8550
- if (cxAttr != null) {
8551
- x2 = parseFloat(cxAttr);
8552
- y = parseFloat((_b = dot.getAttribute("cy")) != null ? _b : "");
8553
- r = parseFloat((_c = dot.getAttribute("r")) != null ? _c : "3") || 3;
8554
- } else {
8555
- const wAttr = parseFloat((_d = dot.getAttribute("width")) != null ? _d : "0") || 0;
8556
- const hAttr = parseFloat((_e = dot.getAttribute("height")) != null ? _e : "0") || 0;
8557
- x2 = parseFloat((_f = dot.getAttribute("x")) != null ? _f : "") + wAttr / 2;
8558
- y = parseFloat((_g = dot.getAttribute("y")) != null ? _g : "") + hAttr / 2;
8559
- r = Math.max(wAttr, hAttr) / 2 || 3;
8560
- }
8561
- if (!isFinite(x2) || !isFinite(y)) return;
8562
- let list = unitDots.get(i);
8563
- if (!list) {
8564
- list = [];
8565
- unitDots.set(i, list);
8566
- }
8567
- list.push({ x: x2, y, r, fill: dot.getAttribute("fill") });
8568
- const box = boxes.get(i);
8569
- if (!box) {
8570
- boxes.set(i, {
8571
- minX: x2,
8572
- minY: y,
8573
- maxX: x2,
8574
- maxY: y,
8575
- fill: dot.getAttribute("fill")
8576
- });
8577
- return;
8578
- }
8579
- if (x2 < box.minX) box.minX = x2;
8580
- if (x2 > box.maxX) box.maxX = x2;
8581
- if (y < box.minY) box.minY = y;
8582
- if (y > box.maxY) box.maxY = y;
8583
- });
8584
- Array.from(boxes.keys()).sort((a, b) => a - b).forEach((i) => {
8585
- const b = (
8586
- /** @type {any} */
8587
- boxes.get(i)
8552
+ this._readUnitDots(baseEl, unitDots);
8553
+ Array.from(unitDots.keys()).sort((a, b) => a - b).forEach((i) => {
8554
+ const list = (
8555
+ /** @type {any[]} */
8556
+ unitDots.get(i)
8588
8557
  );
8558
+ const xs = list.map((d) => d.x);
8559
+ const ys = list.map((d) => d.y);
8589
8560
  const pad = 2;
8590
- const x1 = b.minX - pad;
8591
- const y1 = b.minY - pad;
8592
- const x2 = b.maxX + pad;
8593
- const y2 = b.maxY + pad;
8561
+ const x1 = Math.min(...xs) - pad;
8562
+ const y1 = Math.min(...ys) - pad;
8563
+ const x2 = Math.max(...xs) + pad;
8564
+ const y2 = Math.max(...ys) + pad;
8594
8565
  captured.push({
8595
8566
  realIndex: i,
8596
8567
  j: 0,
8597
8568
  d: `M ${x1} ${y1} L ${x2} ${y1} L ${x2} ${y2} L ${x1} ${y2} Z`,
8598
- fill: b.fill
8569
+ fill: list[0].fill
8599
8570
  });
8600
8571
  });
8601
8572
  } else if (fam === "radial") {
8602
8573
  if (fromType === "radialBar" || fromType === "gauge") {
8603
- const centerX = this.w.layout.gridWidth / 2;
8604
- const centerY = Math.min(this.w.layout.gridWidth, this.w.layout.gridHeight) / 2;
8574
+ const cg = this.w.globals.circleGeometry;
8575
+ const centerX = cg ? cg.cx : this.w.layout.gridWidth / 2;
8576
+ const centerY = cg ? cg.cy : this.w.layout.gridHeight / 2;
8605
8577
  const rings = baseEl.querySelectorAll(
8606
8578
  ".apexcharts-radial-series .apexcharts-radialbar-area"
8607
8579
  );
@@ -8784,31 +8756,48 @@ class MorphTypeChange {
8784
8756
  });
8785
8757
  }
8786
8758
  }
8759
+ const fromUnit = familyOf(_fromType) === "unit";
8787
8760
  if (tf === "radial" || tf === "unit" || tf === "partition") {
8788
8761
  flat.forEach((c, i) => {
8789
- map.set(`${i}:0`, { d: c.d, fill: c.fill });
8762
+ map.set(`${fromUnit ? c.realIndex : i}:0`, { d: c.d, fill: c.fill });
8790
8763
  });
8791
8764
  return map;
8792
8765
  }
8793
8766
  if (tf === "bar" || tf === "summary") {
8794
- const positions = [];
8795
- const series = Array.isArray(newSeries) ? newSeries : [];
8796
- series.forEach((s, seriesIdx) => {
8797
- const data = s && Array.isArray(s.data) ? s.data : [];
8798
- for (let j = 0; j < data.length; j++) {
8799
- positions.push({ realIndex: seriesIdx, j });
8800
- }
8801
- });
8767
+ const keys = this._targetKeys(tf, newSeries);
8802
8768
  flat.forEach((c, i) => {
8803
- const pos = positions[i];
8804
- if (pos) {
8805
- map.set(`${pos.realIndex}:${pos.j}`, { d: c.d, fill: c.fill });
8806
- }
8769
+ const key = keys[fromUnit ? c.realIndex : i];
8770
+ if (key) map.set(key, { d: c.d, fill: c.fill });
8807
8771
  });
8808
- return map;
8809
8772
  }
8810
8773
  return map;
8811
8774
  }
8775
+ /**
8776
+ * The incoming chart's mark keys `${realIndex}:${j}`, in draw order. A
8777
+ * radial chart draws one slice per value, and the single-series object
8778
+ * form `[{ data: [...] }]` expands to one slice per datum. A bar chart
8779
+ * (boxPlot and violin render through it) draws one mark per datum of each
8780
+ * series.
8781
+ *
8782
+ * @param {string|null} tf - the incoming family
8783
+ * @param {any} newSeries
8784
+ * @returns {string[]}
8785
+ */
8786
+ _targetKeys(tf, newSeries) {
8787
+ var _a;
8788
+ const keys = [];
8789
+ const series = Array.isArray(newSeries) ? newSeries : [];
8790
+ if (tf === "radial") {
8791
+ const n = series.length === 1 && Array.isArray((_a = series[0]) == null ? void 0 : _a.data) ? series[0].data.length : series.length;
8792
+ for (let i = 0; i < n; i++) keys.push(`${i}:0`);
8793
+ } else {
8794
+ series.forEach((s, si) => {
8795
+ const data = s && Array.isArray(s.data) ? s.data : [];
8796
+ for (let j = 0; j < data.length; j++) keys.push(`${si}:${j}`);
8797
+ });
8798
+ }
8799
+ return keys;
8800
+ }
8812
8801
  isActive() {
8813
8802
  return this._snapshot !== null;
8814
8803
  }
@@ -8998,46 +8987,64 @@ class MorphTypeChange {
8998
8987
  * @returns {{ minX:number, minY:number, maxX:number, maxY:number } | null}
8999
8988
  */
9000
8989
  _pathBBox(d) {
9001
- const commands = parsePath(d);
9002
8990
  let minX = Infinity;
9003
8991
  let minY = Infinity;
9004
8992
  let maxX = -Infinity;
9005
8993
  let maxY = -Infinity;
9006
- let seen = false;
9007
- commands.forEach(
8994
+ let px = 0;
8995
+ let py = 0;
8996
+ let sx = 0;
8997
+ let sy = 0;
8998
+ const add = (x2, y) => {
8999
+ if (!isFinite(x2) || !isFinite(y)) return;
9000
+ if (x2 < minX) minX = x2;
9001
+ if (x2 > maxX) maxX = x2;
9002
+ if (y < minY) minY = y;
9003
+ if (y > maxY) maxY = y;
9004
+ };
9005
+ parsePath(d).forEach(
9008
9006
  /** @param {any[]} c */
9009
9007
  (c) => {
9010
9008
  const cmd = c[0];
9011
- if (cmd === "Z") return;
9012
- let pairs = [];
9013
- if (cmd === "H") pairs = [[c[1], (minY + maxY) / 2 || c[1]]];
9014
- else if (cmd === "V") pairs = [[(minX + maxX) / 2 || c[1], c[1]]];
9015
- else if (cmd === "A") pairs = [[c[6], c[7]]];
9016
- else {
9017
- for (let k2 = 1; k2 + 1 < c.length; k2 += 2) pairs.push([c[k2], c[k2 + 1]]);
9009
+ if (cmd === "Z") {
9010
+ px = sx;
9011
+ py = sy;
9012
+ return;
9013
+ }
9014
+ const n = c.length;
9015
+ const x2 = cmd === "H" ? c[1] : cmd === "V" ? px : c[n - 2];
9016
+ const y = cmd === "H" ? py : cmd === "V" ? c[1] : c[n - 1];
9017
+ if (cmd === "A") {
9018
+ if (c[1]) {
9019
+ const hx = (px - x2) / 2;
9020
+ const hy = (py - y) / 2;
9021
+ const f = (c[4] === c[5] ? -1 : 1) * Math.sqrt(Math.max(0, c[1] * c[1] / (hx * hx + hy * hy) - 1));
9022
+ const cx = px - hx + f * hy;
9023
+ const cy = py - hy - f * hx;
9024
+ const r = Math.hypot(px - cx, py - cy);
9025
+ const a0 = Math.atan2(py - cy, px - cx);
9026
+ const TAU = 2 * Math.PI;
9027
+ let sweep = Math.atan2(y - cy, x2 - cx) - a0;
9028
+ if (c[5] && sweep < 0) sweep += TAU;
9029
+ else if (!c[5] && sweep > 0) sweep -= TAU;
9030
+ for (let a = 0; a < TAU; a += Math.PI / 2) {
9031
+ const t = ((sweep > 0 ? a - a0 : a0 - a) % TAU + TAU) % TAU;
9032
+ if (t <= Math.abs(sweep)) add(cx + r * Math.cos(a), cy + r * Math.sin(a));
9033
+ }
9034
+ }
9035
+ } else if (cmd !== "H" && cmd !== "V") {
9036
+ for (let k2 = 1; k2 + 1 < n; k2 += 2) add(c[k2], c[k2 + 1]);
9037
+ }
9038
+ add(x2, y);
9039
+ px = x2;
9040
+ py = y;
9041
+ if (cmd === "M") {
9042
+ sx = x2;
9043
+ sy = y;
9018
9044
  }
9019
- pairs.forEach(([x2, y]) => {
9020
- if (!isFinite(x2) || !isFinite(y)) return;
9021
- seen = true;
9022
- if (x2 < minX) minX = x2;
9023
- if (x2 > maxX) maxX = x2;
9024
- if (y < minY) minY = y;
9025
- if (y > maxY) maxY = y;
9026
- });
9027
9045
  }
9028
9046
  );
9029
- if (!seen) return null;
9030
- return { minX, minY, maxX, maxY };
9031
- }
9032
- /**
9033
- * @param {number} realIndex
9034
- * @param {number} j
9035
- * @returns {string | null}
9036
- */
9037
- getInitialFillFor(realIndex, j) {
9038
- if (!this._snapshot) return null;
9039
- const entry = this._snapshot.mapping.get(`${realIndex}:${j}`);
9040
- return entry ? entry.fill : null;
9047
+ return minX > maxX ? null : { minX, minY, maxX, maxY };
9041
9048
  }
9042
9049
  /** @returns {number} */
9043
9050
  getSpeed() {
@@ -9055,55 +9062,78 @@ class MorphTypeChange {
9055
9062
  if (!this._snapshot || !Environment.isBrowser()) return;
9056
9063
  this._shown = true;
9057
9064
  const baseEl = (_a = this.w.globals.dom) == null ? void 0 : _a.baseEl;
9058
- if (!baseEl) return;
9065
+ if (!baseEl || this._snapshot.resume) return;
9059
9066
  if (this._snapshot.pieceOut) this._separatePieces();
9060
9067
  else if (this._snapshot.pieceIn) this._combinePieces();
9061
9068
  else this._mountGhost();
9062
9069
  const speed = this.getSpeed();
9063
- const chromeSelectors = [
9064
- ".apexcharts-xaxis",
9065
- ".apexcharts-yaxis",
9066
- ".apexcharts-grid",
9067
- ".apexcharts-gridlines-horizontal",
9068
- ".apexcharts-gridlines-vertical",
9069
- ".apexcharts-legend",
9070
- ".apexcharts-title-text",
9071
- ".apexcharts-subtitle-text"
9072
- ];
9073
- chromeSelectors.forEach((sel) => {
9074
- baseEl.querySelectorAll(sel).forEach((el) => {
9075
- if (!el.style) return;
9076
- el.style.opacity = "0";
9077
- el.style.transition = `opacity ${speed}ms ease-out`;
9078
- BrowserAPIs.requestAnimationFrame(() => {
9079
- el.style.opacity = "1";
9080
- });
9081
- setTimeout(() => {
9082
- el.style.transition = "";
9083
- el.style.opacity = "";
9084
- }, speed + 80);
9085
- });
9070
+ const chrome = Array.from(
9071
+ baseEl.querySelectorAll(
9072
+ ".apexcharts-xaxis,.apexcharts-yaxis,.apexcharts-grid,.apexcharts-legend,.apexcharts-title-text,.apexcharts-subtitle-text"
9073
+ )
9074
+ ).filter((el) => el.style);
9075
+ const set = (opacity, transition) => chrome.forEach((el) => {
9076
+ el.style.opacity = opacity;
9077
+ if (transition != null) el.style.transition = transition;
9086
9078
  });
9079
+ set("0", `opacity ${speed}ms ease-out`);
9080
+ const dead = () => this.w.globals.isDestroyed;
9081
+ BrowserAPIs.requestAnimationFrame(() => dead() || set("1"));
9082
+ setTimeout(() => dead() || set("", ""), speed + 80);
9087
9083
  const snap = this._snapshot;
9088
9084
  setTimeout(() => {
9089
- if (!this._snapshot || this._snapshot === snap) this.cleanup();
9085
+ if (!dead() && (!this._snapshot || this._snapshot === snap)) this.cleanup();
9090
9086
  }, speed + 100);
9091
9087
  }
9092
9088
  /**
9093
9089
  * A render after the one a morph was captured for (an update while the
9094
9090
  * morph is still finishing, or just after) must not start its marks from
9095
9091
  * the old chart's shapes again: it starts from the screen, as any update
9096
- * does. The morph's ghost and pieces go with it, as the new render
9097
- * replaces what they were leaving over. A no-op until that render has
9098
- * mounted, so a second update in the same tick still morphs.
9092
+ * does. The morph's pieces go with it, as the new render replaces what
9093
+ * they were leaving over, but where they are is handed on first: a piece
9094
+ * flying to a dot becomes that dot's previous slot, so the unit chart's
9095
+ * own keyed update carries it on, and the tiles of a mosaic still
9096
+ * assembling become its mark's start shape, their bounding box, through
9097
+ * the morph's snapshot, kept for that one render. A ghost already fading
9098
+ * is left to finish its own fade (its timer removes it) rather than vanish
9099
+ * mid-way. A no-op until that render has mounted, so a second update in
9100
+ * the same tick still morphs.
9099
9101
  */
9100
9102
  retire() {
9101
- if (this._snapshot && this._shown) this.cleanup();
9103
+ const snap = this._snapshot;
9104
+ if (!snap || !this._shown) return;
9105
+ const layer = this._pieceLayer;
9106
+ this.ctx._unitPieces = snap.pieceOut && layer;
9107
+ const mapping = /* @__PURE__ */ new Map();
9108
+ layer == null ? void 0 : layer.querySelectorAll("g").forEach((g) => {
9109
+ const r = g.firstChild && g.getBBox();
9110
+ if (r) {
9111
+ mapping.set(g.firstChild.getAttribute("data-key"), {
9112
+ d: `M${r.x} ${r.y}H${r.x + r.width}V${r.y + r.height}H${r.x}Z`
9113
+ });
9114
+ }
9115
+ });
9116
+ this.cleanup(true);
9117
+ if (!mapping.size) return;
9118
+ this._collectTargetMarks(snap.toType).forEach((t, k2) => {
9119
+ if (!mapping.has(k2)) mapping.set(k2, { d: this._markD(t) });
9120
+ });
9121
+ this.w.globals.previousPaths = [];
9122
+ this._snapshot = Object.assign(snap, {
9123
+ mapping,
9124
+ pieceIn: false,
9125
+ resume: true,
9126
+ oldLayout: __spreadValues({}, this.w.layout)
9127
+ });
9128
+ BrowserAPIs.requestAnimationFrame(() => {
9129
+ if (this._snapshot === snap) this._shown = true;
9130
+ });
9102
9131
  }
9103
- cleanup() {
9132
+ /** @param {boolean} [keepGhost] leave a mounted ghost to its own timer */
9133
+ cleanup(keepGhost) {
9104
9134
  this._snapshot = null;
9105
9135
  this._shown = false;
9106
- this._removeGhost();
9136
+ if (!keepGhost) this._removeGhost();
9107
9137
  this._cancelPieces();
9108
9138
  }
9109
9139
  }
@@ -9124,12 +9154,12 @@ const CLAIMABLE = Object.freeze({
9124
9154
  "stroke.dashArray": Object.freeze({ type: "number" }),
9125
9155
  "dataLabels.enabledOnSeries": Object.freeze({ type: "boolean" })
9126
9156
  });
9127
- function store(w) {
9157
+ function store$1(w) {
9128
9158
  if (!w.weaveClaims) w.weaveClaims = { byOption: /* @__PURE__ */ new Map() };
9129
9159
  return w.weaveClaims;
9130
9160
  }
9131
9161
  function claimsFor(w, option) {
9132
- const s = store(w);
9162
+ const s = store$1(w);
9133
9163
  if (!s.byOption.has(option)) s.byOption.set(option, []);
9134
9164
  return s.byOption.get(option);
9135
9165
  }
@@ -9179,11 +9209,16 @@ function releaseClaim(w, record) {
9179
9209
  if (at > -1) list.splice(at, 1);
9180
9210
  }
9181
9211
  function releaseOwner(w, owner) {
9182
- if (!w.weaveClaims) return;
9212
+ if (!w.weaveClaims) return false;
9213
+ let released = false;
9183
9214
  for (const [option, list] of w.weaveClaims.byOption) {
9184
9215
  const kept = list.filter((c) => c.owner !== owner);
9185
- if (kept.length !== list.length) w.weaveClaims.byOption.set(option, kept);
9216
+ if (kept.length !== list.length) {
9217
+ w.weaveClaims.byOption.set(option, kept);
9218
+ released = true;
9219
+ }
9186
9220
  }
9221
+ return released;
9187
9222
  }
9188
9223
  function indexOfSeries(w, series) {
9189
9224
  if (typeof series === "number") return series;
@@ -9286,7 +9321,7 @@ function collectDrawn(w, host) {
9286
9321
  }
9287
9322
  return [...seriesItems(w, host), ...annotationItems(w), ...declared];
9288
9323
  }
9289
- const WEAVE_API_VERSION = 6;
9324
+ const WEAVE_API_VERSION = 7;
9290
9325
  const WEAVE_CAPABILITIES = Object.freeze([
9291
9326
  "layer",
9292
9327
  "derived",
@@ -9296,7 +9331,8 @@ const WEAVE_CAPABILITIES = Object.freeze([
9296
9331
  "claim",
9297
9332
  "drawn",
9298
9333
  "observations",
9299
- "scale-orientation"
9334
+ "scale-orientation",
9335
+ "highlight"
9300
9336
  ]);
9301
9337
  const PLUGIN_CHART_METHODS = [
9302
9338
  "updateOptions",
@@ -9643,7 +9679,8 @@ function buildPluginAPI(host, record) {
9643
9679
  * Claimable options are an allowlist (see `CLAIMABLE`). An option that is
9644
9680
  * not on it returns null rather than throwing, so a plugin written against
9645
9681
  * a newer host degrades. Every claim is released on teardown, on destroy,
9646
- * and if the host disables this plugin after repeated failures.
9682
+ * when the plugin is removed from `plugins`, and if the host disables this
9683
+ * plugin after repeated failures.
9647
9684
  *
9648
9685
  * @param {string} option
9649
9686
  * @param {Array<{series: string|number, value: any}>} entries
@@ -9662,6 +9699,48 @@ function buildPluginAPI(host, record) {
9662
9699
  }
9663
9700
  });
9664
9701
  },
9702
+ /**
9703
+ * Draw a PART of each value, inside the slot that value already occupies.
9704
+ *
9705
+ * The alternative for a plugin with a second number per datum has been
9706
+ * `markDerived()`: add a series. A series is a large thing to put on
9707
+ * someone else's chart. It takes a legend entry, a tooltip row and an
9708
+ * export column, it rescales the value axis to fit, and where the chart is
9709
+ * bars it takes half the width of every bar the caller had. A part takes
9710
+ * none of those: the whole is drawn faded, the part solid in front of it,
9711
+ * same slot, same baseline.
9712
+ *
9713
+ * const parts = api.highlight([
9714
+ * { series: 'Revenue', values: [10, 30, 60] },
9715
+ * ])
9716
+ * parts?.update([{ series: 'Revenue', values: [10, 30, 90] }])
9717
+ * parts?.release()
9718
+ *
9719
+ * `values` runs parallel to that series' data, with null where a datum has
9720
+ * no part. Name the series rather than its position where you can: the name
9721
+ * is resolved on every parse, so the parts follow the series through the
9722
+ * caller adding, removing or reordering others.
9723
+ *
9724
+ * NULL means the parts were not taken, and a plugin that gets null must
9725
+ * have something else to do (or nothing). The host says null when the
9726
+ * highlight-filter feature is not loaded on the page, when the chart is not
9727
+ * an axis chart, when the type draws no parts, and when the CALLER is
9728
+ * already showing parts of their own. A plugin cannot fix any of the four,
9729
+ * and three of them can change under it on the next update, so the answer
9730
+ * is checked per call rather than remembered.
9731
+ *
9732
+ * Registering, updating and releasing each re-render the chart, coalesced
9733
+ * to one render per turn. Every registration is released on teardown, on
9734
+ * destroy, when the plugin is removed from `plugins`, and if the host
9735
+ * disables this plugin after repeated failures.
9736
+ *
9737
+ * @param {Array<{series: string|number, values: Array<number|null>}>} entries
9738
+ * @returns {{release: () => void, update: (entries: Array<{series: string|number, values: Array<number|null>}>) => void}|null}
9739
+ * @since Weave v7
9740
+ */
9741
+ highlight(entries) {
9742
+ return host._highlight(record.def.name, entries);
9743
+ },
9665
9744
  /**
9666
9745
  * Everything drawn on this chart, including what other features drew.
9667
9746
  *
@@ -9719,7 +9798,8 @@ function buildPluginAPI(host, record) {
9719
9798
  * Nothing here gives a plugin the ability to intercept or cancel: the
9720
9799
  * chart's own tooltip, selection state and caller events are unaffected,
9721
9800
  * and a handler that throws is contained rather than allowed to break the
9722
- * interaction it was watching.
9801
+ * interaction it was watching. It counts toward the same three failures as
9802
+ * a hook, and a disabled or removed plugin stops being called.
9723
9803
  *
9724
9804
  * `modifiers` (v6) reports the keys held during the interaction, for the
9725
9805
  * gestures that need them: shift-click to add to a selection is the one
@@ -9779,8 +9859,67 @@ const WIRED = {
9779
9859
  observations: () => true,
9780
9860
  // Scales are null until the first draw and on every non-axis chart, so the
9781
9861
  // facade has nothing to probe; this host builds them oriented on every draw.
9782
- "scale-orientation": () => true
9862
+ "scale-orientation": () => true,
9863
+ // The SEAM, not the drawing. Whether parts can actually be drawn depends on
9864
+ // the chart type, on what the caller's data carries, and on whether the page
9865
+ // imported the highlight-filter feature at all, and all three can change
9866
+ // after this is answered. `api.highlight()` returns null for each of them,
9867
+ // which is the answer a plugin can act on; advertising the capability and
9868
+ // then returning null is the same shape as `claim()` on an option this host
9869
+ // does not know.
9870
+ highlight: (a) => typeof a.highlight === "function"
9783
9871
  };
9872
+ function store(w) {
9873
+ if (!w.weaveHighlights) w.weaveHighlights = { records: [] };
9874
+ return w.weaveHighlights;
9875
+ }
9876
+ function normaliseHighlightEntries(entries) {
9877
+ const out = [];
9878
+ for (const entry of Array.isArray(entries) ? entries : []) {
9879
+ if (!entry || typeof entry.series !== "string" && typeof entry.series !== "number") {
9880
+ console.warn(
9881
+ "[apexcharts] highlight: each entry needs a series name or index."
9882
+ );
9883
+ continue;
9884
+ }
9885
+ if (!Array.isArray(entry.values)) {
9886
+ console.warn(
9887
+ `[apexcharts] highlight: expected an array of values for series ${String(
9888
+ entry.series
9889
+ )}, got ${typeof entry.values}.`
9890
+ );
9891
+ continue;
9892
+ }
9893
+ out.push({
9894
+ series: entry.series,
9895
+ values: entry.values.map(
9896
+ (v) => typeof v === "number" && Number.isFinite(v) ? v : null
9897
+ )
9898
+ });
9899
+ }
9900
+ return out;
9901
+ }
9902
+ function addHighlight(w, owner, entries) {
9903
+ const normalised = normaliseHighlightEntries(entries);
9904
+ if (!normalised.length) return null;
9905
+ const record = { owner, entries: normalised };
9906
+ store(w).records.push(record);
9907
+ return record;
9908
+ }
9909
+ function releaseHighlight(w, record) {
9910
+ if (!w || !w.weaveHighlights || !record) return;
9911
+ const list = w.weaveHighlights.records;
9912
+ const at = list.indexOf(record);
9913
+ if (at > -1) list.splice(at, 1);
9914
+ }
9915
+ function releaseHighlightOwner(w, owner) {
9916
+ if (!w || !w.weaveHighlights) return false;
9917
+ const list = w.weaveHighlights.records;
9918
+ const kept = list.filter((r) => r.owner !== owner);
9919
+ if (kept.length === list.length) return false;
9920
+ w.weaveHighlights.records = kept;
9921
+ return true;
9922
+ }
9784
9923
  const _WeaveHost = class _WeaveHost {
9785
9924
  /**
9786
9925
  * @param {import('../../types/internal').ChartStateW} w
@@ -9798,6 +9937,7 @@ const _WeaveHost = class _WeaveHost {
9798
9937
  this._derived = null;
9799
9938
  this._reserved = null;
9800
9939
  this._reserveTimer = null;
9940
+ this._highlightTimer = null;
9801
9941
  this._pointerSubs = null;
9802
9942
  this._declared = null;
9803
9943
  this._pointerWired = null;
@@ -9905,7 +10045,7 @@ const _WeaveHost = class _WeaveHost {
9905
10045
  record.failures = (record.failures || 0) + 1;
9906
10046
  if (record.failures >= 3) {
9907
10047
  record.disabled = true;
9908
- releaseOwner(this.w, record.def.name);
10048
+ this._forget(record.def.name);
9909
10049
  console.error(
9910
10050
  `[apexcharts] plugin "${record.def.name}" disabled after repeated errors.`
9911
10051
  );
@@ -9956,15 +10096,32 @@ const _WeaveHost = class _WeaveHost {
9956
10096
  /** @type {number} */
9957
10097
  rows.get(v)
9958
10098
  ) : v) + 0.5) : (v) => (v - gl.minX) / xRatio;
10099
+ const yaxisOf = (axis) => {
10100
+ const k2 = gl.seriesYAxisReverseMap && gl.seriesYAxisReverseMap[axis];
10101
+ return w.config.yaxis[k2 != null ? k2 : axis] || w.config.yaxis[0];
10102
+ };
9959
10103
  const reversed = (axis) => {
9960
- const ya = w.config.yaxis[axis] || w.config.yaxis[0];
10104
+ const ya = yaxisOf(axis);
9961
10105
  return !!(ya && ya.reversed);
9962
10106
  };
10107
+ let coreUtils = null;
10108
+ const logFraction = (v, axis) => {
10109
+ const ya = yaxisOf(axis);
10110
+ if (!ya || !ya.logarithmic || gl.invalidLogScale) return null;
10111
+ if (!coreUtils) coreUtils = new CoreUtils(w);
10112
+ return coreUtils.getLogVal(ya.logBase, v, axis);
10113
+ };
9963
10114
  const y = horizontal ? (v, axis = 0) => {
9964
10115
  const range = Math.abs(maxY(axis) - minY(axis));
9965
10116
  const px = range ? (v - minY(axis)) / range * L2.gridWidth : 0;
9966
10117
  return reversed(axis) ? L2.gridWidth - px : px;
9967
- } : (v, axis = 0) => (maxY(axis) - v) / yr(axis);
10118
+ } : (v, axis = 0) => {
10119
+ const f = logFraction(v, axis);
10120
+ if (f !== null) {
10121
+ return reversed(axis) ? f * L2.gridHeight : (1 - f) * L2.gridHeight;
10122
+ }
10123
+ return reversed(axis) ? (v - minY(axis)) / yr(axis) : (maxY(axis) - v) / yr(axis);
10124
+ };
9968
10125
  this._currentScales = {
9969
10126
  x: x2,
9970
10127
  y,
@@ -10055,13 +10212,11 @@ const _WeaveHost = class _WeaveHost {
10055
10212
  /**
10056
10213
  * Record the series a plugin owns, and repair the initial-series snapshot.
10057
10214
  *
10058
- * `Data.parseData()` assigns `globals.initialSeries` on every parse
10059
- * unconditionally, so `updateSeries(..., overwriteInitialSeries: false)` does
10060
- * NOT keep a plugin's computed series out of it. That assignment is
10061
- * deliberate (it is what keeps resetSeries() correct for the reducer,
10062
- * histogram, dumbbell, streamgraph, waterfall and treemap raw-series paths),
10063
- * so the fix is to put the caller's own series back afterwards rather than to
10064
- * make the assignment conditional.
10215
+ * A plugin that adds its series with `updateSeries(..., overwriteInitialSeries:
10216
+ * false)` keeps it out of `globals.initialSeries` (#5283), but one that lets
10217
+ * the baseline move, or a caller's later update that does, takes the plugin's
10218
+ * series in with everything else. So the plugin's names are filtered back out
10219
+ * of the baseline after every update rather than trusted to stay out.
10065
10220
  *
10066
10221
  * Without this, a plugin that adds a computed series poisons resetSeries():
10067
10222
  * pressing the toolbar's reset hands the user the plugin's output as if it
@@ -10169,15 +10324,10 @@ const _WeaveHost = class _WeaveHost {
10169
10324
  modifiers: _WeaveHost._modifiers(e)
10170
10325
  };
10171
10326
  for (const [name, handlers] of this._pointerSubs) {
10327
+ const record = this.active.find((r) => r.def.name === name);
10328
+ if (!record) continue;
10172
10329
  for (const fn of handlers.slice()) {
10173
- try {
10174
- fn(payload);
10175
- } catch (e2) {
10176
- console.warn(
10177
- '[apexcharts] plugin "' + name + '" threw in a pointer handler',
10178
- e2
10179
- );
10180
- }
10330
+ this._guard(record, "pointer", () => fn(payload));
10181
10331
  }
10182
10332
  }
10183
10333
  }
@@ -10316,10 +10466,96 @@ const _WeaveHost = class _WeaveHost {
10316
10466
  if (gl.isDestroyed) return;
10317
10467
  gl.resized = true;
10318
10468
  gl.dataChanged = false;
10319
- try {
10320
- this.ctx.update();
10321
- } catch (e) {
10469
+ this._update("a plugin reservation");
10470
+ }, 0);
10471
+ }
10472
+ /**
10473
+ * Run one of the host's own deferred re-renders, failures contained.
10474
+ *
10475
+ * `update()` reports a failure by rejecting, which a try/catch around the
10476
+ * call never sees, so a rejection surfaced as an unhandled one from inside
10477
+ * the library with nothing saying what asked for the render.
10478
+ *
10479
+ * @param {string} why
10480
+ */
10481
+ _update(why) {
10482
+ try {
10483
+ Promise.resolve(this.ctx.update()).catch(
10484
+ (e) => console.error(`[apexcharts] re-render for ${why} failed:`, e)
10485
+ );
10486
+ } catch (e) {
10487
+ }
10488
+ }
10489
+ // ─── Highlight parts ────────────────────────────────────────────────────
10490
+ /**
10491
+ * Register a plugin's highlight parts, or say why not.
10492
+ *
10493
+ * Null is the answer to four different questions, and a plugin treats them
10494
+ * alike because its fallback is the same in all four:
10495
+ *
10496
+ * 1. the highlight filter feature is not loaded on this page. A plugin
10497
+ * cannot import it for the caller: it is premium and dashboard-scoped,
10498
+ * and pulling it in would add weight to every chart the plugin runs on.
10499
+ * 2. the chart is not an axis chart. A slice's part is one value per slice
10500
+ * and is configured per chart rather than per series, so the entry shape
10501
+ * here does not describe it.
10502
+ * 3. this chart type draws no parts (a combo, a range, a histogram).
10503
+ * 4. the caller is ALREADY showing parts of their own. Two sources of parts
10504
+ * in one slot leave a viewer unable to tell whose pick they are looking
10505
+ * at, and the plugin's would be the one they did not ask for.
10506
+ *
10507
+ * Distinguishing them would be a worse API, not a better one: a plugin that
10508
+ * branched on the reason would still do the same thing, and the reason can
10509
+ * change under it on the caller's next update.
10510
+ *
10511
+ * @param {string} owner plugin name
10512
+ * @param {any} entries [{ series: name | index, values: (number|null)[] }]
10513
+ * @returns {{release: () => void, update: (entries: any) => void}|null}
10514
+ */
10515
+ _highlight(owner, entries) {
10516
+ const w = this.w;
10517
+ const hf = (
10518
+ /** @type {any} */
10519
+ this.ctx.highlightFilter
10520
+ );
10521
+ if (!hf) return null;
10522
+ if (!w.globals.axisCharts) return null;
10523
+ if (!hf.canDrawParts()) return null;
10524
+ if (hf.callerCarriesParts()) return null;
10525
+ const record = addHighlight(w, owner, entries);
10526
+ if (!record) return null;
10527
+ this._redrawForHighlight();
10528
+ return Object.freeze({
10529
+ release: () => {
10530
+ releaseHighlight(w, record);
10531
+ this._redrawForHighlight();
10532
+ },
10533
+ update: (next) => {
10534
+ record.entries = normaliseHighlightEntries(next);
10535
+ this._redrawForHighlight();
10322
10536
  }
10537
+ });
10538
+ }
10539
+ /**
10540
+ * Re-render so the parts are parsed, one task later and coalesced.
10541
+ *
10542
+ * One task later for the reason reservations are: the call can come from
10543
+ * inside a dispatch, and re-entering a render from a draw handler is how a
10544
+ * plugin takes the chart down. Coalesced, so a plugin registering parts for
10545
+ * several series in one turn costs one render.
10546
+ *
10547
+ * `dataChanged`, unlike the reservation path: the numbers on screen are
10548
+ * about to change, so the parts should grow and shrink into place rather
10549
+ * than appear as if the chart had been resized.
10550
+ */
10551
+ _redrawForHighlight() {
10552
+ if (this._highlightTimer != null) return;
10553
+ this._highlightTimer = setTimeout(() => {
10554
+ this._highlightTimer = null;
10555
+ const gl = this.w.globals;
10556
+ if (gl.isDestroyed) return;
10557
+ gl.dataChanged = true;
10558
+ this._update("plugin highlight parts");
10323
10559
  }, 0);
10324
10560
  }
10325
10561
  /** All series names currently claimed by plugins. */
@@ -10331,23 +10567,31 @@ const _WeaveHost = class _WeaveHost {
10331
10567
  }
10332
10568
  return out;
10333
10569
  }
10570
+ /**
10571
+ * Take the plugins' series out of the reset baseline.
10572
+ *
10573
+ * Filters the baseline the chart already holds rather than rebuilding it from
10574
+ * `w.config.series`. The live config is not the caller's data: a legend hide
10575
+ * empties the hidden row in place (#5118), and on the raw-stash types it holds
10576
+ * the derived rows the parse keeps out of the baseline on purpose. Rebuilt
10577
+ * from it, a reset brought a hidden series back empty.
10578
+ */
10334
10579
  _repairInitialSeries() {
10335
10580
  const drop = this._derivedNames();
10336
10581
  if (!drop.size) return;
10337
- const w = this.w;
10338
- const series = (
10339
- /** @type {any[]} */
10340
- Array.isArray(w.config.series) ? w.config.series : []
10341
- );
10342
- const own = series.filter(
10343
- (s) => !drop.has(String(s && s.name))
10344
- );
10345
- if (!own.length) return;
10582
+ const gl = this.w.globals;
10583
+ const own = (s) => !drop.has(String(s && s.name));
10584
+ const keep = (list) => {
10585
+ if (!Array.isArray(list)) return null;
10586
+ const kept = list.filter(own);
10587
+ return kept.length && kept.length !== list.length ? kept : null;
10588
+ };
10346
10589
  try {
10347
- w.globals.initialSeries = own;
10348
- if (w.globals.initialConfig && Array.isArray(w.globals.initialConfig.series)) {
10349
- w.globals.initialConfig.series = own;
10350
- }
10590
+ const base = keep(gl._initialSeriesPeek);
10591
+ if (base) gl.initialSeries = base;
10592
+ const ic = gl.initialConfig;
10593
+ const config = ic && keep(ic.series);
10594
+ if (config) ic.series = config;
10351
10595
  } catch (e) {
10352
10596
  }
10353
10597
  }
@@ -10473,7 +10717,7 @@ const _WeaveHost = class _WeaveHost {
10473
10717
  if (!want) {
10474
10718
  this._guard(r, "destroy", () => r.def.destroy && r.def.destroy(r.api));
10475
10719
  this.active.splice(i, 1);
10476
- this._reserve(r.def.name, null);
10720
+ this._forget(r.def.name);
10477
10721
  } else {
10478
10722
  r.options = Object.freeze(__spreadValues({}, want.entry.options || {}));
10479
10723
  }
@@ -10485,6 +10729,28 @@ const _WeaveHost = class _WeaveHost {
10485
10729
  });
10486
10730
  toAdd.sort((a, b) => a.order - b.order).forEach((v) => this._activate(v.entry));
10487
10731
  }
10732
+ /**
10733
+ * Let go of everything one plugin holds on this chart.
10734
+ *
10735
+ * The one exit for all three ways a plugin leaves: removed from `plugins`,
10736
+ * disabled after repeated errors, and torn down with the chart. Each used to
10737
+ * release its own subset, so a removed plugin went on dashing a series and
10738
+ * receiving hovers after its destroy had run, and a disabled one kept its
10739
+ * gutter.
10740
+ *
10741
+ * @param {string} name plugin
10742
+ */
10743
+ _forget(name) {
10744
+ const w = this.w;
10745
+ const claims = releaseOwner(w, name);
10746
+ const parts = releaseHighlightOwner(w, name);
10747
+ if (this._pointerSubs) this._pointerSubs.delete(name);
10748
+ if (this._derived) this._derived.delete(name);
10749
+ if (this._declared) this._declared.delete(name);
10750
+ const gutter = !!(this._reserved && this._reserved.has(name));
10751
+ this._reserve(name, null);
10752
+ if ((claims || parts) && !gutter) this._redrawForHighlight();
10753
+ }
10488
10754
  /**
10489
10755
  * @param {boolean} [isUpdating]
10490
10756
  */
@@ -10494,7 +10760,7 @@ const _WeaveHost = class _WeaveHost {
10494
10760
  for (const record of this.active) {
10495
10761
  this._guard(record, "destroy", () => record.def.destroy && record.def.destroy(record.api));
10496
10762
  }
10497
- for (const record of this.active) releaseOwner(this.w, record.def.name);
10763
+ for (const record of this.active) this._forget(record.def.name);
10498
10764
  this.active = [];
10499
10765
  this._derived = null;
10500
10766
  this._reserved = null;
@@ -10510,6 +10776,10 @@ const _WeaveHost = class _WeaveHost {
10510
10776
  clearTimeout(this._reserveTimer);
10511
10777
  this._reserveTimer = null;
10512
10778
  }
10779
+ if (this._highlightTimer != null) {
10780
+ clearTimeout(this._highlightTimer);
10781
+ this._highlightTimer = null;
10782
+ }
10513
10783
  if (this._updatedWired) {
10514
10784
  this.ctx.removeEventListener && this.ctx.removeEventListener("updated", this._onUpdated);
10515
10785
  this._updatedWired = false;
@@ -10917,6 +11187,25 @@ function registerRowSource(name, fn) {
10917
11187
  }
10918
11188
  getSources()[name] = fn;
10919
11189
  }
11190
+ function collapsedIndices(gl) {
11191
+ return (gl.collapsedSeriesIndices || []).concat(
11192
+ gl.ancillaryCollapsedSeriesIndices || []
11193
+ );
11194
+ }
11195
+ function stashSeries(ser, gl) {
11196
+ const records = (gl.collapsedSeries || []).concat(
11197
+ gl.ancillaryCollapsedSeries || []
11198
+ );
11199
+ return ser.map((s, i) => {
11200
+ const _a = s || {}, { hidden: _hidden } = _a, rest = __objRest(_a, ["hidden"]);
11201
+ let data = rest.data;
11202
+ if (Array.isArray(data) && !data.length) {
11203
+ const rec = records.find((r) => r.index === i);
11204
+ if (rec && Array.isArray(rec.data)) data = rec.data;
11205
+ }
11206
+ return __spreadProps(__spreadValues({}, rest), { data: Array.isArray(data) ? data.slice() : data });
11207
+ });
11208
+ }
10920
11209
  const M = 1e3;
10921
11210
  function A(e, t) {
10922
11211
  const s = e.length;
@@ -11142,6 +11431,26 @@ function observationsOf(d, allowFlatY) {
11142
11431
  }
11143
11432
  return out.length ? out : null;
11144
11433
  }
11434
+ function derivedStats(w, kind) {
11435
+ var _a, _b;
11436
+ const all = (_a = w.statsDerived) != null ? _a : w.statsDerived = {};
11437
+ return (_b = all[kind]) != null ? _b : all[kind] = /* @__PURE__ */ new Map();
11438
+ }
11439
+ function isDerived(derived, key, value) {
11440
+ const ours = derived.get(key);
11441
+ if (!ours || !Array.isArray(value) || ours.length !== value.length) {
11442
+ return false;
11443
+ }
11444
+ for (let k2 = 0; k2 < value.length; k2++) {
11445
+ const a = ours[k2];
11446
+ const b = value[k2];
11447
+ if (a === b) continue;
11448
+ if (!Array.isArray(a) || !Array.isArray(b) || a[0] !== b[0] || a[1] !== b[1]) {
11449
+ return false;
11450
+ }
11451
+ }
11452
+ return true;
11453
+ }
11145
11454
  function histogramValues(data) {
11146
11455
  const out = [];
11147
11456
  if (!Array.isArray(data)) return out;
@@ -11161,9 +11470,7 @@ function histogramTransform(ser, w) {
11161
11470
  const gl = w.globals;
11162
11471
  if (!Array.isArray(ser)) return ser;
11163
11472
  if (!gl.histogramRawSeries) {
11164
- gl.histogramRawSeries = ser.map((s) => __spreadProps(__spreadValues({}, s), {
11165
- data: Array.isArray(s == null ? void 0 : s.data) ? s.data.slice() : s == null ? void 0 : s.data
11166
- }));
11473
+ gl.histogramRawSeries = stashSeries(ser, gl);
11167
11474
  }
11168
11475
  const raw = gl.histogramRawSeries;
11169
11476
  const hcfg = ((_a = cnf.plotOptions) == null ? void 0 : _a.histogram) || {};
@@ -11200,7 +11507,7 @@ function histogramTransform(ser, w) {
11200
11507
  rule: binning.rule,
11201
11508
  capped: binning.capped
11202
11509
  };
11203
- const collapsed = gl.collapsedSeriesIndices || [];
11510
+ const collapsed = collapsedIndices(gl);
11204
11511
  w.seriesObservations = perSeries.map(
11205
11512
  (values, i) => ({
11206
11513
  values,
@@ -11221,18 +11528,19 @@ function histogramTransform(ser, w) {
11221
11528
  return __spreadProps(__spreadValues({}, s), { data });
11222
11529
  });
11223
11530
  }
11224
- const derivedData = /* @__PURE__ */ new WeakSet();
11225
11531
  function boxPlotTransform(ser, w) {
11226
11532
  var _a, _b;
11227
11533
  if (!Array.isArray(ser)) return ser;
11228
11534
  const whiskers = ((_b = (_a = w.config.plotOptions) == null ? void 0 : _a.boxPlot) == null ? void 0 : _b.whiskers) || "minmax";
11535
+ const derived = derivedStats(w, "boxPlot");
11229
11536
  const observed = [];
11230
11537
  const out = ser.map((s, i) => {
11231
11538
  if (!Array.isArray(s == null ? void 0 : s.data) || s.type && s.type !== "boxPlot") return s;
11232
11539
  let touched = false;
11233
11540
  const byPoint = new Array(s.data.length).fill(null);
11234
11541
  const data = s.data.map((d, j) => {
11235
- if (Array.isArray(d == null ? void 0 : d.y) && d.y.length === 5 && !derivedData.has(d)) {
11542
+ const key = i + ":" + j;
11543
+ if (Array.isArray(d == null ? void 0 : d.y) && d.y.length === 5 && !isDerived(derived, key, d.y)) {
11236
11544
  return d;
11237
11545
  }
11238
11546
  const values = observationsOf(d, false);
@@ -11241,9 +11549,8 @@ function boxPlotTransform(ser, w) {
11241
11549
  if (!summary) return d;
11242
11550
  touched = true;
11243
11551
  byPoint[j] = values;
11244
- const next = __spreadProps(__spreadValues({}, d), { y: summary.summary, points: values });
11245
- derivedData.add(next);
11246
- return next;
11552
+ derived.set(key, summary.summary);
11553
+ return __spreadProps(__spreadValues({}, d), { y: summary.summary, points: values });
11247
11554
  });
11248
11555
  if (touched) observed[i] = byPoint;
11249
11556
  return touched ? __spreadProps(__spreadValues({}, s), { data }) : s;
@@ -11255,6 +11562,7 @@ function violinTransform(ser, w) {
11255
11562
  var _a, _b;
11256
11563
  if (!Array.isArray(ser)) return ser;
11257
11564
  const kde = ((_b = (_a = w.config.plotOptions) == null ? void 0 : _a.violin) == null ? void 0 : _b.kde) || {};
11565
+ const derived = derivedStats(w, "violin");
11258
11566
  const observed = [];
11259
11567
  const out = ser.map((s, i) => {
11260
11568
  if (!Array.isArray(s == null ? void 0 : s.data) || s.type && s.type !== "violin") return s;
@@ -11262,7 +11570,8 @@ function violinTransform(ser, w) {
11262
11570
  const byPoint = new Array(s.data.length).fill(null);
11263
11571
  const data = s.data.map((d, j) => {
11264
11572
  var _a2;
11265
- if (Array.isArray((_a2 = d == null ? void 0 : d.y) == null ? void 0 : _a2.density) && d.y.density.length && !derivedData.has(d)) {
11573
+ const key = i + ":" + j;
11574
+ if (Array.isArray((_a2 = d == null ? void 0 : d.y) == null ? void 0 : _a2.density) && d.y.density.length && !isDerived(derived, key, d.y.density)) {
11266
11575
  return d;
11267
11576
  }
11268
11577
  const values = observationsOf(d, true);
@@ -11275,11 +11584,8 @@ function violinTransform(ser, w) {
11275
11584
  touched = true;
11276
11585
  byPoint[j] = values;
11277
11586
  const rest = d.y && typeof d.y === "object" && !Array.isArray(d.y) ? d.y : {};
11278
- const next = __spreadProps(__spreadValues({}, d), {
11279
- y: __spreadProps(__spreadValues({}, rest), { density: est.density, points: values })
11280
- });
11281
- derivedData.add(next);
11282
- return next;
11587
+ derived.set(key, est.density);
11588
+ return __spreadProps(__spreadValues({}, d), { y: __spreadProps(__spreadValues({}, rest), { density: est.density, points: values }) });
11283
11589
  });
11284
11590
  if (touched) observed[i] = byPoint;
11285
11591
  return touched ? __spreadProps(__spreadValues({}, s), { data }) : s;
@@ -11359,7 +11665,7 @@ function histogramRows(w, opts) {
11359
11665
  const raw = gl && gl.histogramRawSeries;
11360
11666
  if (!hd || !Array.isArray(hd.edges) || hd.edges.length < 2) return null;
11361
11667
  if (!Array.isArray(raw) || !raw.length) return null;
11362
- const collapsed = gl && gl.collapsedSeriesIndices || [];
11668
+ const collapsed = collapsedIndices(gl);
11363
11669
  const edges = hd.edges;
11364
11670
  const clusters = [];
11365
11671
  raw.forEach((s, i) => {
@@ -11389,7 +11695,7 @@ function pointsRowSource(pick) {
11389
11695
  var _a;
11390
11696
  const perSeries = pick(w);
11391
11697
  if (!Array.isArray(perSeries) || !perSeries.length) return null;
11392
- const collapsed = w.globals && w.globals.collapsedSeriesIndices || [];
11698
+ const collapsed = w.globals ? collapsedIndices(w.globals) : [];
11393
11699
  const labels = w.globals && (((_a = w.globals.categoryLabels) == null ? void 0 : _a.length) ? w.globals.categoryLabels : w.globals.labels) || [];
11394
11700
  const clusters = [];
11395
11701
  perSeries.forEach((byCat, i) => {
@@ -12020,18 +12326,32 @@ class BarDataLabels {
12020
12326
  realIndex,
12021
12327
  j
12022
12328
  );
12329
+ const val = (hl == null ? void 0 : hl.hide) ? void 0 : waterfallStep !== null ? waterfallStep : (
12330
+ // only RangeBar passes a range, vertical or horizontal
12331
+ y2 !== void 0 ? [y1, y2] : w.config.chart.stackType === "100%" ? (
12332
+ // Read the percentages globally rather than out of `series`.
12333
+ // Under `stackType: '100%'` BarStacked replaces `series` with
12334
+ // the percentage rows, and in a combo chart it narrows them to
12335
+ // just the series it draws as bars, so `series` is indexed by
12336
+ // bar position while `realIndex` counts every series. A line
12337
+ // ahead of a column pushed `realIndex` past the end and the
12338
+ // label read a value off `undefined` (#2429).
12339
+ w.globals.seriesPercent[realIndex][j]
12340
+ ) : w.seriesData.series[realIndex][j]
12341
+ );
12342
+ let text;
12023
12343
  let textRects = {
12024
12344
  width: 0,
12025
12345
  height: 0
12026
12346
  };
12027
- if (w.config.dataLabels.enabled) {
12028
- const yLabel = waterfallStep !== null ? waterfallStep : w.seriesData.series[realIndex][j];
12347
+ if (dataLabelsConfig.enabled) {
12348
+ text = val === void 0 ? "" : dataLabelsConfig.formatter(val, __spreadProps(__spreadValues({}, w), {
12349
+ seriesIndex: realIndex,
12350
+ dataPointIndex: j,
12351
+ w
12352
+ }));
12029
12353
  textRects = graphics.getTextRects(
12030
- w.config.dataLabels.formatter ? w.config.dataLabels.formatter(yLabel, __spreadProps(__spreadValues({}, w), {
12031
- seriesIndex: realIndex,
12032
- dataPointIndex: j,
12033
- w
12034
- })) : w.formatters.yLabelFormatters[0](yLabel),
12354
+ text,
12035
12355
  parseFloat(dataLabelsConfig.style.fontSize).toString(),
12036
12356
  dataLabelsConfig.style.fontFamily,
12037
12357
  void 0,
@@ -12076,19 +12396,8 @@ class BarDataLabels {
12076
12396
  x: dataLabelsPos.dataLabelsX,
12077
12397
  y: dataLabelsPos.dataLabelsY,
12078
12398
  neg: params.neg,
12079
- // A datum the highlight filter leaves without a part keeps no label. It
12080
- // is still drawn, blank, as a null value is: the overlap pass indexes
12081
- // its rects by data point, so a skipped one would misalign the rest.
12082
- val: (hl == null ? void 0 : hl.hide) ? void 0 : waterfallStep !== null ? waterfallStep : this.barCtx.isRangeBar ? [y1, y2] : w.config.chart.stackType === "100%" ? (
12083
- // Read the percentages globally rather than out of `series`.
12084
- // Under `stackType: '100%'` BarStacked replaces `series` with
12085
- // the percentage rows, and in a combo chart it narrows them to
12086
- // just the series it draws as bars, so `series` is indexed by
12087
- // bar position while `realIndex` counts every series. A line
12088
- // ahead of a column pushed `realIndex` past the end and the
12089
- // label read a value off `undefined` (#2429).
12090
- w.globals.seriesPercent[realIndex][j]
12091
- ) : w.seriesData.series[realIndex][j],
12399
+ val,
12400
+ text,
12092
12401
  i: realIndex,
12093
12402
  j,
12094
12403
  barWidth: params.barWidth,
@@ -12126,16 +12435,16 @@ class BarDataLabels {
12126
12435
  return this.w.labelData.seriesGroups.length > 1;
12127
12436
  }
12128
12437
  /**
12129
- * The series group `realIndex` belongs to, and that group's own stacking
12130
- * state, or null when totals are chart-wide (the single-group case).
12438
+ * The series group `realIndex` belongs to, or null when totals are
12439
+ * chart-wide (the single-group case).
12131
12440
  * @param {number} realIndex
12132
- * @returns {{groupIndex: number, group: string[]} | null}
12441
+ * @returns {{groupIndex: number} | null}
12133
12442
  */
12134
12443
  getTotalGroupContext(realIndex) {
12135
12444
  if (!this.hasMultipleSeriesGroups()) return null;
12136
12445
  const groupIndex = this.barCtx.barHelpers.getSeriesGroupIndex(realIndex);
12137
12446
  if (groupIndex < 0) return null;
12138
- return { groupIndex, group: this.w.labelData.seriesGroups[groupIndex] };
12447
+ return { groupIndex };
12139
12448
  }
12140
12449
  /**
12141
12450
  * Whether `realIndex` is the series that should draw the stacked total.
@@ -12162,10 +12471,23 @@ class BarDataLabels {
12162
12471
  getStackedTotalValue({ realIndex, j }) {
12163
12472
  if (this.hlt) return this.hlt.val;
12164
12473
  const w = this.w;
12474
+ const top = this.xStackTop(realIndex, j);
12475
+ if (top) return top[3];
12165
12476
  const ctx = this.getTotalGroupContext(realIndex);
12166
12477
  const byGroups = w.seriesData.stackedSeriesTotalsByGroups;
12167
12478
  return ctx && byGroups && byGroups[ctx.groupIndex] ? byGroups[ctx.groupIndex][j] : this.barCtx.stackedSeriesTotals[j];
12168
12479
  }
12480
+ /**
12481
+ * The running stack at this column's x (BarStacked `tops`, columns only) on
12482
+ * a numeric axis, where columns stack by x rather than by index.
12483
+ * @param {number} realIndex @param {number} j
12484
+ */
12485
+ xStackTop(realIndex, j) {
12486
+ var _a, _b;
12487
+ const w = this.w;
12488
+ return w.axisFlags.isXNumeric && /** @type {any} */
12489
+ ((_b = (_a = this.barCtx.stacks) == null ? void 0 : _a[w.labelData.seriesGroupIndex[realIndex]]) == null ? void 0 : _b.tops.get(w.seriesData.seriesX[realIndex][j]));
12490
+ }
12169
12491
  /** @param {{realIndex: any, j: any}} opts */
12170
12492
  getStackedTotalDataLabel({ realIndex, j }) {
12171
12493
  const w = this.w;
@@ -12285,18 +12607,23 @@ class BarDataLabels {
12285
12607
  }
12286
12608
  let lowestPrevY = newY;
12287
12609
  const totalGroupCtx = this.getTotalGroupContext(realIndex);
12288
- const prevYGroups = totalGroupCtx ? [totalGroupCtx.group] : w.labelData.seriesGroups;
12289
- prevYGroups.forEach((sg) => {
12290
- var _a2;
12291
- (_a2 = this.barCtx[sg.join(",")]) == null ? void 0 : _a2.prevY.forEach(
12292
- (arr) => {
12293
- if (valIsNegative) {
12294
- lowestPrevY = Math.max(arr[j], lowestPrevY);
12295
- } else {
12296
- lowestPrevY = Math.min(arr[j], lowestPrevY);
12297
- }
12610
+ const top = this.xStackTop(realIndex, j);
12611
+ const stacks = top ? [] : (
12612
+ /** @type {any} */
12613
+ this.barCtx.stacks || []
12614
+ );
12615
+ if (top) {
12616
+ lowestPrevY = valIsNegative ? Math.max(newY, top[5]) : Math.min(newY, top[4]);
12617
+ }
12618
+ stacks.forEach((g, gi) => {
12619
+ if (totalGroupCtx && gi !== totalGroupCtx.groupIndex) return;
12620
+ g.prevY.forEach((arr) => {
12621
+ if (valIsNegative) {
12622
+ lowestPrevY = Math.max(arr[j], lowestPrevY);
12623
+ } else {
12624
+ lowestPrevY = Math.min(arr[j], lowestPrevY);
12298
12625
  }
12299
- );
12626
+ });
12300
12627
  });
12301
12628
  if (this.hlt) lowestPrevY = this.hlt.edge;
12302
12629
  if (this.drawsStackedTotal(realIndex) && barTotalDataLabelsConfig.enabled) {
@@ -12408,18 +12735,19 @@ class BarDataLabels {
12408
12735
  }
12409
12736
  let lowestPrevX = newX;
12410
12737
  const totalGroupCtx = this.getTotalGroupContext(realIndex);
12411
- const prevXGroups = totalGroupCtx ? [totalGroupCtx.group] : w.labelData.seriesGroups;
12412
- prevXGroups.forEach((sg) => {
12413
- var _a2;
12414
- (_a2 = this.barCtx[sg.join(",")]) == null ? void 0 : _a2.prevX.forEach(
12415
- (arr) => {
12416
- if (valIsNegative) {
12417
- lowestPrevX = Math.min(arr[j], lowestPrevX);
12418
- } else {
12419
- lowestPrevX = Math.max(arr[j], lowestPrevX);
12420
- }
12738
+ const stacks = (
12739
+ /** @type {any} */
12740
+ this.barCtx.stacks || []
12741
+ );
12742
+ stacks.forEach((g, gi) => {
12743
+ if (totalGroupCtx && gi !== totalGroupCtx.groupIndex) return;
12744
+ g.prevX.forEach((arr) => {
12745
+ if (valIsNegative) {
12746
+ lowestPrevX = Math.min(arr[j], lowestPrevX);
12747
+ } else {
12748
+ lowestPrevX = Math.max(arr[j], lowestPrevX);
12421
12749
  }
12422
- );
12750
+ });
12423
12751
  });
12424
12752
  if (this.hlt) lowestPrevX = this.hlt.edge;
12425
12753
  if (this.drawsStackedTotal(realIndex) && barTotalDataLabelsConfig.enabled) {
@@ -12470,11 +12798,12 @@ class BarDataLabels {
12470
12798
  totalDataLabelsAnchor
12471
12799
  };
12472
12800
  }
12473
- /** @param {{x: any, y: any, val: any, neg?: boolean, i: any, j: any, textRects: any, barHeight: any, barWidth: any, dataLabelsConfig: any}} opts */
12801
+ /** @param {{x: any, y: any, val: any, text?: any, neg?: boolean, i: any, j: any, textRects: any, barHeight: any, barWidth: any, dataLabelsConfig: any}} opts */
12474
12802
  drawCalculatedDataLabels({
12475
12803
  x: x2,
12476
12804
  y,
12477
12805
  val,
12806
+ text,
12478
12807
  neg,
12479
12808
  i,
12480
12809
  // = realIndex
@@ -12497,7 +12826,10 @@ class BarDataLabels {
12497
12826
  const isSeriesCollapsing = (w.globals.collapsingSeriesIndices || []).indexOf(i) > -1;
12498
12827
  if (isSeriesCollapsing) {
12499
12828
  const prev = (_a = w.globals.prevDataLabels) == null ? void 0 : _a.get(`${i}::${datumKey(w, i, j)}`);
12500
- if (prev && isFinite(prev.val)) val = prev.val;
12829
+ if (prev && isFinite(prev.val)) {
12830
+ val = prev.val;
12831
+ text = void 0;
12832
+ }
12501
12833
  }
12502
12834
  if (dataLabelsConfig.enabled && (!isSeriesCollapsed || isSeriesCollapsing)) {
12503
12835
  elDataLabelsWrap = graphics.group({
@@ -12515,8 +12847,9 @@ class BarDataLabels {
12515
12847
  elDataLabelsWrap.node.setAttribute("data:dlVal", String(val));
12516
12848
  }
12517
12849
  }
12518
- let text = "";
12519
- if (typeof val !== "undefined") {
12850
+ if (val === void 0) {
12851
+ text = "";
12852
+ } else if (text === void 0) {
12520
12853
  text = formatter(val, __spreadProps(__spreadValues({}, w), {
12521
12854
  seriesIndex: i,
12522
12855
  dataPointIndex: j,
@@ -12733,9 +13066,9 @@ let Helpers$1 = class Helpers3 {
12733
13066
  }
12734
13067
  /**
12735
13068
  * Smallest positive gap between neighbouring x values once every series is
12736
- * merged onto one axis. A k-way merge over the series arrays, which are
12737
- * already sorted in every ordinary case; an unsorted one can only make the
12738
- * answer smaller, i.e. the bars narrower, never overlapping.
13069
+ * merged onto one axis. A k-way merge over the series arrays, which needs
13070
+ * each one ascending: a non-ascending array (newest-first data) is merged
13071
+ * from a sorted copy, or every gap would read as one huge slot.
12739
13072
  *
12740
13073
  * Collapsed series count too, exactly as they did for `minXDiff`. Skipping
12741
13074
  * them would widen every bar the moment someone hid the tightest-spaced
@@ -12749,7 +13082,11 @@ let Helpers$1 = class Helpers3 {
12749
13082
  const arrays = [];
12750
13083
  for (let i = 0; i < seriesX.length; i++) {
12751
13084
  const xs = seriesX[i];
12752
- if (Array.isArray(xs) && xs.length > 0) arrays.push(xs);
13085
+ if (Array.isArray(xs) && xs.length > 0) {
13086
+ arrays.push(
13087
+ xs.some((v, n) => v < xs[n - 1]) ? xs.filter((v) => v === +v).sort((a, b) => a - b) : xs
13088
+ );
13089
+ }
12753
13090
  }
12754
13091
  if (!arrays.length) return 0;
12755
13092
  const cursor = new Array(arrays.length).fill(0);
@@ -12861,30 +13198,27 @@ let Helpers$1 = class Helpers3 {
12861
13198
  * @param {Record<string, any>} ctx
12862
13199
  */
12863
13200
  initializeStackedPrevVars(ctx) {
12864
- const w = ctx.w;
12865
- w.labelData.seriesGroups.forEach((group) => {
12866
- if (!ctx[group]) ctx[group] = {};
12867
- ctx[group].prevY = [];
12868
- ctx[group].prevX = [];
12869
- ctx[group].prevYF = [];
12870
- ctx[group].prevXF = [];
12871
- ctx[group].prevYVal = [];
12872
- ctx[group].prevXVal = [];
12873
- });
13201
+ ctx.stacks = ctx.w.labelData.seriesGroups.map(() => ({
13202
+ prevY: [],
13203
+ prevX: [],
13204
+ prevYF: [],
13205
+ prevXF: [],
13206
+ prevYVal: [],
13207
+ prevXVal: [],
13208
+ tops: /* @__PURE__ */ new Map()
13209
+ }));
12874
13210
  }
12875
13211
  /**
12876
13212
  * @param {Record<string, any>} ctx
12877
13213
  */
12878
13214
  initializeStackedXYVars(ctx) {
12879
- const w = ctx.w;
12880
- w.labelData.seriesGroups.forEach((group) => {
12881
- if (!ctx[group]) ctx[group] = {};
12882
- ctx[group].xArrj = [];
12883
- ctx[group].xArrjF = [];
12884
- ctx[group].xArrjVal = [];
12885
- ctx[group].yArrj = [];
12886
- ctx[group].yArrjF = [];
12887
- ctx[group].yArrjVal = [];
13215
+ ctx.stacks.forEach((g) => {
13216
+ g.xArrj = [];
13217
+ g.xArrjF = [];
13218
+ g.xArrjVal = [];
13219
+ g.yArrj = [];
13220
+ g.yArrjF = [];
13221
+ g.yArrjVal = [];
12888
13222
  });
12889
13223
  }
12890
13224
  /**
@@ -13210,7 +13544,7 @@ let Helpers$1 = class Helpers3 {
13210
13544
  direction
13211
13545
  };
13212
13546
  }
13213
- /** @param {{ barWidth?: any, barXPosition?: any, y1?: any, y2?: any, yRatio?: any, strokeWidth?: any, isReversed?: any, series?: any, seriesGroup?: any, realIndex?: any, i?: any, j?: any, w?: any }} opts */
13547
+ /** @param {{ barWidth?: any, barXPosition?: any, y1?: any, y2?: any, yRatio?: any, strokeWidth?: any, isReversed?: any, series?: any, realIndex?: any, i?: any, j?: any, w?: any }} opts */
13214
13548
  getColumnPaths({
13215
13549
  barWidth,
13216
13550
  barXPosition,
@@ -13218,7 +13552,6 @@ let Helpers$1 = class Helpers3 {
13218
13552
  y2,
13219
13553
  strokeWidth,
13220
13554
  series,
13221
- seriesGroup,
13222
13555
  realIndex,
13223
13556
  i,
13224
13557
  j,
@@ -13252,8 +13585,7 @@ let Helpers$1 = class Helpers3 {
13252
13585
  pathFrom = r.base;
13253
13586
  }
13254
13587
  if (w.config.chart.stacked) {
13255
- let _ctx = this.barCtx;
13256
- _ctx = this.barCtx[seriesGroup];
13588
+ const _ctx = this.barCtx.groupCtx;
13257
13589
  _ctx.yArrj.push(y2 - strokeCenter * direction);
13258
13590
  _ctx.yArrjF.push(Math.abs(y1 - y2 + r.strokeWidth * direction));
13259
13591
  _ctx.yArrjVal.push(this.barCtx.series[i][j]);
@@ -13433,7 +13765,7 @@ let Helpers$1 = class Helpers3 {
13433
13765
  barXPosition: center
13434
13766
  };
13435
13767
  }
13436
- /** @param {{ barYPosition?: any, barHeight?: any, x1?: any, x2?: any, strokeWidth?: any, isReversed?: any, series?: any, seriesGroup?: any, realIndex?: any, i?: any, j?: any, w?: any }} opts */
13768
+ /** @param {{ barYPosition?: any, barHeight?: any, x1?: any, x2?: any, strokeWidth?: any, isReversed?: any, series?: any, realIndex?: any, i?: any, j?: any, w?: any }} opts */
13437
13769
  getBarpaths({
13438
13770
  barYPosition,
13439
13771
  barHeight,
@@ -13441,7 +13773,6 @@ let Helpers$1 = class Helpers3 {
13441
13773
  x2,
13442
13774
  strokeWidth,
13443
13775
  series,
13444
- seriesGroup,
13445
13776
  realIndex,
13446
13777
  i,
13447
13778
  j,
@@ -13480,8 +13811,7 @@ let Helpers$1 = class Helpers3 {
13480
13811
  pathFrom = graphics.move(fromX, y1) + graphics.line(fromX, y1) + slFrom + slFrom + slFrom + slFrom + slFrom + graphics.line(fromX, y1) + closing;
13481
13812
  }
13482
13813
  if (w.config.chart.stacked) {
13483
- let _ctx = this.barCtx;
13484
- _ctx = this.barCtx[seriesGroup];
13814
+ const _ctx = this.barCtx.groupCtx;
13485
13815
  _ctx.xArrj.push(x2 + strokeCenter * direction);
13486
13816
  _ctx.xArrjF.push(Math.abs(x1 - x2 - r.strokeWidth * direction));
13487
13817
  _ctx.xArrjVal.push(this.barCtx.series[i][j]);
@@ -13807,24 +14137,14 @@ let Helpers$1 = class Helpers3 {
13807
14137
  * @returns {number}
13808
14138
  */
13809
14139
  getSeriesGroupIndex(seriesIndex) {
13810
- const w = this.w;
13811
- return w.labelData.seriesGroups.findIndex(
13812
- (group) => group.indexOf(w.seriesData.seriesNames[seriesIndex]) > -1
13813
- );
14140
+ var _a;
14141
+ return (_a = this.w.labelData.seriesGroupIndex[seriesIndex]) != null ? _a : -1;
13814
14142
  }
13815
14143
  /**
13816
14144
  * @param {number} seriesIndex
13817
14145
  */
13818
14146
  getGroupIndex(seriesIndex) {
13819
- const w = this.w;
13820
- const groupIndex = w.labelData.seriesGroups.findIndex(
13821
- (group) => (
13822
- // w.config.series[i].name may be undefined, so use
13823
- // w.seriesData.seriesNames[i], which has default names for those
13824
- // series. w.labelData.seriesGroups[] uses the same default naming.
13825
- group.indexOf(w.seriesData.seriesNames[seriesIndex]) > -1
13826
- )
13827
- );
14147
+ const groupIndex = this.getSeriesGroupIndex(seriesIndex);
13828
14148
  const cGI = this.barCtx.columnGroupIndices;
13829
14149
  let columnGroupIndex = cGI.indexOf(groupIndex);
13830
14150
  if (columnGroupIndex < 0) {
@@ -13897,6 +14217,20 @@ class Bar {
13897
14217
  );
13898
14218
  this.barHelpers = new Helpers$1(this);
13899
14219
  }
14220
+ /**
14221
+ * Point the per-series axis state at this series' y axis. Every bar-family
14222
+ * renderer calls it before initialPositions, which reads the baseline by
14223
+ * this.translationsIndex.
14224
+ * @param {number} realIndex
14225
+ * @return {number} translationsIndex
14226
+ */
14227
+ setSeriesAxis(realIndex) {
14228
+ if (this.yRatio.length > 1) {
14229
+ this.yaxisIndex = this.w.globals.seriesYAxisReverseMap[realIndex];
14230
+ this.translationsIndex = realIndex;
14231
+ }
14232
+ return this.translationsIndex;
14233
+ }
13900
14234
  /** primary draw method which is called on bar object
13901
14235
  * @memberof Bar
13902
14236
  * @param {any[]} series - user supplied series values
@@ -13942,11 +14276,7 @@ class Bar {
13942
14276
  if (series[i].length > 0) {
13943
14277
  this.visibleI = this.visibleI + 1;
13944
14278
  }
13945
- if (this.yRatio.length > 1) {
13946
- this.yaxisIndex = w.globals.seriesYAxisReverseMap[realIndex];
13947
- this.translationsIndex = realIndex;
13948
- }
13949
- const translationsIndex = this.translationsIndex;
14279
+ const translationsIndex = this.setSeriesAxis(realIndex);
13950
14280
  this.isReversed = w.config.yaxis[this.yaxisIndex] && w.config.yaxis[this.yaxisIndex].reversed;
13951
14281
  if (this.isPyramid) {
13952
14282
  this.pyramidLayout = this.barHelpers.computePyramidLayout(series[i]);
@@ -14964,7 +15294,6 @@ class BarStacked extends Bar {
14964
15294
  draw(series, seriesIndex) {
14965
15295
  const w = this.w;
14966
15296
  this.graphics = new Graphics(this.w);
14967
- this.bar = new Bar(this.w, this.ctx, this.xyRatios);
14968
15297
  const coreUtils = new CoreUtils(this.w);
14969
15298
  series = coreUtils.getLogSeries(series);
14970
15299
  this.yRatio = coreUtils.getLogYRatios(this.yRatio);
@@ -14995,18 +15324,10 @@ class BarStacked extends Bar {
14995
15324
  ) : i;
14996
15325
  const { groupIndex, columnGroupIndex } = this.barHelpers.getGroupIndex(realIndex);
14997
15326
  this.groupCtx = /** @type {any} */
14998
- this[
14999
- /** @type {any} */
15000
- w.labelData.seriesGroups[groupIndex]
15001
- ];
15327
+ this.stacks[groupIndex];
15002
15328
  const xArrValues = [];
15003
15329
  const yArrValues = [];
15004
- let translationsIndex = 0;
15005
- if (this.yRatio.length > 1) {
15006
- this.yaxisIndex = /** @type {any} */
15007
- w.globals.seriesYAxisReverseMap[realIndex][0];
15008
- translationsIndex = realIndex;
15009
- }
15330
+ const translationsIndex = this.setSeriesAxis(realIndex);
15010
15331
  this.isReversed = w.config.yaxis[this.yaxisIndex] && w.config.yaxis[this.yaxisIndex].reversed;
15011
15332
  let elSeries = this.graphics.group({
15012
15333
  class: `apexcharts-series`,
@@ -15070,8 +15391,7 @@ class BarStacked extends Bar {
15070
15391
  x: x2,
15071
15392
  y,
15072
15393
  elSeries,
15073
- columnGroupIndex,
15074
- seriesGroup: w.labelData.seriesGroups[groupIndex]
15394
+ columnGroupIndex
15075
15395
  };
15076
15396
  let paths = (
15077
15397
  /** @type {any} */
@@ -15262,7 +15582,7 @@ class BarStacked extends Bar {
15262
15582
  zeroW
15263
15583
  };
15264
15584
  }
15265
- /** @param {{indexes: any, barHeight: any, strokeWidth: any, zeroW: any, x: any, y: any, columnGroupIndex: any, seriesGroup: any, yDivision: any, elSeries: any}} opts */
15585
+ /** @param {{indexes: any, barHeight: any, strokeWidth: any, zeroW: any, x: any, y: any, columnGroupIndex: any, yDivision: any, elSeries: any}} opts */
15266
15586
  drawStackedBarPaths({
15267
15587
  indexes,
15268
15588
  barHeight,
@@ -15271,7 +15591,6 @@ class BarStacked extends Bar {
15271
15591
  x: x2,
15272
15592
  y,
15273
15593
  columnGroupIndex,
15274
- seriesGroup,
15275
15594
  yDivision,
15276
15595
  elSeries
15277
15596
  }) {
@@ -15322,7 +15641,6 @@ class BarStacked extends Bar {
15322
15641
  isReversed: this.isReversed,
15323
15642
  series: this.series,
15324
15643
  realIndex: indexes.realIndex,
15325
- seriesGroup,
15326
15644
  i,
15327
15645
  j,
15328
15646
  w
@@ -15353,7 +15671,7 @@ class BarStacked extends Bar {
15353
15671
  y
15354
15672
  };
15355
15673
  }
15356
- /** @param {{indexes: any, x: any, y: any, xDivision: any, barWidth: any, zeroH: any, columnGroupIndex: any, seriesGroup: any, elSeries: any}} opts */
15674
+ /** @param {{indexes: any, x: any, y: any, xDivision: any, barWidth: any, zeroH: any, columnGroupIndex: any, elSeries: any}} opts */
15357
15675
  drawStackedColumnPaths({
15358
15676
  indexes,
15359
15677
  x: x2,
@@ -15362,10 +15680,9 @@ class BarStacked extends Bar {
15362
15680
  barWidth,
15363
15681
  zeroH,
15364
15682
  columnGroupIndex,
15365
- seriesGroup,
15366
15683
  elSeries
15367
15684
  }) {
15368
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
15685
+ var _a, _b, _c, _d, _e, _f;
15369
15686
  const w = this.w;
15370
15687
  const i = indexes.i;
15371
15688
  const j = indexes.j;
@@ -15379,43 +15696,23 @@ class BarStacked extends Bar {
15379
15696
  }
15380
15697
  const barXPosition = x2 + columnGroupIndex * barWidth;
15381
15698
  let barYPosition;
15382
- let prevBarH = 0;
15383
- for (let k2 = 0; k2 < this.groupCtx.prevYF.length; k2++) {
15384
- prevBarH = prevBarH + (!isNaN(this.groupCtx.prevYF[k2][j]) ? this.groupCtx.prevYF[k2][j] : 0);
15385
- }
15386
- const gsi = this.groupCtx.prevY.length;
15387
- if (gsi > 0 && !w.axisFlags.isXNumeric || gsi > 0 && w.axisFlags.isXNumeric && w.seriesData.seriesX[realIndex - 1][j] === w.seriesData.seriesX[realIndex][j]) {
15699
+ const g = this.groupCtx;
15700
+ const key = w.axisFlags.isXNumeric ? w.seriesData.seriesX[realIndex][j] : j;
15701
+ const top = g.tops.get(key);
15702
+ if (top) {
15703
+ const [prevYValue, prevVal, prevBarH] = top;
15388
15704
  let bYP;
15389
- let prevYValue;
15390
- const p = Math.min(this.yRatio.length + 1, realIndex + 1);
15391
- if (this.groupCtx.prevY[gsi - 1] !== void 0 && this.groupCtx.prevY[gsi - 1].length) {
15392
- for (let ii = 1; ii < p; ii++) {
15393
- if (!isNaN((_a = this.groupCtx.prevY[gsi - ii]) == null ? void 0 : _a[j])) {
15394
- prevYValue = this.groupCtx.prevY[gsi - ii][j];
15395
- break;
15396
- }
15397
- }
15398
- }
15399
- for (let ii = 1; ii < p; ii++) {
15400
- if (((_b = this.groupCtx.prevYVal[gsi - ii]) == null ? void 0 : _b[j]) < 0) {
15401
- bYP = /** @type {any} */
15402
- ((_c = this.series[i]) == null ? void 0 : _c[j]) >= 0 ? prevYValue - prevBarH + (this.isReversed ? prevBarH : 0) * 2 : prevYValue;
15403
- break;
15404
- } else if (((_d = this.groupCtx.prevYVal[gsi - ii]) == null ? void 0 : _d[j]) >= 0) {
15405
- bYP = /** @type {any} */
15406
- ((_e = this.series[i]) == null ? void 0 : _e[j]) >= 0 ? prevYValue : prevYValue + prevBarH - (this.isReversed ? prevBarH : 0) * 2;
15407
- break;
15408
- }
15705
+ if (prevVal < 0) {
15706
+ bYP = /** @type {any} */
15707
+ ((_a = this.series[i]) == null ? void 0 : _a[j]) >= 0 ? prevYValue - prevBarH + (this.isReversed ? prevBarH : 0) * 2 : prevYValue;
15708
+ } else if (prevVal >= 0) {
15709
+ bYP = /** @type {any} */
15710
+ ((_b = this.series[i]) == null ? void 0 : _b[j]) >= 0 ? prevYValue : prevYValue + prevBarH - (this.isReversed ? prevBarH : 0) * 2;
15409
15711
  }
15410
15712
  if (typeof bYP === "undefined") bYP = w.layout.gridHeight;
15411
- if (
15412
- /**
15413
- * @param {number} val
15414
- */
15415
- ((_f = this.groupCtx.prevYF[0]) == null ? void 0 : _f.every((val) => val === 0)) && this.groupCtx.prevYF.slice(1, gsi).every(
15416
- (arr) => arr.every((val) => isNaN(val))
15417
- )
15418
- ) {
15713
+ if (((_c = g.prevYF[0]) == null ? void 0 : _c.every((val) => val === 0)) && g.prevYF.slice(1).every(
15714
+ (arr) => arr.every((val) => isNaN(val))
15715
+ )) {
15419
15716
  barYPosition = zeroH;
15420
15717
  } else {
15421
15718
  barYPosition = bYP;
@@ -15425,12 +15722,12 @@ class BarStacked extends Bar {
15425
15722
  }
15426
15723
  if (
15427
15724
  /** @type {any} */
15428
- (_g = this.series[i]) == null ? void 0 : _g[j]
15725
+ (_d = this.series[i]) == null ? void 0 : _d[j]
15429
15726
  ) {
15430
15727
  y = barYPosition - /** @type {any} */
15431
- ((_h = this.series[i]) == null ? void 0 : _h[j]) / this.yRatio[translationsIndex] + (this.isReversed ? (
15728
+ ((_e = this.series[i]) == null ? void 0 : _e[j]) / this.yRatio[translationsIndex] + (this.isReversed ? (
15432
15729
  /** @type {any} */
15433
- ((_i = this.series[i]) == null ? void 0 : _i[j]) / this.yRatio[translationsIndex]
15730
+ ((_f = this.series[i]) == null ? void 0 : _f[j]) / this.yRatio[translationsIndex]
15434
15731
  ) : 0) * 2;
15435
15732
  } else {
15436
15733
  y = barYPosition;
@@ -15444,12 +15741,22 @@ class BarStacked extends Bar {
15444
15741
  strokeWidth: this.strokeWidth,
15445
15742
  isReversed: this.isReversed,
15446
15743
  series: this.series,
15447
- seriesGroup,
15448
15744
  realIndex: indexes.realIndex,
15449
15745
  i,
15450
15746
  j,
15451
15747
  w
15452
15748
  });
15749
+ const t = g.yArrj[j];
15750
+ if (!isNaN(t)) {
15751
+ g.tops.set(key, [
15752
+ t,
15753
+ g.yArrjVal[j],
15754
+ (top ? top[2] : 0) + g.yArrjF[j],
15755
+ (top ? top[3] : 0) + (w.seriesData.series[realIndex][j] || 0),
15756
+ top ? Math.min(top[0], top[4]) : 1 / 0,
15757
+ top ? Math.max(top[0], top[5]) : -1 / 0
15758
+ ]);
15759
+ }
15453
15760
  this.barHelpers.barBackground({
15454
15761
  bc,
15455
15762
  j,
@@ -15731,12 +16038,7 @@ class BoxCandleStick extends Bar {
15731
16038
  if (series[i].length > 0) {
15732
16039
  this.visibleI = this.visibleI + 1;
15733
16040
  }
15734
- let translationsIndex = 0;
15735
- if (this.yRatio.length > 1) {
15736
- this.yaxisIndex = /** @type {any} */
15737
- w.globals.seriesYAxisReverseMap[realIndex][0];
15738
- translationsIndex = realIndex;
15739
- }
16041
+ const translationsIndex = this.setSeriesAxis(realIndex);
15740
16042
  const initPositions = this.barHelpers.initialPositions(realIndex);
15741
16043
  const {
15742
16044
  y: initY,
@@ -16283,7 +16585,7 @@ class TreemapHelpers {
16283
16585
  percent
16284
16586
  };
16285
16587
  }
16286
- /** @param {{ text?: any, x?: any, y?: any, i?: any, j?: any, colorProps?: any, fontSize?: any, series?: any }} opts */
16588
+ /** @param {{ text?: any, x?: any, y?: any, i?: any, j?: any, colorProps?: any, fontSize?: any }} opts */
16287
16589
  calculateDataLabels({ text, x: x2, y, i, j, colorProps, fontSize }) {
16288
16590
  const w = this.w;
16289
16591
  const dataLabelsConfig = w.config.dataLabels;
@@ -16313,6 +16615,19 @@ class TreemapHelpers {
16313
16615
  return elDataLabelsWrap;
16314
16616
  }
16315
16617
  }
16618
+ function cellSpan(w) {
16619
+ const gl = w.globals;
16620
+ let diff = gl.minXDiff;
16621
+ if (!w.seriesData.series.some((s) => s.length > 1)) {
16622
+ const xs = w.seriesData.seriesX.map((s) => s && s[0]).filter(Number.isFinite).sort((a, b) => a - b);
16623
+ diff = Infinity;
16624
+ for (let k2 = 1; k2 < xs.length; k2++) {
16625
+ if (xs[k2] > xs[k2 - 1]) diff = Math.min(diff, xs[k2] - xs[k2 - 1]);
16626
+ }
16627
+ if (diff === Infinity) diff = (gl.maxX - gl.minX) / 4;
16628
+ }
16629
+ return Number.isFinite(diff) && diff > 0 ? diff : 0;
16630
+ }
16316
16631
  class HeatMap {
16317
16632
  /**
16318
16633
  * @param {import('../types/internal').ChartStateW} w
@@ -16330,6 +16645,35 @@ class HeatMap {
16330
16645
  this.shape = this.w.config.plotOptions.heatmap.shape || "rect";
16331
16646
  this.strokeWidth = this.w.config.stroke.show ? this.w.config.stroke.width : 0;
16332
16647
  }
16648
+ /**
16649
+ * Called by Range.setXRange, off the prototype, before it builds the x
16650
+ * scale. A numeric or datetime heatmap centres each cell on its x, so an
16651
+ * axis ending at the first and last x left the outer half of both edge
16652
+ * columns outside the plot, where gridRectMask clipped it. Reach half a
16653
+ * cell past the data unless the user pinned the axis. The zoom
16654
+ * clamps (initialMinX/MaxX) always take the padded extent, so zooming all
16655
+ * the way out lands on the same view.
16656
+ *
16657
+ * @param {any} range the Range instance
16658
+ */
16659
+ padXRange(range) {
16660
+ const { w } = range;
16661
+ const gl = w.globals;
16662
+ const x2 = w.config.xaxis;
16663
+ if ((x2.type === "numeric" || x2.type === "datetime") && gl.initialMinX < gl.initialMaxX) {
16664
+ range._getMinXDiff();
16665
+ const half = cellSpan(w) / 2;
16666
+ gl.initialMinX -= half;
16667
+ gl.initialMaxX += half;
16668
+ if (x2.min == null && x2.max == null && x2.range == null) {
16669
+ gl.minX -= half;
16670
+ gl.maxX += half;
16671
+ if (!x2.tickAmount && gl.xTickAmount === gl.dataPoints - 1) {
16672
+ gl.xTickAmount = gl.dataPoints;
16673
+ }
16674
+ }
16675
+ }
16676
+ }
16333
16677
  /**
16334
16678
  * @param {any[]} series
16335
16679
  */
@@ -16345,8 +16689,8 @@ class HeatMap {
16345
16689
  const isContinuousX = (w.config.xaxis.type === "numeric" || w.config.xaxis.type === "datetime") && w.axisFlags.isXNumeric && this.xRatio > 0;
16346
16690
  let binPx = xDivision;
16347
16691
  if (isContinuousX) {
16348
- const diff = w.globals.minXDiff;
16349
- binPx = Number.isFinite(diff) && diff > 0 ? diff / this.xRatio : xDivision;
16692
+ const span = cellSpan(w);
16693
+ if (span) binPx = span / this.xRatio;
16350
16694
  }
16351
16695
  let shape = this.shape;
16352
16696
  if (isContinuousX && shape === "hexagon") {
@@ -16396,7 +16740,7 @@ class HeatMap {
16396
16740
  continue;
16397
16741
  }
16398
16742
  }
16399
- if (j >= heatSeries[i].length) break;
16743
+ if (j >= series[i].length) break;
16400
16744
  const cellW = isContinuousX ? binPx : xDivision;
16401
16745
  if (isContinuousX) {
16402
16746
  const xVal = w.seriesData.seriesX[i] ? w.seriesData.seriesX[i][j] : null;
@@ -16544,8 +16888,7 @@ class HeatMap {
16544
16888
  y: y1 + yDivision / 2,
16545
16889
  i,
16546
16890
  j,
16547
- colorProps: heatColorProps,
16548
- series: heatSeries
16891
+ colorProps: heatColorProps
16549
16892
  });
16550
16893
  if (dataLabels !== null) {
16551
16894
  elSeries.add(dataLabels);
@@ -16557,16 +16900,6 @@ class HeatMap {
16557
16900
  y1 = y1 + yDivision;
16558
16901
  ret.add(elSeries);
16559
16902
  }
16560
- const yAxisScale = (
16561
- /** @type {any[]} */
16562
- w.globals.yAxisScale[0].result.slice()
16563
- );
16564
- if (w.config.yaxis[0].reversed) {
16565
- yAxisScale.unshift("");
16566
- } else {
16567
- yAxisScale.push("");
16568
- }
16569
- w.globals.yAxisScale[0].result = yAxisScale;
16570
16903
  return ret;
16571
16904
  }
16572
16905
  /**
@@ -17177,7 +17510,11 @@ class Line {
17177
17510
  this.zRatio = this.xyRatios.zRatio;
17178
17511
  this.xRatio = this.xyRatios.xRatio;
17179
17512
  this.baseLineY = this.xyRatios.baseLineY;
17180
- series = coreUtils.getLogSeries(series);
17513
+ series = coreUtils.getLogSeries(
17514
+ series,
17515
+ /** @type {any} */
17516
+ seriesIndex
17517
+ );
17181
17518
  this.yRatio = coreUtils.getLogYRatios(this.yRatio);
17182
17519
  this.prevSeriesY = [];
17183
17520
  this.prevSeriesYByX = /* @__PURE__ */ new Map();
@@ -17262,7 +17599,6 @@ class Line {
17262
17599
  xArrj.push(x2);
17263
17600
  const pX = x2;
17264
17601
  let pY2;
17265
- const prevX = pX;
17266
17602
  let prevY = this.zeroY;
17267
17603
  let prevY2 = this.zeroY;
17268
17604
  const lineYPosition = 0;
@@ -17295,16 +17631,7 @@ class Line {
17295
17631
  pY2 = prevY2;
17296
17632
  y2Arrj.push(yArrj[0] !== null ? prevY2 : null);
17297
17633
  }
17298
- const pathsFrom = this._calculatePathsFrom({
17299
- type,
17300
- series,
17301
- i,
17302
- realIndex,
17303
- translationsIndex,
17304
- prevX,
17305
- prevY,
17306
- prevY2
17307
- });
17634
+ const pathsFrom = this._calculatePathsFrom(realIndex, prevY);
17308
17635
  const rYArrj = [yArrj[0]];
17309
17636
  const rY2Arrj = [y2Arrj[0]];
17310
17637
  const iteratingOpts = {
@@ -17332,13 +17659,7 @@ class Line {
17332
17659
  isRangeStart: true
17333
17660
  }));
17334
17661
  if (type === "rangeArea") {
17335
- const pathsFrom2 = this._calculatePathsFrom({
17336
- series: seriesRangeEnd,
17337
- i,
17338
- realIndex,
17339
- prevX,
17340
- prevY: prevY2
17341
- });
17662
+ const pathsFrom2 = this._calculatePathsFrom(realIndex, prevY2);
17342
17663
  const rangePaths = this._iterateOverDataPoints(__spreadProps(__spreadValues({}, iteratingOpts), {
17343
17664
  series: seriesRangeEnd,
17344
17665
  xArrj: [x2],
@@ -17462,40 +17783,18 @@ class Line {
17462
17783
  });
17463
17784
  this.appendPathFrom = true;
17464
17785
  }
17465
- /** @param {{ type?: any, series?: any, i?: any, realIndex?: any, translationsIndex?: any, prevX?: any, prevY?: any, prevY2?: any }} opts */
17466
- _calculatePathsFrom({
17467
- type,
17468
- series,
17469
- i,
17470
- realIndex,
17471
- translationsIndex,
17472
- prevX,
17473
- prevY,
17474
- prevY2
17475
- }) {
17476
- const w = this.w;
17786
+ /**
17787
+ * The baseline pathFrom a series grows from on mount, or the previous
17788
+ * render's paths when there are any. `prevY` rides along for the first
17789
+ * point's marker.
17790
+ * @param {number} realIndex
17791
+ * @param {number} prevY
17792
+ */
17793
+ _calculatePathsFrom(realIndex, prevY) {
17477
17794
  const graphics = new Graphics(this.w);
17478
- let linePath, areaPath, pathFromLine, pathFromArea;
17479
- if (series[i][0] === null) {
17480
- for (let s = 0; s < series[i].length; s++) {
17481
- if (series[i][s] !== null) {
17482
- prevX = this.xDivision * s;
17483
- prevY = this.zeroY - series[i][s] / this.yRatio[translationsIndex];
17484
- linePath = graphics.move(prevX, prevY);
17485
- areaPath = graphics.move(prevX, this.areaBottomY);
17486
- break;
17487
- }
17488
- }
17489
- } else {
17490
- linePath = graphics.move(prevX, prevY);
17491
- if (type === "rangeArea") {
17492
- linePath = graphics.move(prevX, prevY2) + graphics.line(prevX, prevY);
17493
- }
17494
- areaPath = graphics.move(prevX, this.areaBottomY) + graphics.line(prevX, prevY);
17495
- }
17496
- pathFromLine = graphics.move(0, this.areaBottomY) + graphics.line(0, this.areaBottomY);
17497
- pathFromArea = graphics.move(0, this.areaBottomY) + graphics.line(0, this.areaBottomY);
17498
- if (w.globals.previousPaths.length > 0) {
17795
+ let pathFromLine = graphics.move(0, this.areaBottomY) + graphics.line(0, this.areaBottomY);
17796
+ let pathFromArea = pathFromLine;
17797
+ if (this.w.globals.previousPaths.length > 0) {
17499
17798
  const pathFrom = this.lineHelpers.checkPreviousPaths({
17500
17799
  pathFromLine,
17501
17800
  pathFromArea,
@@ -17504,14 +17803,7 @@ class Line {
17504
17803
  pathFromLine = pathFrom.pathFromLine;
17505
17804
  pathFromArea = pathFrom.pathFromArea;
17506
17805
  }
17507
- return {
17508
- prevX,
17509
- prevY,
17510
- linePath,
17511
- areaPath,
17512
- pathFromLine,
17513
- pathFromArea
17514
- };
17806
+ return { prevY, pathFromLine, pathFromArea };
17515
17807
  }
17516
17808
  /**
17517
17809
  * The identity a stacked baseline is looked up by.
@@ -17794,7 +18086,10 @@ class Line {
17794
18086
  const w = this.w;
17795
18087
  const graphics = new Graphics(this.w);
17796
18088
  const yRatio = this.yRatio;
17797
- let { prevY, linePath, areaPath, pathFromLine, pathFromArea } = pathsFrom;
18089
+ const prevY = pathsFrom.prevY;
18090
+ let { pathFromLine, pathFromArea } = pathsFrom;
18091
+ let linePath;
18092
+ let areaPath;
17798
18093
  const minY = Utils.isNumber(w.globals.minYArr[realIndex]) ? w.globals.minYArr[realIndex] : w.globals.minY;
17799
18094
  if (!iterations) {
17800
18095
  iterations = w.globals.dataPoints > 1 ? w.globals.dataPoints - 1 : w.globals.dataPoints;
@@ -17960,9 +18255,7 @@ class Line {
17960
18255
  pathFromArea,
17961
18256
  areaPaths,
17962
18257
  pathFromLine,
17963
- linePaths,
17964
- linePath,
17965
- areaPath
18258
+ linePaths
17966
18259
  };
17967
18260
  }
17968
18261
  /** @param {{type: any, pointsPos: any, isRangeStart: any, i: any, j: any, realIndex: any}} opts */
@@ -18154,8 +18447,6 @@ class Line {
18154
18447
  areaPaths,
18155
18448
  pathFromLine,
18156
18449
  linePaths,
18157
- linePath,
18158
- areaPath,
18159
18450
  numericXY: nxs ? { xs: nxs, ys: nys, areaCloseY: bottomY } : void 0
18160
18451
  };
18161
18452
  }
@@ -18535,6 +18826,12 @@ function spaceOutLabels(items, minGap, maxY, minY) {
18535
18826
  }
18536
18827
  }
18537
18828
  }
18829
+ if (minY != null && col.length && col[0].labelY < minY) {
18830
+ const shift = minY - col[0].labelY;
18831
+ for (let k2 = 0; k2 < col.length; k2++) {
18832
+ col[k2].labelY += shift;
18833
+ }
18834
+ }
18538
18835
  }
18539
18836
  class CircularChartsHelpers {
18540
18837
  /**
@@ -18569,10 +18866,11 @@ class CircularChartsHelpers {
18569
18866
  * Widest rendered width among the given label strings. Used to reserve
18570
18867
  * horizontal room for outer (name) labels so the pie can shrink to fit them.
18571
18868
  * @param {string[]} labels
18572
- * @param {{ fontSize?: string, fontFamily?: string }} style
18869
+ * @param {{ fontSize?: string, fontFamily?: string, fontWeight?: string | number }} style
18870
+ * the weight the labels draw at: bold text is wider
18573
18871
  * @returns {number}
18574
18872
  */
18575
- getMaxLabelWidth(labels, { fontSize, fontFamily } = {}) {
18873
+ getMaxLabelWidth(labels, { fontSize, fontFamily, fontWeight } = {}) {
18576
18874
  const graphics = new Graphics(this.w);
18577
18875
  let maxWidth = 0;
18578
18876
  labels.forEach((text) => {
@@ -18581,7 +18879,9 @@ class CircularChartsHelpers {
18581
18879
  `${text}`,
18582
18880
  fontSize || "12px",
18583
18881
  fontFamily,
18584
- ""
18882
+ "",
18883
+ true,
18884
+ fontWeight
18585
18885
  );
18586
18886
  maxWidth = Math.max(maxWidth, rect.width);
18587
18887
  });
@@ -18850,10 +19150,10 @@ class Pie {
18850
19150
  const lineSets = (w.seriesData.seriesNames || []).map(
18851
19151
  (_, i) => this.getExternalLabelLines(i)
18852
19152
  );
18853
- const maxLabelWidth = helpers.getMaxLabelWidth(lineSets.flat(), {
18854
- fontSize: this.externalLabelStyle.fontSize,
18855
- fontFamily: this.externalLabelStyle.fontFamily
18856
- });
19153
+ const maxLabelWidth = helpers.getMaxLabelWidth(
19154
+ lineSets.flat(),
19155
+ this.externalLabelStyle
19156
+ );
18857
19157
  this.externalLabelMaxLines = lineSets.reduce((m, s) => Math.max(m, s.length), 1);
18858
19158
  this.externalLabelLineH = Math.round(
18859
19159
  (parseFloat(this.externalLabelStyle.fontSize) || 12) * 1.35
@@ -18887,11 +19187,20 @@ class Pie {
18887
19187
  if (w.globals.noData) return elPie;
18888
19188
  (_a = this.ctx.highlightFilter) == null ? void 0 : _a.pie(this);
18889
19189
  const scaleSize = w.config.plotOptions.pie.customScale;
19190
+ const ri = this.chartType === "donut" ? this.donutSize : 0;
19191
+ const ys = [];
19192
+ const s = this.initialAngle;
19193
+ const at = (r, a) => this.translateY + scaleSize * Utils.polarToCartesian(this.centerX, this.centerY, r, a).y;
19194
+ for (let a = s; a <= s + this.fullAngle; a++) {
19195
+ ys.push(at(w.globals.radialSize, a), at(ri, a));
19196
+ }
19197
+ if (this.donutDataLabels.show) ys.push(at(ri, 180));
18890
19198
  w.globals.circleGeometry = {
18891
19199
  node: elPie.node,
18892
19200
  cx: this.translateX + scaleSize * this.centerX,
18893
19201
  cy: this.translateY + scaleSize * this.centerY,
18894
- r: scaleSize * w.globals.radialSize
19202
+ r: scaleSize * w.globals.radialSize,
19203
+ y: this.chartType !== "polarArea" && [Math.min(...ys), Math.max(...ys)]
18895
19204
  };
18896
19205
  let total = 0;
18897
19206
  for (let k2 = 0; k2 < series.length; k2++) {
@@ -18926,7 +19235,7 @@ class Pie {
18926
19235
  if (this.chartType === "polarArea") {
18927
19236
  sectorAngleArr[i] = collapsedIdx.indexOf(i) > -1 ? 0 : this.fullAngle / polarVisible;
18928
19237
  this.sliceSizes.push(
18929
- w.globals.radialSize * series[i] / (this.maxY || 1)
19238
+ w.globals.radialSize * Utils.negToZero(series[i]) / (this.maxY || 1)
18930
19239
  );
18931
19240
  } else {
18932
19241
  this.sliceSizes.push(w.globals.radialSize);
@@ -18966,18 +19275,21 @@ class Pie {
18966
19275
  for (let k2 = 0; k2 < w.globals.previousPaths.length; k2++) {
18967
19276
  prevTotal += Utils.negToZero(w.globals.previousPaths[k2]);
18968
19277
  }
18969
- let previousAngle;
18970
19278
  for (let i = 0; i < w.globals.previousPaths.length; i++) {
18971
- previousAngle = this.fullAngle * Utils.negToZero(w.globals.previousPaths[i]) / prevTotal;
18972
- this.prevSectorAngleArr.push(previousAngle);
19279
+ this.prevSectorAngleArr.push(
19280
+ prevTotal ? this.fullAngle * Utils.negToZero(w.globals.previousPaths[i]) / prevTotal : 0
19281
+ );
18973
19282
  }
18974
19283
  }
19284
+ while (w.globals.shouldAnimate !== false && this.prevSectorAngleArr.length < series.length) {
19285
+ this.prevSectorAngleArr.push(0);
19286
+ }
18975
19287
  }
18976
19288
  if (this.chartType === "polarArea") {
18977
19289
  w.globals.prevPolarAngles = sectorAngleArr.slice();
18978
19290
  const radius = w.globals.radialSize || 1;
18979
19291
  w.globals.prevPolarSizes = this.sliceSizes.map(
18980
- (s) => s / radius
19292
+ (s2) => s2 / radius
18981
19293
  );
18982
19294
  }
18983
19295
  if (this.donutSize < 0) {
@@ -18993,8 +19305,8 @@ class Pie {
18993
19305
  elSeries.add(circle);
18994
19306
  }
18995
19307
  const elG = self.drawArcs(sectorAngleArr, series);
18996
- this.sliceLabels.forEach((s) => {
18997
- elG.add(s);
19308
+ this.sliceLabels.forEach((s2) => {
19309
+ elG.add(s2);
18998
19310
  });
18999
19311
  elSeries.attr({
19000
19312
  transform: `translate(${this.translateX}, ${this.translateY}) scale(${w.config.plotOptions.pie.customScale})`
@@ -19208,7 +19520,6 @@ class Pie {
19208
19520
  endAngle,
19209
19521
  startAngle,
19210
19522
  i,
19211
- totalItems: sectorAngleArr.length - 1,
19212
19523
  animBeginArr: this.animBeginArr,
19213
19524
  dur,
19214
19525
  collapsed
@@ -19221,11 +19532,12 @@ class Pie {
19221
19532
  }
19222
19533
  if (typeof w.interact.selectedDataPoints[0] !== "undefined" && w.interact.selectedDataPoints[0].indexOf(i) > -1) {
19223
19534
  if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged && this.animDur > 0) {
19224
- const _this = this;
19225
- const _i = i;
19226
- setTimeout(() => _this.pieClicked(_i, { animate: false }), this.animDur);
19535
+ const paper = w.dom.Paper;
19536
+ setTimeout(() => {
19537
+ if (w.dom.Paper === paper) this.setSliceOut(i);
19538
+ }, this.animDur);
19227
19539
  } else {
19228
- this.pieClicked(i, { animate: false });
19540
+ this.setSliceOut(i);
19229
19541
  }
19230
19542
  }
19231
19543
  if (w.config.dataLabels.enabled) {
@@ -19270,9 +19582,9 @@ class Pie {
19270
19582
  filters.dropShadow(elPieLabel, textShadow);
19271
19583
  }
19272
19584
  elPieLabel.node.classList.add("apexcharts-pie-label");
19273
- if (w.config.chart.animations.animate && w.globals.resized === false) {
19274
- elPieLabel.node.classList.add("apexcharts-pie-label-delay");
19275
- elPieLabel.node.style.animationDelay = w.config.chart.animations.speed / 940 + "s";
19585
+ if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
19586
+ elPieLabel.attr({ opacity: 0 });
19587
+ elPieLabel.animate(300, w.config.chart.animations.speed).attr({ opacity: 1 });
19276
19588
  }
19277
19589
  this.sliceLabels.push(elPieLabelWrap);
19278
19590
  this.sliceLabelGroups[i] = elPieLabelWrap.node;
@@ -19347,13 +19659,17 @@ class Pie {
19347
19659
  */
19348
19660
  placeExternalLabels() {
19349
19661
  const w = this.w;
19350
- const lineHeight = this.externalLabelMaxLines * this.externalLabelLineH + 2;
19351
- const maxY = this.centerY + w.globals.radialSize + w.globals.pieExternalLabelMarginY;
19662
+ const blockH = this.externalLabelMaxLines * this.externalLabelLineH;
19663
+ const band = w.globals.radialSize + w.globals.pieExternalLabelMarginY;
19664
+ const maxY = this.centerY + band;
19665
+ const minY = this.centerY - band + blockH / 2;
19352
19666
  ["left", "right"].forEach((side) => {
19667
+ const col = this.externalLabels.filter((l) => l.side === side);
19353
19668
  spaceOutLabels(
19354
- this.externalLabels.filter((l) => l.side === side),
19355
- lineHeight,
19356
- maxY
19669
+ col,
19670
+ Math.min(blockH + 2, (maxY - minY) / Math.max(1, col.length - 1)),
19671
+ maxY,
19672
+ minY
19357
19673
  );
19358
19674
  });
19359
19675
  }
@@ -19407,7 +19723,6 @@ class Pie {
19407
19723
  * @param {Record<string, any>} opts
19408
19724
  */
19409
19725
  animatePaths(el, opts) {
19410
- const w = this.w;
19411
19726
  const me = this;
19412
19727
  let angle = opts.endAngle < opts.startAngle ? this.fullAngle + opts.endAngle - opts.startAngle : opts.endAngle - opts.startAngle;
19413
19728
  let prevAngle = angle;
@@ -19417,13 +19732,6 @@ class Pie {
19417
19732
  fromStartAngle = opts.prevEndAngle;
19418
19733
  prevAngle = opts.prevEndAngle < opts.prevStartAngle ? this.fullAngle + opts.prevEndAngle - opts.prevStartAngle : opts.prevEndAngle - opts.prevStartAngle;
19419
19734
  }
19420
- if (opts.i === w.config.series.length - 1) {
19421
- if (angle + toStartAngle > this.fullAngle) {
19422
- opts.endAngle = opts.endAngle - (angle + toStartAngle);
19423
- } else if (angle + toStartAngle < this.fullAngle) {
19424
- opts.endAngle = opts.endAngle + (this.fullAngle - (angle + toStartAngle));
19425
- }
19426
- }
19427
19735
  if (angle === this.fullAngle) angle = this.fullAngle - 0.01;
19428
19736
  me.animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts);
19429
19737
  }
@@ -19443,8 +19751,11 @@ class Pie {
19443
19751
  let path;
19444
19752
  if (isNaN(fromStartAngle) || isNaN(prevAngle)) {
19445
19753
  fromStartAngle = toStartAngle;
19446
- prevAngle = angle;
19447
- opts.dur = 0;
19754
+ prevAngle = 0;
19755
+ if (w.globals.shouldAnimate === false) {
19756
+ prevAngle = angle;
19757
+ opts.dur = 0;
19758
+ }
19448
19759
  }
19449
19760
  let currAngle = angle;
19450
19761
  let startAngle = toStartAngle;
@@ -19537,14 +19848,16 @@ class Pie {
19537
19848
  this.offsetSlice(i, 0, animate);
19538
19849
  return;
19539
19850
  }
19540
- const allEls = w.dom.baseEl.getElementsByClassName("apexcharts-pie-area");
19541
- Array.prototype.forEach.call(allEls, (pieSlice) => {
19542
- const wasOut = pieSlice.getAttribute("data:pieClicked") === "true";
19543
- pieSlice.setAttribute("data:pieClicked", "false");
19544
- if (wasOut) {
19545
- this.offsetSlice(parseInt(pieSlice.getAttribute("j"), 10), 0, animate);
19546
- }
19547
- });
19851
+ if (!w.config.states.active.allowMultipleDataPointsSelection) {
19852
+ const allEls = w.dom.baseEl.getElementsByClassName("apexcharts-pie-area");
19853
+ Array.prototype.forEach.call(allEls, (pieSlice) => {
19854
+ const wasOut = pieSlice.getAttribute("data:pieClicked") === "true";
19855
+ pieSlice.setAttribute("data:pieClicked", "false");
19856
+ if (wasOut) {
19857
+ this.offsetSlice(parseInt(pieSlice.getAttribute("j"), 10), 0, animate);
19858
+ }
19859
+ });
19860
+ }
19548
19861
  w.interact.capturedDataPointIndex = i;
19549
19862
  elPath.attr("data:pieClicked", "true");
19550
19863
  this.offsetSlice(i, this.getExpandOffset(), animate);
@@ -19675,6 +19988,14 @@ class Pie {
19675
19988
  this.elHoverOutline.node.style.opacity = "0";
19676
19989
  }
19677
19990
  }
19991
+ /**
19992
+ * Park a pre-selected slice outside the pie without sliding it. Unlike the
19993
+ * pieClicked toggle this is idempotent, so a second pass leaves it out.
19994
+ * @param {number} i
19995
+ */
19996
+ setSliceOut(i) {
19997
+ if (!this.isSliceOut(i)) this.pieClicked(i, { animate: false });
19998
+ }
19678
19999
  /** @param {number} i @returns {boolean} */
19679
20000
  isSliceOut(i) {
19680
20001
  const elPath = this.w.dom.Paper.findOne(
@@ -19726,29 +20047,21 @@ class Pie {
19726
20047
  const r = Math.min(thickness / 2, spanDeg * Math.PI / 180 / 2 * rIn);
19727
20048
  return r > 0.5 ? roundedDonutSegmentPath(__spreadProps(__spreadValues({}, geo), { r })) : sharpDonutSegmentPath(geo);
19728
20049
  }
19729
- /**
19730
- * @param {number} prevStartAngle
19731
- * @param {number} prevEndAngle
19732
- */
19733
20050
  /**
19734
20051
  * @param {number} prevStartAngle
19735
20052
  * @param {number} prevEndAngle
19736
20053
  * @param {number} [prevSize] - polarArea passes its previous slice radius,
19737
20054
  * so the pre-animation frame sits at the previous VALUE too, not just the
19738
- * previous angles.
20055
+ * previous angles. Without one (pie, donut) there is no previous shape
20056
+ * to draw: the path starts empty and animateArc sets the first frame.
19739
20057
  */
19740
20058
  getChangedPath(prevStartAngle, prevEndAngle, prevSize) {
19741
- let path = "";
19742
- if (this.dynamicAnim && this.w.globals.dataChanged) {
19743
- path = this.getPiePath({
19744
- me: this,
19745
- startAngle: prevStartAngle,
19746
- angle: prevEndAngle - prevStartAngle,
19747
- // @ts-ignore — size is set dynamically during draw()
19748
- size: typeof prevSize === "number" ? prevSize : this.size
19749
- });
19750
- }
19751
- return path;
20059
+ return this.dynamicAnim && this.w.globals.dataChanged && typeof prevSize === "number" ? this.getPiePath({
20060
+ me: this,
20061
+ startAngle: prevStartAngle,
20062
+ angle: prevEndAngle - prevStartAngle,
20063
+ size: prevSize
20064
+ }) : "";
19752
20065
  }
19753
20066
  /**
19754
20067
  * The angular extent a slice is actually drawn over: the raw start / span
@@ -19946,7 +20259,8 @@ class Pie {
19946
20259
  dataLabelsGroup.node.innerHTML = "";
19947
20260
  dataLabelsGroup.node.style.opacity = opts.opacity;
19948
20261
  const x2 = opts.centerX;
19949
- const y = !this.donutDataLabels.total.label ? opts.centerY - opts.centerY / 6 : opts.centerY;
20262
+ const y = opts.centerY;
20263
+ const nameRow = dataLabelsConfig.name.show && !!this.donutDataLabels.total.label;
19950
20264
  let labelColor, valueColor;
19951
20265
  if (dataLabelsConfig.name.color === void 0) {
19952
20266
  labelColor = w.globals.colors[0];
@@ -19999,7 +20313,7 @@ class Pie {
19999
20313
  dataLabelsGroup.add(elLabel);
20000
20314
  }
20001
20315
  if (dataLabelsConfig.value.show) {
20002
- const valOffset = dataLabelsConfig.name.show ? parseFloat(dataLabelsConfig.value.offsetY) + 16 : dataLabelsConfig.value.offsetY;
20316
+ const valOffset = nameRow ? parseFloat(dataLabelsConfig.value.offsetY) + 16 : dataLabelsConfig.value.offsetY;
20003
20317
  const elValue = graphics.drawText({
20004
20318
  x: x2,
20005
20319
  y: y + valOffset,
@@ -20089,19 +20403,18 @@ class Pie {
20089
20403
  const graphics = new Graphics(this.w);
20090
20404
  const spokeConfig = w.config.plotOptions.polarArea.spokes;
20091
20405
  if (spokeConfig.strokeWidth === 0) return;
20092
- const spokes = [];
20093
- const angleDivision = 360 / w.seriesData.series.length;
20094
- for (let i = 0; i < w.seriesData.series.length; i++) {
20095
- spokes.push(
20096
- Utils.polarToCartesian(
20097
- this.centerX,
20098
- this.centerY,
20099
- w.globals.radialSize,
20100
- w.config.plotOptions.pie.startAngle + angleDivision * i
20101
- )
20406
+ const collapsedIdx = w.globals.collapsedSeriesIndices || [];
20407
+ const n = w.seriesData.series.length;
20408
+ const angleDivision = 360 / Math.max(1, n - collapsedIdx.filter((k2) => k2 < n).length);
20409
+ let slot = 0;
20410
+ for (let i = 0; i < n; i++) {
20411
+ if (collapsedIdx.indexOf(i) > -1) continue;
20412
+ const p = Utils.polarToCartesian(
20413
+ this.centerX,
20414
+ this.centerY,
20415
+ w.globals.radialSize,
20416
+ w.config.plotOptions.pie.startAngle + angleDivision * slot++
20102
20417
  );
20103
- }
20104
- spokes.forEach((p, i) => {
20105
20418
  const line = graphics.drawLine(
20106
20419
  p.x,
20107
20420
  p.y,
@@ -20110,7 +20423,7 @@ class Pie {
20110
20423
  Array.isArray(spokeConfig.connectorColors) ? spokeConfig.connectorColors[i] : spokeConfig.connectorColors
20111
20424
  );
20112
20425
  parent.add(line);
20113
- });
20426
+ }
20114
20427
  }
20115
20428
  revertDataLabelsInner() {
20116
20429
  const w = this.w;
@@ -20393,7 +20706,7 @@ class Radar {
20393
20706
  const w = this.w;
20394
20707
  const { parent } = opts;
20395
20708
  const helpers = new CircularChartsHelpers(this.w);
20396
- const yaxisTexts = w.globals.yAxisScale[0].result.reverse();
20709
+ const yaxisTexts = w.globals.yAxisScale[0].result.slice().reverse();
20397
20710
  const layers = yaxisTexts.length;
20398
20711
  const radiusSizes = [];
20399
20712
  const layerDis = this.size / (layers - 1);
@@ -20603,7 +20916,6 @@ class Radial extends Pie {
20603
20916
  this.ctx = ctx;
20604
20917
  this.w = w;
20605
20918
  this.animBeginArr = [0];
20606
- this.animDur = 0;
20607
20919
  this.startAngle = w.config.plotOptions.radialBar.startAngle;
20608
20920
  this.endAngle = w.config.plotOptions.radialBar.endAngle;
20609
20921
  this.totalAngle = Math.abs(
@@ -20708,9 +21020,13 @@ class Radial extends Pie {
20708
21020
  const ticksNode = elTicks.node;
20709
21021
  ticksNode.style.opacity = "0";
20710
21022
  ticksNode.style.transition = "opacity 280ms ease-out";
20711
- const sweepDur = w.config.chart.animations.speed || 800;
20712
- setTimeout(() => {
20713
- ticksNode.style.opacity = "1";
21023
+ const motion = isNeedleShape && this.needleMotion();
21024
+ const sweepDur = Math.max(
21025
+ (this.animBeginArr[series.length - 1] || 0) + w.config.chart.animations.speed,
21026
+ motion ? motion.speed : 0
21027
+ );
21028
+ w.globals.radialTickTimer = setTimeout(() => {
21029
+ if (!w.globals.isDestroyed) ticksNode.style.opacity = "1";
20714
21030
  }, sweepDur);
20715
21031
  }
20716
21032
  elSeries.add(elTicks);
@@ -20801,7 +21117,6 @@ class Radial extends Pie {
20801
21117
  startAngle,
20802
21118
  size: opts.size,
20803
21119
  i,
20804
- totalItems: 2,
20805
21120
  animBeginArr: 0,
20806
21121
  dur: 0,
20807
21122
  isTrack: true
@@ -20889,7 +21204,8 @@ class Radial extends Pie {
20889
21204
  let prevEndAngle;
20890
21205
  if (w.globals.dataChanged) {
20891
21206
  prevStartAngle = this.startAngle;
20892
- prevEndAngle = this._arcEnd(w.globals.previousPaths[i]);
21207
+ const prev = w.globals.previousPaths[i];
21208
+ prevEndAngle = prev === void 0 ? NaN : this._arcEnd(prev);
20893
21209
  }
20894
21210
  const angle = endAngle - startAngle;
20895
21211
  const dashArray = resolveClaimed(
@@ -20986,10 +21302,10 @@ class Radial extends Pie {
20986
21302
  if (this.dynamicAnim && w.globals.dataChanged && w.globals.shouldAnimate) {
20987
21303
  dur = w.config.chart.animations.dynamicAnimation.speed;
20988
21304
  }
20989
- this.animDur = dur / (opts.series.length * 1.2) + this.animDur;
20990
- this.animBeginArr.push(this.animDur);
21305
+ this.animBeginArr[i] = i * dur / (opts.series.length * 1.2);
20991
21306
  if (morphActive && morphFrom) {
20992
21307
  const morphSpeed = this.ctx.morphTypeChange.getSpeed();
21308
+ const animations = this.ctx.animations;
20993
21309
  const actualArcD = this.getPiePath({
20994
21310
  me: this,
20995
21311
  startAngle,
@@ -21014,10 +21330,11 @@ class Radial extends Pie {
21014
21330
  stroke: opts.skipValueArc ? "transparent" : pathFill,
21015
21331
  "stroke-width": opts.skipValueArc ? 0 : strokeWidth
21016
21332
  });
21333
+ animations.animationCompleted(elPath);
21017
21334
  }
21018
21335
  );
21019
21336
  } else {
21020
- elPath.animate(morphSpeed).plot(actualArcD, "polygons").attr({ "stroke-width": strokeWidth });
21337
+ elPath.animate(morphSpeed).plot(actualArcD, "polygons").attr({ "stroke-width": strokeWidth }).after(() => animations.animationCompleted(elPath));
21021
21338
  }
21022
21339
  } else {
21023
21340
  this.animatePaths(elPath, {
@@ -21029,7 +21346,6 @@ class Radial extends Pie {
21029
21346
  prevStartAngle,
21030
21347
  size: opts.size,
21031
21348
  i,
21032
- totalItems: 2,
21033
21349
  animBeginArr: this.animBeginArr,
21034
21350
  dur,
21035
21351
  shouldSetPrevPaths: true
@@ -21043,43 +21359,51 @@ class Radial extends Pie {
21043
21359
  };
21044
21360
  }
21045
21361
  /**
21046
- * Where a ring's value arc ends for value `v`, in whole degrees: the value
21047
- * as a fraction of the configured min/max domain (clamped, negatives read
21048
- * as 0). Defaults (min: 0, max: 100) preserve the historical percentage
21049
- * behavior; custom domains (e.g. min: 0, max: 240 for a speedometer) make
21050
- * the filled arc honor the same domain as the needle, ticks, and threshold
21051
- * bands. An arc that would close on itself stops just short.
21362
+ * The gauge's value domain, `[min, max]`, shared by the arc, needle, ticks
21363
+ * and bands. Defaults (0..100) keep the historical percentage scale; a
21364
+ * degenerate domain widens to one unit.
21052
21365
  *
21053
- * @param {any} v
21054
- * @returns {number}
21366
+ * @returns {number[]}
21055
21367
  */
21056
- _arcEnd(v) {
21368
+ _domain() {
21057
21369
  const rb = this.w.config.plotOptions.radialBar;
21058
21370
  const min = typeof rb.min === "number" ? rb.min : 0;
21059
21371
  const max = typeof rb.max === "number" ? rb.max : 100;
21060
- const f = Math.max(
21061
- 0,
21062
- (Math.min(Math.max(Utils.negToZero(v), min), max) - min) / (max === min ? 1 : max - min)
21063
- );
21064
- const end = Math.round(this.totalAngle * f) + this.startAngle;
21372
+ return [min, max === min ? min + 1 : max];
21373
+ }
21374
+ /**
21375
+ * Where `v` sits in the domain, 0..1: clamped to `[min, max]`, and a
21376
+ * missing or non-numeric value reads as min.
21377
+ *
21378
+ * @param {any} v
21379
+ * @returns {number}
21380
+ */
21381
+ _fraction(v) {
21382
+ const [min, max] = this._domain();
21383
+ const n = Number(v);
21384
+ return Number.isFinite(n) ? (Math.min(Math.max(n, min), max) - min) / (max - min) : 0;
21385
+ }
21386
+ /**
21387
+ * Where a ring's value arc ends for value `v`, in whole degrees. An arc
21388
+ * that would close on itself stops just short.
21389
+ *
21390
+ * @param {any} v
21391
+ * @returns {number}
21392
+ */
21393
+ _arcEnd(v) {
21394
+ const end = Math.round(this.totalAngle * this._fraction(v)) + this.startAngle;
21065
21395
  return Math.abs(end) + Math.abs(this.startAngle) > 360 ? end - 0.01 : end;
21066
21396
  }
21067
21397
  /**
21068
- * Map a domain value (between `min` and `max`) to the corresponding angle
21069
- * in the gauge's `startAngle`..`endAngle` range. Values outside the
21070
- * domain are clamped.
21398
+ * The angle of value `value` on the dial. Like the value arc and the track,
21399
+ * the dial always runs clockwise from `startAngle`, whichever of
21400
+ * startAngle and endAngle is larger.
21071
21401
  *
21072
- * @param {number} value
21402
+ * @param {any} value
21073
21403
  * @returns {number}
21074
21404
  */
21075
21405
  _angleAtValue(value) {
21076
- const rb = this.w.config.plotOptions.radialBar;
21077
- const min = typeof rb.min === "number" ? rb.min : 0;
21078
- const max = typeof rb.max === "number" ? rb.max : 100;
21079
- const safeMax = max === min ? min + 1 : max;
21080
- const clamped = Math.max(min, Math.min(safeMax, Number(value)));
21081
- const t = (clamped - min) / (safeMax - min);
21082
- return this.startAngle + t * (this.endAngle - this.startAngle);
21406
+ return this.startAngle + this._fraction(value) * Math.abs(this.endAngle - this.startAngle);
21083
21407
  }
21084
21408
  /**
21085
21409
  * Build an SVG arc path from `startAngle` to `endAngle` at radius `r`
@@ -21118,9 +21442,7 @@ class Radial extends Pie {
21118
21442
  const strokeWidth = this.getStrokeWidth(opts);
21119
21443
  const radius = opts.size - strokeWidth / 2 - strokeWidth - this.margin;
21120
21444
  const bandStroke = strokeWidth * parseInt(rb.bandsStyle.strokeWidth, 10) / 100;
21121
- const min = typeof rb.min === "number" ? rb.min : 0;
21122
- const max = typeof rb.max === "number" ? rb.max : 100;
21123
- const gapDeg = max === min ? 0 : (rb.bandsStyle.gap || 0) * ((this.endAngle - this.startAngle) / (max - min));
21445
+ const gapDeg = radius > 0 ? Math.abs(rb.bandsStyle.gap || 0) / radius * (180 / Math.PI) : 0;
21124
21446
  for (let b = 0; b < bands.length; b++) {
21125
21447
  const band = bands[b];
21126
21448
  if (band.from === void 0 || band.to === void 0) continue;
@@ -21157,8 +21479,7 @@ class Radial extends Pie {
21157
21479
  const g = graphics.group({ class: "apexcharts-gauge-ticks" });
21158
21480
  const strokeWidth = this.getStrokeWidth(opts);
21159
21481
  const radius = opts.size - strokeWidth / 2 - strokeWidth - this.margin;
21160
- const min = typeof rb.min === "number" ? rb.min : 0;
21161
- const max = typeof rb.max === "number" ? rb.max : 100;
21482
+ const [min, max] = this._domain();
21162
21483
  const majorCount = Math.max(2, (_b = (_a = ticks.major) == null ? void 0 : _a.count) != null ? _b : 11);
21163
21484
  const minorCount = Math.max(0, (_d = (_c = ticks.minor) == null ? void 0 : _c.count) != null ? _d : 0);
21164
21485
  const drawTickAt = (value, cfg, isMajor) => {
@@ -21258,22 +21579,22 @@ class Radial extends Pie {
21258
21579
  g.add(elNeedle);
21259
21580
  const value = Number(opts.series[0]);
21260
21581
  const targetAngle = this._angleAtValue(value);
21261
- const ctx = (
21262
- /** @type {any} */
21263
- this.ctx
21264
- );
21265
- const fromAngle = typeof ctx._lastNeedleAngle === "number" ? ctx._lastNeedleAngle : this.startAngle;
21266
- ctx._lastNeedleAngle = targetAngle;
21582
+ const gl = w.globals;
21267
21583
  const motion = this.needleMotion();
21584
+ const fromAngle = Number.isFinite(gl.radialNeedleAngle) && !(motion == null ? void 0 : motion.mount) ? (
21585
+ /** @type {number} */
21586
+ gl.radialNeedleAngle
21587
+ ) : this.startAngle;
21588
+ gl.radialNeedleAngle = targetAngle;
21589
+ if (w.globals.radialNeedleRAF != null) {
21590
+ BrowserAPIs.cancelAnimationFrame(w.globals.radialNeedleRAF);
21591
+ w.globals.radialNeedleRAF = null;
21592
+ }
21268
21593
  if (motion && fromAngle !== targetAngle) {
21269
21594
  const { speed, ease } = motion;
21270
21595
  const node = g.node;
21271
21596
  node.setAttribute("transform-origin", `${cx} ${cy}`);
21272
21597
  node.setAttribute("transform", `rotate(${fromAngle})`);
21273
- if (w.globals.radialNeedleRAF != null) {
21274
- BrowserAPIs.cancelAnimationFrame(w.globals.radialNeedleRAF);
21275
- w.globals.radialNeedleRAF = null;
21276
- }
21277
21598
  const startAt = performance.now();
21278
21599
  const step = (now) => {
21279
21600
  if (this.w.globals.isDestroyed) {
@@ -21324,23 +21645,26 @@ class Radial extends Pie {
21324
21645
  * How the needle moves this render: its speed and curve, or null when it
21325
21646
  * lands at once. Ease-out-back on initial mount (spring-loaded settle);
21326
21647
  * plain ease-out on data updates (no overshoot, feels mechanical,
21327
- * instrument-like).
21648
+ * instrument-like). With no `needle.animation.duration` it keeps the value
21649
+ * arc's clock for the phase.
21328
21650
  *
21329
- * @returns {{speed: number, ease: (t: number) => number} | null}
21651
+ * @returns {{speed: number, mount: boolean, ease: (t: number) => number} | null}
21330
21652
  */
21331
21653
  needleMotion() {
21332
- var _a, _b;
21654
+ var _a, _b, _c;
21333
21655
  const w = this.w;
21334
21656
  const cfg = w.config.plotOptions.radialBar.needle || {};
21657
+ const anim = w.config.chart.animations;
21335
21658
  const isInitialMount = this.initialAnim && !w.globals.dataChanged && !w.globals.resized;
21336
- if (!(Environment.isBrowser() && w.globals.shouldAnimate && (isInitialMount || this.dynamicAnim && w.globals.dataChanged))) {
21659
+ if (!(Environment.isBrowser() && w.globals.shouldAnimate && ((_a = cfg.animation) == null ? void 0 : _a.enabled) !== false && (isInitialMount || this.dynamicAnim && w.globals.dataChanged))) {
21337
21660
  return null;
21338
21661
  }
21339
- const speed = ((_a = cfg.animation) == null ? void 0 : _a.duration) && Number(cfg.animation.duration) || cfg.animationSpeed && Number(cfg.animationSpeed) || ((_b = w.config.chart.animations.dynamicAnimation) == null ? void 0 : _b.speed) || w.config.chart.animations.speed || 800;
21662
+ const speed = Number((_b = cfg.animation) == null ? void 0 : _b.duration) || Number(cfg.animationSpeed) || (isInitialMount ? anim.speed : (_c = anim.dynamicAnimation) == null ? void 0 : _c.speed) || 800;
21340
21663
  const c1 = 1.70158;
21341
21664
  const c3 = c1 + 1;
21342
21665
  return {
21343
21666
  speed,
21667
+ mount: isInitialMount,
21344
21668
  ease: isInitialMount ? (t) => 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2) : (t) => 1 - Math.pow(1 - t, 3)
21345
21669
  };
21346
21670
  }
@@ -21478,12 +21802,7 @@ class RangeBar extends Bar {
21478
21802
  if (series[i].length > 0) {
21479
21803
  this.visibleI = this.visibleI + 1;
21480
21804
  }
21481
- let translationsIndex = 0;
21482
- if (this.yRatio.length > 1) {
21483
- this.yaxisIndex = /** @type {any} */
21484
- w.globals.seriesYAxisReverseMap[realIndex][0];
21485
- translationsIndex = realIndex;
21486
- }
21805
+ const translationsIndex = this.setSeriesAxis(realIndex);
21487
21806
  const initPositions = this.barHelpers.initialPositions(realIndex);
21488
21807
  const {
21489
21808
  y: initY,
@@ -22008,41 +22327,6 @@ function squarify(data, xoffset, yoffset, width, height) {
22008
22327
  }
22009
22328
  return coords;
22010
22329
  }
22011
- function generate(data, width, height) {
22012
- const n = data.length;
22013
- const sums = new Array(n);
22014
- for (let i = 0; i < n; i++) {
22015
- let s = 0;
22016
- const series = data[i];
22017
- for (let j = 0; j < series.length; j++) {
22018
- s += series[j];
22019
- }
22020
- sums[i] = s;
22021
- }
22022
- const seriesRects = squarify(
22023
- normalize(sums, width * height),
22024
- 0,
22025
- 0,
22026
- width,
22027
- height
22028
- );
22029
- const results = new Array(n);
22030
- for (let i = 0; i < n; i++) {
22031
- const rect = seriesRects[i];
22032
- const rx = rect[0];
22033
- const ry = rect[1];
22034
- const rw = rect[2] - rx;
22035
- const rh = rect[3] - ry;
22036
- results[i] = squarify(
22037
- normalize(data[i], rw * rh),
22038
- rx,
22039
- ry,
22040
- rw,
22041
- rh
22042
- );
22043
- }
22044
- return results;
22045
- }
22046
22330
  function computeArea(node) {
22047
22331
  const kids = node.children;
22048
22332
  if (kids && kids.length) {
@@ -22110,7 +22394,7 @@ function generateNested(nodes, width, height, opts = {}) {
22110
22394
  layoutLevel(nodes, 0, 0, width, height, 0, padding, header);
22111
22395
  return nodes;
22112
22396
  }
22113
- const TreemapSquared = { generate, generateNested };
22397
+ const TreemapSquared = { generateNested };
22114
22398
  function drilldownById(w, id) {
22115
22399
  const dd = w.config.drilldown;
22116
22400
  const list = dd && Array.isArray(dd.series) ? dd.series : [];
@@ -22386,14 +22670,10 @@ class TreemapChart {
22386
22670
  this._total = null;
22387
22671
  this._avgLabelSize = null;
22388
22672
  this._tooltipEl = null;
22389
- this._tipOwned = false;
22390
22673
  this._morphLeafIndex = 0;
22391
22674
  this.camera = null;
22392
22675
  }
22393
- /**
22394
- * @param {any[]} series
22395
- */
22396
- draw(series) {
22676
+ draw() {
22397
22677
  var _a, _b;
22398
22678
  const w = this.w;
22399
22679
  const graphics = new Graphics(this.w, this.ctx);
@@ -22402,11 +22682,6 @@ class TreemapChart {
22402
22682
  class: "apexcharts-treemap"
22403
22683
  });
22404
22684
  if (w.globals.noData) return ret;
22405
- series.forEach((s) => {
22406
- s.map((v) => {
22407
- return Math.abs(v);
22408
- });
22409
- });
22410
22685
  this.negRange = this.helpers.checkColorRange();
22411
22686
  w.config.series.forEach((s, i) => {
22412
22687
  if (!Array.isArray(this.labels[i])) this.labels[i] = [];
@@ -22654,8 +22929,7 @@ class TreemapChart {
22654
22929
  i,
22655
22930
  j,
22656
22931
  colorProps,
22657
- fontSize,
22658
- series
22932
+ fontSize
22659
22933
  });
22660
22934
  }
22661
22935
  if (w.config.dataLabels.enabled && dataLabels) {
@@ -23711,8 +23985,8 @@ class TreemapChart {
23711
23985
  /**
23712
23986
  * A parent is not a row in the series matrix, so the shared tooltip - which
23713
23987
  * addresses everything by (seriesIndex, dataPointIndex) - has nothing to look
23714
- * up. It writes into the same tooltip element instead, so the aggregate looks
23715
- * like every other tooltip in the chart.
23988
+ * up. It writes into a sibling with the same classes instead, so the
23989
+ * aggregate looks like every other tooltip without touching the shared one.
23716
23990
  * @param {MouseEvent} e
23717
23991
  * @param {any} node
23718
23992
  */
@@ -23750,16 +24024,24 @@ class TreemapChart {
23750
24024
  }
23751
24025
  t.innerHTML = html;
23752
24026
  t.classList.add("apexcharts-active");
23753
- t.style.opacity = "1";
23754
- this._tipOwned = true;
24027
+ t.removeAttribute("aria-hidden");
23755
24028
  this._positionTooltip(e);
23756
24029
  }
23757
24030
  /** @returns {any} */
23758
24031
  _tip() {
23759
- if (!this._tooltipEl) {
23760
- this._tooltipEl = this.w.dom.baseEl.querySelector(".apexcharts-tooltip");
24032
+ const wrap = this.w.dom.elWrap;
24033
+ let t = this._tooltipEl;
24034
+ if (!(t == null ? void 0 : t.isConnected)) {
24035
+ t = wrap.querySelector(".apexcharts-treemap-tooltip");
24036
+ const core = !t && wrap.querySelector(".apexcharts-tooltip");
24037
+ if (core) {
24038
+ t = core.cloneNode(false);
24039
+ t.classList.add("apexcharts-treemap-tooltip");
24040
+ wrap.appendChild(t);
24041
+ }
24042
+ this._tooltipEl = t;
23761
24043
  }
23762
- return this._tooltipEl;
24044
+ return t;
23763
24045
  }
23764
24046
  /**
23765
24047
  * Position beside the cursor, flipping to the opposite side when the box
@@ -23768,7 +24050,7 @@ class TreemapChart {
23768
24050
  */
23769
24051
  _positionTooltip(e) {
23770
24052
  const t = this._tip();
23771
- if (!t || !this._tipOwned) return;
24053
+ if (!t) return;
23772
24054
  const rect = this.w.dom.elWrap.getBoundingClientRect();
23773
24055
  const tw = t.offsetWidth;
23774
24056
  const th = t.offsetHeight;
@@ -23783,11 +24065,9 @@ class TreemapChart {
23783
24065
  t.style.top = y + "px";
23784
24066
  }
23785
24067
  _hideParentTooltip() {
23786
- const t = this._tip();
23787
- if (!t || !this._tipOwned) return;
23788
- this._tipOwned = false;
23789
- t.classList.remove("apexcharts-active");
23790
- t.style.opacity = "0";
24068
+ const t = this._tooltipEl;
24069
+ t == null ? void 0 : t.classList.remove("apexcharts-active");
24070
+ t == null ? void 0 : t.setAttribute("aria-hidden", "true");
23791
24071
  }
23792
24072
  /**
23793
24073
  * The whole tree's area, zoomed in or not: "% of total" has to mean the same
@@ -23888,33 +24168,10 @@ class TreemapChart {
23888
24168
  */
23889
24169
  _averageLabelSize() {
23890
24170
  if (this._avgLabelSize != null) return this._avgLabelSize;
23891
- function totalLabelLength(arr) {
23892
- let i, total = 0;
23893
- if (Array.isArray(arr[0])) {
23894
- for (i = 0; i < arr.length; i++) {
23895
- total += totalLabelLength(arr[i]);
23896
- }
23897
- } else {
23898
- for (i = 0; i < arr.length; i++) {
23899
- total += arr[i].length;
23900
- }
23901
- }
23902
- return total;
23903
- }
23904
- function countLabels(arr) {
23905
- let i, total = 0;
23906
- if (Array.isArray(arr[0])) {
23907
- for (i = 0; i < arr.length; i++) {
23908
- total += countLabels(arr[i]);
23909
- }
23910
- } else {
23911
- for (i = 0; i < arr.length; i++) {
23912
- total += 1;
23913
- }
23914
- }
23915
- return total;
23916
- }
23917
- this._avgLabelSize = totalLabelLength(this.labels) / countLabels(this.labels);
24171
+ const all = this.labels.flat();
24172
+ let total = 0;
24173
+ for (const x2 of all) total += String(x2 != null ? x2 : "").length;
24174
+ this._avgLabelSize = total / (all.length || 1);
23918
24175
  return this._avgLabelSize;
23919
24176
  }
23920
24177
  // This calculates a font-size based upon