apexcharts 8.3.0 → 8.4.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.
- package/README.md +7 -7
- package/dist/apexcharts.common.js +2 -2
- package/dist/apexcharts.core.js +20039 -19931
- package/dist/apexcharts.core.min.js +2 -2
- package/dist/apexcharts.css +3 -8
- package/dist/apexcharts.esm.js +950 -574
- package/dist/apexcharts.full.js +23401 -22504
- package/dist/apexcharts.full.min.js +2 -2
- package/dist/apexcharts.js +21723 -21287
- package/dist/apexcharts.min.js +2 -2
- package/dist/apexcharts.ssr.common.js +2 -2
- package/dist/apexcharts.ssr.esm.js +21758 -21242
- package/dist/area.common.js +2 -2
- package/dist/area.esm.js +118 -65
- package/dist/bar.common.js +2 -2
- package/dist/bar.esm.js +404 -218
- package/dist/bar.js +2 -2
- package/dist/boxPlot.common.js +2 -2
- package/dist/boxPlot.esm.js +379 -205
- package/dist/bubble.common.js +2 -2
- package/dist/bubble.esm.js +118 -65
- package/dist/candlestick.common.js +2 -2
- package/dist/candlestick.esm.js +379 -205
- package/dist/candlestick.js +2 -2
- package/dist/column.common.js +2 -2
- package/dist/column.esm.js +404 -218
- package/dist/core.common.js +2 -2
- package/dist/core.esm.js +20034 -19926
- package/dist/donut.common.js +2 -2
- package/dist/donut.esm.js +106 -11
- package/dist/dumbbell.common.js +2 -2
- package/dist/dumbbell.esm.js +404 -218
- package/dist/features/all.common.js +2 -2
- package/dist/features/all.esm.js +282 -184
- package/dist/features/annotations.common.js +2 -2
- package/dist/features/annotations.esm.js +65 -48
- package/dist/features/annotations.js +2 -2
- package/dist/features/context-menu.common.js +1 -1
- package/dist/features/context-menu.esm.js +1 -1
- package/dist/features/context-menu.js +1 -1
- package/dist/features/drilldown.common.js +2 -2
- package/dist/features/drilldown.esm.js +137 -124
- package/dist/features/drilldown.js +2 -2
- package/dist/features/dumbbell.common.js +1 -1
- package/dist/features/dumbbell.esm.js +1 -1
- package/dist/features/dumbbell.js +1 -1
- package/dist/features/exports.common.js +2 -2
- package/dist/features/exports.esm.js +31 -15
- package/dist/features/exports.js +2 -2
- package/dist/features/facet.common.js +1 -1
- package/dist/features/facet.esm.js +1 -1
- package/dist/features/facet.js +1 -1
- package/dist/features/highlight-filter.common.js +2 -2
- package/dist/features/highlight-filter.esm.js +206 -119
- package/dist/features/highlight-filter.js +2 -2
- package/dist/features/history.common.js +1 -1
- package/dist/features/history.esm.js +1 -1
- package/dist/features/history.js +1 -1
- package/dist/features/ink.common.js +1 -1
- package/dist/features/ink.esm.js +1 -1
- package/dist/features/ink.js +1 -1
- package/dist/features/keyboard.common.js +1 -1
- package/dist/features/keyboard.esm.js +1 -1
- package/dist/features/keyboard.js +1 -1
- package/dist/features/legend.common.js +2 -2
- package/dist/features/legend.esm.js +52 -28
- package/dist/features/legend.js +2 -2
- package/dist/features/link.common.js +1 -1
- package/dist/features/link.esm.js +1 -1
- package/dist/features/link.js +1 -1
- package/dist/features/marks.common.js +1 -1
- package/dist/features/marks.esm.js +1 -1
- package/dist/features/marks.js +1 -1
- package/dist/features/measure.common.js +1 -1
- package/dist/features/measure.esm.js +1 -1
- package/dist/features/measure.js +1 -1
- package/dist/features/morph.common.js +2 -2
- package/dist/features/morph.esm.js +27 -14
- package/dist/features/morph.js +2 -2
- package/dist/features/perspectives.common.js +2 -2
- package/dist/features/perspectives.esm.js +4 -1
- package/dist/features/perspectives.js +2 -2
- package/dist/features/raincloud.common.js +2 -2
- package/dist/features/raincloud.esm.js +26 -27
- package/dist/features/raincloud.js +2 -2
- package/dist/features/renderer-canvas.common.js +2 -2
- package/dist/features/renderer-canvas.esm.js +35 -21
- package/dist/features/renderer-canvas.js +2 -2
- package/dist/features/stats.common.js +2 -2
- package/dist/features/stats.esm.js +52 -59
- package/dist/features/stats.js +2 -2
- package/dist/features/storyboard.common.js +2 -2
- package/dist/features/storyboard.esm.js +4 -1
- package/dist/features/storyboard.js +2 -2
- package/dist/features/streamgraph.common.js +2 -2
- package/dist/features/streamgraph.esm.js +160 -55
- package/dist/features/streamgraph.js +2 -2
- package/dist/features/toolbar.common.js +2 -2
- package/dist/features/toolbar.esm.js +78 -28
- package/dist/features/toolbar.js +2 -2
- package/dist/features/trellis.common.js +2 -2
- package/dist/features/trellis.esm.js +876 -543
- package/dist/features/trellis.js +2 -2
- package/dist/features/waterfall.common.js +2 -2
- package/dist/features/waterfall.esm.js +14 -25
- package/dist/features/waterfall.js +2 -2
- package/dist/features/weave.common.js +2 -2
- package/dist/features/weave.esm.js +13 -12
- package/dist/features/weave.js +2 -2
- package/dist/full.common.js +2 -2
- package/dist/full.esm.js +1893 -1342
- package/dist/heatmap.common.js +2 -2
- package/dist/heatmap.esm.js +38 -54
- package/dist/heatmap.js +2 -2
- package/dist/histogram.common.js +2 -2
- package/dist/histogram.esm.js +455 -276
- package/dist/icicle.common.js +2 -2
- package/dist/icicle.esm.js +156 -91
- package/dist/icicle.js +2 -2
- package/dist/line.common.js +2 -2
- package/dist/line.esm.js +118 -65
- package/dist/line.js +2 -2
- package/dist/pictograms.common.js +2 -2
- package/dist/pictograms.esm.js +2 -2
- package/dist/pictograms.js +2 -2
- package/dist/pie.common.js +2 -2
- package/dist/pie.esm.js +106 -11
- package/dist/pie.js +2 -2
- package/dist/polarArea.common.js +2 -2
- package/dist/polarArea.esm.js +106 -11
- package/dist/radar.common.js +2 -2
- package/dist/radar.esm.js +23 -9
- package/dist/radar.js +2 -2
- package/dist/radialBar.common.js +2 -2
- package/dist/radialBar.esm.js +108 -14
- package/dist/radialBar.js +2 -2
- package/dist/raincloud.common.js +2 -2
- package/dist/raincloud.esm.js +39 -31
- package/dist/rangeArea.common.js +2 -2
- package/dist/rangeArea.esm.js +118 -65
- package/dist/rangeBar.common.js +2 -2
- package/dist/rangeBar.esm.js +404 -218
- package/dist/scatter.common.js +2 -2
- package/dist/scatter.esm.js +118 -65
- package/dist/streamgraph.common.js +2 -2
- package/dist/streamgraph.esm.js +276 -118
- package/dist/sunburst.common.js +2 -2
- package/dist/sunburst.esm.js +333 -116
- package/dist/sunburst.js +2 -2
- package/dist/treemap.common.js +2 -2
- package/dist/treemap.esm.js +155 -124
- package/dist/treemap.js +2 -2
- package/dist/unit-shapes.common.js +2 -2
- package/dist/unit-shapes.esm.js +2 -2
- package/dist/unit-shapes.js +2 -2
- package/dist/unit.common.js +2 -2
- package/dist/unit.esm.js +29 -27
- package/dist/unit.js +2 -2
- package/dist/violin.common.js +2 -2
- package/dist/violin.esm.js +14 -5
- package/dist/violin.js +2 -2
- package/dist/waterfall.common.js +2 -2
- package/dist/waterfall.esm.js +417 -242
- package/package.json +1 -1
- package/src/apexcharts.js +37 -60
- package/src/assets/apexcharts.css +3 -8
- package/src/charts/Bar.js +30 -12
- package/src/charts/BarStacked.js +10 -4
- package/src/charts/BoxCandleStick.js +8 -2
- package/src/charts/Icicle.js +60 -76
- package/src/charts/Line.js +58 -22
- package/src/charts/Pie.js +136 -14
- package/src/charts/Radar.js +6 -9
- package/src/charts/Radial.js +2 -6
- package/src/charts/RangeBar.js +13 -13
- package/src/charts/Scatter.js +5 -7
- package/src/charts/Sunburst.js +157 -135
- package/src/charts/Treemap.js +100 -56
- package/src/charts/common/Breadcrumb.js +37 -16
- package/src/charts/common/PreviousPaths.js +45 -0
- package/src/charts/common/Stats.js +30 -23
- package/src/charts/common/bar/DataLabels.js +85 -77
- package/src/charts/common/bar/Helpers.js +144 -56
- package/src/charts/common/line/Helpers.js +8 -11
- package/src/charts/common/partition/NodeTooltip.js +62 -22
- package/src/charts/common/partition/Partition.js +64 -19
- package/src/charts/common/partition/Tint.js +6 -3
- package/src/charts/common/partition/Transitions.js +108 -0
- package/src/charts/common/treemap/ColorScale.js +30 -14
- package/src/charts/common/treemap/Helpers.js +47 -68
- package/src/charts/common/treemap/Nested.js +2 -3
- package/src/features/raincloud.js +16 -10
- package/src/features/stats.js +67 -62
- package/src/modules/Animations.js +102 -95
- package/src/modules/AxisMapping.js +47 -12
- package/src/modules/Base.js +12 -14
- package/src/modules/CoreUtils.js +26 -46
- package/src/modules/Data.js +82 -55
- package/src/modules/DataLabels.js +14 -13
- package/src/modules/Exports.js +44 -19
- package/src/modules/Fill.js +17 -8
- package/src/modules/Filters.js +50 -50
- package/src/modules/Graphics.js +65 -84
- package/src/modules/Markers.js +57 -58
- package/src/modules/MorphPieces.js +16 -10
- package/src/modules/MorphTypeChange.js +21 -9
- package/src/modules/Range.js +32 -55
- package/src/modules/RendererController.js +4 -4
- package/src/modules/Responsive.js +5 -1
- package/src/modules/Scales.js +24 -15
- package/src/modules/Series.js +85 -73
- package/src/modules/Toolbar.js +3 -2
- package/src/modules/UnitLayoutRegistry.js +8 -5
- package/src/modules/UnitMarkRegistry.js +7 -10
- package/src/modules/ZoomPanSelection.js +4 -0
- package/src/modules/animations/AxisTransition.js +11 -4
- package/src/modules/animations/DataLabelTransition.js +30 -15
- package/src/modules/animations/Easing.js +2 -1
- package/src/modules/animations/LayoutTransition.js +43 -32
- package/src/modules/animations/LengthTransition.js +176 -84
- package/src/modules/annotations/Helpers.js +68 -52
- package/src/modules/axes/AxesUtils.js +14 -12
- package/src/modules/axes/Grid.js +21 -7
- package/src/modules/axes/XAxis.js +4 -4
- package/src/modules/axes/YAxis.js +12 -13
- package/src/modules/dimensions/Dimensions.js +9 -3
- package/src/modules/dimensions/Grid.js +2 -2
- package/src/modules/dimensions/XAxis.js +2 -5
- package/src/modules/drilldown/Breadcrumb.js +11 -53
- package/src/modules/drilldown/Drilldown.js +151 -95
- package/src/modules/helpers/InitCtxVariables.js +2 -1
- package/src/modules/helpers/UpdateHelpers.js +165 -15
- package/src/modules/helpers/XKey.js +56 -0
- package/src/modules/highlightFilter/HighlightFilter.js +98 -49
- package/src/modules/highlightFilter/PiePart.js +6 -3
- package/src/modules/highlightFilter/RadialPart.js +41 -7
- package/src/modules/highlightFilter/TreemapPart.js +71 -44
- package/src/modules/highlightFilter/util.js +23 -7
- package/src/modules/legend/Helpers.js +6 -1
- package/src/modules/legend/Legend.js +39 -13
- package/src/modules/license/LicenseEnforcer.js +5 -0
- package/src/modules/settings/Defaults.js +62 -106
- package/src/modules/settings/Globals.js +5 -0
- package/src/modules/settings/Options.js +0 -7
- package/src/modules/settings/TypeAliases.js +33 -16
- package/src/modules/streamgraph/StreamData.js +81 -35
- package/src/modules/streamgraph/StreamLabels.js +44 -17
- package/src/modules/tooltip/Labels.js +80 -80
- package/src/modules/tooltip/Marker.js +25 -21
- package/src/modules/tooltip/Position.js +88 -51
- package/src/modules/tooltip/Tooltip.js +229 -253
- package/src/modules/tooltip/Utils.js +64 -131
- package/src/modules/tooltip/constants.js +5 -5
- package/src/modules/trellis/Trellis.js +402 -248
- package/src/modules/trellis/TrellisChrome.js +110 -44
- package/src/modules/trellis/TrellisExports.js +48 -13
- package/src/modules/trellis/TrellisFrames.js +11 -15
- package/src/modules/trellis/TrellisScales.js +201 -115
- package/src/modules/trellis/TrellisSplit.js +72 -36
- package/src/modules/trellis/TrellisSync.js +41 -13
- package/src/modules/trellis/TrellisTooltip.js +101 -78
- package/src/modules/trellis/pivotRows.js +20 -6
- package/src/modules/waterfall/WaterfallData.js +14 -30
- package/src/modules/weave/WeaveHost.js +18 -12
- package/src/pictograms/registry.js +2 -1
- package/src/renderers/Renderer.js +41 -37
- package/src/renderers/canvas/CanvasCompositor.js +4 -1
- package/src/renderers/canvas/CanvasGraphics.js +56 -24
- package/src/ssr/RenderShim.js +129 -20
- package/src/svg/SVGContainer.js +3 -2
- package/src/svg/SVGFilter.js +26 -17
- package/src/types/internal.d.ts +8 -6
- package/src/unit-shapes/registry.js +3 -1
- package/src/utils/DateTime.js +5 -20
- package/src/utils/Utils.js +0 -14
- package/src/utils/nameAsHtml.js +16 -0
- package/types/apexcharts.d.ts +72 -13
|
@@ -26,6 +26,21 @@ const ICONS = {
|
|
|
26
26
|
'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M12 4v11"/><path d="M7 11l5 5 5-5"/><path d="M4 20h16"/></svg>',
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Paint one legend item from the trellis's state: the marker from the
|
|
31
|
+
* colour map, the inactive look from the hidden set (which every panel
|
|
32
|
+
* mounted from it honours too, so the two always agree).
|
|
33
|
+
* @param {import('./Trellis').default} t
|
|
34
|
+
* @param {any} item
|
|
35
|
+
* @param {string} name
|
|
36
|
+
*/
|
|
37
|
+
function paintItem(t, item, name) {
|
|
38
|
+
const hidden = t.sync.isHidden(name)
|
|
39
|
+
item.firstChild.style.background = t.scales ? t.scales.colorOf(name) : '#008FFB'
|
|
40
|
+
item.classList.toggle('apexcharts-inactive-legend', hidden)
|
|
41
|
+
item.setAttribute('data:collapsed', String(hidden))
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
export default class TrellisChrome {
|
|
30
45
|
/**
|
|
31
46
|
* @param {import('./Trellis').default} trellis
|
|
@@ -39,6 +54,8 @@ export default class TrellisChrome {
|
|
|
39
54
|
/** @type {HTMLElement|null} */
|
|
40
55
|
this.elTitle = null
|
|
41
56
|
/** @type {HTMLElement|null} */
|
|
57
|
+
this.elSubtitle = null
|
|
58
|
+
/** @type {HTMLElement|null} */
|
|
42
59
|
this.elBreadcrumb = null
|
|
43
60
|
/** @type {HeatmapGradientLegend|null} shared gradient strip (P5, heatmap) */
|
|
44
61
|
this.gradientLegend = null
|
|
@@ -170,21 +187,42 @@ export default class TrellisChrome {
|
|
|
170
187
|
}
|
|
171
188
|
|
|
172
189
|
/**
|
|
173
|
-
* The trellis-level title, from the host's own `title`
|
|
174
|
-
* theirs suppressed).
|
|
190
|
+
* The trellis-level title and subtitle, from the host's own `title` and
|
|
191
|
+
* `subtitle` config (panels have theirs suppressed). The title keeps the
|
|
192
|
+
* stylesheet's lighter weight unless the page set `title.style.fontWeight`
|
|
193
|
+
* itself (the merged core default, 900, is heavier than the grid chrome).
|
|
175
194
|
* @param {HTMLElement} host
|
|
176
195
|
*/
|
|
177
196
|
buildTitle(host) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
197
|
+
const config = this.trellis.w.config
|
|
198
|
+
/** @param {'title'|'subtitle'} k */
|
|
199
|
+
const make = (k) => {
|
|
200
|
+
const cfg = config[k]
|
|
201
|
+
if (!cfg || !cfg.text) return null
|
|
202
|
+
const el = BrowserAPIs.createElement('div')
|
|
203
|
+
el.className = 'apexcharts-trellis-' + k
|
|
204
|
+
el.textContent = cfg.text
|
|
205
|
+
const { fontSize, fontWeight, fontFamily, color } = cfg.style || {}
|
|
206
|
+
const s = el.style
|
|
207
|
+
if (fontSize) s.fontSize = fontSize
|
|
208
|
+
// the title's stylesheet weight stands unless the page set one
|
|
209
|
+
const fw =
|
|
210
|
+
k === 'title'
|
|
211
|
+
? this.trellis.ctx.opts?.title?.style?.fontWeight
|
|
212
|
+
: fontWeight
|
|
213
|
+
if (fw) s.fontWeight = String(fw)
|
|
214
|
+
if (fontFamily) s.fontFamily = fontFamily
|
|
215
|
+
if (color || k !== 'title') {
|
|
216
|
+
// no stylesheet rule for the subtitle (core CSS stays untouched)
|
|
217
|
+
s.color = color || 'var(--apx-fore, var(--apx-trellis-fore, #373d3f))'
|
|
218
|
+
}
|
|
219
|
+
if (k !== 'title') s.padding = '0 0 6px'
|
|
220
|
+
if (cfg.align && cfg.align !== 'left') s.textAlign = cfg.align
|
|
221
|
+
host.appendChild(el)
|
|
222
|
+
return el
|
|
223
|
+
}
|
|
224
|
+
this.elTitle = make('title')
|
|
225
|
+
this.elSubtitle = make('subtitle')
|
|
188
226
|
}
|
|
189
227
|
|
|
190
228
|
/**
|
|
@@ -194,6 +232,8 @@ export default class TrellisChrome {
|
|
|
194
232
|
*/
|
|
195
233
|
buildLegend(host) {
|
|
196
234
|
const t = this.trellis
|
|
235
|
+
/** @type {string|null} the categorical legend's names, as JSON */
|
|
236
|
+
this._names = null
|
|
197
237
|
if ((t.cfg.legend || 'shared') !== 'shared') return
|
|
198
238
|
// A heatmap's legend IS its color scale (P5): one shared gradient strip
|
|
199
239
|
// for the grid instead of a categorical name list.
|
|
@@ -215,11 +255,9 @@ export default class TrellisChrome {
|
|
|
215
255
|
item.className = 'apexcharts-legend-series apexcharts-trellis-legend-item'
|
|
216
256
|
item.setAttribute('role', 'listitem')
|
|
217
257
|
item.setAttribute('tabindex', '0')
|
|
218
|
-
item.setAttribute('data:collapsed', 'false')
|
|
219
258
|
|
|
220
259
|
const marker = BrowserAPIs.createElement('span')
|
|
221
260
|
marker.className = 'apexcharts-legend-marker'
|
|
222
|
-
marker.style.background = t.scales ? t.scales.colorOf(name) : '#008FFB'
|
|
223
261
|
|
|
224
262
|
const text = BrowserAPIs.createElement('span')
|
|
225
263
|
text.className = 'apexcharts-legend-text'
|
|
@@ -227,11 +265,11 @@ export default class TrellisChrome {
|
|
|
227
265
|
|
|
228
266
|
item.appendChild(marker)
|
|
229
267
|
item.appendChild(text)
|
|
268
|
+
paintItem(t, item, name)
|
|
230
269
|
|
|
231
270
|
const toggle = () => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
item.setAttribute('data:collapsed', String(hidden))
|
|
271
|
+
t.sync.toggleSeries(name)
|
|
272
|
+
paintItem(t, item, name)
|
|
235
273
|
}
|
|
236
274
|
item.addEventListener('click', toggle)
|
|
237
275
|
item.addEventListener('keydown', (/** @type {any} */ e) => {
|
|
@@ -245,25 +283,33 @@ export default class TrellisChrome {
|
|
|
245
283
|
|
|
246
284
|
host.appendChild(wrap)
|
|
247
285
|
this.elLegend = wrap
|
|
286
|
+
this._names = JSON.stringify(names)
|
|
248
287
|
}
|
|
249
288
|
|
|
250
289
|
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
290
|
+
* Bring the shared legend up to date after an in-place update: new data
|
|
291
|
+
* may add or drop names (and a heatmap strip has to span the new colour
|
|
292
|
+
* range); a `colors` change moves the markers. The same names repaint in
|
|
293
|
+
* place, so a streaming grid neither churns the DOM nor takes keyboard
|
|
294
|
+
* focus off an item. Otherwise the legend is rebuilt where it stood.
|
|
255
295
|
*/
|
|
256
|
-
|
|
296
|
+
rebuildLegend() {
|
|
257
297
|
const t = this.trellis
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
298
|
+
const old = this.elLegend
|
|
299
|
+
const names = t.split ? t.split.seriesNames : []
|
|
300
|
+
if (old && this._names === JSON.stringify(names)) {
|
|
301
|
+
names.forEach((n, i) =>
|
|
302
|
+
paintItem(t, old.children[i], n),
|
|
303
|
+
)
|
|
304
|
+
return
|
|
305
|
+
}
|
|
306
|
+
this.destroyGradientLegend()
|
|
307
|
+
this.elLegend = null
|
|
308
|
+
if (t.elWrap) this.buildLegend(t.elWrap)
|
|
309
|
+
// (buildLegend set it; the cast undoes the narrowing to null above)
|
|
310
|
+
const el = /** @type {HTMLElement|null} */ (this.elLegend)
|
|
311
|
+
// the new legend takes the old one's place in the wrap
|
|
312
|
+
if (old) el ? old.replaceWith(el) : old.remove()
|
|
267
313
|
}
|
|
268
314
|
|
|
269
315
|
/**
|
|
@@ -328,11 +374,19 @@ export default class TrellisChrome {
|
|
|
328
374
|
t.ctx.events.removeEventListener?.('panelMounted', this._gradPending)
|
|
329
375
|
this._gradPending = null
|
|
330
376
|
}
|
|
331
|
-
// the panels' own buses die with them right after (teardown)
|
|
332
377
|
t.ctx.events.removeEventListener('panelMounted', this._gradWire)
|
|
333
|
-
|
|
378
|
+
this._gradWire = null
|
|
379
|
+
const legend = this.gradientLegend
|
|
380
|
+
if (legend) {
|
|
381
|
+
// Live panels outlive a strip rebuilt in place (an update), so their
|
|
382
|
+
// hover wiring has to go with it; on teardown they die right after.
|
|
383
|
+
t.panels.forEach((p) => {
|
|
384
|
+
const ev = /** @type {any} */ (p.chart)?.ctx.events
|
|
385
|
+
ev?.removeEventListener('dataPointMouseEnter', legend._onCellEnter)
|
|
386
|
+
ev?.removeEventListener('dataPointMouseLeave', legend._onCellLeave)
|
|
387
|
+
})
|
|
334
388
|
try {
|
|
335
|
-
|
|
389
|
+
legend.destroy()
|
|
336
390
|
} catch (e) {
|
|
337
391
|
// The carrier panel may already be destroyed; the strip DOM goes
|
|
338
392
|
// with the trellis wrap either way.
|
|
@@ -358,10 +412,13 @@ export default class TrellisChrome {
|
|
|
358
412
|
const buttons = {}
|
|
359
413
|
/** @param {'zoom'|'pan'} tool */
|
|
360
414
|
const arm = (tool) => {
|
|
415
|
+
// kept on the trellis, so panels mounted later start with this tool
|
|
416
|
+
t._tool = tool
|
|
361
417
|
t.panels.forEach((p) => {
|
|
362
418
|
if (!p.chart) return
|
|
363
419
|
const it = p.chart.w.interact
|
|
364
|
-
|
|
420
|
+
// never arms a zoom the panel's config turned off
|
|
421
|
+
it.zoomEnabled = tool === 'zoom' && p.chart.w.config.chart.zoom.enabled
|
|
365
422
|
it.panEnabled = tool === 'pan'
|
|
366
423
|
it.selectionEnabled = false
|
|
367
424
|
})
|
|
@@ -389,11 +446,17 @@ export default class TrellisChrome {
|
|
|
389
446
|
return b
|
|
390
447
|
}
|
|
391
448
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
t.
|
|
396
|
-
|
|
449
|
+
// Same rule as the panels' zoom.enabled: with zoom off for the grid there
|
|
450
|
+
// is nothing for zoom, pan or reset to do, so they are left out.
|
|
451
|
+
const zoom =
|
|
452
|
+
t.cfg.zoom !== 'none' && t.ctx.opts?.chart?.zoom?.enabled !== false
|
|
453
|
+
if (zoom) {
|
|
454
|
+
makeButton('zoom', 'Selection zoom', () => arm('zoom'))
|
|
455
|
+
makeButton('pan', 'Pan', () => arm('pan'))
|
|
456
|
+
makeButton('reset', 'Reset zoom', () => {
|
|
457
|
+
t.sync.resetAll()
|
|
458
|
+
})
|
|
459
|
+
}
|
|
397
460
|
|
|
398
461
|
// The download tool (P3): one composed artifact for the whole grid.
|
|
399
462
|
// Requires the exports feature on the panels; omitted otherwise.
|
|
@@ -421,10 +484,13 @@ export default class TrellisChrome {
|
|
|
421
484
|
bar.appendChild(menu)
|
|
422
485
|
}
|
|
423
486
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
487
|
+
if (!bar.firstChild) return
|
|
488
|
+
if (zoom) {
|
|
489
|
+
// Default tool mirrors the per-chart default (toolbar.autoSelected 'zoom').
|
|
490
|
+
buttons.zoom.classList.add('apexcharts-selected')
|
|
491
|
+
buttons.zoom.setAttribute('aria-pressed', 'true')
|
|
492
|
+
buttons.pan.setAttribute('aria-pressed', 'false')
|
|
493
|
+
}
|
|
428
494
|
|
|
429
495
|
host.appendChild(bar)
|
|
430
496
|
this.elToolbar = bar
|
|
@@ -49,6 +49,17 @@ export default class TrellisExports {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Panels on screen. A promotion parks the rest as display:none, whose
|
|
54
|
+
* rects collapse onto the wrap origin; the export is what the user sees,
|
|
55
|
+
* so a promoted grid exports the promoted panel alone.
|
|
56
|
+
*/
|
|
57
|
+
_shown() {
|
|
58
|
+
return this.trellis.panels.filter(
|
|
59
|
+
(p) => !p.cellEl?.classList.contains('apexcharts-trellis-cell-parked'),
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
52
63
|
/** Export surface size = the wrap's own box. */
|
|
53
64
|
_size() {
|
|
54
65
|
const wrap = /** @type {HTMLElement} */ (this.trellis.elWrap)
|
|
@@ -67,19 +78,28 @@ export default class TrellisExports {
|
|
|
67
78
|
return '#fff'
|
|
68
79
|
}
|
|
69
80
|
|
|
70
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Text pieces to compose: title + subtitle + one header per cell (+ legend
|
|
83
|
+
* items). An inline `text-align` (the title's `align`) wins over the
|
|
84
|
+
* piece's default anchor.
|
|
85
|
+
*/
|
|
71
86
|
_chromeTexts() {
|
|
72
87
|
const t = this.trellis
|
|
73
|
-
/** @type {Array<{ text: string, x: number, y: number, font: string, fontSize: number, color: string, align: 'left'|'center' }>} */
|
|
88
|
+
/** @type {Array<{ text: string, x: number, y: number, font: string, fontSize: number, color: string, align: 'left'|'center'|'right' }>} */
|
|
74
89
|
const texts = []
|
|
75
|
-
/** @param {Element|null} el @param {'left'|'center'}
|
|
76
|
-
const push = (el,
|
|
90
|
+
/** @param {Element|null} el @param {'left'|'center'} fallback */
|
|
91
|
+
const push = (el, fallback) => {
|
|
77
92
|
if (!el || !el.textContent) return
|
|
78
93
|
const rect = this._rectIn(el)
|
|
79
94
|
const cs = getComputedStyle(/** @type {HTMLElement} */ (el))
|
|
95
|
+
const align = /** @type {'left'|'center'|'right'} */ (
|
|
96
|
+
/** @type {HTMLElement} */ (el).style.textAlign || fallback
|
|
97
|
+
)
|
|
80
98
|
texts.push({
|
|
81
99
|
text: el.textContent,
|
|
82
|
-
x:
|
|
100
|
+
x:
|
|
101
|
+
rect.x +
|
|
102
|
+
(align === 'left' ? 0 : align === 'right' ? rect.w : rect.w / 2),
|
|
83
103
|
y: rect.y + rect.h / 2,
|
|
84
104
|
font: `${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`,
|
|
85
105
|
fontSize: parseFloat(cs.fontSize) || 12,
|
|
@@ -88,7 +108,8 @@ export default class TrellisExports {
|
|
|
88
108
|
})
|
|
89
109
|
}
|
|
90
110
|
push(t.chrome.elTitle, 'left')
|
|
91
|
-
t.
|
|
111
|
+
push(t.chrome.elSubtitle, 'left')
|
|
112
|
+
this._shown().forEach((p) => {
|
|
92
113
|
if (!p.cellEl) return
|
|
93
114
|
push(p.cellEl.querySelector('.apexcharts-trellis-header'), 'center')
|
|
94
115
|
})
|
|
@@ -122,7 +143,6 @@ export default class TrellisExports {
|
|
|
122
143
|
* @returns {Promise<{ imgURI: string }>}
|
|
123
144
|
*/
|
|
124
145
|
async dataURI(options = {}) {
|
|
125
|
-
const t = this.trellis
|
|
126
146
|
const scale = options.scale || 1
|
|
127
147
|
const size = this._size()
|
|
128
148
|
const canvas = document.createElement('canvas')
|
|
@@ -136,7 +156,7 @@ export default class TrellisExports {
|
|
|
136
156
|
ctx.fillRect(0, 0, size.w, size.h)
|
|
137
157
|
|
|
138
158
|
// Panels first (their own export path), skeleton tint for unmounted.
|
|
139
|
-
for (const p of
|
|
159
|
+
for (const p of this._shown()) {
|
|
140
160
|
if (!p.el) continue
|
|
141
161
|
const rect = this._rectIn(p.el)
|
|
142
162
|
if (!p.chart) {
|
|
@@ -180,7 +200,6 @@ export default class TrellisExports {
|
|
|
180
200
|
* @returns {Promise<string>}
|
|
181
201
|
*/
|
|
182
202
|
async svgString(scale = 1) {
|
|
183
|
-
const t = this.trellis
|
|
184
203
|
const size = this._size()
|
|
185
204
|
/** @type {string[]} */
|
|
186
205
|
const parts = []
|
|
@@ -190,7 +209,7 @@ export default class TrellisExports {
|
|
|
190
209
|
parts.push(
|
|
191
210
|
`<rect width="${size.w}" height="${size.h}" fill="${this._background()}"/>`,
|
|
192
211
|
)
|
|
193
|
-
for (const p of
|
|
212
|
+
for (const p of this._shown()) {
|
|
194
213
|
if (!p.el) continue
|
|
195
214
|
const rect = this._rectIn(p.el)
|
|
196
215
|
if (!p.chart) {
|
|
@@ -205,7 +224,12 @@ export default class TrellisExports {
|
|
|
205
224
|
)
|
|
206
225
|
}
|
|
207
226
|
for (const piece of this._chromeTexts()) {
|
|
208
|
-
const anchor =
|
|
227
|
+
const anchor =
|
|
228
|
+
piece.align === 'left'
|
|
229
|
+
? 'start'
|
|
230
|
+
: piece.align === 'right'
|
|
231
|
+
? 'end'
|
|
232
|
+
: 'middle'
|
|
209
233
|
parts.push(
|
|
210
234
|
`<text x="${piece.x}" y="${piece.y}" text-anchor="${anchor}" dominant-baseline="central" style="font:${escapeAttr(
|
|
211
235
|
piece.font,
|
|
@@ -248,9 +272,20 @@ export default class TrellisExports {
|
|
|
248
272
|
? `"${s.replace(/"/g, '""')}"`
|
|
249
273
|
: s
|
|
250
274
|
}
|
|
275
|
+
// Plain value arrays carry no x: the union holds positions, so write the
|
|
276
|
+
// label the axis shows there (categories, then labels, then 1-based).
|
|
277
|
+
const cats =
|
|
278
|
+
split.xForm === 'plain' &&
|
|
279
|
+
(w.config.xaxis.categories?.length
|
|
280
|
+
? w.config.xaxis.categories
|
|
281
|
+
: w.config.labels || [])
|
|
251
282
|
/** @param {any} x */
|
|
252
|
-
const xOut = (x) =>
|
|
253
|
-
|
|
283
|
+
const xOut = (x) => {
|
|
284
|
+
if (cats) x = cats[x] ?? x + 1
|
|
285
|
+
// a multi-line category reads as one line, as in a plain chart's CSV
|
|
286
|
+
if (Array.isArray(x)) x = x.join(' ')
|
|
287
|
+
return isDatetime && typeof x === 'number' ? new Date(x).toISOString() : x
|
|
288
|
+
}
|
|
254
289
|
|
|
255
290
|
const names = split.seriesNames
|
|
256
291
|
const lines = [
|
|
@@ -78,13 +78,12 @@ function observationValues(data) {
|
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Raw observation ARRAYS of one series' data (the violin/boxPlot raw form:
|
|
81
|
-
* `{ x: 'A', y: [obs...] }`), flattened
|
|
81
|
+
* `{ x: 'A', y: [obs...] }`), flattened onto `out`.
|
|
82
82
|
* @param {any} data
|
|
83
|
+
* @param {number[]} out appended to in place, so a union grows in one pass
|
|
83
84
|
* @returns {number[]}
|
|
84
85
|
*/
|
|
85
|
-
function rawObservationArrays(data) {
|
|
86
|
-
/** @type {number[]} */
|
|
87
|
-
const out = []
|
|
86
|
+
function rawObservationArrays(data, out) {
|
|
88
87
|
if (!Array.isArray(data)) return out
|
|
89
88
|
data.forEach((/** @type {any} */ d) => {
|
|
90
89
|
const y = d && typeof d === 'object' ? d.y : null
|
|
@@ -146,16 +145,13 @@ export function buildTypeFrames(splitResult, cfg, hostConfig, chartType) {
|
|
|
146
145
|
// which pins the edges no matter what each panel's own extent is.
|
|
147
146
|
if (chartType === 'histogram') {
|
|
148
147
|
const hcfg = plot.histogram || {}
|
|
149
|
-
/** @type {number[]} */
|
|
150
|
-
let union = []
|
|
151
148
|
/** @type {number[][][]} per panel, per series */
|
|
152
149
|
const panelSeriesVals = panels.map((p) =>
|
|
153
|
-
p.series.map((/** @type {any} */ s) =>
|
|
154
|
-
const vals = observationValues(s.data)
|
|
155
|
-
union = union.concat(vals)
|
|
156
|
-
return vals
|
|
157
|
-
}),
|
|
150
|
+
p.series.map((/** @type {any} */ s) => observationValues(s.data)),
|
|
158
151
|
)
|
|
152
|
+
// One flatten: re-concatenating the growing union per series copied it
|
|
153
|
+
// once per series (quadratic in the panel count).
|
|
154
|
+
const union = panelSeriesVals.flat(2)
|
|
159
155
|
const binning = computeBinning(union, {
|
|
160
156
|
bins: hcfg.bins,
|
|
161
157
|
binWidth: hcfg.binWidth,
|
|
@@ -203,11 +199,11 @@ export function buildTypeFrames(splitResult, cfg, hostConfig, chartType) {
|
|
|
203
199
|
const kde = plot.violin?.kde || {}
|
|
204
200
|
if (!(typeof kde.bandwidth === 'number' && kde.bandwidth > 0)) {
|
|
205
201
|
/** @type {number[]} */
|
|
206
|
-
|
|
202
|
+
const union = []
|
|
207
203
|
panels.forEach((p) =>
|
|
208
|
-
p.series.forEach((/** @type {any} */ s) =>
|
|
209
|
-
|
|
210
|
-
|
|
204
|
+
p.series.forEach((/** @type {any} */ s) =>
|
|
205
|
+
rawObservationArrays(s.data, union),
|
|
206
|
+
),
|
|
211
207
|
)
|
|
212
208
|
const est = union.length
|
|
213
209
|
? kernelDensity(union, { resolution: 8 })
|