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.
- package/README.md +14 -8
- package/dist/apexcharts.common.js +2 -2
- package/dist/apexcharts.core.js +2310 -2274
- package/dist/apexcharts.core.min.js +2 -2
- package/dist/apexcharts.esm.js +1367 -1110
- package/dist/apexcharts.full.js +3880 -3531
- package/dist/apexcharts.full.min.js +2 -2
- package/dist/apexcharts.js +3676 -3409
- package/dist/apexcharts.min.js +2 -2
- package/dist/apexcharts.ssr.common.js +2 -2
- package/dist/apexcharts.ssr.esm.js +4114 -3591
- package/dist/area.common.js +2 -2
- package/dist/area.esm.js +25 -67
- package/dist/bar.common.js +2 -2
- package/dist/bar.esm.js +159 -163
- package/dist/bar.js +2 -2
- package/dist/boxPlot.common.js +2 -2
- package/dist/boxPlot.esm.js +125 -106
- package/dist/bubble.common.js +2 -2
- package/dist/bubble.esm.js +25 -67
- package/dist/candlestick.common.js +2 -2
- package/dist/candlestick.esm.js +125 -106
- package/dist/candlestick.js +2 -2
- package/dist/column.common.js +2 -2
- package/dist/column.esm.js +159 -163
- package/dist/core.common.js +2 -2
- package/dist/core.esm.js +2310 -2274
- package/dist/donut.common.js +2 -2
- package/dist/donut.esm.js +100 -78
- package/dist/dumbbell.common.js +2 -2
- package/dist/dumbbell.esm.js +192 -167
- package/dist/features/all.common.js +2 -2
- package/dist/features/all.esm.js +945 -640
- package/dist/features/annotations.common.js +2 -2
- package/dist/features/annotations.esm.js +46 -21
- 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 +22 -2
- package/dist/features/drilldown.js +2 -2
- package/dist/features/dumbbell.common.js +2 -2
- package/dist/features/dumbbell.esm.js +34 -5
- package/dist/features/dumbbell.js +2 -2
- package/dist/features/exports.common.js +2 -2
- package/dist/features/exports.esm.js +203 -204
- 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 +97 -41
- package/dist/features/highlight-filter.js +2 -2
- package/dist/features/history.common.js +2 -2
- package/dist/features/history.esm.js +4 -3
- package/dist/features/history.js +2 -2
- 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 +2 -2
- package/dist/features/keyboard.esm.js +20 -23
- package/dist/features/keyboard.js +2 -2
- package/dist/features/legend.common.js +2 -2
- package/dist/features/legend.esm.js +61 -41
- package/dist/features/legend.js +2 -2
- package/dist/features/link.common.js +2 -2
- package/dist/features/link.esm.js +8 -8
- package/dist/features/link.js +2 -2
- package/dist/features/marks.common.js +2 -2
- 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 +260 -279
- package/dist/features/morph.js +2 -2
- package/dist/features/perspectives.common.js +2 -2
- package/dist/features/perspectives.esm.js +28 -19
- package/dist/features/perspectives.js +2 -2
- package/dist/features/raincloud.common.js +2 -2
- package/dist/features/raincloud.esm.js +54 -36
- package/dist/features/raincloud.js +2 -2
- package/dist/features/renderer-canvas.common.js +1 -1
- package/dist/features/renderer-canvas.esm.js +1 -1
- package/dist/features/renderer-canvas.js +1 -1
- package/dist/features/stats.common.js +2 -2
- package/dist/features/stats.esm.js +66 -18
- package/dist/features/stats.js +2 -2
- package/dist/features/storyboard.common.js +2 -2
- package/dist/features/storyboard.esm.js +24 -15
- package/dist/features/storyboard.js +2 -2
- package/dist/features/streamgraph.common.js +2 -2
- package/dist/features/streamgraph.esm.js +34 -5
- package/dist/features/streamgraph.js +2 -2
- package/dist/features/toolbar.common.js +2 -2
- package/dist/features/toolbar.esm.js +211 -217
- package/dist/features/toolbar.js +2 -2
- package/dist/features/trellis.common.js +2 -2
- package/dist/features/trellis.esm.js +31 -19
- package/dist/features/trellis.js +2 -2
- package/dist/features/waterfall.common.js +2 -2
- package/dist/features/waterfall.esm.js +34 -5
- package/dist/features/waterfall.js +2 -2
- package/dist/features/weave.common.js +2 -2
- package/dist/features/weave.esm.js +290 -48
- package/dist/features/weave.js +2 -2
- package/dist/full.common.js +2 -2
- package/dist/full.esm.js +289 -150
- package/dist/heatmap.common.js +2 -2
- package/dist/heatmap.esm.js +48 -17
- package/dist/heatmap.js +2 -2
- package/dist/histogram.common.js +2 -2
- package/dist/histogram.esm.js +224 -180
- package/dist/icicle.common.js +2 -2
- package/dist/icicle.esm.js +1 -1
- package/dist/icicle.js +1 -1
- package/dist/line.common.js +2 -2
- package/dist/line.esm.js +25 -67
- package/dist/line.js +2 -2
- package/dist/pictograms.common.js +1 -1
- package/dist/pictograms.esm.js +1 -1
- package/dist/pictograms.js +1 -1
- package/dist/pie.common.js +2 -2
- package/dist/pie.esm.js +100 -78
- package/dist/pie.js +2 -2
- package/dist/polarArea.common.js +2 -2
- package/dist/polarArea.esm.js +100 -78
- package/dist/radar.common.js +2 -2
- package/dist/radar.esm.js +8 -5
- package/dist/radar.js +2 -2
- package/dist/radialBar.common.js +2 -2
- package/dist/radialBar.esm.js +166 -133
- package/dist/radialBar.js +2 -2
- package/dist/raincloud.common.js +2 -2
- package/dist/raincloud.esm.js +55 -42
- package/dist/rangeArea.common.js +2 -2
- package/dist/rangeArea.esm.js +25 -67
- package/dist/rangeBar.common.js +2 -2
- package/dist/rangeBar.esm.js +159 -163
- package/dist/scatter.common.js +2 -2
- package/dist/scatter.esm.js +25 -67
- package/dist/streamgraph.common.js +2 -2
- package/dist/streamgraph.esm.js +58 -71
- package/dist/sunburst.common.js +2 -2
- package/dist/sunburst.esm.js +1 -1
- package/dist/sunburst.js +1 -1
- package/dist/treemap.common.js +2 -2
- package/dist/treemap.esm.js +28 -90
- package/dist/treemap.js +2 -2
- package/dist/unit-shapes.common.js +2 -2
- package/dist/unit-shapes.esm.js +1 -1
- package/dist/unit-shapes.js +1 -1
- package/dist/unit.common.js +2 -2
- package/dist/unit.esm.js +30 -6
- package/dist/unit.js +2 -2
- package/dist/violin.common.js +2 -2
- package/dist/violin.esm.js +2 -7
- package/dist/violin.js +2 -2
- package/dist/waterfall.common.js +2 -2
- package/dist/waterfall.esm.js +192 -167
- package/package.json +3 -1
- package/src/apexcharts.js +260 -201
- package/src/charts/Bar.js +16 -5
- package/src/charts/BarStacked.js +42 -88
- package/src/charts/BoxCandleStick.js +1 -7
- package/src/charts/HeatMap.js +73 -16
- package/src/charts/Line.js +21 -71
- package/src/charts/Pie.js +142 -89
- package/src/charts/Radar.js +4 -1
- package/src/charts/Radial.js +91 -63
- package/src/charts/RangeBar.js +1 -7
- package/src/charts/Treemap.js +25 -78
- package/src/charts/Unit.js +28 -10
- package/src/charts/Violin.js +1 -7
- package/src/charts/common/Hierarchy.js +0 -22
- package/src/charts/common/OuterLabels.js +12 -5
- package/src/charts/common/Stats.js +55 -28
- package/src/charts/common/bar/DataLabels.js +94 -83
- package/src/charts/common/bar/Helpers.js +34 -57
- package/src/charts/common/circle/Helpers.js +5 -2
- package/src/charts/common/treemap/Helpers.js +1 -1
- package/src/entries/full.js +0 -17
- package/src/features/link.js +9 -10
- package/src/features/perspectives.js +20 -19
- package/src/features/raincloud.js +51 -53
- package/src/features/stats.js +23 -35
- package/src/libs/Treemap-squared.js +7 -47
- package/src/modules/Animations.js +55 -73
- package/src/modules/Base.js +3 -2
- package/src/modules/ChartFactory.js +6 -1
- package/src/modules/Core.js +57 -30
- package/src/modules/CoreUtils.js +32 -33
- package/src/modules/Crosshairs.js +29 -11
- package/src/modules/Data.js +279 -153
- package/src/modules/DataLabels.js +18 -2
- package/src/modules/Events.js +1 -4
- package/src/modules/Exports.js +284 -305
- package/src/modules/Fill.js +23 -10
- package/src/modules/Formatters.js +14 -3
- package/src/modules/Graphics.js +8 -14
- package/src/modules/MorphPieces.js +4 -2
- package/src/modules/MorphTypeChange.js +332 -316
- package/src/modules/Range.js +56 -99
- package/src/modules/Responsive.js +186 -61
- package/src/modules/Scales.js +4 -47
- package/src/modules/Series.js +14 -45
- package/src/modules/Theme.js +108 -57
- package/src/modules/Toolbar.js +7 -13
- package/src/modules/accessibility/KeyboardNavigation.js +29 -28
- package/src/modules/animations/AxisTransition.js +54 -16
- package/src/modules/animations/CircleTransition.js +1 -4
- package/src/modules/animations/DataLabelTransition.js +15 -10
- package/src/modules/animations/StreamScroll.js +6 -4
- package/src/modules/annotations/Annotations.js +18 -17
- package/src/modules/annotations/Helpers.js +41 -17
- package/src/modules/axes/XAxis.js +4 -4
- package/src/modules/axes/YAxis.js +1 -6
- package/src/modules/dimensions/Dimensions.js +12 -7
- package/src/modules/dimensions/Grid.js +15 -3
- package/src/modules/dimensions/YAxis.js +7 -6
- package/src/modules/drilldown/Drilldown.js +22 -1
- package/src/modules/dumbbell/DumbbellData.js +3 -5
- package/src/modules/helpers/Destroy.js +10 -1
- package/src/modules/helpers/InitCtxVariables.js +19 -16
- package/src/modules/helpers/RawStash.js +51 -0
- package/src/modules/helpers/UpdateHelpers.js +95 -30
- package/src/modules/highlightFilter/HighlightFilter.js +107 -52
- package/src/modules/highlightFilter/PiePart.js +1 -1
- package/src/modules/highlightFilter/RadialPart.js +1 -1
- package/src/modules/history/History.js +7 -2
- package/src/modules/legend/Legend.js +100 -62
- package/src/modules/license/LicenseEnforcer.js +6 -1
- package/src/modules/settings/Config.js +60 -153
- package/src/modules/settings/Defaults.js +352 -58
- package/src/modules/settings/Globals.js +23 -5
- package/src/modules/settings/Options.js +19 -5
- package/src/modules/settings/TypeAliases.js +3 -6
- package/src/modules/streamgraph/StreamData.js +3 -5
- package/src/modules/tooltip/AxesTooltip.js +33 -41
- package/src/modules/tooltip/Intersect.js +50 -43
- package/src/modules/tooltip/Labels.js +62 -23
- package/src/modules/tooltip/Marker.js +6 -7
- package/src/modules/tooltip/Position.js +31 -35
- package/src/modules/tooltip/Tooltip.js +107 -119
- package/src/modules/tooltip/Utils.js +94 -159
- package/src/modules/trellis/TrellisExports.js +21 -9
- package/src/modules/trellis/TrellisTooltip.js +18 -8
- package/src/modules/waterfall/WaterfallData.js +3 -5
- package/src/modules/weave/Claims.js +14 -3
- package/src/modules/weave/Highlights.js +209 -0
- package/src/modules/weave/PluginAPI.js +64 -3
- package/src/modules/weave/WeaveHost.js +215 -51
- package/src/ssr/BrowserAPIs.js +5 -3
- package/src/ssr/DOMShim.js +6 -30
- package/src/ssr/Hydration.js +5 -36
- package/src/ssr/RenderShim.js +333 -0
- package/src/ssr/SSRRenderer.js +81 -36
- package/src/svg/SVGAnimation.js +10 -7
- package/src/types/internal.d.ts +37 -7
- package/src/utils/Constants.js +7 -8
- package/src/utils/DateTime.js +21 -195
- package/src/utils/MissingFeature.js +7 -9
- package/src/utils/Resize.js +4 -0
- package/src/utils/Utils.js +102 -171
- package/types/apexcharts.d.ts +57 -7
|
@@ -83,6 +83,9 @@ const SUMMARY_FAMILY = new Set(['boxPlot', 'violin'])
|
|
|
83
83
|
// objects, a source family without piece support, a bailed mount).
|
|
84
84
|
const GHOST_FADE_FRACTION = 0.55
|
|
85
85
|
|
|
86
|
+
// Suffixes the ids of each ghost copy, so two copies never share one.
|
|
87
|
+
let ghostSeq = 0
|
|
88
|
+
|
|
86
89
|
// Above this many objects the piece layer stands down and the ghost fade runs
|
|
87
90
|
// instead. Every piece is a live SVG node driven per frame; a unit chart's own
|
|
88
91
|
// gather animation moves this many dots comfortably, and past it the overlay
|
|
@@ -94,6 +97,15 @@ const PIECE_BUDGET = 1500
|
|
|
94
97
|
// one still lands within the configured speed.
|
|
95
98
|
const PIECE_STAGGER_MAX = 300
|
|
96
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Show a mark or dot a piece takeover held hidden.
|
|
102
|
+
* @param {any} el
|
|
103
|
+
*/
|
|
104
|
+
const reveal = (el) => {
|
|
105
|
+
el.removeAttribute('opacity')
|
|
106
|
+
el.removeAttribute('data-piece-hidden')
|
|
107
|
+
}
|
|
108
|
+
|
|
97
109
|
/** @param {string} type */
|
|
98
110
|
function familyOf(type) {
|
|
99
111
|
if (BAR_FAMILY.has(type)) return 'bar'
|
|
@@ -112,7 +124,7 @@ export default class MorphTypeChange {
|
|
|
112
124
|
constructor(w, ctx) {
|
|
113
125
|
this.w = w
|
|
114
126
|
this.ctx = ctx
|
|
115
|
-
/** @type {null | { fromType: string, toType: string, mapping: Map<string, {d: string, fill: string|null}>, oldLayout: { translateX: number, translateY: number, scale?: number, shiftX?: number, shiftY?: number }, pieceOut?: boolean, pieceIn?: boolean, sourceDots?: Map<number, Array<{x:number,y:number,r:number,fill:string|null}>>, keyOrder?: string[] }} */
|
|
127
|
+
/** @type {null | { fromType: string, toType: string, mapping: Map<string, {d: string, fill: string|null}>, oldLayout: { translateX: number, translateY: number, scale?: number, shiftX?: number, shiftY?: number }, pieceOut?: boolean, pieceIn?: boolean, resume?: boolean, sourceDots?: Map<number, Array<{x:number,y:number,r:number,fill:string|null}>>, keyOrder?: string[] }} */
|
|
116
128
|
this._snapshot = null
|
|
117
129
|
// Whether the render the snapshot was captured for has mounted.
|
|
118
130
|
this._shown = false
|
|
@@ -126,6 +138,8 @@ export default class MorphTypeChange {
|
|
|
126
138
|
this._pieceLayer = null
|
|
127
139
|
/** @type {null | (() => void)} */
|
|
128
140
|
this._pieceCancel = null
|
|
141
|
+
/** @type {any} */
|
|
142
|
+
this._ghostTimer = undefined
|
|
129
143
|
}
|
|
130
144
|
|
|
131
145
|
/**
|
|
@@ -308,7 +322,11 @@ export default class MorphTypeChange {
|
|
|
308
322
|
this._snapshot.pieceOut = total > 0 && total <= PIECE_BUDGET
|
|
309
323
|
} else if (
|
|
310
324
|
ff === 'unit' &&
|
|
311
|
-
(tf === 'bar' ||
|
|
325
|
+
(tf === 'bar' ||
|
|
326
|
+
tf === 'summary' ||
|
|
327
|
+
// Only slices can be tiled: a radialBar ring is a stroked arc the
|
|
328
|
+
// target collector does not read, so it keeps the ghost fade.
|
|
329
|
+
(tf === 'radial' && canShape && !/^(radialBar|gauge)$/.test(toType)))
|
|
312
330
|
) {
|
|
313
331
|
// objects -> mark. The dots were just captured, so the count is exact.
|
|
314
332
|
let total = 0
|
|
@@ -318,29 +336,9 @@ export default class MorphTypeChange {
|
|
|
318
336
|
if (total > 0 && total <= PIECE_BUDGET) {
|
|
319
337
|
this._snapshot.pieceIn = true
|
|
320
338
|
this._snapshot.sourceDots = unitDots
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
|
|
324
|
-
const keyOrder = []
|
|
325
|
-
if (tf === 'radial') {
|
|
326
|
-
// A radial series is one flat value per slice, and its marks are
|
|
327
|
-
// keyed the way the radial capture keys them: slice index, j = 0.
|
|
328
|
-
;(Array.isArray(newSeries) ? newSeries : []).forEach(
|
|
329
|
-
(/** @type {any} */ _v, /** @type {number} */ i) => {
|
|
330
|
-
keyOrder.push(`${i}:0`)
|
|
331
|
-
},
|
|
332
|
-
)
|
|
333
|
-
} else {
|
|
334
|
-
;(Array.isArray(newSeries) ? newSeries : []).forEach(
|
|
335
|
-
(/** @type {any} */ s, /** @type {number} */ seriesIdx) => {
|
|
336
|
-
const data = s && Array.isArray(s.data) ? s.data : []
|
|
337
|
-
for (let j = 0; j < data.length; j++) {
|
|
338
|
-
keyOrder.push(`${seriesIdx}:${j}`)
|
|
339
|
-
}
|
|
340
|
-
},
|
|
341
|
-
)
|
|
342
|
-
}
|
|
343
|
-
this._snapshot.keyOrder = keyOrder
|
|
339
|
+
// The incoming chart's mark keys, the same ones _buildMapping pairs
|
|
340
|
+
// with, so cluster i flies to keyOrder[i].
|
|
341
|
+
this._snapshot.keyOrder = this._targetKeys(tf, newSeries)
|
|
344
342
|
}
|
|
345
343
|
}
|
|
346
344
|
|
|
@@ -414,9 +412,8 @@ export default class MorphTypeChange {
|
|
|
414
412
|
const drop = [
|
|
415
413
|
'.apexcharts-xaxis',
|
|
416
414
|
'.apexcharts-yaxis',
|
|
415
|
+
// (the gridlines go with it)
|
|
417
416
|
'.apexcharts-grid',
|
|
418
|
-
'.apexcharts-gridlines-horizontal',
|
|
419
|
-
'.apexcharts-gridlines-vertical',
|
|
420
417
|
'.apexcharts-legend',
|
|
421
418
|
'.apexcharts-title-text',
|
|
422
419
|
'.apexcharts-subtitle-text',
|
|
@@ -429,16 +426,32 @@ export default class MorphTypeChange {
|
|
|
429
426
|
if (typeof clone.querySelectorAll === 'function') {
|
|
430
427
|
drop.forEach((sel) => {
|
|
431
428
|
clone.querySelectorAll(sel).forEach((/** @type {any} */ el) => {
|
|
432
|
-
|
|
429
|
+
el.remove()
|
|
433
430
|
})
|
|
434
431
|
})
|
|
435
432
|
}
|
|
436
433
|
|
|
437
434
|
// An id collision would let the live chart resolve a gradient or clip-path
|
|
438
|
-
// against the dead one's defs
|
|
435
|
+
// against the dead one's defs (or the copy against the live one's), and a
|
|
436
|
+
// stripped id leaves a gradient fill painting nothing. So every id in the
|
|
437
|
+
// copy gets a suffix of its own and the copy's references follow it.
|
|
439
438
|
if (typeof clone.querySelectorAll === 'function') {
|
|
439
|
+
const tag = `-ghost${++ghostSeq}`
|
|
440
|
+
/** @type {Set<string>} */
|
|
441
|
+
const ids = new Set()
|
|
440
442
|
clone.querySelectorAll('[id]').forEach((/** @type {any} */ el) => {
|
|
441
|
-
el.
|
|
443
|
+
ids.add(el.id)
|
|
444
|
+
el.id += tag
|
|
445
|
+
})
|
|
446
|
+
clone.querySelectorAll('*').forEach((/** @type {any} */ el) => {
|
|
447
|
+
for (const a of el.attributes) {
|
|
448
|
+
const v = a.value.replace(
|
|
449
|
+
/(url\(['"]?#|^#)([^'")\s]+)/g,
|
|
450
|
+
(/** @type {string} */ m, /** @type {string} */ pre, /** @type {string} */ id) =>
|
|
451
|
+
ids.has(id) ? pre + id + tag : m,
|
|
452
|
+
)
|
|
453
|
+
if (v !== a.value) a.value = v
|
|
454
|
+
}
|
|
442
455
|
})
|
|
443
456
|
}
|
|
444
457
|
clone.removeAttribute?.('id')
|
|
@@ -500,14 +513,17 @@ export default class MorphTypeChange {
|
|
|
500
513
|
style.transition = `opacity ${fade}ms ease-in`
|
|
501
514
|
style.opacity = '0'
|
|
502
515
|
})
|
|
503
|
-
|
|
516
|
+
// Kept so dropping this ghost early also drops its timer, which would
|
|
517
|
+
// otherwise remove the NEXT morph's ghost mid-fade.
|
|
518
|
+
this._ghostTimer = setTimeout(() => this._removeGhost(), fade + 60)
|
|
504
519
|
}
|
|
505
520
|
|
|
506
521
|
/** Detach the ghost if one is mounted. Safe to call at any time. */
|
|
507
522
|
_removeGhost() {
|
|
523
|
+
clearTimeout(this._ghostTimer)
|
|
508
524
|
const ghost = this._ghost
|
|
509
525
|
this._ghost = null
|
|
510
|
-
|
|
526
|
+
ghost?.remove()
|
|
511
527
|
}
|
|
512
528
|
|
|
513
529
|
/* ------------------------------------------------------------------ *
|
|
@@ -601,12 +617,7 @@ export default class MorphTypeChange {
|
|
|
601
617
|
/** @type {any} */
|
|
602
618
|
const baseEl = this.w.globals.dom?.baseEl
|
|
603
619
|
if (!baseEl || typeof baseEl.querySelectorAll !== 'function') return
|
|
604
|
-
baseEl.querySelectorAll('[data-piece-hidden]').forEach(
|
|
605
|
-
(/** @type {any} */ el) => {
|
|
606
|
-
el.removeAttribute('opacity')
|
|
607
|
-
el.removeAttribute('data-piece-hidden')
|
|
608
|
-
},
|
|
609
|
-
)
|
|
620
|
+
baseEl.querySelectorAll('[data-piece-hidden]').forEach(reveal)
|
|
610
621
|
}
|
|
611
622
|
|
|
612
623
|
/** Stop the piece run, drop the overlay, and reveal anything still hidden. */
|
|
@@ -617,7 +628,7 @@ export default class MorphTypeChange {
|
|
|
617
628
|
}
|
|
618
629
|
const layer = this._pieceLayer
|
|
619
630
|
this._pieceLayer = null
|
|
620
|
-
|
|
631
|
+
layer?.remove()
|
|
621
632
|
this._revealPieceHidden()
|
|
622
633
|
}
|
|
623
634
|
|
|
@@ -784,7 +795,7 @@ export default class MorphTypeChange {
|
|
|
784
795
|
return {
|
|
785
796
|
intervalsAt,
|
|
786
797
|
dispose: () => {
|
|
787
|
-
|
|
798
|
+
probe.remove()
|
|
788
799
|
},
|
|
789
800
|
}
|
|
790
801
|
}
|
|
@@ -804,38 +815,11 @@ export default class MorphTypeChange {
|
|
|
804
815
|
|
|
805
816
|
// The live dots, grouped by cluster. They exist and are hidden: the unit
|
|
806
817
|
// renderer drew them at their final slots before this ran.
|
|
807
|
-
|
|
808
|
-
const byCluster = new Map()
|
|
818
|
+
const byCluster = this._readUnitDots(baseEl, new Map())
|
|
809
819
|
let total = 0
|
|
810
|
-
|
|
811
|
-
.
|
|
812
|
-
|
|
813
|
-
const i = parseInt(dot.getAttribute('i') ?? '', 10)
|
|
814
|
-
if (isNaN(i)) return
|
|
815
|
-
const cxAttr = dot.getAttribute('cx')
|
|
816
|
-
let x
|
|
817
|
-
let y
|
|
818
|
-
let r = 3
|
|
819
|
-
if (cxAttr != null) {
|
|
820
|
-
x = parseFloat(cxAttr)
|
|
821
|
-
y = parseFloat(dot.getAttribute('cy') ?? '')
|
|
822
|
-
r = parseFloat(dot.getAttribute('r') ?? '3') || 3
|
|
823
|
-
} else {
|
|
824
|
-
const wAttr = parseFloat(dot.getAttribute('width') ?? '0') || 0
|
|
825
|
-
const hAttr = parseFloat(dot.getAttribute('height') ?? '0') || 0
|
|
826
|
-
x = parseFloat(dot.getAttribute('x') ?? '') + wAttr / 2
|
|
827
|
-
y = parseFloat(dot.getAttribute('y') ?? '') + hAttr / 2
|
|
828
|
-
r = Math.max(wAttr, hAttr) / 2 || 3
|
|
829
|
-
}
|
|
830
|
-
if (!isFinite(x) || !isFinite(y)) return
|
|
831
|
-
let list = byCluster.get(i)
|
|
832
|
-
if (!list) {
|
|
833
|
-
list = []
|
|
834
|
-
byCluster.set(i, list)
|
|
835
|
-
}
|
|
836
|
-
list.push({ el: dot, x, y, r, fill: dot.getAttribute('fill') })
|
|
837
|
-
total++
|
|
838
|
-
})
|
|
820
|
+
byCluster.forEach((list) => {
|
|
821
|
+
total += list.length
|
|
822
|
+
})
|
|
839
823
|
|
|
840
824
|
if (total === 0 || total > PIECE_BUDGET) return this._revealPieceHidden()
|
|
841
825
|
|
|
@@ -862,10 +846,7 @@ export default class MorphTypeChange {
|
|
|
862
846
|
if (!box || !entry) {
|
|
863
847
|
// No outgoing mark stood for this cluster (an entering series): the
|
|
864
848
|
// dots have nothing to come out of, so just show them.
|
|
865
|
-
dots.forEach((d) =>
|
|
866
|
-
d.el.removeAttribute('opacity')
|
|
867
|
-
d.el.removeAttribute('data-piece-hidden')
|
|
868
|
-
})
|
|
849
|
+
dots.forEach((d) => reveal(d.el))
|
|
869
850
|
return
|
|
870
851
|
}
|
|
871
852
|
|
|
@@ -896,8 +877,10 @@ export default class MorphTypeChange {
|
|
|
896
877
|
const cell = cells[k]
|
|
897
878
|
const dot = ordered[k]
|
|
898
879
|
const el = doc.createElementNS('http://www.w3.org/2000/svg', 'rect')
|
|
899
|
-
// Which cluster this piece serves;
|
|
880
|
+
// Which cluster and dot this piece serves; retire and tests key on
|
|
881
|
+
// them.
|
|
900
882
|
el.setAttribute('data-i', String(i))
|
|
883
|
+
el.setAttribute('data-key', dot.el.getAttribute('data-key'))
|
|
901
884
|
el.setAttribute('x', String(cell.x))
|
|
902
885
|
el.setAttribute('y', String(cell.y))
|
|
903
886
|
el.setAttribute('width', String(cell.width))
|
|
@@ -928,13 +911,39 @@ export default class MorphTypeChange {
|
|
|
928
911
|
this._runPieces(pieces, (piece) => {
|
|
929
912
|
// The dot appears exactly where its piece just was, then the piece goes:
|
|
930
913
|
// a swap, not a fade.
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
dotEl.removeAttribute('data-piece-hidden')
|
|
934
|
-
if (piece.el.parentNode) piece.el.parentNode.removeChild(piece.el)
|
|
914
|
+
reveal(piece.meta.dotEl)
|
|
915
|
+
piece.el.remove()
|
|
935
916
|
})
|
|
936
917
|
}
|
|
937
918
|
|
|
919
|
+
/**
|
|
920
|
+
* The unit chart's dots, grouped by cluster index into `into`. Circles
|
|
921
|
+
* carry cx/cy; square and image dots carry their top-left x/y.
|
|
922
|
+
*
|
|
923
|
+
* @param {any} baseEl
|
|
924
|
+
* @param {Map<number, any[]>} into - each dot as {el, x, y, r, fill}
|
|
925
|
+
*/
|
|
926
|
+
_readUnitDots(baseEl, into) {
|
|
927
|
+
baseEl
|
|
928
|
+
.querySelectorAll('.apexcharts-unit-area')
|
|
929
|
+
.forEach((/** @type {any} */ dot) => {
|
|
930
|
+
const i = parseInt(dot.getAttribute('i') ?? '', 10)
|
|
931
|
+
if (isNaN(i)) return
|
|
932
|
+
const num = (/** @type {string} */ a) => parseFloat(dot.getAttribute(a))
|
|
933
|
+
const cx = dot.getAttribute('cx')
|
|
934
|
+
const w = num('width') || 0
|
|
935
|
+
const h = num('height') || 0
|
|
936
|
+
const x = cx != null ? parseFloat(cx) : num('x') + w / 2
|
|
937
|
+
const y = cx != null ? num('cy') : num('y') + h / 2
|
|
938
|
+
const r = (cx != null ? num('r') : Math.max(w, h) / 2) || 3
|
|
939
|
+
if (!isFinite(x) || !isFinite(y)) return
|
|
940
|
+
let list = into.get(i)
|
|
941
|
+
if (!list) into.set(i, (list = []))
|
|
942
|
+
list.push({ el: dot, x, y, r, fill: dot.getAttribute('fill') })
|
|
943
|
+
})
|
|
944
|
+
return into
|
|
945
|
+
}
|
|
946
|
+
|
|
938
947
|
/**
|
|
939
948
|
* objects -> mark. Each captured outgoing dot flies to one cell of the
|
|
940
949
|
* incoming mark, squaring off and blending towards the mark's fill; the
|
|
@@ -975,45 +984,31 @@ export default class MorphTypeChange {
|
|
|
975
984
|
|
|
976
985
|
for (let k = 0; k < clusterIdx.length; k++) {
|
|
977
986
|
const dots = /** @type {any[]} */ (snap.sourceDots.get(clusterIdx[k]))
|
|
978
|
-
const key = snap.keyOrder[k]
|
|
979
|
-
const target = key ? targets.get(key) : null
|
|
980
|
-
|
|
987
|
+
const key = snap.keyOrder[clusterIdx[k]]
|
|
988
|
+
const target = /** @type {any} */ (key ? targets.get(key) : null)
|
|
989
|
+
// The mark's final geometry, straight off its (hidden) elements. A
|
|
990
|
+
// boxPlot is more than one path per mark, so it is measured and probed
|
|
991
|
+
// as one; a radial mark carries the final path the renderer stamped,
|
|
992
|
+
// since its live `d` is still wherever its own animation left it.
|
|
993
|
+
const d = target && this._markD(target)
|
|
994
|
+
const b = d && this._pathBBox(d)
|
|
995
|
+
if (!b || !dots || !dots.length) {
|
|
981
996
|
// A mark with no incoming dots (or dots with no mark) has no pieces;
|
|
982
997
|
// whatever was hidden for it must still show.
|
|
983
|
-
if (target)
|
|
984
|
-
target.els.forEach((/** @type {any} */ el) => {
|
|
985
|
-
el.removeAttribute('opacity')
|
|
986
|
-
el.removeAttribute('data-piece-hidden')
|
|
987
|
-
})
|
|
988
|
-
}
|
|
998
|
+
if (target) target.els.forEach(reveal)
|
|
989
999
|
continue
|
|
990
1000
|
}
|
|
1001
|
+
const bbox = { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY }
|
|
991
1002
|
|
|
992
1003
|
const markFill =
|
|
993
1004
|
target.fill && target.fill.indexOf('url(') !== 0
|
|
994
1005
|
? target.fill
|
|
995
1006
|
: this.w.globals.colors?.[target.realIndex] || dots[0].fill
|
|
996
1007
|
|
|
997
|
-
|
|
998
|
-
if (shapedTarget) {
|
|
999
|
-
// The mark's final geometry, straight off its (hidden) elements. A
|
|
1000
|
-
// boxPlot is more than one path per mark, so probe them as one; a
|
|
1001
|
-
// radial mark carries the final path the renderer stamped, since its
|
|
1002
|
-
// live `d` is still wherever its own animation left it.
|
|
1003
|
-
const d =
|
|
1004
|
-
target.d ||
|
|
1005
|
-
target.els
|
|
1006
|
-
.map(
|
|
1007
|
-
(/** @type {any} */ p) =>
|
|
1008
|
-
p.getAttribute('pathTo') || p.getAttribute('d'),
|
|
1009
|
-
)
|
|
1010
|
-
.filter(Boolean)
|
|
1011
|
-
.join(' ')
|
|
1012
|
-
if (d) prober = this._makeExtentProber(d, target.bbox, layer)
|
|
1013
|
-
}
|
|
1008
|
+
const prober = shapedTarget ? this._makeExtentProber(d, bbox, layer) : null
|
|
1014
1009
|
const divided = prober
|
|
1015
|
-
? gridDivideShape(
|
|
1016
|
-
: gridDivideRect(
|
|
1010
|
+
? gridDivideShape(bbox, dots.length, prober.intervalsAt)
|
|
1011
|
+
: gridDivideRect(bbox, dots.length)
|
|
1017
1012
|
if (prober) prober.dispose()
|
|
1018
1013
|
|
|
1019
1014
|
const cells = sortByHilbert(divided, (c) => [
|
|
@@ -1023,9 +1018,14 @@ export default class MorphTypeChange {
|
|
|
1023
1018
|
const ordered = sortByHilbert(dots, (d) => [d.x, d.y])
|
|
1024
1019
|
|
|
1025
1020
|
// Landed-piece bookkeeping: the mark reveals when ALL of its pieces are
|
|
1026
|
-
// down, and its tiles
|
|
1027
|
-
// moment it becomes the solid
|
|
1028
|
-
|
|
1021
|
+
// down, and its tiles (grouped, so retire can measure the mosaic) leave
|
|
1022
|
+
// together, so the mosaic holds until the moment it becomes the solid
|
|
1023
|
+
// mark.
|
|
1024
|
+
const markState = {
|
|
1025
|
+
remaining: ordered.length,
|
|
1026
|
+
els: target.els,
|
|
1027
|
+
g: layer.appendChild(doc.createElementNS('http://www.w3.org/2000/svg', 'g')),
|
|
1028
|
+
}
|
|
1029
1029
|
|
|
1030
1030
|
for (let m = 0; m < ordered.length; m++) {
|
|
1031
1031
|
const dot = ordered[m]
|
|
@@ -1041,8 +1041,7 @@ export default class MorphTypeChange {
|
|
|
1041
1041
|
el.setAttribute('height', String(dot.r * 2))
|
|
1042
1042
|
el.setAttribute('rx', String(dot.r))
|
|
1043
1043
|
el.setAttribute('fill', String(dot.fill || markFill))
|
|
1044
|
-
|
|
1045
|
-
markState.tiles.push(el)
|
|
1044
|
+
markState.g.appendChild(el)
|
|
1046
1045
|
pieces.push({
|
|
1047
1046
|
el,
|
|
1048
1047
|
from: { x: fx, y: fy, width: dot.r * 2, height: dot.r * 2, rx: dot.r },
|
|
@@ -1061,17 +1060,31 @@ export default class MorphTypeChange {
|
|
|
1061
1060
|
const state = piece.meta.markState
|
|
1062
1061
|
state.remaining--
|
|
1063
1062
|
if (state.remaining === 0) {
|
|
1064
|
-
state.els.forEach(
|
|
1065
|
-
|
|
1066
|
-
el.removeAttribute('data-piece-hidden')
|
|
1067
|
-
})
|
|
1068
|
-
state.tiles.forEach((/** @type {any} */ t) => {
|
|
1069
|
-
if (t.parentNode) t.parentNode.removeChild(t)
|
|
1070
|
-
})
|
|
1063
|
+
state.els.forEach(reveal)
|
|
1064
|
+
state.g.remove()
|
|
1071
1065
|
}
|
|
1072
1066
|
})
|
|
1073
1067
|
}
|
|
1074
1068
|
|
|
1069
|
+
/**
|
|
1070
|
+
* A collected target mark's final geometry as one path: the radial `d` it
|
|
1071
|
+
* carries, else every path that makes it up, joined.
|
|
1072
|
+
* @param {{ d?: string, els: any[] }} target
|
|
1073
|
+
* @returns {string}
|
|
1074
|
+
*/
|
|
1075
|
+
_markD(target) {
|
|
1076
|
+
return (
|
|
1077
|
+
target.d ||
|
|
1078
|
+
target.els
|
|
1079
|
+
.map(
|
|
1080
|
+
(/** @type {any} */ p) =>
|
|
1081
|
+
p.getAttribute('pathTo') || p.getAttribute('d'),
|
|
1082
|
+
)
|
|
1083
|
+
.filter(Boolean)
|
|
1084
|
+
.join(' ')
|
|
1085
|
+
)
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1075
1088
|
/**
|
|
1076
1089
|
* Stagger and start a piece run. Delays sweep the (already spatially
|
|
1077
1090
|
* sorted) list front to back, and the last piece still lands within the
|
|
@@ -1091,6 +1104,8 @@ export default class MorphTypeChange {
|
|
|
1091
1104
|
pieces,
|
|
1092
1105
|
duration: flight,
|
|
1093
1106
|
onPieceDone,
|
|
1107
|
+
// destroy() mid-flight: stop writing to the detached pieces.
|
|
1108
|
+
alive: () => !this.w.globals.isDestroyed,
|
|
1094
1109
|
onAllDone: () => {
|
|
1095
1110
|
this._pieceCancel = null
|
|
1096
1111
|
this._cancelPieces()
|
|
@@ -1100,12 +1115,12 @@ export default class MorphTypeChange {
|
|
|
1100
1115
|
|
|
1101
1116
|
/**
|
|
1102
1117
|
* The incoming chart's marks, read live: every `path[pathTo]` grouped into
|
|
1103
|
-
* one mark per (realIndex, j)
|
|
1104
|
-
*
|
|
1105
|
-
*
|
|
1118
|
+
* one mark per (realIndex, j); _markD reads its final geometry. Bar marks
|
|
1119
|
+
* are one path each; summary marks (boxPlot, violin) may be several,
|
|
1120
|
+
* walked exactly like the capture branch walks the outgoing ones.
|
|
1106
1121
|
*
|
|
1107
1122
|
* @param {string} toType
|
|
1108
|
-
* @returns {Map<string, { realIndex: number,
|
|
1123
|
+
* @returns {Map<string, { realIndex: number, fill: string|null, els: any[], d?: string }>}
|
|
1109
1124
|
*/
|
|
1110
1125
|
_collectTargetMarks(toType) {
|
|
1111
1126
|
/** @type {any} */
|
|
@@ -1124,22 +1139,9 @@ export default class MorphTypeChange {
|
|
|
1124
1139
|
.querySelectorAll('.apexcharts-pie-series .apexcharts-pie-area')
|
|
1125
1140
|
.forEach((/** @type {any} */ p, /** @type {number} */ i) => {
|
|
1126
1141
|
const d = p.getAttribute('data:pathFinal') || p.getAttribute('d')
|
|
1127
|
-
if (
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
out.set(`${i}:0`, {
|
|
1131
|
-
realIndex: i,
|
|
1132
|
-
j: 0,
|
|
1133
|
-
d,
|
|
1134
|
-
bbox: {
|
|
1135
|
-
x: box.minX,
|
|
1136
|
-
y: box.minY,
|
|
1137
|
-
width: box.maxX - box.minX,
|
|
1138
|
-
height: box.maxY - box.minY,
|
|
1139
|
-
},
|
|
1140
|
-
fill: p.getAttribute('fill'),
|
|
1141
|
-
els: [p],
|
|
1142
|
-
})
|
|
1142
|
+
if (d && d.trim()) {
|
|
1143
|
+
out.set(`${i}:0`, { realIndex: i, d, fill: p.getAttribute('fill'), els: [p] })
|
|
1144
|
+
}
|
|
1143
1145
|
})
|
|
1144
1146
|
return out
|
|
1145
1147
|
}
|
|
@@ -1163,36 +1165,10 @@ export default class MorphTypeChange {
|
|
|
1163
1165
|
// draw order, which is the same order the mapping was keyed in.
|
|
1164
1166
|
const jAttr = parseInt(p.getAttribute('j') ?? '', 10)
|
|
1165
1167
|
const j = isNaN(jAttr) ? order++ : jAttr
|
|
1166
|
-
const box = this._pathBBox(d)
|
|
1167
|
-
if (!box) return
|
|
1168
1168
|
const key = `${realIndex}:${j}`
|
|
1169
1169
|
const prev = out.get(key)
|
|
1170
|
-
if (prev)
|
|
1171
|
-
|
|
1172
|
-
prev.bbox = {
|
|
1173
|
-
x: Math.min(prev.bbox.x, box.minX),
|
|
1174
|
-
y: Math.min(prev.bbox.y, box.minY),
|
|
1175
|
-
width:
|
|
1176
|
-
Math.max(prev.bbox.x + prev.bbox.width, box.maxX) -
|
|
1177
|
-
Math.min(prev.bbox.x, box.minX),
|
|
1178
|
-
height:
|
|
1179
|
-
Math.max(prev.bbox.y + prev.bbox.height, box.maxY) -
|
|
1180
|
-
Math.min(prev.bbox.y, box.minY),
|
|
1181
|
-
}
|
|
1182
|
-
} else {
|
|
1183
|
-
out.set(key, {
|
|
1184
|
-
realIndex,
|
|
1185
|
-
j,
|
|
1186
|
-
bbox: {
|
|
1187
|
-
x: box.minX,
|
|
1188
|
-
y: box.minY,
|
|
1189
|
-
width: box.maxX - box.minX,
|
|
1190
|
-
height: box.maxY - box.minY,
|
|
1191
|
-
},
|
|
1192
|
-
fill: p.getAttribute('fill'),
|
|
1193
|
-
els: [p],
|
|
1194
|
-
})
|
|
1195
|
-
}
|
|
1170
|
+
if (prev) prev.els.push(p)
|
|
1171
|
+
else out.set(key, { realIndex, fill: p.getAttribute('fill'), els: [p] })
|
|
1196
1172
|
})
|
|
1197
1173
|
})
|
|
1198
1174
|
|
|
@@ -1238,7 +1214,9 @@ export default class MorphTypeChange {
|
|
|
1238
1214
|
'path[pathTo]:not(.apexcharts-highlight-part)',
|
|
1239
1215
|
)
|
|
1240
1216
|
paths.forEach((/** @type {Element} */ p, /** @type {number} */ j) => {
|
|
1241
|
-
|
|
1217
|
+
// The live shape, not where its own tween is heading: a type change
|
|
1218
|
+
// made mid-grow starts from the bar on screen.
|
|
1219
|
+
const d = p.getAttribute('d') || p.getAttribute('pathTo')
|
|
1242
1220
|
if (!d) return
|
|
1243
1221
|
captured.push({
|
|
1244
1222
|
realIndex,
|
|
@@ -1274,7 +1252,7 @@ export default class MorphTypeChange {
|
|
|
1274
1252
|
.forEach((/** @type {any} */ p) => {
|
|
1275
1253
|
const j = parseInt(p.getAttribute('j') ?? '', 10)
|
|
1276
1254
|
if (isNaN(j)) return
|
|
1277
|
-
const d = p.getAttribute('
|
|
1255
|
+
const d = p.getAttribute('d') || p.getAttribute('pathTo')
|
|
1278
1256
|
if (!d || !d.trim()) return
|
|
1279
1257
|
const group =
|
|
1280
1258
|
typeof p.closest === 'function' ? p.closest('.apexcharts-series') : null
|
|
@@ -1371,71 +1349,25 @@ export default class MorphTypeChange {
|
|
|
1371
1349
|
// cluster's dots actually sat and synthesise the rect they filled: the
|
|
1372
1350
|
// incoming mark then grows out of its own dot cloud, which is the mirror
|
|
1373
1351
|
// of the burst that brought the dots out of it.
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
const boxes = new Map()
|
|
1377
|
-
dots.forEach((/** @type {Element} */ dot) => {
|
|
1378
|
-
const i = parseInt(dot.getAttribute('i') ?? '', 10)
|
|
1379
|
-
if (isNaN(i)) return
|
|
1380
|
-
// Circles carry cx/cy; square / image dots carry their top-left x/y.
|
|
1381
|
-
const cxAttr = dot.getAttribute('cx')
|
|
1382
|
-
let x
|
|
1383
|
-
let y
|
|
1384
|
-
let r = 3
|
|
1385
|
-
if (cxAttr != null) {
|
|
1386
|
-
x = parseFloat(cxAttr)
|
|
1387
|
-
y = parseFloat(dot.getAttribute('cy') ?? '')
|
|
1388
|
-
r = parseFloat(dot.getAttribute('r') ?? '3') || 3
|
|
1389
|
-
} else {
|
|
1390
|
-
const wAttr = parseFloat(dot.getAttribute('width') ?? '0') || 0
|
|
1391
|
-
const hAttr = parseFloat(dot.getAttribute('height') ?? '0') || 0
|
|
1392
|
-
x = parseFloat(dot.getAttribute('x') ?? '') + wAttr / 2
|
|
1393
|
-
y = parseFloat(dot.getAttribute('y') ?? '') + hAttr / 2
|
|
1394
|
-
r = Math.max(wAttr, hAttr) / 2 || 3
|
|
1395
|
-
}
|
|
1396
|
-
if (!isFinite(x) || !isFinite(y)) return
|
|
1397
|
-
// The per-dot record, for the piece layer: when the target can be
|
|
1398
|
-
// tiled, each of these dots flies to its own cell of the incoming mark
|
|
1399
|
-
// instead of vanishing with the teardown.
|
|
1400
|
-
let list = unitDots.get(i)
|
|
1401
|
-
if (!list) {
|
|
1402
|
-
list = []
|
|
1403
|
-
unitDots.set(i, list)
|
|
1404
|
-
}
|
|
1405
|
-
list.push({ x, y, r, fill: dot.getAttribute('fill') })
|
|
1406
|
-
const box = boxes.get(i)
|
|
1407
|
-
if (!box) {
|
|
1408
|
-
boxes.set(i, {
|
|
1409
|
-
minX: x,
|
|
1410
|
-
minY: y,
|
|
1411
|
-
maxX: x,
|
|
1412
|
-
maxY: y,
|
|
1413
|
-
fill: dot.getAttribute('fill'),
|
|
1414
|
-
})
|
|
1415
|
-
return
|
|
1416
|
-
}
|
|
1417
|
-
if (x < box.minX) box.minX = x
|
|
1418
|
-
if (x > box.maxX) box.maxX = x
|
|
1419
|
-
if (y < box.minY) box.minY = y
|
|
1420
|
-
if (y > box.maxY) box.maxY = y
|
|
1421
|
-
})
|
|
1422
|
-
|
|
1423
|
-
Array.from(boxes.keys())
|
|
1352
|
+
this._readUnitDots(baseEl, unitDots)
|
|
1353
|
+
Array.from(unitDots.keys())
|
|
1424
1354
|
.sort((a, b) => a - b)
|
|
1425
1355
|
.forEach((i) => {
|
|
1426
|
-
const
|
|
1356
|
+
const list = /** @type {any[]} */ (unitDots.get(i))
|
|
1357
|
+
const xs = list.map((d) => d.x)
|
|
1358
|
+
const ys = list.map((d) => d.y)
|
|
1427
1359
|
// A single-dot cluster has a zero-area box; give it the width of one
|
|
1428
1360
|
// dot so the incoming mark has something to grow from.
|
|
1429
1361
|
const pad = 2
|
|
1430
|
-
const x1 =
|
|
1431
|
-
const y1 =
|
|
1432
|
-
const x2 =
|
|
1433
|
-
const y2 =
|
|
1362
|
+
const x1 = Math.min(...xs) - pad
|
|
1363
|
+
const y1 = Math.min(...ys) - pad
|
|
1364
|
+
const x2 = Math.max(...xs) + pad
|
|
1365
|
+
const y2 = Math.max(...ys) + pad
|
|
1434
1366
|
captured.push({
|
|
1435
1367
|
realIndex: i,
|
|
1436
1368
|
j: 0,
|
|
1437
1369
|
d: `M ${x1} ${y1} L ${x2} ${y1} L ${x2} ${y2} L ${x1} ${y2} Z`,
|
|
1438
|
-
fill:
|
|
1370
|
+
fill: list[0].fill,
|
|
1439
1371
|
})
|
|
1440
1372
|
})
|
|
1441
1373
|
} else if (fam === 'radial') {
|
|
@@ -1449,9 +1381,10 @@ export default class MorphTypeChange {
|
|
|
1449
1381
|
// So we transform each captured arc into an equivalent closed
|
|
1450
1382
|
// donut-segment whose FILLED rendering visually matches the
|
|
1451
1383
|
// outgoing radialBar's stroked appearance.
|
|
1452
|
-
|
|
1453
|
-
const
|
|
1454
|
-
|
|
1384
|
+
// The centre the rings were drawn around (the band's, see #4875).
|
|
1385
|
+
const cg = this.w.globals.circleGeometry
|
|
1386
|
+
const centerX = cg ? cg.cx : this.w.layout.gridWidth / 2
|
|
1387
|
+
const centerY = cg ? cg.cy : this.w.layout.gridHeight / 2
|
|
1455
1388
|
const rings = baseEl.querySelectorAll(
|
|
1456
1389
|
'.apexcharts-radial-series .apexcharts-radialbar-area',
|
|
1457
1390
|
)
|
|
@@ -1682,6 +1615,11 @@ export default class MorphTypeChange {
|
|
|
1682
1615
|
}
|
|
1683
1616
|
}
|
|
1684
1617
|
|
|
1618
|
+
// A unit cluster pairs by its own index: a cluster that drew no dots has
|
|
1619
|
+
// no captured mark, and pairing by rank would shift every later cluster
|
|
1620
|
+
// onto its neighbour's mark.
|
|
1621
|
+
const fromUnit = familyOf(_fromType) === 'unit'
|
|
1622
|
+
|
|
1685
1623
|
if (tf === 'radial' || tf === 'unit' || tf === 'partition') {
|
|
1686
1624
|
// pie / donut / polarArea / radialBar iterate i = 0..N-1 with j=0. unit
|
|
1687
1625
|
// clusters iterate the same way (one cluster per category), reading the
|
|
@@ -1689,37 +1627,52 @@ export default class MorphTypeChange {
|
|
|
1689
1627
|
// leaves have no (realIndex, j) grid at all and pair up by draw order,
|
|
1690
1628
|
// which this same index keying gives them (see getInitialPathAt).
|
|
1691
1629
|
flat.forEach((c, i) => {
|
|
1692
|
-
map.set(`${i}:0`, { d: c.d, fill: c.fill })
|
|
1630
|
+
map.set(`${fromUnit ? c.realIndex : i}:0`, { d: c.d, fill: c.fill })
|
|
1693
1631
|
})
|
|
1694
1632
|
return map
|
|
1695
1633
|
}
|
|
1696
1634
|
|
|
1697
1635
|
if (tf === 'bar' || tf === 'summary') {
|
|
1698
|
-
|
|
1699
|
-
// `{ data: number[] }` entry produces (realIndex=seriesIdx, j=k) tuples.
|
|
1700
|
-
// boxPlot and violin iterate the same grid through Bar's renderSeries,
|
|
1701
|
-
// so one branch serves both.
|
|
1702
|
-
/** @type {Array<{ realIndex: number, j: number }>} */
|
|
1703
|
-
const positions = []
|
|
1704
|
-
const series = Array.isArray(newSeries) ? newSeries : []
|
|
1705
|
-
series.forEach((/** @type {any} */ s, /** @type {number} */ seriesIdx) => {
|
|
1706
|
-
const data = s && Array.isArray(s.data) ? s.data : []
|
|
1707
|
-
for (let j = 0; j < data.length; j++) {
|
|
1708
|
-
positions.push({ realIndex: seriesIdx, j })
|
|
1709
|
-
}
|
|
1710
|
-
})
|
|
1636
|
+
const keys = this._targetKeys(tf, newSeries)
|
|
1711
1637
|
flat.forEach((c, i) => {
|
|
1712
|
-
const
|
|
1713
|
-
if (
|
|
1714
|
-
map.set(`${pos.realIndex}:${pos.j}`, { d: c.d, fill: c.fill })
|
|
1715
|
-
}
|
|
1638
|
+
const key = keys[fromUnit ? c.realIndex : i]
|
|
1639
|
+
if (key) map.set(key, { d: c.d, fill: c.fill })
|
|
1716
1640
|
})
|
|
1717
|
-
return map
|
|
1718
1641
|
}
|
|
1719
1642
|
|
|
1720
1643
|
return map
|
|
1721
1644
|
}
|
|
1722
1645
|
|
|
1646
|
+
/**
|
|
1647
|
+
* The incoming chart's mark keys `${realIndex}:${j}`, in draw order. A
|
|
1648
|
+
* radial chart draws one slice per value, and the single-series object
|
|
1649
|
+
* form `[{ data: [...] }]` expands to one slice per datum. A bar chart
|
|
1650
|
+
* (boxPlot and violin render through it) draws one mark per datum of each
|
|
1651
|
+
* series.
|
|
1652
|
+
*
|
|
1653
|
+
* @param {string|null} tf - the incoming family
|
|
1654
|
+
* @param {any} newSeries
|
|
1655
|
+
* @returns {string[]}
|
|
1656
|
+
*/
|
|
1657
|
+
_targetKeys(tf, newSeries) {
|
|
1658
|
+
/** @type {string[]} */
|
|
1659
|
+
const keys = []
|
|
1660
|
+
const series = Array.isArray(newSeries) ? newSeries : []
|
|
1661
|
+
if (tf === 'radial') {
|
|
1662
|
+
const n =
|
|
1663
|
+
series.length === 1 && Array.isArray(series[0]?.data)
|
|
1664
|
+
? series[0].data.length
|
|
1665
|
+
: series.length
|
|
1666
|
+
for (let i = 0; i < n; i++) keys.push(`${i}:0`)
|
|
1667
|
+
} else {
|
|
1668
|
+
series.forEach((/** @type {any} */ s, /** @type {number} */ si) => {
|
|
1669
|
+
const data = s && Array.isArray(s.data) ? s.data : []
|
|
1670
|
+
for (let j = 0; j < data.length; j++) keys.push(`${si}:${j}`)
|
|
1671
|
+
})
|
|
1672
|
+
}
|
|
1673
|
+
return keys
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1723
1676
|
isActive() {
|
|
1724
1677
|
return this._snapshot !== null
|
|
1725
1678
|
}
|
|
@@ -1930,47 +1883,71 @@ export default class MorphTypeChange {
|
|
|
1930
1883
|
* @returns {{ minX:number, minY:number, maxX:number, maxY:number } | null}
|
|
1931
1884
|
*/
|
|
1932
1885
|
_pathBBox(d) {
|
|
1933
|
-
const commands = parsePath(d)
|
|
1934
1886
|
let minX = Infinity
|
|
1935
1887
|
let minY = Infinity
|
|
1936
1888
|
let maxX = -Infinity
|
|
1937
1889
|
let maxY = -Infinity
|
|
1938
|
-
|
|
1939
|
-
|
|
1890
|
+
// The current point, and where the open subpath started (Z returns there).
|
|
1891
|
+
let px = 0
|
|
1892
|
+
let py = 0
|
|
1893
|
+
let sx = 0
|
|
1894
|
+
let sy = 0
|
|
1895
|
+
const add = (/** @type {number} */ x, /** @type {number} */ y) => {
|
|
1896
|
+
if (!isFinite(x) || !isFinite(y)) return
|
|
1897
|
+
if (x < minX) minX = x
|
|
1898
|
+
if (x > maxX) maxX = x
|
|
1899
|
+
if (y < minY) minY = y
|
|
1900
|
+
if (y > maxY) maxY = y
|
|
1901
|
+
}
|
|
1902
|
+
parsePath(d).forEach(/** @param {any[]} c */ (c) => {
|
|
1940
1903
|
const cmd = c[0]
|
|
1941
|
-
if (cmd === 'Z')
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1904
|
+
if (cmd === 'Z') {
|
|
1905
|
+
px = sx
|
|
1906
|
+
py = sy
|
|
1907
|
+
return
|
|
1908
|
+
}
|
|
1909
|
+
const n = c.length
|
|
1910
|
+
const x = cmd === 'H' ? c[1] : cmd === 'V' ? px : c[n - 2]
|
|
1911
|
+
const y = cmd === 'H' ? py : cmd === 'V' ? c[1] : c[n - 1]
|
|
1912
|
+
if (cmd === 'A') {
|
|
1913
|
+
// An arc bulges past its end points: add each axis extreme its sweep
|
|
1914
|
+
// passes, or a half-pie slice would measure zero wide. Every arc the
|
|
1915
|
+
// library draws is circular and unrotated, so the centre is SVG's
|
|
1916
|
+
// endpoint-to-centre conversion with rx = ry (a radius too short for
|
|
1917
|
+
// the chord grows to fit, as the spec says).
|
|
1918
|
+
if (c[1]) {
|
|
1919
|
+
const hx = (px - x) / 2
|
|
1920
|
+
const hy = (py - y) / 2
|
|
1921
|
+
const f =
|
|
1922
|
+
(c[4] === c[5] ? -1 : 1) *
|
|
1923
|
+
Math.sqrt(Math.max(0, (c[1] * c[1]) / (hx * hx + hy * hy) - 1))
|
|
1924
|
+
const cx = px - hx + f * hy
|
|
1925
|
+
const cy = py - hy - f * hx
|
|
1926
|
+
const r = Math.hypot(px - cx, py - cy)
|
|
1927
|
+
const a0 = Math.atan2(py - cy, px - cx)
|
|
1928
|
+
const TAU = 2 * Math.PI
|
|
1929
|
+
let sweep = Math.atan2(y - cy, x - cx) - a0
|
|
1930
|
+
if (c[5] && sweep < 0) sweep += TAU
|
|
1931
|
+
else if (!c[5] && sweep > 0) sweep -= TAU
|
|
1932
|
+
for (let a = 0; a < TAU; a += Math.PI / 2) {
|
|
1933
|
+
// How far along the sweep's own direction this extreme lies.
|
|
1934
|
+
const t = ((((sweep > 0 ? a - a0 : a0 - a) % TAU) + TAU) % TAU)
|
|
1935
|
+
if (t <= Math.abs(sweep)) add(cx + r * Math.cos(a), cy + r * Math.sin(a))
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
} else if (cmd !== 'H' && cmd !== 'V') {
|
|
1939
|
+
// Control points are included: a superset is fine for a footprint.
|
|
1940
|
+
for (let k = 1; k + 1 < n; k += 2) add(c[k], c[k + 1])
|
|
1941
|
+
}
|
|
1942
|
+
add(x, y)
|
|
1943
|
+
px = x
|
|
1944
|
+
py = y
|
|
1945
|
+
if (cmd === 'M') {
|
|
1946
|
+
sx = x
|
|
1947
|
+
sy = y
|
|
1951
1948
|
}
|
|
1952
|
-
pairs.forEach(([x, y]) => {
|
|
1953
|
-
if (!isFinite(x) || !isFinite(y)) return
|
|
1954
|
-
seen = true
|
|
1955
|
-
if (x < minX) minX = x
|
|
1956
|
-
if (x > maxX) maxX = x
|
|
1957
|
-
if (y < minY) minY = y
|
|
1958
|
-
if (y > maxY) maxY = y
|
|
1959
|
-
})
|
|
1960
1949
|
})
|
|
1961
|
-
|
|
1962
|
-
return { minX, minY, maxX, maxY }
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
/**
|
|
1966
|
-
* @param {number} realIndex
|
|
1967
|
-
* @param {number} j
|
|
1968
|
-
* @returns {string | null}
|
|
1969
|
-
*/
|
|
1970
|
-
getInitialFillFor(realIndex, j) {
|
|
1971
|
-
if (!this._snapshot) return null
|
|
1972
|
-
const entry = this._snapshot.mapping.get(`${realIndex}:${j}`)
|
|
1973
|
-
return entry ? entry.fill : null
|
|
1950
|
+
return minX > maxX ? null : { minX, minY, maxX, maxY }
|
|
1974
1951
|
}
|
|
1975
1952
|
|
|
1976
1953
|
/** @returns {number} */
|
|
@@ -1996,7 +1973,9 @@ export default class MorphTypeChange {
|
|
|
1996
1973
|
this._shown = true
|
|
1997
1974
|
/** @type {any} */
|
|
1998
1975
|
const baseEl = this.w.globals.dom?.baseEl
|
|
1999
|
-
|
|
1976
|
+
// A mosaic handed on by retire is an update, not a type change: its
|
|
1977
|
+
// chrome stays put and there is nothing outgoing left to show.
|
|
1978
|
+
if (!baseEl || this._snapshot.resume) return
|
|
2000
1979
|
|
|
2001
1980
|
// The incoming chart exists now, so the outgoing marks captured before
|
|
2002
1981
|
// the teardown finally have something to leave over. Pieces when the pair
|
|
@@ -2007,37 +1986,30 @@ export default class MorphTypeChange {
|
|
|
2007
1986
|
else this._mountGhost()
|
|
2008
1987
|
|
|
2009
1988
|
const speed = this.getSpeed()
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
})
|
|
2030
|
-
setTimeout(() => {
|
|
2031
|
-
el.style.transition = ''
|
|
2032
|
-
el.style.opacity = ''
|
|
2033
|
-
}, speed + 80)
|
|
2034
|
-
})
|
|
2035
|
-
})
|
|
1989
|
+
// The grid group carries its gridlines, so they are not listed again: a
|
|
1990
|
+
// nested fade multiplies, and the grid would trail the axes.
|
|
1991
|
+
/** @type {any[]} */
|
|
1992
|
+
const chrome = Array.from(
|
|
1993
|
+
baseEl.querySelectorAll(
|
|
1994
|
+
'.apexcharts-xaxis,.apexcharts-yaxis,.apexcharts-grid,.apexcharts-legend,.apexcharts-title-text,.apexcharts-subtitle-text',
|
|
1995
|
+
),
|
|
1996
|
+
).filter((/** @type {any} */ el) => el.style)
|
|
1997
|
+
/** @param {string} opacity @param {string} [transition] */
|
|
1998
|
+
const set = (opacity, transition) =>
|
|
1999
|
+
chrome.forEach((el) => {
|
|
2000
|
+
el.style.opacity = opacity
|
|
2001
|
+
if (transition != null) el.style.transition = transition
|
|
2002
|
+
})
|
|
2003
|
+
set('0', `opacity ${speed}ms ease-out`)
|
|
2004
|
+
// One frame and one timer for the whole set; a destroyed chart skips both.
|
|
2005
|
+
const dead = () => this.w.globals.isDestroyed
|
|
2006
|
+
BrowserAPIs.requestAnimationFrame(() => dead() || set('1'))
|
|
2007
|
+
setTimeout(() => dead() || set('', ''), speed + 80)
|
|
2036
2008
|
|
|
2037
2009
|
// Not a newer morph's: one started meanwhile cleans up after itself.
|
|
2038
2010
|
const snap = this._snapshot
|
|
2039
2011
|
setTimeout(() => {
|
|
2040
|
-
if (!this._snapshot || this._snapshot === snap) this.cleanup()
|
|
2012
|
+
if (!dead() && (!this._snapshot || this._snapshot === snap)) this.cleanup()
|
|
2041
2013
|
}, speed + 100)
|
|
2042
2014
|
}
|
|
2043
2015
|
|
|
@@ -2045,18 +2017,62 @@ export default class MorphTypeChange {
|
|
|
2045
2017
|
* A render after the one a morph was captured for (an update while the
|
|
2046
2018
|
* morph is still finishing, or just after) must not start its marks from
|
|
2047
2019
|
* the old chart's shapes again: it starts from the screen, as any update
|
|
2048
|
-
* does. The morph's
|
|
2049
|
-
*
|
|
2050
|
-
*
|
|
2020
|
+
* does. The morph's pieces go with it, as the new render replaces what
|
|
2021
|
+
* they were leaving over, but where they are is handed on first: a piece
|
|
2022
|
+
* flying to a dot becomes that dot's previous slot, so the unit chart's
|
|
2023
|
+
* own keyed update carries it on, and the tiles of a mosaic still
|
|
2024
|
+
* assembling become its mark's start shape, their bounding box, through
|
|
2025
|
+
* the morph's snapshot, kept for that one render. A ghost already fading
|
|
2026
|
+
* is left to finish its own fade (its timer removes it) rather than vanish
|
|
2027
|
+
* mid-way. A no-op until that render has mounted, so a second update in
|
|
2028
|
+
* the same tick still morphs.
|
|
2051
2029
|
*/
|
|
2052
2030
|
retire() {
|
|
2053
|
-
|
|
2031
|
+
const snap = this._snapshot
|
|
2032
|
+
if (!snap || !this._shown) return
|
|
2033
|
+
const layer = this._pieceLayer
|
|
2034
|
+
// Pieces flying to dots: the unit chart reads them off itself.
|
|
2035
|
+
this.ctx._unitPieces = snap.pieceOut && layer
|
|
2036
|
+
// Mosaics still assembling (a mark's tiles share a group), each measured
|
|
2037
|
+
// as one box.
|
|
2038
|
+
/** @type {Map<string, any>} */
|
|
2039
|
+
const mapping = new Map()
|
|
2040
|
+
layer?.querySelectorAll('g').forEach((/** @type {any} */ g) => {
|
|
2041
|
+
const r = g.firstChild && g.getBBox()
|
|
2042
|
+
if (r) {
|
|
2043
|
+
mapping.set(g.firstChild.getAttribute('data-key'), {
|
|
2044
|
+
d: `M${r.x} ${r.y}H${r.x + r.width}V${r.y + r.height}H${r.x}Z`,
|
|
2045
|
+
})
|
|
2046
|
+
}
|
|
2047
|
+
})
|
|
2048
|
+
this.cleanup(true)
|
|
2049
|
+
if (!mapping.size) return
|
|
2050
|
+
// Every other mark starts as itself, so all of them move on one clock,
|
|
2051
|
+
// and none from the capture of the still hidden marks (a boxPlot prefers
|
|
2052
|
+
// that capture to its start shape).
|
|
2053
|
+
this._collectTargetMarks(snap.toType).forEach((t, k) => {
|
|
2054
|
+
if (!mapping.has(k)) mapping.set(k, { d: this._markD(t) })
|
|
2055
|
+
})
|
|
2056
|
+
this.w.globals.previousPaths = []
|
|
2057
|
+
// Kept for the next render, in this layout's plot space. Over once that
|
|
2058
|
+
// render is on screen (the fast update path never calls
|
|
2059
|
+
// applyChromeFade), and cleared by the morph's own timer.
|
|
2060
|
+
this._snapshot = Object.assign(snap, {
|
|
2061
|
+
mapping,
|
|
2062
|
+
pieceIn: false,
|
|
2063
|
+
resume: true,
|
|
2064
|
+
oldLayout: { ...this.w.layout },
|
|
2065
|
+
})
|
|
2066
|
+
BrowserAPIs.requestAnimationFrame(() => {
|
|
2067
|
+
if (this._snapshot === snap) this._shown = true
|
|
2068
|
+
})
|
|
2054
2069
|
}
|
|
2055
2070
|
|
|
2056
|
-
|
|
2071
|
+
/** @param {boolean} [keepGhost] leave a mounted ghost to its own timer */
|
|
2072
|
+
cleanup(keepGhost) {
|
|
2057
2073
|
this._snapshot = null
|
|
2058
2074
|
this._shown = false
|
|
2059
|
-
this._removeGhost()
|
|
2075
|
+
if (!keepGhost) this._removeGhost()
|
|
2060
2076
|
// Belt and braces for the piece layer: normally it has already finished
|
|
2061
2077
|
// and detached itself, but a throttled tab can leave it mid-flight, and
|
|
2062
2078
|
// nothing hidden may survive the transition.
|