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
@@ -6,7 +6,7 @@
6
6
  * state, no config object, so it is testable on its own and safe under SSR.
7
7
  *
8
8
  * A histogram is the one aggregate mark that knows exactly which rows it
9
- * stands for, because the binning is what aggregated them. `rowsForBin`
9
+ * stands for, because the binning is what aggregated them. `rowsByBin`
10
10
  * recovers those rows on demand from the same (values, edges) pair the render
11
11
  * used, so nothing has to be retained per bar.
12
12
  *
@@ -73,36 +73,14 @@ function stdDev(values) {
73
73
  }
74
74
 
75
75
  /**
76
- * The observations a given bar aggregates.
76
+ * Every bar's rows at once, as one bucket per bin in bin order.
77
77
  *
78
78
  * This is the row source an object/aggregate transition needs: a histogram bar
79
79
  * can name its rows exactly, without any of them being retained at render
80
- * time. Recomputed on demand from the same inputs the binning used.
81
- *
82
- * @param {number[]} values
83
- * @param {number[]} edges
84
- * @param {number} k - bin index
85
- * @returns {number[]}
86
- */
87
- export function rowsForBin(values, edges, k) {
88
- /** @type {number[]} */
89
- const out = []
90
- if (k < 0 || k >= edges.length - 1) return out
91
- for (let i = 0; i < values.length; i++) {
92
- if (binIndexOf(values[i], edges) === k) out.push(values[i])
93
- }
94
- return out
95
- }
96
-
97
- /**
98
- * Every bar's rows at once, as one bucket per bin in bin order.
99
- *
100
- * The same answer `rowsForBin` gives, in a single pass. Asking that function
101
- * for each bin in turn re-walks the whole sample every time, which is O(n·bins)
102
- * and turns a 50k-observation, 100-bin explode into five million comparisons on
103
- * the click. Bins with no observations keep their (empty) slot: the caller maps
104
- * bucket k onto bar k positionally, so a compacted array would silently shift
105
- * every bar after the first gap.
80
+ * time. One pass over the sample, recomputed on demand from the same inputs
81
+ * the binning used. Bins with no observations keep their (empty) slot: the
82
+ * caller maps bucket k onto bar k positionally, so a compacted array would
83
+ * silently shift every bar after the first gap.
106
84
  *
107
85
  * @param {number[]} values
108
86
  * @param {number[]} edges
@@ -301,3 +279,52 @@ export function observationsOf(d, allowFlatY) {
301
279
  }
302
280
  return out.length ? out : null
303
281
  }
282
+
283
+ /**
284
+ * The statistics a transform derived on this chart, keyed `series:datum`,
285
+ * holding the value it wrote. parseData writes a transform's output back to
286
+ * `config.series`, so the next pass meets a datum that already carries a
287
+ * summary or density and has to tell its own output (re-derive: the options
288
+ * that shaped it may have changed) from one the caller supplied (keep). This
289
+ * is decided by value: legend toggles and resetSeries() feed the series back
290
+ * through a deep clone, and an identity marker (a WeakSet of the datums) did
291
+ * not survive it, so the statistic froze after the first legend click.
292
+ *
293
+ * @param {any} w
294
+ * @param {string} kind
295
+ * @returns {Map<string, any[]>}
296
+ */
297
+ export function derivedStats(w, kind) {
298
+ const all = (w.statsDerived ??= {})
299
+ return (all[kind] ??= new Map())
300
+ }
301
+
302
+ /**
303
+ * Whether a statistic still holds exactly the value recorded at `key`: a flat
304
+ * summary, or a density of `[value, weight]` pairs.
305
+ *
306
+ * @param {Map<string, any[]>} derived
307
+ * @param {string} key
308
+ * @param {any} value
309
+ * @returns {boolean}
310
+ */
311
+ export function isDerived(derived, key, value) {
312
+ const ours = derived.get(key)
313
+ if (!ours || !Array.isArray(value) || ours.length !== value.length) {
314
+ return false
315
+ }
316
+ for (let k = 0; k < value.length; k++) {
317
+ const a = ours[k]
318
+ const b = value[k]
319
+ if (a === b) continue
320
+ if (
321
+ !Array.isArray(a) ||
322
+ !Array.isArray(b) ||
323
+ a[0] !== b[0] ||
324
+ a[1] !== b[1]
325
+ ) {
326
+ return false
327
+ }
328
+ }
329
+ return true
330
+ }
@@ -124,20 +124,45 @@ export default class BarDataLabels {
124
124
  j,
125
125
  )
126
126
 
127
+ // A datum the highlight filter leaves without a part keeps no label. It
128
+ // is still drawn, blank, as a null value is: the overlap pass indexes
129
+ // its rects by data point, so a skipped one would misalign the rest.
130
+ // Use realIndex (the full-config series index), not the local loop index
131
+ // `i` which is the compacted bar-subset index in a combo chart.
132
+ const val = hl?.hide
133
+ ? undefined
134
+ : waterfallStep !== null
135
+ ? waterfallStep
136
+ : // only RangeBar passes a range, vertical or horizontal
137
+ y2 !== undefined
138
+ ? [y1, y2]
139
+ : w.config.chart.stackType === '100%'
140
+ ? // Read the percentages globally rather than out of `series`.
141
+ // Under `stackType: '100%'` BarStacked replaces `series` with
142
+ // the percentage rows, and in a combo chart it narrows them to
143
+ // just the series it draws as bars, so `series` is indexed by
144
+ // bar position while `realIndex` counts every series. A line
145
+ // ahead of a column pushed `realIndex` past the end and the
146
+ // label read a value off `undefined` (#2429).
147
+ w.globals.seriesPercent[realIndex][j]
148
+ : w.seriesData.series[realIndex][j]
149
+
150
+ let text
127
151
  let textRects = {
128
152
  width: 0,
129
153
  height: 0,
130
154
  }
131
- if (w.config.dataLabels.enabled) {
132
- // Use realIndex (the full-config series index), not the local loop index
133
- // `i` which is the compacted bar-subset index in a combo chart. Otherwise
134
- // the label is measured/formatted from a different series than the value
135
- // actually drawn (drawCalculatedDataLabels below uses realIndex).
136
- const yLabel =
137
- waterfallStep !== null
138
- ? waterfallStep
139
- : w.seriesData.series[realIndex][j]
140
-
155
+ if (dataLabelsConfig.enabled) {
156
+ // Format once and measure the exact string that is drawn.
157
+ text =
158
+ val === undefined
159
+ ? ''
160
+ : dataLabelsConfig.formatter(val, {
161
+ ...w,
162
+ seriesIndex: realIndex,
163
+ dataPointIndex: j,
164
+ w,
165
+ })
141
166
  // Measure in the SAME font the label will be drawn in. Data labels
142
167
  // default to fontWeight 600, and the default measurement is taken at
143
168
  // 'regular', which under-reports the width by 3-7% on these strings. That
@@ -145,14 +170,7 @@ export default class BarDataLabels {
145
170
  // `textRects.width`, so an under-measured label is clamped to a position
146
171
  // that still runs off the chart.
147
172
  textRects = graphics.getTextRects(
148
- w.config.dataLabels.formatter
149
- ? w.config.dataLabels.formatter(yLabel, {
150
- ...w,
151
- seriesIndex: realIndex,
152
- dataPointIndex: j,
153
- w,
154
- })
155
- : w.formatters.yLabelFormatters[0](yLabel),
173
+ text,
156
174
  parseFloat(dataLabelsConfig.style.fontSize).toString(),
157
175
  dataLabelsConfig.style.fontFamily,
158
176
  undefined,
@@ -210,25 +228,8 @@ export default class BarDataLabels {
210
228
  x: dataLabelsPos.dataLabelsX,
211
229
  y: dataLabelsPos.dataLabelsY,
212
230
  neg: params.neg,
213
- // A datum the highlight filter leaves without a part keeps no label. It
214
- // is still drawn, blank, as a null value is: the overlap pass indexes
215
- // its rects by data point, so a skipped one would misalign the rest.
216
- val: hl?.hide
217
- ? undefined
218
- : waterfallStep !== null
219
- ? waterfallStep
220
- : this.barCtx.isRangeBar
221
- ? [y1, y2]
222
- : w.config.chart.stackType === '100%'
223
- ? // Read the percentages globally rather than out of `series`.
224
- // Under `stackType: '100%'` BarStacked replaces `series` with
225
- // the percentage rows, and in a combo chart it narrows them to
226
- // just the series it draws as bars, so `series` is indexed by
227
- // bar position while `realIndex` counts every series. A line
228
- // ahead of a column pushed `realIndex` past the end and the
229
- // label read a value off `undefined` (#2429).
230
- w.globals.seriesPercent[realIndex][j]
231
- : w.seriesData.series[realIndex][j],
231
+ val,
232
+ text,
232
233
  i: realIndex,
233
234
  j,
234
235
  barWidth: params.barWidth,
@@ -274,16 +275,16 @@ export default class BarDataLabels {
274
275
  }
275
276
 
276
277
  /**
277
- * The series group `realIndex` belongs to, and that group's own stacking
278
- * state, or null when totals are chart-wide (the single-group case).
278
+ * The series group `realIndex` belongs to, or null when totals are
279
+ * chart-wide (the single-group case).
279
280
  * @param {number} realIndex
280
- * @returns {{groupIndex: number, group: string[]} | null}
281
+ * @returns {{groupIndex: number} | null}
281
282
  */
282
283
  getTotalGroupContext(realIndex) {
283
284
  if (!this.hasMultipleSeriesGroups()) return null
284
285
  const groupIndex = this.barCtx.barHelpers.getSeriesGroupIndex(realIndex)
285
286
  if (groupIndex < 0) return null
286
- return { groupIndex, group: this.w.labelData.seriesGroups[groupIndex] }
287
+ return { groupIndex }
287
288
  }
288
289
 
289
290
  /**
@@ -312,6 +313,8 @@ export default class BarDataLabels {
312
313
  getStackedTotalValue({ realIndex, j }) {
313
314
  if (this.hlt) return this.hlt.val
314
315
  const w = this.w
316
+ const top = this.xStackTop(realIndex, j)
317
+ if (top) return top[3]
315
318
 
316
319
  // With grouped stacks the total is the sum of this group's series only;
317
320
  // `stackedSeriesTotals` sums every series at this data point, which mixed
@@ -323,6 +326,21 @@ export default class BarDataLabels {
323
326
  : this.barCtx.stackedSeriesTotals[j]
324
327
  }
325
328
 
329
+ /**
330
+ * The running stack at this column's x (BarStacked `tops`, columns only) on
331
+ * a numeric axis, where columns stack by x rather than by index.
332
+ * @param {number} realIndex @param {number} j
333
+ */
334
+ xStackTop(realIndex, j) {
335
+ const w = this.w
336
+ return (
337
+ w.axisFlags.isXNumeric &&
338
+ /** @type {any} */ (this.barCtx).stacks?.[
339
+ w.labelData.seriesGroupIndex[realIndex]
340
+ ]?.tops.get(w.seriesData.seriesX[realIndex][j])
341
+ )
342
+ }
343
+
326
344
  /** @param {{realIndex: any, j: any}} opts */
327
345
  getStackedTotalDataLabel({ realIndex, j }) {
328
346
  const w = this.w
@@ -467,25 +485,22 @@ export default class BarDataLabels {
467
485
  // across the whole cluster, so a group's total floated above the tallest
468
486
  // *other* group's stack instead of its own. See #4173.
469
487
  const totalGroupCtx = this.getTotalGroupContext(realIndex)
470
- const prevYGroups = totalGroupCtx
471
- ? [totalGroupCtx.group]
472
- : w.labelData.seriesGroups
473
- /**
474
- * @param {string[]} sg
475
- */
476
- prevYGroups.forEach((/** @type {any} */ sg) => {
477
- /**
478
- * @param {any[]} arr
479
- */
480
- ;/** @type {any} */ (this.barCtx)[sg.join(',')]?.prevY.forEach(
481
- (/** @type {any} */ arr) => {
482
- if (valIsNegative) {
483
- lowestPrevY = Math.max(arr[j], lowestPrevY)
484
- } else {
485
- lowestPrevY = Math.min(arr[j], lowestPrevY)
486
- }
487
- },
488
- )
488
+ const top = this.xStackTop(realIndex, j)
489
+ const stacks = top ? [] : /** @type {any} */ (this.barCtx).stacks || []
490
+ if (top) {
491
+ lowestPrevY = valIsNegative
492
+ ? Math.max(newY, top[5])
493
+ : Math.min(newY, top[4])
494
+ }
495
+ stacks.forEach((/** @type {any} */ g, /** @type {number} */ gi) => {
496
+ if (totalGroupCtx && gi !== totalGroupCtx.groupIndex) return
497
+ g.prevY.forEach((/** @type {any} */ arr) => {
498
+ if (valIsNegative) {
499
+ lowestPrevY = Math.max(arr[j], lowestPrevY)
500
+ } else {
501
+ lowestPrevY = Math.min(arr[j], lowestPrevY)
502
+ }
503
+ })
489
504
  })
490
505
  if (this.hlt) lowestPrevY = this.hlt.edge
491
506
 
@@ -663,25 +678,16 @@ export default class BarDataLabels {
663
678
  let lowestPrevX = newX
664
679
  // This series' own group only — see the matching note in the column path.
665
680
  const totalGroupCtx = this.getTotalGroupContext(realIndex)
666
- const prevXGroups = totalGroupCtx
667
- ? [totalGroupCtx.group]
668
- : w.labelData.seriesGroups
669
- /**
670
- * @param {string[]} sg
671
- */
672
- prevXGroups.forEach((/** @type {any} */ sg) => {
673
- /**
674
- * @param {any[]} arr
675
- */
676
- ;/** @type {any} */ (this.barCtx)[sg.join(',')]?.prevX.forEach(
677
- (/** @type {any} */ arr) => {
678
- if (valIsNegative) {
679
- lowestPrevX = Math.min(arr[j], lowestPrevX)
680
- } else {
681
- lowestPrevX = Math.max(arr[j], lowestPrevX)
682
- }
683
- },
684
- )
681
+ const stacks = /** @type {any} */ (this.barCtx).stacks || []
682
+ stacks.forEach((/** @type {any} */ g, /** @type {number} */ gi) => {
683
+ if (totalGroupCtx && gi !== totalGroupCtx.groupIndex) return
684
+ g.prevX.forEach((/** @type {any} */ arr) => {
685
+ if (valIsNegative) {
686
+ lowestPrevX = Math.min(arr[j], lowestPrevX)
687
+ } else {
688
+ lowestPrevX = Math.max(arr[j], lowestPrevX)
689
+ }
690
+ })
685
691
  })
686
692
  if (this.hlt) lowestPrevX = this.hlt.edge
687
693
 
@@ -779,11 +785,12 @@ export default class BarDataLabels {
779
785
  }
780
786
  }
781
787
 
782
- /** @param {{x: any, y: any, val: any, neg?: boolean, i: any, j: any, textRects: any, barHeight: any, barWidth: any, dataLabelsConfig: any}} opts */
788
+ /** @param {{x: any, y: any, val: any, text?: any, neg?: boolean, i: any, j: any, textRects: any, barHeight: any, barWidth: any, dataLabelsConfig: any}} opts */
783
789
  drawCalculatedDataLabels({
784
790
  x,
785
791
  y,
786
792
  val,
793
+ text,
787
794
  neg,
788
795
  i, // = realIndex
789
796
  j,
@@ -816,7 +823,10 @@ export default class BarDataLabels {
816
823
  // though the bar on screen is still at its old height. Label it with what
817
824
  // it was until it has finished shrinking away.
818
825
  const prev = w.globals.prevDataLabels?.get(`${i}::${datumKey(w, i, j)}`)
819
- if (prev && isFinite(prev.val)) val = prev.val
826
+ if (prev && isFinite(prev.val)) {
827
+ val = prev.val
828
+ text = undefined
829
+ }
820
830
  }
821
831
 
822
832
  if (dataLabelsConfig.enabled && (!isSeriesCollapsed || isSeriesCollapsing)) {
@@ -840,8 +850,9 @@ export default class BarDataLabels {
840
850
  }
841
851
  }
842
852
 
843
- let text = ''
844
- if (typeof val !== 'undefined') {
853
+ if (val === undefined) {
854
+ text = ''
855
+ } else if (text === undefined) {
845
856
  text = formatter(val, {
846
857
  ...w,
847
858
  seriesIndex: i,
@@ -131,9 +131,9 @@ export default class Helpers {
131
131
 
132
132
  /**
133
133
  * Smallest positive gap between neighbouring x values once every series is
134
- * merged onto one axis. A k-way merge over the series arrays, which are
135
- * already sorted in every ordinary case; an unsorted one can only make the
136
- * answer smaller, i.e. the bars narrower, never overlapping.
134
+ * merged onto one axis. A k-way merge over the series arrays, which needs
135
+ * each one ascending: a non-ascending array (newest-first data) is merged
136
+ * from a sorted copy, or every gap would read as one huge slot.
137
137
  *
138
138
  * Collapsed series count too, exactly as they did for `minXDiff`. Skipping
139
139
  * them would widen every bar the moment someone hid the tightest-spaced
@@ -149,7 +149,13 @@ export default class Helpers {
149
149
  const arrays = []
150
150
  for (let i = 0; i < seriesX.length; i++) {
151
151
  const xs = seriesX[i]
152
- if (Array.isArray(xs) && xs.length > 0) arrays.push(xs)
152
+ if (Array.isArray(xs) && xs.length > 0) {
153
+ arrays.push(
154
+ xs.some((v, n) => v < xs[n - 1])
155
+ ? xs.filter((v) => v === +v).sort((a, b) => a - b)
156
+ : xs,
157
+ )
158
+ }
153
159
  }
154
160
  if (!arrays.length) return 0
155
161
 
@@ -308,40 +314,30 @@ export default class Helpers {
308
314
  * @param {Record<string, any>} ctx
309
315
  */
310
316
  initializeStackedPrevVars(ctx) {
311
- const w = ctx.w
312
- /**
313
- * @param {Element} group
314
- */
315
- w.labelData.seriesGroups.forEach((/** @type {any} */ group) => {
316
- if (!ctx[group]) ctx[group] = {}
317
-
318
- ctx[group].prevY = []
319
- ctx[group].prevX = []
320
- ctx[group].prevYF = []
321
- ctx[group].prevXF = []
322
- ctx[group].prevYVal = []
323
- ctx[group].prevXVal = []
324
- })
317
+ // One stack state per series group, by index (groups may reuse names).
318
+ // `tops` is the running stack top per x, see drawStackedColumnPaths.
319
+ ctx.stacks = ctx.w.labelData.seriesGroups.map(() => ({
320
+ prevY: [],
321
+ prevX: [],
322
+ prevYF: [],
323
+ prevXF: [],
324
+ prevYVal: [],
325
+ prevXVal: [],
326
+ tops: new Map(),
327
+ }))
325
328
  }
326
329
 
327
330
  /**
328
331
  * @param {Record<string, any>} ctx
329
332
  */
330
333
  initializeStackedXYVars(ctx) {
331
- const w = ctx.w
332
-
333
- /**
334
- * @param {Element} group
335
- */
336
- w.labelData.seriesGroups.forEach((/** @type {any} */ group) => {
337
- if (!ctx[group]) ctx[group] = {}
338
-
339
- ctx[group].xArrj = []
340
- ctx[group].xArrjF = []
341
- ctx[group].xArrjVal = []
342
- ctx[group].yArrj = []
343
- ctx[group].yArrjF = []
344
- ctx[group].yArrjVal = []
334
+ ctx.stacks.forEach((/** @type {any} */ g) => {
335
+ g.xArrj = []
336
+ g.xArrjF = []
337
+ g.xArrjVal = []
338
+ g.yArrj = []
339
+ g.yArrjF = []
340
+ g.yArrjVal = []
345
341
  })
346
342
  }
347
343
 
@@ -783,7 +779,7 @@ export default class Helpers {
783
779
  }
784
780
  }
785
781
 
786
- /** @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 */
782
+ /** @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 */
787
783
  getColumnPaths({
788
784
  barWidth,
789
785
  barXPosition,
@@ -791,7 +787,6 @@ export default class Helpers {
791
787
  y2,
792
788
  strokeWidth,
793
789
  series,
794
- seriesGroup,
795
790
  realIndex,
796
791
  i,
797
792
  j,
@@ -834,8 +829,7 @@ export default class Helpers {
834
829
  }
835
830
 
836
831
  if (w.config.chart.stacked) {
837
- let _ctx = this.barCtx
838
- _ctx = this.barCtx[seriesGroup]
832
+ const _ctx = this.barCtx.groupCtx
839
833
  _ctx.yArrj.push(y2 - strokeCenter * direction)
840
834
  _ctx.yArrjF.push(Math.abs(y1 - y2 + r.strokeWidth * direction))
841
835
  _ctx.yArrjVal.push(this.barCtx.series[i][j])
@@ -1060,7 +1054,7 @@ export default class Helpers {
1060
1054
  }
1061
1055
  }
1062
1056
 
1063
- /** @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 */
1057
+ /** @param {{ barYPosition?: any, barHeight?: any, x1?: any, x2?: any, strokeWidth?: any, isReversed?: any, series?: any, realIndex?: any, i?: any, j?: any, w?: any }} opts */
1064
1058
  getBarpaths({
1065
1059
  barYPosition,
1066
1060
  barHeight,
@@ -1068,7 +1062,6 @@ export default class Helpers {
1068
1062
  x2,
1069
1063
  strokeWidth,
1070
1064
  series,
1071
- seriesGroup,
1072
1065
  realIndex,
1073
1066
  i,
1074
1067
  j,
@@ -1127,8 +1120,7 @@ export default class Helpers {
1127
1120
  }
1128
1121
 
1129
1122
  if (w.config.chart.stacked) {
1130
- let _ctx = this.barCtx
1131
- _ctx = this.barCtx[seriesGroup]
1123
+ const _ctx = this.barCtx.groupCtx
1132
1124
  _ctx.xArrj.push(x2 + strokeCenter * direction)
1133
1125
  _ctx.xArrjF.push(Math.abs(x1 - x2 - r.strokeWidth * direction))
1134
1126
  _ctx.xArrjVal.push(this.barCtx.series[i][j])
@@ -1577,29 +1569,14 @@ export default class Helpers {
1577
1569
  * @returns {number}
1578
1570
  */
1579
1571
  getSeriesGroupIndex(seriesIndex) {
1580
- const w = this.w
1581
- return w.labelData.seriesGroups.findIndex(
1582
- (/** @type {string[]} */ group) =>
1583
- group.indexOf(w.seriesData.seriesNames[seriesIndex]) > -1,
1584
- )
1572
+ return this.w.labelData.seriesGroupIndex[seriesIndex] ?? -1
1585
1573
  }
1586
1574
 
1587
1575
  /**
1588
1576
  * @param {number} seriesIndex
1589
1577
  */
1590
1578
  getGroupIndex(seriesIndex) {
1591
- const w = this.w
1592
- // groupIndex is the index of group buckets (group1, group2, ...)
1593
- /**
1594
- * @param {Element} group
1595
- */
1596
- const groupIndex = w.labelData.seriesGroups.findIndex(
1597
- (/** @type {any} */ group) =>
1598
- // w.config.series[i].name may be undefined, so use
1599
- // w.seriesData.seriesNames[i], which has default names for those
1600
- // series. w.labelData.seriesGroups[] uses the same default naming.
1601
- group.indexOf(w.seriesData.seriesNames[seriesIndex]) > -1
1602
- )
1579
+ const groupIndex = this.getSeriesGroupIndex(seriesIndex)
1603
1580
  // We need the column groups to be indexable as 0,1,2,... for their
1604
1581
  // positioning relative to each other.
1605
1582
  const cGI = this.barCtx.columnGroupIndices
@@ -42,10 +42,11 @@ export default class CircularChartsHelpers {
42
42
  * Widest rendered width among the given label strings. Used to reserve
43
43
  * horizontal room for outer (name) labels so the pie can shrink to fit them.
44
44
  * @param {string[]} labels
45
- * @param {{ fontSize?: string, fontFamily?: string }} style
45
+ * @param {{ fontSize?: string, fontFamily?: string, fontWeight?: string | number }} style
46
+ * the weight the labels draw at: bold text is wider
46
47
  * @returns {number}
47
48
  */
48
- getMaxLabelWidth(labels, { fontSize, fontFamily } = {}) {
49
+ getMaxLabelWidth(labels, { fontSize, fontFamily, fontWeight } = {}) {
49
50
  const graphics = new Graphics(this.w)
50
51
  let maxWidth = 0
51
52
  labels.forEach((text) => {
@@ -55,6 +56,8 @@ export default class CircularChartsHelpers {
55
56
  fontSize || '12px',
56
57
  fontFamily,
57
58
  '',
59
+ true,
60
+ fontWeight,
58
61
  )
59
62
  maxWidth = Math.max(maxWidth, rect.width)
60
63
  })
@@ -193,7 +193,7 @@ export default class TreemapHelpers {
193
193
  }
194
194
  }
195
195
 
196
- /** @param {{ text?: any, x?: any, y?: any, i?: any, j?: any, colorProps?: any, fontSize?: any, series?: any }} opts */
196
+ /** @param {{ text?: any, x?: any, y?: any, i?: any, j?: any, colorProps?: any, fontSize?: any }} opts */
197
197
  calculateDataLabels({ text, x, y, i, j, colorProps, fontSize }) {
198
198
  const w = this.w
199
199
  const dataLabelsConfig = w.config.dataLabels
@@ -26,7 +26,6 @@
26
26
  * on the same class, and a second non-configurable define throws.
27
27
  */
28
28
  import ApexCharts from './standard.js'
29
- import Core from '../apexcharts.js'
30
29
 
31
30
  // Chart types outside the default bundle.
32
31
  import './violin.js'
@@ -66,20 +65,4 @@ const A = /** @type {any} */ (ApexCharts)
66
65
  A.unitShapes = unitShapes
67
66
  A.pictograms = pictograms
68
67
 
69
- // Under Node's default conditions `apexcharts` resolves to the self-contained
70
- // server build, whose class is not the `apexcharts/core` one the features
71
- // above hang their statics on (`ApexCharts.perspectives`, the crossfilter
72
- // factory). Chart types and features reach both classes through globalThis
73
- // registries; plain statics do not, so `ApexCharts.perspectives` was null and
74
- // `ApexCharts.crossfilter()` said the link feature was missing from the bundle
75
- // that carries it. Hand the class this entry exports whatever it lacks. With a
76
- // bundler, and in the script-tag build, the two are one class and this is a
77
- // no-op.
78
- const CoreClass = /** @type {any} */ (Core)
79
- if (CoreClass !== A) {
80
- for (const key of Object.getOwnPropertyNames(CoreClass)) {
81
- if (A[key] == null && CoreClass[key] != null) A[key] = CoreClass[key]
82
- }
83
- }
84
-
85
68
  export default ApexCharts
@@ -14,15 +14,14 @@ import Crossfilter from '../modules/link/Crossfilter'
14
14
  // AFTER apexcharts.js.
15
15
  //
16
16
  // P1: per-chart linked-highlighting module (opt-in via chart.link.enabled).
17
- ApexCharts.registerFeatures({ linkedViews: LinkedViews })
18
-
19
- // Phase 2: install the crossfilter engine factory so ApexCharts.crossfilter(...)
20
- // (declared in core, always callable) resolves the real coordinator. Without
21
- // this feature the core static warns and no-ops, so the engine tree-shakes out.
22
- const AC = /** @type {any} */ (ApexCharts)
23
- /** @param {{id:string, records?:any[]}} opts */
24
- AC._crossfilterFactory = (opts) => Crossfilter.getOrCreate(opts)
25
- /** @param {string} id */
26
- AC._crossfilterGet = (id) => Crossfilter.get(id)
17
+ // Phase 2: the crossfilter engine, which ApexCharts.crossfilter(...) (declared
18
+ // in core, always callable) resolves through the globalThis-backed registry,
19
+ // so it reaches every copy of the class (Node's server build is a second one).
20
+ // Without this feature the core static warns and no-ops, so the engine
21
+ // tree-shakes out.
22
+ ApexCharts.registerFeatures({
23
+ linkedViews: LinkedViews,
24
+ crossfilter: /** @type {any} */ (Crossfilter),
25
+ })
27
26
 
28
27
  export default ApexCharts