apexcharts 8.2.0 → 8.3.1

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 (256) hide show
  1. package/README.md +7 -7
  2. package/dist/apexcharts.common.js +2 -2
  3. package/dist/apexcharts.core.js +19793 -19713
  4. package/dist/apexcharts.core.min.js +2 -2
  5. package/dist/apexcharts.css +38 -8
  6. package/dist/apexcharts.esm.js +1882 -1625
  7. package/dist/apexcharts.full.js +22044 -21634
  8. package/dist/apexcharts.full.min.js +2 -2
  9. package/dist/apexcharts.js +21414 -21124
  10. package/dist/apexcharts.min.js +2 -2
  11. package/dist/apexcharts.ssr.common.js +2 -2
  12. package/dist/apexcharts.ssr.esm.js +21413 -21123
  13. package/dist/area.common.js +2 -2
  14. package/dist/area.esm.js +91 -40
  15. package/dist/bar.common.js +2 -2
  16. package/dist/bar.esm.js +478 -406
  17. package/dist/bar.js +2 -2
  18. package/dist/boxPlot.common.js +2 -2
  19. package/dist/boxPlot.esm.js +409 -334
  20. package/dist/bubble.common.js +2 -2
  21. package/dist/bubble.esm.js +91 -40
  22. package/dist/candlestick.common.js +2 -2
  23. package/dist/candlestick.esm.js +409 -334
  24. package/dist/candlestick.js +2 -2
  25. package/dist/column.common.js +2 -2
  26. package/dist/column.esm.js +478 -406
  27. package/dist/core.common.js +2 -2
  28. package/dist/core.esm.js +19793 -19713
  29. package/dist/donut.common.js +2 -2
  30. package/dist/donut.esm.js +3 -9
  31. package/dist/dumbbell.common.js +2 -2
  32. package/dist/dumbbell.esm.js +478 -406
  33. package/dist/features/all.common.js +2 -2
  34. package/dist/features/all.esm.js +442 -324
  35. package/dist/features/annotations.common.js +2 -2
  36. package/dist/features/annotations.esm.js +65 -48
  37. package/dist/features/annotations.js +2 -2
  38. package/dist/features/context-menu.common.js +1 -1
  39. package/dist/features/context-menu.esm.js +1 -1
  40. package/dist/features/context-menu.js +1 -1
  41. package/dist/features/drilldown.common.js +2 -2
  42. package/dist/features/drilldown.esm.js +4 -2
  43. package/dist/features/drilldown.js +2 -2
  44. package/dist/features/dumbbell.common.js +1 -1
  45. package/dist/features/dumbbell.esm.js +1 -1
  46. package/dist/features/dumbbell.js +1 -1
  47. package/dist/features/exports.common.js +2 -2
  48. package/dist/features/exports.esm.js +10 -4
  49. package/dist/features/exports.js +2 -2
  50. package/dist/features/facet.common.js +1 -1
  51. package/dist/features/facet.esm.js +1 -1
  52. package/dist/features/facet.js +1 -1
  53. package/dist/features/highlight-filter.common.js +2 -2
  54. package/dist/features/highlight-filter.esm.js +14 -9
  55. package/dist/features/highlight-filter.js +2 -2
  56. package/dist/features/history.common.js +1 -1
  57. package/dist/features/history.esm.js +1 -1
  58. package/dist/features/history.js +1 -1
  59. package/dist/features/ink.common.js +1 -1
  60. package/dist/features/ink.esm.js +1 -1
  61. package/dist/features/ink.js +1 -1
  62. package/dist/features/keyboard.common.js +2 -2
  63. package/dist/features/keyboard.esm.js +97 -145
  64. package/dist/features/keyboard.js +2 -2
  65. package/dist/features/legend.common.js +2 -2
  66. package/dist/features/legend.esm.js +64 -44
  67. package/dist/features/legend.js +2 -2
  68. package/dist/features/link.common.js +1 -1
  69. package/dist/features/link.esm.js +1 -1
  70. package/dist/features/link.js +1 -1
  71. package/dist/features/marks.common.js +1 -1
  72. package/dist/features/marks.esm.js +1 -1
  73. package/dist/features/marks.js +1 -1
  74. package/dist/features/measure.common.js +1 -1
  75. package/dist/features/measure.esm.js +1 -1
  76. package/dist/features/measure.js +1 -1
  77. package/dist/features/morph.common.js +2 -2
  78. package/dist/features/morph.esm.js +9 -5
  79. package/dist/features/morph.js +2 -2
  80. package/dist/features/perspectives.common.js +2 -2
  81. package/dist/features/perspectives.esm.js +4 -1
  82. package/dist/features/perspectives.js +2 -2
  83. package/dist/features/raincloud.common.js +2 -2
  84. package/dist/features/raincloud.esm.js +26 -27
  85. package/dist/features/raincloud.js +2 -2
  86. package/dist/features/renderer-canvas.common.js +2 -2
  87. package/dist/features/renderer-canvas.esm.js +2 -1
  88. package/dist/features/renderer-canvas.js +2 -2
  89. package/dist/features/stats.common.js +2 -2
  90. package/dist/features/stats.esm.js +52 -59
  91. package/dist/features/stats.js +2 -2
  92. package/dist/features/storyboard.common.js +2 -2
  93. package/dist/features/storyboard.esm.js +4 -1
  94. package/dist/features/storyboard.js +2 -2
  95. package/dist/features/streamgraph.common.js +2 -2
  96. package/dist/features/streamgraph.esm.js +48 -14
  97. package/dist/features/streamgraph.js +2 -2
  98. package/dist/features/toolbar.common.js +2 -2
  99. package/dist/features/toolbar.esm.js +148 -18
  100. package/dist/features/toolbar.js +2 -2
  101. package/dist/features/trellis.common.js +2 -2
  102. package/dist/features/trellis.esm.js +150 -63
  103. package/dist/features/trellis.js +2 -2
  104. package/dist/features/waterfall.common.js +1 -1
  105. package/dist/features/waterfall.esm.js +1 -1
  106. package/dist/features/waterfall.js +1 -1
  107. package/dist/features/weave.common.js +2 -2
  108. package/dist/features/weave.esm.js +13 -12
  109. package/dist/features/weave.js +2 -2
  110. package/dist/full.common.js +2 -2
  111. package/dist/full.esm.js +1068 -842
  112. package/dist/heatmap.common.js +2 -2
  113. package/dist/heatmap.esm.js +3 -17
  114. package/dist/heatmap.js +2 -2
  115. package/dist/histogram.common.js +2 -2
  116. package/dist/histogram.esm.js +529 -464
  117. package/dist/icicle.common.js +2 -2
  118. package/dist/icicle.esm.js +80 -46
  119. package/dist/icicle.js +2 -2
  120. package/dist/line.common.js +2 -2
  121. package/dist/line.esm.js +91 -40
  122. package/dist/line.js +2 -2
  123. package/dist/locales/en.json +2 -1
  124. package/dist/locales/ro.json +3 -2
  125. package/dist/pictograms.common.js +1 -1
  126. package/dist/pictograms.esm.js +1 -1
  127. package/dist/pictograms.js +1 -1
  128. package/dist/pie.common.js +2 -2
  129. package/dist/pie.esm.js +3 -9
  130. package/dist/pie.js +2 -2
  131. package/dist/polarArea.common.js +2 -2
  132. package/dist/polarArea.esm.js +3 -9
  133. package/dist/radar.common.js +2 -2
  134. package/dist/radar.esm.js +5 -4
  135. package/dist/radar.js +2 -2
  136. package/dist/radialBar.common.js +2 -2
  137. package/dist/radialBar.esm.js +5 -12
  138. package/dist/radialBar.js +2 -2
  139. package/dist/raincloud.common.js +2 -2
  140. package/dist/raincloud.esm.js +97 -52
  141. package/dist/rangeArea.common.js +2 -2
  142. package/dist/rangeArea.esm.js +91 -40
  143. package/dist/rangeBar.common.js +2 -2
  144. package/dist/rangeBar.esm.js +478 -406
  145. package/dist/scatter.common.js +2 -2
  146. package/dist/scatter.esm.js +91 -40
  147. package/dist/streamgraph.common.js +2 -2
  148. package/dist/streamgraph.esm.js +138 -53
  149. package/dist/sunburst.common.js +2 -2
  150. package/dist/sunburst.esm.js +116 -94
  151. package/dist/sunburst.js +2 -2
  152. package/dist/treemap.common.js +2 -2
  153. package/dist/treemap.esm.js +138 -104
  154. package/dist/treemap.js +2 -2
  155. package/dist/unit-shapes.common.js +1 -1
  156. package/dist/unit-shapes.esm.js +1 -1
  157. package/dist/unit-shapes.js +1 -1
  158. package/dist/unit.common.js +2 -2
  159. package/dist/unit.esm.js +280 -202
  160. package/dist/unit.js +2 -2
  161. package/dist/violin.common.js +2 -2
  162. package/dist/violin.esm.js +72 -26
  163. package/dist/violin.js +2 -2
  164. package/dist/waterfall.common.js +2 -2
  165. package/dist/waterfall.esm.js +477 -405
  166. package/package.json +1 -1
  167. package/src/apexcharts.js +40 -59
  168. package/src/assets/apexcharts.css +38 -8
  169. package/src/charts/Bar.js +62 -55
  170. package/src/charts/BarStacked.js +80 -88
  171. package/src/charts/BoxCandleStick.js +28 -31
  172. package/src/charts/Icicle.js +68 -47
  173. package/src/charts/Line.js +118 -42
  174. package/src/charts/Pie.js +2 -8
  175. package/src/charts/Radar.js +5 -7
  176. package/src/charts/Radial.js +2 -6
  177. package/src/charts/RangeBar.js +47 -43
  178. package/src/charts/Sunburst.js +101 -98
  179. package/src/charts/Treemap.js +150 -88
  180. package/src/charts/Unit.js +368 -250
  181. package/src/charts/Violin.js +48 -30
  182. package/src/charts/common/Breadcrumb.js +2 -2
  183. package/src/charts/common/Hierarchy.js +32 -11
  184. package/src/charts/common/Jitter.js +32 -7
  185. package/src/charts/common/Stats.js +30 -23
  186. package/src/charts/common/bar/DataLabels.js +76 -81
  187. package/src/charts/common/bar/Helpers.js +43 -7
  188. package/src/charts/common/line/Helpers.js +12 -15
  189. package/src/charts/common/partition/NodeTooltip.js +29 -7
  190. package/src/charts/common/partition/Partition.js +33 -1
  191. package/src/charts/common/treemap/Helpers.js +3 -11
  192. package/src/charts/common/treemap/Nested.js +2 -3
  193. package/src/features/raincloud.js +16 -10
  194. package/src/features/stats.js +67 -62
  195. package/src/locales/en.json +2 -1
  196. package/src/locales/ro.json +3 -2
  197. package/src/modules/Animations.js +102 -95
  198. package/src/modules/AxisMapping.js +47 -12
  199. package/src/modules/Core.js +4 -0
  200. package/src/modules/CoreUtils.js +18 -42
  201. package/src/modules/Data.js +23 -24
  202. package/src/modules/DataLabels.js +6 -6
  203. package/src/modules/Exports.js +12 -5
  204. package/src/modules/Fill.js +17 -8
  205. package/src/modules/Filters.js +50 -50
  206. package/src/modules/Graphics.js +69 -51
  207. package/src/modules/Markers.js +3 -1
  208. package/src/modules/MorphTypeChange.js +13 -7
  209. package/src/modules/Range.js +44 -29
  210. package/src/modules/RendererController.js +17 -3
  211. package/src/modules/Scales.js +32 -9
  212. package/src/modules/Series.js +41 -19
  213. package/src/modules/Theme.js +1 -1
  214. package/src/modules/Toolbar.js +3 -2
  215. package/src/modules/UnitMarkRegistry.js +0 -5
  216. package/src/modules/ZoomPanSelection.js +123 -2
  217. package/src/modules/accessibility/KeyboardNavigation.js +114 -186
  218. package/src/modules/animations/Easing.js +2 -1
  219. package/src/modules/animations/LengthTransition.js +22 -2
  220. package/src/modules/annotations/Helpers.js +68 -52
  221. package/src/modules/axes/Grid.js +21 -7
  222. package/src/modules/axes/YAxis.js +8 -9
  223. package/src/modules/dimensions/Dimensions.js +9 -3
  224. package/src/modules/dimensions/Grid.js +2 -2
  225. package/src/modules/dimensions/XAxis.js +2 -5
  226. package/src/modules/drilldown/Breadcrumb.js +5 -2
  227. package/src/modules/helpers/Destroy.js +1 -1
  228. package/src/modules/helpers/UpdateHelpers.js +33 -15
  229. package/src/modules/highlightFilter/HighlightFilter.js +8 -9
  230. package/src/modules/highlightFilter/TreemapPart.js +2 -2
  231. package/src/modules/legend/HeatmapGradientLegend.js +76 -45
  232. package/src/modules/legend/Helpers.js +8 -1
  233. package/src/modules/legend/Legend.js +11 -12
  234. package/src/modules/license/LicenseEnforcer.js +5 -0
  235. package/src/modules/settings/Defaults.js +28 -56
  236. package/src/modules/settings/Globals.js +5 -0
  237. package/src/modules/settings/Options.js +7 -7
  238. package/src/modules/settings/TypeAliases.js +33 -16
  239. package/src/modules/streamgraph/StreamLabels.js +1 -0
  240. package/src/modules/tooltip/Labels.js +73 -76
  241. package/src/modules/tooltip/Marker.js +25 -21
  242. package/src/modules/tooltip/Position.js +88 -51
  243. package/src/modules/tooltip/Tooltip.js +242 -255
  244. package/src/modules/tooltip/Utils.js +71 -130
  245. package/src/modules/tooltip/constants.js +5 -5
  246. package/src/modules/trellis/Trellis.js +6 -0
  247. package/src/modules/trellis/TrellisChrome.js +18 -7
  248. package/src/modules/trellis/TrellisSync.js +2 -0
  249. package/src/modules/trellis/TrellisTooltip.js +2 -11
  250. package/src/modules/weave/WeaveHost.js +18 -12
  251. package/src/renderers/canvas/CanvasGraphics.js +1 -0
  252. package/src/ssr/DOMShim.js +10 -0
  253. package/src/svg/SVGFilter.js +26 -17
  254. package/src/types/internal.d.ts +9 -3
  255. package/src/utils/Utils.js +0 -14
  256. package/types/apexcharts.d.ts +33 -12
@@ -31,7 +31,7 @@ var __objRest = (source, exclude) => {
31
31
  };
32
32
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
33
33
  /*!
34
- * ApexCharts v8.2.0
34
+ * ApexCharts v8.3.1
35
35
  * (c) 2018-2026 ApexCharts
36
36
  */
37
37
  import * as _core from "apexcharts/core";
@@ -838,10 +838,14 @@ class Exports {
838
838
  const byCategory = /* @__PURE__ */ new Map();
839
839
  series.forEach((s, sI) => {
840
840
  var _a;
841
+ const seen = /* @__PURE__ */ new Map();
841
842
  (_a = s == null ? void 0 : s.data) == null ? void 0 : _a.forEach((d, i) => {
842
843
  if (!d || typeof d !== "object") return;
843
844
  const cat = Array.isArray(d) ? d[0] : d.x;
844
- const key = String(cat);
845
+ const x2 = String(cat);
846
+ const n = seen.get(x2) || 0;
847
+ seen.set(x2, n + 1);
848
+ const key = `${n}:${x2}`;
845
849
  let row = byCategory.get(key);
846
850
  if (!row) {
847
851
  row = { cat, values: cols.map((c) => c.head.map(() => "")) };
@@ -855,7 +859,8 @@ class Exports {
855
859
  const bText = typeof b.cat === "string";
856
860
  if (aText !== bText) return aText ? 1 : -1;
857
861
  if (!aText) return a.cat - b.cat;
858
- return w.axisFlags.isXNumeric ? a.cat < b.cat ? -1 : 1 : 0;
862
+ if (!w.axisFlags.isXNumeric) return 0;
863
+ return a.cat < b.cat ? -1 : a.cat > b.cat ? 1 : 0;
859
864
  }).forEach(({ cat, values }) => body.push([cat, ...values.flat()]));
860
865
  } else {
861
866
  const len = Math.max(
@@ -880,7 +885,8 @@ class Exports {
880
885
  }
881
886
  }
882
887
  const dates = body.map((r) => r[0]).filter(isDateCat);
883
- const withTime = new Set(dates.map((c) => datetimeText(c))).size < dates.length;
888
+ const stamps = new Set(dates.map((c) => +new Date(c)));
889
+ const withTime = new Set([...stamps].map((t) => datetimeText(t))).size < stamps.size;
884
890
  body.forEach(
885
891
  (r) => rows.push(
886
892
  [getFormattedCategory(r[0], withTime), ...r.slice(1)].join(
@@ -960,6 +966,7 @@ let Helpers$1 = class Helpers {
960
966
  toggleDataSeries(seriesCnt, isHidden) {
961
967
  var _a, _b, _c;
962
968
  const w = this.w;
969
+ if (!w.dom.baseEl) return;
963
970
  if (w.globals.axisCharts || w.config.chart.type === "radialBar") {
964
971
  w.globals.resized = true;
965
972
  let seriesEl = null;
@@ -1123,7 +1130,7 @@ let Helpers$1 = class Helpers {
1123
1130
  var _a, _b;
1124
1131
  const w = this.w;
1125
1132
  const gl = w.globals;
1126
- const series = Utils.clone(w.config.series);
1133
+ const series = gl.axisCharts ? Utils.copySeriesShallow(w.config.series) : Utils.clone(w.config.series);
1127
1134
  if (gl.axisCharts) {
1128
1135
  const yaxis = w.config.yaxis[gl.seriesYAxisReverseMap[realIndex]];
1129
1136
  const collapseData = {
@@ -1426,9 +1433,11 @@ class HeatmapGradientLegend {
1426
1433
  this._min = 0;
1427
1434
  this._max = 0;
1428
1435
  this._geom = null;
1436
+ this._grad = null;
1429
1437
  this._bandHitEls = [];
1430
1438
  this._activeBandIndex = -1;
1431
1439
  this._targetEl = null;
1440
+ this.panelsW = null;
1432
1441
  this._onCellEnter = this._onCellEnter.bind(this);
1433
1442
  this._onCellLeave = this._onCellLeave.bind(this);
1434
1443
  this._onBandEnter = this._onBandEnter.bind(this);
@@ -1543,15 +1552,8 @@ class HeatmapGradientLegend {
1543
1552
  linearGrad.setAttribute("x2", "1");
1544
1553
  linearGrad.setAttribute("y2", "0");
1545
1554
  }
1546
- const { min, max, stops, bands } = this._computeStops();
1547
- this._min = min;
1548
- this._max = max;
1549
- stops.forEach((s) => {
1550
- const stopEl = BrowserAPIs.createElementNS(SVG_NS, "stop");
1551
- stopEl.setAttribute("offset", `${(s.percent * 100).toFixed(2)}%`);
1552
- stopEl.setAttribute("stop-color", s.color);
1553
- linearGrad.appendChild(stopEl);
1554
- });
1555
+ this._grad = linearGrad;
1556
+ const { min, max, bands } = this._paintStops();
1555
1557
  defs.appendChild(linearGrad);
1556
1558
  svg.appendChild(defs);
1557
1559
  const rect = BrowserAPIs.createElementNS(SVG_NS, "rect");
@@ -1760,6 +1762,7 @@ class HeatmapGradientLegend {
1760
1762
  */
1761
1763
  repositionToPlot() {
1762
1764
  var _a, _b;
1765
+ if (this._grad) this._paintStops();
1763
1766
  if (!Environment.isBrowser()) return;
1764
1767
  if (this._targetEl) return;
1765
1768
  const w = this.w;
@@ -1894,14 +1897,25 @@ class HeatmapGradientLegend {
1894
1897
  if (idx < 0 || idx === this._activeBandIndex) return;
1895
1898
  this._activeBandIndex = idx;
1896
1899
  (_d = (_c = (_b = this.ctx) == null ? void 0 : _b.events) == null ? void 0 : _c.fireEvent) == null ? void 0 : _d.call(_c, "legendHover", [this.ctx, idx, w]);
1897
- new Series(w).highlightRangeInSeries(idx, "highlight");
1900
+ this._highlightRange(idx, "highlight");
1898
1901
  }
1899
1902
  /** Leaving a band clears the highlight. */
1900
1903
  _onBandLeave() {
1901
1904
  if (this._activeBandIndex < 0) return;
1902
1905
  const idx = this._activeBandIndex;
1903
1906
  this._activeBandIndex = -1;
1904
- new Series(this.w).highlightRangeInSeries(idx, "reset");
1907
+ this._highlightRange(idx, "reset");
1908
+ }
1909
+ /**
1910
+ * A shared trellis strip sets `panelsW` so a band reaches every panel.
1911
+ * @param {number} idx
1912
+ * @param {'highlight'|'reset'} action
1913
+ */
1914
+ _highlightRange(idx, action) {
1915
+ var _a;
1916
+ (((_a = this.panelsW) == null ? void 0 : _a.call(this)) || [this.w]).forEach(
1917
+ (w) => new Series(w).highlightRangeInSeries(idx, action)
1918
+ );
1905
1919
  }
1906
1920
  _attachHoverListeners() {
1907
1921
  var _a, _b;
@@ -1923,10 +1937,10 @@ class HeatmapGradientLegend {
1923
1937
  */
1924
1938
  _onCellEnter(...args) {
1925
1939
  var _a, _b, _c;
1926
- const w = this.w;
1927
1940
  if (!this.arrowEl) return;
1928
1941
  const opts = args[args.length - 1];
1929
1942
  if (!opts || typeof opts !== "object") return;
1943
+ const w = opts.w || this.w;
1930
1944
  const i = opts.seriesIndex;
1931
1945
  const j = opts.dataPointIndex;
1932
1946
  if (typeof i !== "number" || typeof j !== "number") return;
@@ -2038,6 +2052,21 @@ class HeatmapGradientLegend {
2038
2052
  polygon.setAttribute("pointer-events", "none");
2039
2053
  return polygon;
2040
2054
  }
2055
+ /** (Re)write the strip's stops; returns `_computeStops()`. */
2056
+ _paintStops() {
2057
+ const r = this._computeStops();
2058
+ const grad = this._grad;
2059
+ this._min = r.min;
2060
+ this._max = r.max;
2061
+ grad.innerHTML = "";
2062
+ r.stops.forEach((s) => {
2063
+ const stopEl = BrowserAPIs.createElementNS(SVG_NS, "stop");
2064
+ stopEl.setAttribute("offset", `${(s.percent * 100).toFixed(2)}%`);
2065
+ stopEl.setAttribute("stop-color", s.color);
2066
+ grad.appendChild(stopEl);
2067
+ });
2068
+ return r;
2069
+ }
2041
2070
  /**
2042
2071
  * Build gradient stops + return effective min/max.
2043
2072
  * - If `colorScale.ranges` is set, stops are placed at each range boundary
@@ -2079,7 +2108,8 @@ class HeatmapGradientLegend {
2079
2108
  if (!Number.isFinite(dataMax)) dataMax = 0;
2080
2109
  let min = dataMin;
2081
2110
  let max = dataMax;
2082
- if (typeof cs.min !== "undefined" && typeof cs.max !== "undefined" && cs.max > cs.min) {
2111
+ const csWindow = typeof cs.min !== "undefined" && typeof cs.max !== "undefined" && cs.max > cs.min;
2112
+ if (csWindow) {
2083
2113
  min = cs.min;
2084
2114
  max = cs.max;
2085
2115
  } else {
@@ -2110,34 +2140,30 @@ class HeatmapGradientLegend {
2110
2140
  } else {
2111
2141
  const baseColor = w.globals.colors[0] || "#008FFB";
2112
2142
  const utils = new Utils();
2113
- const plot = w.config.plotOptions[w.config.chart.type] || {};
2143
+ const type = w.config.chart.type;
2144
+ const plot = w.config.plotOptions[type] || {};
2114
2145
  const shadeIntensity = (_b = plot.shadeIntensity) != null ? _b : 0.5;
2115
- const hasNegs = (
2146
+ const g = (
2116
2147
  /** @type {any} */
2117
- w.globals.hasNegs
2148
+ w.globals
2118
2149
  );
2150
+ const hasNegs = g.hasNegs;
2151
+ const yExt = type === "heatmap" && !plot.distributed && !csWindow && g.maxY >= g.minY;
2152
+ const hi = yExt ? g.maxY : max;
2153
+ const total = Math.abs(hi) + Math.abs(yExt ? cs.min < g.minY ? cs.min : g.minY : min);
2154
+ const k2 = shadeIntensity * 1.25;
2119
2155
  const n = Math.max(2, cfg.stops || 16);
2120
2156
  for (let s = 0; s < n; s++) {
2121
2157
  const t = s / (n - 1);
2122
- const v = min + t * (max - min);
2123
- const total = Math.abs(max) + Math.abs(min);
2124
- const percent_v = total === 0 ? 0 : 100 * v / total;
2125
- let colorShadePercent;
2126
- if (hasNegs) {
2127
- if (plot.reverseNegativeShade) {
2128
- colorShadePercent = percent_v < 0 ? percent_v / 100 * (shadeIntensity * 1.25) : (1 - percent_v / 100) * (shadeIntensity * 1.25);
2129
- } else {
2130
- colorShadePercent = percent_v <= 0 ? 1 - (1 + percent_v / 100) * shadeIntensity : (1 - percent_v / 100) * shadeIntensity;
2131
- }
2132
- } else {
2133
- colorShadePercent = 1 - percent_v / 100;
2134
- }
2135
- if (colorShadePercent > 1) colorShadePercent = 1;
2136
- if (colorShadePercent < -1) colorShadePercent = -1;
2137
- const shaded = plot.enableShades ? utils.shadeColor(
2138
- w.config.theme.mode === "dark" ? colorShadePercent * -1 : colorShadePercent,
2139
- baseColor
2140
- ) : baseColor;
2158
+ const p = total === 0 ? 0 : Math.min(min + t * (max - min), hi) / total;
2159
+ const c = Math.max(
2160
+ -1,
2161
+ Math.min(
2162
+ 1,
2163
+ hasNegs ? plot.reverseNegativeShade ? (p < 0 ? p : 1 - p) * k2 : p <= 0 ? 1 - (1 + p) * shadeIntensity : (1 - p) * shadeIntensity : (1 - p) * (type === "treemap" ? k2 : 1)
2164
+ )
2165
+ );
2166
+ const shaded = plot.enableShades ? utils.shadeColor(w.config.theme.mode === "dark" ? -c : c, baseColor) : baseColor;
2141
2167
  stops.push({ percent: t, color: shaded });
2142
2168
  }
2143
2169
  }
@@ -2168,9 +2194,12 @@ class Legend {
2168
2194
  this.legendHelpers = new Helpers$1(this);
2169
2195
  }
2170
2196
  init() {
2197
+ var _a;
2171
2198
  const w = this.w;
2172
2199
  const gl = w.globals;
2173
2200
  const cnf = w.config;
2201
+ (_a = this.heatmapGradientLegend) == null ? void 0 : _a.destroy();
2202
+ this.heatmapGradientLegend = null;
2174
2203
  this.isBarsDistributed = cnf.chart.type === "bar" && cnf.plotOptions.bar.distributed && cnf.series.length === 1;
2175
2204
  const showLegendAlways = cnf.legend.showForSingleSeries && this.w.seriesData.series.length === 1 || this.isBarsDistributed || // Heatmap legends are colorScale-driven (discrete ranges or the
2176
2205
  // gradient strip), not series-driven, so they must render even for a
@@ -2188,10 +2217,6 @@ class Legend {
2188
2217
  while (elLegendWrap.firstChild) {
2189
2218
  elLegendWrap.removeChild(elLegendWrap.firstChild);
2190
2219
  }
2191
- if (this.heatmapGradientLegend) {
2192
- this.heatmapGradientLegend.destroy();
2193
- this.heatmapGradientLegend = null;
2194
- }
2195
2220
  if (HeatmapGradientLegend.isEnabled(w)) {
2196
2221
  this.heatmapGradientLegend = new HeatmapGradientLegend(w, this.ctx);
2197
2222
  this.heatmapGradientLegend.draw();
@@ -2369,7 +2394,7 @@ class Legend {
2369
2394
  }
2370
2395
  }
2371
2396
  const lg = legendGroups[w.labelData.seriesGroupIndex[i]];
2372
- if (lg) elLegendWrap.appendChild(lg);
2397
+ if (lg && !lg.parentNode) elLegendWrap.appendChild(lg);
2373
2398
  (lg || elLegendWrap).appendChild(elLegend);
2374
2399
  elLegendWrap.classList.add(
2375
2400
  `apexcharts-align-${w.config.legend.horizontalAlign}`
@@ -2480,7 +2505,7 @@ class Legend {
2480
2505
  );
2481
2506
  const hoverOverLegend = isLegendItem(target);
2482
2507
  if (w.config.chart.type !== "heatmap" && !this.isBarsDistributed) {
2483
- if (!target.classList.contains("apexcharts-inactive-legend") && hoverOverLegend) {
2508
+ if (hoverOverLegend && !target.closest(".apexcharts-inactive-legend")) {
2484
2509
  const series = new Series(this.ctx.w);
2485
2510
  series.toggleSeriesOnHover(e, target);
2486
2511
  }
@@ -2514,7 +2539,8 @@ class Legend {
2514
2539
  me.onLegendClick(e);
2515
2540
  if (rel !== null && w.config.legend.onItemClick.toggleDataSeries) {
2516
2541
  requestAnimationFrame(() => {
2517
- const restored = w.dom.baseEl.querySelector(
2542
+ var _a;
2543
+ const restored = (_a = w.dom.baseEl) == null ? void 0 : _a.querySelector(
2518
2544
  `.apexcharts-legend-series[rel="${rel}"]`
2519
2545
  );
2520
2546
  if (restored) restored.focus();
@@ -3286,7 +3312,7 @@ class Toolbar {
3286
3312
  });
3287
3313
  }
3288
3314
  const series = ch.ctx.series.emptyCollapsedSeries(
3289
- Utils.clone(w.globals.initialSeries)
3315
+ Utils.clone(w.globals._initialSeriesPeek)
3290
3316
  );
3291
3317
  ch.updateHelpers._updateSeries(
3292
3318
  series,
@@ -3337,22 +3363,55 @@ class AxisMapping {
3337
3363
  return w.globals.minX + px * AxisMapping.xRatio(w);
3338
3364
  }
3339
3365
  /**
3340
- * Client (screen) x -> pixels from the plot origin. The origin is the svg
3341
- * element's left edge plus `translateX`, never the `.apexcharts-grid` box
3342
- * (fact 2 above), so the result does not depend on what the grid happens to
3343
- * render. `svgWidth` is the unscaled width the svg was drawn at, so the ratio
3344
- * against the measured one is the CSS zoom of any container the chart sits in.
3366
+ * The plot area on screen, in client px: its corner is where the plot's
3367
+ * group is translated to (translateX, translateY into the svg), and it is
3368
+ * gridWidth by gridHeight. The one screen-to-plot measurement: the tooltip,
3369
+ * zoom, selection and every other pointer reader map through it, so x and y
3370
+ * cannot disagree under CSS zoom.
3371
+ *
3372
+ * Never the `.apexcharts-grid` group's box: a group measures to the union
3373
+ * of what it happens to draw (fact 2 above). The plot's outline starts a
3374
+ * pixel down (`Grid.drawGridArea`), so unless gridlines or row bands reach
3375
+ * the top edge the box starts a pixel below the plot, and on a numeric-x bar
3376
+ * chart the horizontal gridlines run `barPadForNumericAxis` out past both
3377
+ * sides.
3378
+ *
3379
+ * `zoom` is the CSS zoom of any container the chart sits in (screen px per
3380
+ * plot px): the measured svg width over `svgWidth`, the unscaled width it
3381
+ * was drawn at. A distance measured on screen from this corner is divided
3382
+ * by it to land in plot px, the space the series are laid out and painted in.
3383
+ * With nothing mounted to measure, screen px are taken as svg px.
3384
+ *
3385
+ * @param {import('../types/internal').ChartStateW} w
3386
+ * @returns {{ left: number, top: number, width: number, height: number, zoom: number }}
3387
+ */
3388
+ static plotRect(w) {
3389
+ var _a, _b, _c;
3390
+ const svg = ((_a = w.dom.Paper) == null ? void 0 : _a.node) || ((_b = w.dom.baseEl) == null ? void 0 : _b.querySelector(".apexcharts-svg"));
3391
+ const box = ((_c = svg || w.dom.elWrap) == null ? void 0 : _c.getBoundingClientRect()) || {
3392
+ left: 0,
3393
+ top: 0,
3394
+ width: 0
3395
+ };
3396
+ const zoom = (svg && w.globals.svgWidth ? box.width / w.globals.svgWidth : 1) || 1;
3397
+ return {
3398
+ left: box.left + w.layout.translateX * zoom,
3399
+ top: box.top + w.layout.translateY * zoom,
3400
+ width: w.layout.gridWidth * zoom,
3401
+ height: w.layout.gridHeight * zoom,
3402
+ zoom
3403
+ };
3404
+ }
3405
+ /**
3406
+ * Client (screen) x -> pixels from the plot origin of {@link plotRect}.
3407
+ * Pass the rect when the caller has already measured it.
3345
3408
  * @param {import('../types/internal').ChartStateW} w
3346
3409
  * @param {number} screenX
3410
+ * @param {{ left: number, zoom: number }} [plot]
3347
3411
  * @returns {number}
3348
3412
  */
3349
- static screenXToPlotPx(w, screenX) {
3350
- const baseEl = w.dom.baseEl;
3351
- const svg = baseEl && baseEl.querySelector(".apexcharts-svg");
3352
- if (!svg) return screenX - w.layout.translateX;
3353
- const svgRect = svg.getBoundingClientRect();
3354
- const zoom = w.globals.svgWidth ? svgRect.width / w.globals.svgWidth : 1;
3355
- return (screenX - svgRect.left) / (zoom || 1) - w.layout.translateX;
3413
+ static screenXToPlotPx(w, screenX, plot = AxisMapping.plotRect(w)) {
3414
+ return (screenX - plot.left) / plot.zoom;
3356
3415
  }
3357
3416
  }
3358
3417
  const Box = _core.__apex_index_Box;
@@ -3600,6 +3659,63 @@ class ZoomPanSelection extends Toolbar {
3600
3659
  const { zoom } = this.w.config.chart;
3601
3660
  return this._incidentalZoomEnabled(zoom && zoom.allowMouseWheelZoom);
3602
3661
  }
3662
+ /** An explicit `true` zooms on every wheel; 'auto' needs Ctrl/Cmd. */
3663
+ _wheelZoomGreedy() {
3664
+ return this.w.config.chart.zoom.allowMouseWheelZoom === true;
3665
+ }
3666
+ /**
3667
+ * Tell a viewer whose bare wheel just scrolled past the chart how to zoom it.
3668
+ * Shown over the chart while the scroll goes on and faded out shortly after
3669
+ * it stops. Only for a mostly vertical wheel: a sideways trackpad swipe is
3670
+ * not someone reaching for zoom.
3671
+ *
3672
+ * The node lives in elWrap and the timer on w.interact, since a re-render can
3673
+ * replace both this instance and the wrapper's contents while it is up.
3674
+ *
3675
+ * @param {any} e
3676
+ */
3677
+ _showWheelHint(e) {
3678
+ const w = this.w;
3679
+ if (w.config.chart.zoom.wheelHint === false) return;
3680
+ if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
3681
+ const wrap = w.dom.elWrap;
3682
+ if (!wrap) return;
3683
+ let el = wrap.querySelector(".apexcharts-wheel-hint");
3684
+ if (!el) {
3685
+ const win = BrowserAPIs.getWindow();
3686
+ const nav = win && win.navigator;
3687
+ const mac = !!nav && /Mac|iPhone|iPad/.test(nav.platform || nav.userAgent);
3688
+ const text = (w.globals.locale.toolbar.wheelZoomHint || "").replace(
3689
+ "{key}",
3690
+ mac ? "⌘" : "Ctrl"
3691
+ );
3692
+ el = BrowserAPIs.createElement("div");
3693
+ el.className = "apexcharts-wheel-hint";
3694
+ el.setAttribute("aria-hidden", "true");
3695
+ const label = BrowserAPIs.createElement("span");
3696
+ label.textContent = text;
3697
+ label.style.fontFamily = w.config.chart.fontFamily;
3698
+ el.appendChild(label);
3699
+ wrap.appendChild(el);
3700
+ void /** @type {HTMLElement} */
3701
+ el.offsetWidth;
3702
+ }
3703
+ el.classList.add("apexcharts-wheel-hint-visible");
3704
+ const it = w.interact;
3705
+ if (it.wheelHintTimer) clearTimeout(it.wheelHintTimer);
3706
+ it.wheelHintTimer = setTimeout(() => this._hideWheelHint(), 1200);
3707
+ }
3708
+ _hideWheelHint() {
3709
+ var _a;
3710
+ const w = this.w;
3711
+ const it = w.interact;
3712
+ if (it.wheelHintTimer) {
3713
+ clearTimeout(it.wheelHintTimer);
3714
+ it.wheelHintTimer = null;
3715
+ }
3716
+ const el = (_a = w.dom.elWrap) == null ? void 0 : _a.querySelector(".apexcharts-wheel-hint");
3717
+ if (el) el.classList.remove("apexcharts-wheel-hint-visible");
3718
+ }
3603
3719
  /**
3604
3720
  * Put keyboard focus on the chart, where the chart is focusable at all.
3605
3721
  *
@@ -3671,8 +3787,13 @@ class ZoomPanSelection extends Toolbar {
3671
3787
  * @param {any} e
3672
3788
  */
3673
3789
  mouseWheelEvent(e) {
3674
- e.preventDefault();
3675
3790
  const st = this._wheel();
3791
+ if (!this._wheelZoomGreedy() && !e.ctrlKey && !e.metaKey && st.endTimer == null) {
3792
+ this._showWheelHint(e);
3793
+ return;
3794
+ }
3795
+ e.preventDefault();
3796
+ this._hideWheelHint();
3676
3797
  let dy = e.deltaY;
3677
3798
  if (e.deltaMode === 1) dy *= 33;
3678
3799
  else if (e.deltaMode === 2) dy *= 330;
@@ -4252,6 +4373,7 @@ class ZoomPanSelection extends Toolbar {
4252
4373
  xHighestValue = maxX;
4253
4374
  }
4254
4375
  }
4376
+ if (xLowestValue === minX && xHighestValue === maxX) return;
4255
4377
  const xaxis = {
4256
4378
  min: xLowestValue,
4257
4379
  max: xHighestValue
@@ -4436,6 +4558,34 @@ class ZoomPanSelection extends Toolbar {
4436
4558
  w.config.chart.events.scrolled(this.ctx, args);
4437
4559
  this.ctx.events.fireEvent("scrolled", args);
4438
4560
  }
4561
+ /**
4562
+ * Pan a zoomed x-window by `fraction` of its width (keyboard Shift+Arrow),
4563
+ * clamped to the data as a drag pan is, and reported as one (`scrolled`).
4564
+ * @param {number} fraction
4565
+ */
4566
+ panBy(fraction) {
4567
+ const w = this.w;
4568
+ if (!w.interact.zoomed) return;
4569
+ const { min, max } = this._currentXWindow();
4570
+ let d = (max - min) * fraction;
4571
+ if (w.config.xaxis.convertedCatToNumeric) {
4572
+ d = d > 0 ? Math.ceil(d) : Math.floor(d);
4573
+ }
4574
+ if (w.axisFlags.isRangeBar) {
4575
+ const r = w.rangeData;
4576
+ let lo = Infinity;
4577
+ let hi = -Infinity;
4578
+ r.seriesRangeStart.concat(r.seriesRangeEnd).flat().forEach((y) => {
4579
+ if (y != null) {
4580
+ lo = Math.min(lo, y);
4581
+ hi = Math.max(hi, y);
4582
+ }
4583
+ });
4584
+ d = d > 0 ? Math.min(d, Math.max(0, hi - max)) : Math.max(d, Math.min(0, lo - min));
4585
+ if (!d) return;
4586
+ }
4587
+ if (this._applyXRange(min + d, max + d, false)) this._fireScrolled();
4588
+ }
4439
4589
  /** @param {number} x @param {number} t */
4440
4590
  _pushSample(x2, t) {
4441
4591
  const s = this._m().samples;
@@ -4715,10 +4865,16 @@ class Helpers2 {
4715
4865
  }
4716
4866
  }
4717
4867
  /**
4868
+ * Measure a label's background and draw it. With `deferDraw` it only
4869
+ * measures, and returns the step that draws the rect: annotationsBackground
4870
+ * measures every label before drawing any, since each rect drawn would force
4871
+ * a fresh layout for the next label's reads.
4718
4872
  * @param {any} annoEl
4719
4873
  * @param {Record<string, any>} anno
4874
+ * @param {boolean} [deferDraw]
4875
+ * @returns {any}
4720
4876
  */
4721
- addBackgroundToAnno(annoEl, anno) {
4877
+ addBackgroundToAnno(annoEl, anno, deferDraw) {
4722
4878
  const w = this.w;
4723
4879
  if (!annoEl || !anno.label.text || !String(anno.label.text).trim()) {
4724
4880
  return null;
@@ -4745,58 +4901,68 @@ class Helpers2 {
4745
4901
  const gridTop = elGridRect.top - gridBBox.y * zoom;
4746
4902
  const x1 = (coords.left - gridLeft) / zoom - pleft;
4747
4903
  const y1 = (coords.top - gridTop) / zoom - ptop;
4748
- const elRect = this.annoCtx.graphics.drawRect(
4749
- x1,
4750
- y1,
4751
- coords.width / zoom + pleft + pright,
4752
- coords.height / zoom + ptop + pbottom,
4753
- anno.label.borderRadius,
4754
- anno.label.style.background,
4755
- 1,
4756
- anno.label.borderWidth,
4757
- anno.label.borderColor,
4758
- 0
4759
- );
4760
- if (anno.id) {
4761
- elRect.node.classList.add(anno.id);
4762
- }
4763
- return elRect;
4904
+ const draw = () => {
4905
+ const elRect = this.annoCtx.graphics.drawRect(
4906
+ x1,
4907
+ y1,
4908
+ coords.width / zoom + pleft + pright,
4909
+ coords.height / zoom + ptop + pbottom,
4910
+ anno.label.borderRadius,
4911
+ anno.label.style.background,
4912
+ 1,
4913
+ anno.label.borderWidth,
4914
+ anno.label.borderColor,
4915
+ 0
4916
+ );
4917
+ if (anno.id) {
4918
+ elRect.node.classList.add(anno.id);
4919
+ }
4920
+ return elRect;
4921
+ };
4922
+ return deferDraw ? draw : draw();
4764
4923
  }
4765
4924
  annotationsBackground() {
4766
4925
  const w = this.w;
4926
+ const drawn = [];
4767
4927
  const add = (anno, i, type) => {
4768
- const annoLabel = w.dom.baseEl.querySelector(
4769
- `.apexcharts-${type}-annotations .apexcharts-${type}-annotation-label[rel='${i}']`
4928
+ const annoLabel = (
4929
+ /** @type {Element} */
4930
+ w.dom.baseEl.querySelector(
4931
+ `.apexcharts-${type}-annotations .apexcharts-${type}-annotation-label[rel='${i}']`
4932
+ )
4770
4933
  );
4771
- if (annoLabel) {
4772
- const parent = annoLabel.parentNode;
4773
- const elRect = this.addBackgroundToAnno(annoLabel, anno);
4774
- if (elRect) {
4775
- parent == null ? void 0 : parent.insertBefore(elRect.node, annoLabel);
4776
- const labelX = annoLabel.getAttribute("x");
4777
- if (labelX !== null) {
4778
- applyProgressiveReveal(elRect, parseFloat(labelX), w);
4779
- }
4780
- if (anno.label.mouseEnter) {
4781
- elRect.node.addEventListener(
4782
- "mouseenter",
4783
- anno.label.mouseEnter.bind(this, anno)
4784
- );
4785
- }
4786
- if (anno.label.mouseLeave) {
4787
- elRect.node.addEventListener(
4788
- "mouseleave",
4789
- anno.label.mouseLeave.bind(this, anno)
4790
- );
4791
- }
4792
- if (anno.label.click) {
4793
- elRect.node.addEventListener(
4794
- "click",
4795
- anno.label.click.bind(this, anno)
4796
- );
4797
- }
4934
+ const draw = this.addBackgroundToAnno(annoLabel, anno, true);
4935
+ if (!draw) return;
4936
+ drawn.push(() => {
4937
+ const elRect = draw();
4938
+ const parent = (
4939
+ /** @type {Node} */
4940
+ annoLabel.parentNode
4941
+ );
4942
+ parent == null ? void 0 : parent.insertBefore(elRect.node, annoLabel);
4943
+ const labelX = annoLabel.getAttribute("x");
4944
+ if (labelX !== null) {
4945
+ applyProgressiveReveal(elRect, parseFloat(labelX), w);
4798
4946
  }
4799
- }
4947
+ if (anno.label.mouseEnter) {
4948
+ elRect.node.addEventListener(
4949
+ "mouseenter",
4950
+ anno.label.mouseEnter.bind(this, anno)
4951
+ );
4952
+ }
4953
+ if (anno.label.mouseLeave) {
4954
+ elRect.node.addEventListener(
4955
+ "mouseleave",
4956
+ anno.label.mouseLeave.bind(this, anno)
4957
+ );
4958
+ }
4959
+ if (anno.label.click) {
4960
+ elRect.node.addEventListener(
4961
+ "click",
4962
+ anno.label.click.bind(this, anno)
4963
+ );
4964
+ }
4965
+ });
4800
4966
  };
4801
4967
  w.config.annotations.xaxis.forEach(
4802
4968
  (anno, i) => add(anno, i, "xaxis")
@@ -4807,6 +4973,7 @@ class Helpers2 {
4807
4973
  w.config.annotations.points.forEach(
4808
4974
  (anno, i) => add(anno, i, "point")
4809
4975
  );
4976
+ drawn.forEach((draw) => draw());
4810
4977
  }
4811
4978
  /**
4812
4979
  * Does the x position take the category branch of `getX1X2` (a label lookup)
@@ -5903,16 +6070,35 @@ class KeyboardNavigation {
5903
6070
  });
5904
6071
  svgEl.addEventListener("keydown", this._onKeyDown, { passive: false });
5905
6072
  this.ctx.events.addEventListener("legendClick", this._onLegendClick);
6073
+ const kept = w.interact.keyNav;
6074
+ const doc = svgEl.ownerDocument;
6075
+ w.interact.keyNav = null;
6076
+ if (kept && (!doc.activeElement || doc.activeElement === doc.body)) {
6077
+ [this.seriesIndex, this.dataPointIndex, , this._tooltipDismissed] = kept;
6078
+ if (!kept[2]) this.notePointerFocus();
6079
+ svgEl.focus({ preventScroll: true });
6080
+ }
5906
6081
  }
5907
6082
  /**
5908
- * Removes all event listeners. Called from chart.destroy().
6083
+ * Removes all event listeners. Called from chart.destroy(), and with
6084
+ * `updating` when an update is about to replace the SVG.
6085
+ * @param {boolean} [updating]
5909
6086
  */
5910
- destroy() {
6087
+ destroy(updating) {
6088
+ var _a;
5911
6089
  const w = this.w;
5912
6090
  const svgEl = w.dom.Paper && w.dom.Paper.node;
5913
6091
  this.ctx.events.removeEventListener("legendClick", this._onLegendClick);
5914
6092
  clearTimeout(this._announceTimer);
5915
6093
  if (!svgEl) return;
6094
+ if (updating && ((_a = svgEl.getRootNode) == null ? void 0 : _a.call(svgEl).activeElement) === svgEl) {
6095
+ w.interact.keyNav = [
6096
+ this.seriesIndex,
6097
+ this.dataPointIndex,
6098
+ this.active,
6099
+ this._tooltipDismissed
6100
+ ];
6101
+ }
5916
6102
  svgEl.removeEventListener("focus", this._onFocus);
5917
6103
  svgEl.removeEventListener("blur", this._onBlur);
5918
6104
  svgEl.removeEventListener("keydown", this._onKeyDown);
@@ -5964,7 +6150,7 @@ class KeyboardNavigation {
5964
6150
  this.active = true;
5965
6151
  this._clampCursor();
5966
6152
  this._snapToVisibleRange();
5967
- this._showCurrentPoint();
6153
+ if (!this._tooltipDismissed) this._showCurrentPoint();
5968
6154
  }
5969
6155
  _onBlur() {
5970
6156
  this.active = false;
@@ -6010,20 +6196,18 @@ class KeyboardNavigation {
6010
6196
  break;
6011
6197
  case "Home":
6012
6198
  e.preventDefault();
6013
- this.dataPointIndex = 0;
6014
- this._skipNullForward();
6199
+ this._seek(0, 1);
6015
6200
  this._showCurrentPoint();
6016
6201
  break;
6017
6202
  case "End":
6018
6203
  e.preventDefault();
6019
- this.dataPointIndex = this._getDataPointCount(this.seriesIndex) - 1;
6020
- this._skipNullBackward();
6204
+ this._seek(this._getDataPointCount(this.seriesIndex) - 1, -1);
6021
6205
  this._showCurrentPoint();
6022
6206
  break;
6023
6207
  case "Enter":
6024
6208
  case " ":
6025
6209
  e.preventDefault();
6026
- this._fireClick();
6210
+ this._fireClick(e);
6027
6211
  break;
6028
6212
  case "+":
6029
6213
  case "=":
@@ -6071,22 +6255,15 @@ class KeyboardNavigation {
6071
6255
  );
6072
6256
  }
6073
6257
  _canPan() {
6074
- return this._canZoom();
6258
+ return this._canZoom() && this.w.interact.zoomed;
6075
6259
  }
6076
6260
  /**
6077
- * Shift the visible x-range by ~10% in the given direction.
6261
+ * Shift the visible x-range by ~10% in the given direction, as a drag pan.
6078
6262
  * @param {number} direction +1 = right, -1 = left
6079
6263
  */
6080
6264
  _panBy(direction) {
6081
- const toolbar = this.ctx.toolbar;
6082
- if (!toolbar) return;
6083
- const r = toolbar._currentXRange();
6084
- const minX = Number(r.minX);
6085
- const maxX = Number(r.maxX);
6086
- if (!isFinite(minX) || !isFinite(maxX) || minX === maxX) return;
6087
- const span = maxX - minX;
6088
- const step = span * 0.1 * direction;
6089
- toolbar.zoomUpdateOptions(minX + step, maxX + step);
6265
+ var _a;
6266
+ (_a = this.ctx.zoomPanSelection) == null ? void 0 : _a.panBy(direction / 10);
6090
6267
  this._announce(direction > 0 ? "Panned right" : "Panned left");
6091
6268
  }
6092
6269
  // ─── Navigation ───────────────────────────────────────────────────────────
@@ -6101,8 +6278,8 @@ class KeyboardNavigation {
6101
6278
  if (dSeries !== 0) {
6102
6279
  const ttCtx = this.w.globals.tooltip;
6103
6280
  const type = w.config.chart.type;
6104
- const perCell = type === "heatmap" || type === "treemap";
6105
- if (!perCell && ttCtx && ttCtx.tConfig && ttCtx.tConfig.shared) {
6281
+ const perCell = type === "heatmap" || type === "treemap" || type === "radialBar";
6282
+ if (!perCell && (ttCtx == null ? void 0 : ttCtx.ttItems) && ttCtx.tConfig.shared) {
6106
6283
  const j = this.dataPointIndex;
6107
6284
  const isActuallyShared = ttCtx.tooltipUtil && ttCtx.tooltipUtil.isXoverlap(j) && ttCtx.tooltipUtil.isInitialSeriesSameLen();
6108
6285
  if (isActuallyShared) return;
@@ -6128,59 +6305,43 @@ class KeyboardNavigation {
6128
6305
  }
6129
6306
  }
6130
6307
  if (dPoint !== 0) {
6131
- const dpCount = this._getDataPointCount(this.seriesIndex);
6132
- let di = this.dataPointIndex + dPoint;
6133
- if (di < 0) di = wrapAround ? dpCount - 1 : 0;
6134
- if (di >= dpCount) di = wrapAround ? 0 : dpCount - 1;
6135
- this.dataPointIndex = di;
6136
- if (dPoint > 0) {
6137
- this._skipNullForward();
6138
- } else {
6139
- this._skipNullBackward();
6140
- }
6308
+ this._seek(this.dataPointIndex + dPoint, dPoint);
6141
6309
  if (!this._isDataPointVisible(this.seriesIndex, this.dataPointIndex)) {
6142
6310
  this._snapToVisibleRangeInDirection(dPoint);
6143
6311
  }
6144
6312
  }
6145
6313
  this._showCurrentPoint();
6146
6314
  }
6147
- /** Advance dataPointIndex forward past any nulls */
6148
- _skipNullForward() {
6149
- const w = this.w;
6150
- const si = this.seriesIndex;
6151
- const dpCount = this._getDataPointCount(si);
6152
- let di = this.dataPointIndex;
6153
- let attempts = 0;
6154
- if (!Array.isArray(w.seriesData.series[si])) return;
6155
- while (attempts < dpCount && w.seriesData.series[si][di] === null) {
6156
- di = (di + 1) % dpCount;
6157
- attempts++;
6158
- }
6159
- this.dataPointIndex = di;
6160
- }
6161
- /** Retreat dataPointIndex backward past any nulls */
6162
- _skipNullBackward() {
6315
+ /**
6316
+ * Land on the first non-null point from `di` going `dir`. Past an edge it
6317
+ * wraps only with wrapAround; when no point lies ahead the cursor stays.
6318
+ * @param {number} di
6319
+ * @param {number} dir
6320
+ */
6321
+ _seek(di, dir) {
6163
6322
  const w = this.w;
6164
- const si = this.seriesIndex;
6165
- const dpCount = this._getDataPointCount(si);
6166
- let di = this.dataPointIndex;
6167
- let attempts = 0;
6168
- if (!Array.isArray(w.seriesData.series[si])) return;
6169
- while (attempts < dpCount && w.seriesData.series[si][di] === null) {
6170
- di = (di - 1 + dpCount) % dpCount;
6171
- attempts++;
6323
+ const row = w.seriesData.series[this.seriesIndex];
6324
+ const n = this._getDataPointCount(this.seriesIndex);
6325
+ for (let k2 = 0; k2 < n; k2++, di += dir) {
6326
+ if (w.config.chart.accessibility.keyboard.navigation.wrapAround) {
6327
+ di = (di + n) % n;
6328
+ } else if (di < 0 || di >= n) return;
6329
+ if (!Array.isArray(row) || row[di] !== null) {
6330
+ this.dataPointIndex = di;
6331
+ return;
6332
+ }
6172
6333
  }
6173
- this.dataPointIndex = di;
6174
6334
  }
6175
6335
  // ─── Display ──────────────────────────────────────────────────────────────
6176
6336
  _showCurrentPoint() {
6177
6337
  const { seriesIndex: i, dataPointIndex: j } = this;
6178
6338
  const w = this.w;
6179
6339
  const ttCtx = w.globals.tooltip;
6180
- if (!ttCtx || !ttCtx.ttItems) return;
6340
+ this._tooltipDismissed = false;
6181
6341
  w.interact.capturedSeriesIndex = i;
6182
6342
  w.interact.capturedDataPointIndex = j;
6183
6343
  this._applyFocusClass(i, j);
6344
+ if (!(ttCtx == null ? void 0 : ttCtx.ttItems)) return this._announce(this._buildPointLabel(i, j));
6184
6345
  this._showTooltip(
6185
6346
  i,
6186
6347
  j,
@@ -6238,10 +6399,8 @@ class KeyboardNavigation {
6238
6399
  if (w.config.chart.accessibility.enabled && w.config.chart.accessibility.announcements.enabled) {
6239
6400
  tooltipEl.removeAttribute("aria-hidden");
6240
6401
  }
6241
- if (type === "pie" || type === "donut" || type === "polarArea") {
6402
+ if (type === "pie" || type === "donut" || type === "polarArea" || type === "radialBar") {
6242
6403
  this._showTooltipNonAxis(i, j, ttCtx, tooltipEl);
6243
- } else if (type === "radialBar") {
6244
- this._showTooltipRadialBar(i, j, ttCtx, tooltipEl);
6245
6404
  } else if (type === "heatmap" || type === "treemap") {
6246
6405
  this._showTooltipHeatTree(i, j, ttCtx, tooltipEl, type);
6247
6406
  } else if (this._isBarLikeSeries(i)) {
@@ -6596,24 +6755,23 @@ class KeyboardNavigation {
6596
6755
  return true;
6597
6756
  }
6598
6757
  /**
6599
- * pie / donut / polarArea
6758
+ * pie / donut / polarArea (a slice per point, i is 0) and radialBar (a ring
6759
+ * per series, j is 0)
6600
6760
  * @param {number} i
6601
6761
  * @param {number} j
6602
6762
  * @param {import('../tooltip/Tooltip').default} ttCtx
6603
6763
  * @param {HTMLElement} tooltipEl
6604
6764
  */
6605
6765
  _showTooltipNonAxis(i, j, ttCtx, tooltipEl) {
6606
- const w = this.w;
6607
6766
  ttCtx.tooltipLabels.drawSeriesTexts({
6608
6767
  ttItems: ttCtx.ttItems,
6609
- i: j,
6768
+ i: i + j,
6610
6769
  shared: false
6611
6770
  });
6612
6771
  const tooltipBound = tooltipEl.getBoundingClientRect();
6613
6772
  const ttWidth = tooltipBound.width || ttCtx.tooltipRect.ttWidth || 0;
6614
6773
  const ttHeight = tooltipBound.height || ttCtx.tooltipRect.ttHeight || 0;
6615
- const sliceEl = w.dom.baseEl.querySelector(`.apexcharts-pie-area[j='${j}']`);
6616
- const anchor = ttCtx.getSliceAnchor(sliceEl);
6774
+ const anchor = ttCtx.getSliceAnchor(this._getFocusableElement(i, j));
6617
6775
  if (anchor) {
6618
6776
  const pos = ttCtx.tooltipPosition.placeOverAnchor(
6619
6777
  anchor.x,
@@ -6626,56 +6784,6 @@ class KeyboardNavigation {
6626
6784
  tooltipEl.style.top = pos.y + "px";
6627
6785
  }
6628
6786
  }
6629
- /**
6630
- * radialBar — one ring per series, single value each
6631
- * @param {number} i
6632
- * @param {any} _j
6633
- * @param {import('../tooltip/Tooltip').default} ttCtx
6634
- * @param {HTMLElement} tooltipEl
6635
- */
6636
- _showTooltipRadialBar(i, _j, ttCtx, tooltipEl) {
6637
- var _a;
6638
- const w = this.w;
6639
- ttCtx.tooltipLabels.drawSeriesTexts({
6640
- ttItems: ttCtx.ttItems,
6641
- i,
6642
- shared: false
6643
- });
6644
- const { ttWidth = 0, ttHeight = 0 } = ttCtx.getCachedDimensions();
6645
- const arcEl = w.dom.baseEl.querySelector(
6646
- `.apexcharts-radialbar-series[data\\:realIndex='${i}'] path`
6647
- );
6648
- if (arcEl) {
6649
- const angle = parseFloat((_a = arcEl.getAttribute("data:angle")) != null ? _a : "") || 0;
6650
- const initialAngle = w.config.plotOptions.radialBar.startAngle || 0;
6651
- const midAngle = initialAngle + angle / 2;
6652
- const centerX = w.layout.gridWidth / 2;
6653
- const centerY = w.layout.gridHeight / 2;
6654
- const radialSize = w.globals.radialSize || Math.min(w.layout.gridWidth, w.layout.gridHeight) / 2;
6655
- const seriesCount = w.seriesData.series.length;
6656
- const trackSize = radialSize / Math.max(seriesCount, 1);
6657
- const outerRadius = radialSize - i * trackSize;
6658
- const innerRadius = outerRadius - trackSize;
6659
- const ringRadius = (outerRadius + innerRadius) / 2;
6660
- const centroid = Utils.polarToCartesian(
6661
- centerX,
6662
- centerY,
6663
- ringRadius,
6664
- midAngle
6665
- );
6666
- const x2 = centroid.x + (w.layout.translateX || 0);
6667
- const y = centroid.y + (w.layout.translateY || 0);
6668
- const pos = ttCtx.tooltipPosition.placeOverAnchor(
6669
- x2,
6670
- y,
6671
- ttWidth,
6672
- ttHeight,
6673
- 10
6674
- );
6675
- tooltipEl.style.left = pos.x + "px";
6676
- tooltipEl.style.top = pos.y + "px";
6677
- }
6678
- }
6679
6787
  /**
6680
6788
  * heatmap / treemap — position tooltip using element bounding rect
6681
6789
  * @param {number} i
@@ -6935,9 +7043,7 @@ class KeyboardNavigation {
6935
7043
  const mark = this._canvasMark(i, j);
6936
7044
  if (!mark) return this._drawCanvasMarkerFocusRing(i, j);
6937
7045
  const w = this.w;
6938
- const host = Array.from(
6939
- w.dom.baseEl.querySelectorAll(".apexcharts-series")
6940
- ).find((g) => g.getAttribute("data:realIndex") === String(i));
7046
+ const host = this._seriesGroup(i);
6941
7047
  if (!host) return null;
6942
7048
  const ring = new Graphics(w, this.ctx).drawPath({
6943
7049
  d: mark.d,
@@ -6961,9 +7067,7 @@ class KeyboardNavigation {
6961
7067
  const marker = this._canvasMarker(i, j);
6962
7068
  if (!marker) return null;
6963
7069
  const w = this.w;
6964
- const host = Array.from(
6965
- w.dom.baseEl.querySelectorAll(".apexcharts-series")
6966
- ).find((g) => g.getAttribute("data:realIndex") === String(i));
7070
+ const host = this._seriesGroup(i);
6967
7071
  if (!host) return null;
6968
7072
  const ring = new Graphics(w, this.ctx).drawPath({
6969
7073
  d: marker.d,
@@ -7057,6 +7161,7 @@ class KeyboardNavigation {
7057
7161
  * @param {number} j
7058
7162
  */
7059
7163
  _getFocusableElement(i, j) {
7164
+ var _a, _b;
7060
7165
  const w = this.w;
7061
7166
  const type = w.config.chart.type;
7062
7167
  const baseEl = w.dom.baseEl;
@@ -7074,32 +7179,47 @@ class KeyboardNavigation {
7074
7179
  );
7075
7180
  }
7076
7181
  if (type === "radialBar") {
7077
- return baseEl.querySelector(
7078
- `.apexcharts-radialbar-series[data\\:realIndex='${i}'] path`
7079
- );
7182
+ return baseEl.querySelector(`.apexcharts-radialbar-slice-${i}`);
7080
7183
  }
7081
7184
  if (this._isBarLikeSeries(i)) {
7082
7185
  if (this._canvasMark(i, j)) return null;
7083
- return baseEl.querySelector(
7084
- `.apexcharts-series[data\\:realIndex='${i}'] path[j='${j}']`
7085
- );
7186
+ return (_a = this._seriesGroup(i)) == null ? void 0 : _a.querySelector(`path[j='${j}']`);
7086
7187
  }
7087
- const marker = baseEl.querySelector(
7088
- `.apexcharts-series[data\\:realIndex='${i}'] .apexcharts-marker[rel='${j}']`
7089
- );
7090
- return marker || null;
7188
+ return (_b = this._seriesGroup(i)) == null ? void 0 : _b.querySelector(`.apexcharts-marker[rel='${j}']`);
7189
+ }
7190
+ /**
7191
+ * The series' own group, by realIndex (`rel` counts within a type's groups,
7192
+ * which a combo has several of). Matched in script: not every selector
7193
+ * engine takes the escaped `data\:realIndex` attribute.
7194
+ * @param {number} i
7195
+ * @returns {Element | undefined}
7196
+ */
7197
+ _seriesGroup(i) {
7198
+ return Array.from(
7199
+ this.w.dom.baseEl.querySelectorAll(".apexcharts-series")
7200
+ ).find((g) => g.getAttribute("data:realIndex") === String(i));
7091
7201
  }
7092
7202
  // ─── Click / Enter ────────────────────────────────────────────────────────
7093
- _fireClick() {
7094
- const w = this.w;
7095
- const ttCtx = w.globals.tooltip;
7096
- if (!ttCtx) return;
7097
- const syntheticEvent = {
7098
- type: "mouseup",
7099
- clientX: 0,
7100
- clientY: 0
7101
- };
7102
- ttCtx.markerClick(syntheticEvent, this.seriesIndex, this.dataPointIndex);
7203
+ /**
7204
+ * What a click on the focused mark does: its mousedown selects it
7205
+ * (dataPointSelection), its mouseup slides a pie slice out and fires
7206
+ * markerClick.
7207
+ * @param {KeyboardEvent} e
7208
+ */
7209
+ _fireClick(e) {
7210
+ var _a, _b;
7211
+ const el = (
7212
+ /** @type {any} */
7213
+ (_a = this._focusedEl) == null ? void 0 : _a.instance
7214
+ );
7215
+ const pie = this.ctx.pie;
7216
+ if (el) new Graphics(this.w, this.ctx).pathMouseDown(el, e);
7217
+ if (pie && pie.getExpandOffset() > 0) pie.pieClicked(this.dataPointIndex);
7218
+ (_b = this.w.globals.tooltip) == null ? void 0 : _b.markerClick(
7219
+ e,
7220
+ this.seriesIndex,
7221
+ this.dataPointIndex
7222
+ );
7103
7223
  }
7104
7224
  // ─── Helpers ──────────────────────────────────────────────────────────────
7105
7225
  _isNavEnabled() {
@@ -7123,8 +7243,8 @@ class KeyboardNavigation {
7123
7243
  if (type === "pie" || type === "donut" || type === "polarArea") {
7124
7244
  return w.seriesData.series.length;
7125
7245
  }
7126
- const series = w.seriesData.series;
7127
- return series[si] && Array.isArray(series[si]) ? series[si].length : 0;
7246
+ const s = w.seriesData.series[si];
7247
+ return Array.isArray(s) ? s.length : 1;
7128
7248
  }
7129
7249
  _clampCursor() {
7130
7250
  const seriesCount = this._getSeriesCount();
@@ -7894,7 +8014,7 @@ class MorphTypeChange {
7894
8014
  const svg = probe.ownerSVGElement;
7895
8015
  if (typeof /** @type {any} */
7896
8016
  probe.isPointInFill !== "function" || !svg || typeof svg.createSVGPoint !== "function") {
7897
- layer.removeChild(probe);
8017
+ probe.remove();
7898
8018
  return null;
7899
8019
  }
7900
8020
  const pt = svg.createSVGPoint();
@@ -7905,7 +8025,7 @@ class MorphTypeChange {
7905
8025
  /** @type {any} */
7906
8026
  probe
7907
8027
  );
7908
- return p.isPointInFill(pt) || typeof p.isPointInStroke === "function" && p.isPointInStroke(pt);
8028
+ return p.isPointInFill(pt) || p.isPointInStroke(pt);
7909
8029
  };
7910
8030
  const SCAN = 48;
7911
8031
  const intervalsAt = (bandLo, bandHi, horizontal) => {
@@ -7994,6 +8114,7 @@ class MorphTypeChange {
7994
8114
  if (!layer) return this._revealPieceHidden();
7995
8115
  const pieces = [];
7996
8116
  const doc = layer.ownerDocument;
8117
+ const staged = doc.createDocumentFragment();
7997
8118
  const sourceFam = familyOf(snap.fromType);
7998
8119
  const shapedSource = sourceFam === "summary" || sourceFam === "radial";
7999
8120
  Array.from(byCluster.keys()).sort((a, b) => a - b).forEach((i) => {
@@ -8033,7 +8154,7 @@ class MorphTypeChange {
8033
8154
  el.setAttribute("height", String(cell.height));
8034
8155
  el.setAttribute("rx", "0");
8035
8156
  el.setAttribute("fill", String(markFill));
8036
- layer.appendChild(el);
8157
+ staged.appendChild(el);
8037
8158
  pieces.push({
8038
8159
  el,
8039
8160
  from: { x: cell.x, y: cell.y, width: cell.width, height: cell.height, rx: 0 },
@@ -8051,6 +8172,7 @@ class MorphTypeChange {
8051
8172
  });
8052
8173
  }
8053
8174
  });
8175
+ layer.appendChild(staged);
8054
8176
  if (!pieces.length) return this._cancelPieces();
8055
8177
  this._runPieces(pieces, (piece) => {
8056
8178
  reveal(piece.meta.dotEl);
@@ -8104,6 +8226,7 @@ class MorphTypeChange {
8104
8226
  const layer = this._makePieceLayer();
8105
8227
  if (!layer) return this._revealPieceHidden();
8106
8228
  const doc = layer.ownerDocument;
8229
+ const staged = doc.createDocumentFragment();
8107
8230
  const pieces = [];
8108
8231
  const targetFam = familyOf(snap.toType);
8109
8232
  const shapedTarget = targetFam === "summary" || targetFam === "radial";
@@ -8136,7 +8259,7 @@ class MorphTypeChange {
8136
8259
  const markState = {
8137
8260
  remaining: ordered.length,
8138
8261
  els: target.els,
8139
- g: layer.appendChild(doc.createElementNS("http://www.w3.org/2000/svg", "g"))
8262
+ g: staged.appendChild(doc.createElementNS("http://www.w3.org/2000/svg", "g"))
8140
8263
  };
8141
8264
  for (let m = 0; m < ordered.length; m++) {
8142
8265
  const dot = ordered[m];
@@ -8163,6 +8286,7 @@ class MorphTypeChange {
8163
8286
  });
8164
8287
  }
8165
8288
  }
8289
+ layer.appendChild(staged);
8166
8290
  if (!pieces.length) return this._cancelPieces();
8167
8291
  this._runPieces(pieces, (piece) => {
8168
8292
  const state = piece.meta.markState;
@@ -9808,19 +9932,25 @@ const _WeaveHost = class _WeaveHost {
9808
9932
  this._setScales(extra.xyRatios);
9809
9933
  }
9810
9934
  const pass = extra && extra.pass || "full";
9935
+ const host = this;
9811
9936
  let data = null;
9812
9937
  for (const record of this.active) {
9813
9938
  if (record.disabled) continue;
9814
9939
  const fns = record.handlers.get(hook);
9815
9940
  if (!fns || !fns.length) continue;
9816
- if (data === null) {
9817
- data = this._dataSnapshot();
9818
- this._lastData = data;
9819
- }
9820
9941
  const payload = {
9821
9942
  api: record.api,
9822
9943
  scales: this._currentScales,
9823
- data,
9944
+ // Built on first read and shared with api.data for the rest of this
9945
+ // pass: a handler that never reads it costs no snapshot.
9946
+ get data() {
9947
+ return data || (data = host._lastData || (host._lastData = host._dataSnapshot()));
9948
+ },
9949
+ // A handler may still overwrite its own payload.data, as it could
9950
+ // when this was a plain field.
9951
+ set data(v) {
9952
+ Object.defineProperty(this, "data", { value: v, writable: true });
9953
+ },
9824
9954
  pass,
9825
9955
  hook
9826
9956
  };
@@ -10456,12 +10586,7 @@ const _WeaveHost = class _WeaveHost {
10456
10586
  * groups), so without this, fast-path redraws would duplicate plugin output.
10457
10587
  */
10458
10588
  _resetLayers() {
10459
- const el = this.w.dom.elGraphical;
10460
- const parent = el && el.node;
10461
- if (parent) {
10462
- const groups = parent.querySelectorAll('g[class*="apexcharts-plugin-"]');
10463
- Array.prototype.forEach.call(groups, (n) => n.remove());
10464
- }
10589
+ this._layers.forEach((g) => g.node.remove());
10465
10590
  this._layers.clear();
10466
10591
  this._declared = null;
10467
10592
  }
@@ -11233,24 +11358,18 @@ function observationsOf(d, allowFlatY) {
11233
11358
  return out.length ? out : null;
11234
11359
  }
11235
11360
  function derivedStats(w, kind) {
11236
- var _a, _b;
11237
- const all = (_a = w.statsDerived) != null ? _a : w.statsDerived = {};
11238
- return (_b = all[kind]) != null ? _b : all[kind] = /* @__PURE__ */ new Map();
11361
+ const all = w.statsDerived || (w.statsDerived = {});
11362
+ return all[kind] || (all[kind] = /* @__PURE__ */ new Map());
11363
+ }
11364
+ function deriveStat(derived, key, values, opts, fn) {
11365
+ const s = JSON.stringify(opts) + values;
11366
+ let hit = derived.get(key);
11367
+ if (!hit || hit.s !== s) derived.set(key, hit = { s, e: fn(values, opts) });
11368
+ return hit.e;
11239
11369
  }
11240
11370
  function isDerived(derived, key, value) {
11241
- const ours = derived.get(key);
11242
- if (!ours || !Array.isArray(value) || ours.length !== value.length) {
11243
- return false;
11244
- }
11245
- for (let k2 = 0; k2 < value.length; k2++) {
11246
- const a = ours[k2];
11247
- const b = value[k2];
11248
- if (a === b) continue;
11249
- if (!Array.isArray(a) || !Array.isArray(b) || a[0] !== b[0] || a[1] !== b[1]) {
11250
- return false;
11251
- }
11252
- }
11253
- return true;
11371
+ const e = (derived.get(key) || {}).e;
11372
+ return !!e && JSON.stringify(e.density || e.summary) === JSON.stringify(value);
11254
11373
  }
11255
11374
  function histogramValues(data) {
11256
11375
  const out = [];
@@ -11331,62 +11450,61 @@ function histogramTransform(ser, w) {
11331
11450
  }
11332
11451
  function boxPlotTransform(ser, w) {
11333
11452
  var _a, _b;
11334
- if (!Array.isArray(ser)) return ser;
11335
- const whiskers = ((_b = (_a = w.config.plotOptions) == null ? void 0 : _a.boxPlot) == null ? void 0 : _b.whiskers) || "minmax";
11336
- const derived = derivedStats(w, "boxPlot");
11337
- const observed = [];
11338
- const out = ser.map((s, i) => {
11339
- if (!Array.isArray(s == null ? void 0 : s.data) || s.type && s.type !== "boxPlot") return s;
11340
- let touched = false;
11341
- const byPoint = new Array(s.data.length).fill(null);
11342
- const data = s.data.map((d, j) => {
11343
- const key = i + ":" + j;
11344
- if (Array.isArray(d == null ? void 0 : d.y) && d.y.length === 5 && !isDerived(derived, key, d.y)) {
11345
- return d;
11346
- }
11347
- const values = observationsOf(d, false);
11348
- if (!values) return d;
11349
- const summary = fiveNumberSummary(values, { whiskers });
11350
- if (!summary) return d;
11351
- touched = true;
11352
- byPoint[j] = values;
11353
- derived.set(key, summary.summary);
11354
- return __spreadProps(__spreadValues({}, d), { y: summary.summary, points: values });
11355
- });
11356
- if (touched) observed[i] = byPoint;
11357
- return touched ? __spreadProps(__spreadValues({}, s), { data }) : s;
11358
- });
11359
- recordObservations(w, observed, ser.length);
11360
- return out;
11453
+ return sampleTransform(
11454
+ ser,
11455
+ w,
11456
+ "boxPlot",
11457
+ { whiskers: ((_b = (_a = w.config.plotOptions) == null ? void 0 : _a.boxPlot) == null ? void 0 : _b.whiskers) || "minmax" },
11458
+ fiveNumberSummary,
11459
+ (d) => Array.isArray(d == null ? void 0 : d.y) && d.y.length === 5 && d.y,
11460
+ (d, est, values) => __spreadProps(__spreadValues({}, d), {
11461
+ y: est.summary,
11462
+ points: values
11463
+ })
11464
+ );
11361
11465
  }
11362
11466
  function violinTransform(ser, w) {
11363
11467
  var _a, _b;
11364
- if (!Array.isArray(ser)) return ser;
11365
11468
  const kde = ((_b = (_a = w.config.plotOptions) == null ? void 0 : _a.violin) == null ? void 0 : _b.kde) || {};
11366
- const derived = derivedStats(w, "violin");
11469
+ return sampleTransform(
11470
+ ser,
11471
+ w,
11472
+ "violin",
11473
+ { bandwidth: kde.bandwidth, resolution: kde.resolution },
11474
+ kernelDensity,
11475
+ (d) => {
11476
+ var _a2;
11477
+ return Array.isArray((_a2 = d == null ? void 0 : d.y) == null ? void 0 : _a2.density) && d.y.density.length && d.y.density;
11478
+ },
11479
+ (d, est, values) => __spreadProps(__spreadValues({}, d), {
11480
+ // Keep the rest of an object `y`: a summary given with the points still
11481
+ // draws the box lane.
11482
+ y: __spreadProps(__spreadValues({}, d.y && typeof d.y === "object" && !Array.isArray(d.y) ? d.y : {}), {
11483
+ density: est.density,
11484
+ points: values
11485
+ })
11486
+ })
11487
+ );
11488
+ }
11489
+ function sampleTransform(ser, w, type, opts, fn, statOf, write) {
11490
+ if (!Array.isArray(ser)) return ser;
11491
+ const derived = derivedStats(w, type);
11367
11492
  const observed = [];
11368
11493
  const out = ser.map((s, i) => {
11369
- if (!Array.isArray(s == null ? void 0 : s.data) || s.type && s.type !== "violin") return s;
11494
+ if (!Array.isArray(s == null ? void 0 : s.data) || s.type && s.type !== type) return s;
11370
11495
  let touched = false;
11371
11496
  const byPoint = new Array(s.data.length).fill(null);
11372
11497
  const data = s.data.map((d, j) => {
11373
- var _a2;
11374
11498
  const key = i + ":" + j;
11375
- 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)) {
11376
- return d;
11377
- }
11378
- const values = observationsOf(d, true);
11499
+ const stat = statOf(d);
11500
+ if (stat && !isDerived(derived, key, stat)) return d;
11501
+ const values = observationsOf(d, type === "violin");
11379
11502
  if (!values) return d;
11380
- const est = kernelDensity(values, {
11381
- bandwidth: kde.bandwidth,
11382
- resolution: kde.resolution
11383
- });
11503
+ const est = deriveStat(derived, key, values, opts, fn);
11384
11504
  if (!est) return d;
11385
11505
  touched = true;
11386
11506
  byPoint[j] = values;
11387
- const rest = d.y && typeof d.y === "object" && !Array.isArray(d.y) ? d.y : {};
11388
- derived.set(key, est.density);
11389
- return __spreadProps(__spreadValues({}, d), { y: __spreadProps(__spreadValues({}, rest), { density: est.density, points: values }) });
11507
+ return write(d, est, values);
11390
11508
  });
11391
11509
  if (touched) observed[i] = byPoint;
11392
11510
  return touched ? __spreadProps(__spreadValues({}, s), { data }) : s;