apexcharts 7.2.0 → 7.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/LICENSE +30 -11
- package/dist/apexcharts.common.js +2 -2
- package/dist/apexcharts.core.js +545 -463
- package/dist/apexcharts.core.min.js +2 -2
- package/dist/apexcharts.esm.js +1149 -801
- package/dist/apexcharts.js +684 -254
- package/dist/apexcharts.min.js +2 -2
- package/dist/apexcharts.ssr.common.js +2 -2
- package/dist/apexcharts.ssr.esm.js +684 -254
- package/dist/area.common.js +1 -1
- package/dist/area.esm.js +1 -1
- package/dist/bar.common.js +2 -2
- package/dist/bar.esm.js +20 -10
- package/dist/bar.js +2 -2
- package/dist/boxPlot.common.js +2 -2
- package/dist/boxPlot.esm.js +20 -10
- package/dist/bubble.common.js +1 -1
- package/dist/bubble.esm.js +1 -1
- package/dist/candlestick.common.js +2 -2
- package/dist/candlestick.esm.js +20 -10
- package/dist/candlestick.js +2 -2
- package/dist/column.common.js +2 -2
- package/dist/column.esm.js +20 -10
- package/dist/core.common.js +2 -2
- package/dist/core.esm.js +545 -463
- package/dist/donut.common.js +1 -1
- package/dist/donut.esm.js +1 -1
- package/dist/dumbbell.common.js +2 -2
- package/dist/dumbbell.esm.js +20 -10
- package/dist/features/all.common.js +2 -2
- package/dist/features/all.esm.js +364 -26
- package/dist/features/annotations.common.js +1 -1
- package/dist/features/annotations.esm.js +1 -1
- package/dist/features/annotations.js +1 -1
- 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 +1 -1
- package/dist/features/drilldown.esm.js +1 -1
- package/dist/features/drilldown.js +1 -1
- 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 +12 -14
- 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/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 +2 -2
- package/dist/features/keyboard.esm.js +14 -1
- package/dist/features/keyboard.js +2 -2
- package/dist/features/legend.common.js +1 -1
- package/dist/features/legend.esm.js +1 -1
- package/dist/features/legend.js +1 -1
- package/dist/features/link.common.js +1 -1
- package/dist/features/link.esm.js +38 -38
- 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 +1 -1
- package/dist/features/morph.esm.js +1 -1
- package/dist/features/morph.js +1 -1
- package/dist/features/perspectives.common.js +1 -1
- package/dist/features/perspectives.esm.js +11 -11
- package/dist/features/perspectives.js +1 -1
- package/dist/features/raincloud.common.js +1 -1
- package/dist/features/raincloud.esm.js +1 -1
- package/dist/features/raincloud.js +1 -1
- 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 +1 -1
- package/dist/features/stats.esm.js +1 -1
- package/dist/features/stats.js +1 -1
- package/dist/features/storyboard.common.js +1 -1
- package/dist/features/storyboard.esm.js +11 -11
- package/dist/features/storyboard.js +1 -1
- package/dist/features/streamgraph.common.js +1 -1
- package/dist/features/streamgraph.esm.js +1 -1
- package/dist/features/streamgraph.js +1 -1
- package/dist/features/toolbar.common.js +2 -2
- package/dist/features/toolbar.esm.js +172 -25
- package/dist/features/toolbar.js +2 -2
- package/dist/features/trellis.common.js +1 -1
- package/dist/features/trellis.esm.js +1 -1
- package/dist/features/trellis.js +1 -1
- package/dist/features/waterfall.common.js +1 -1
- package/dist/features/waterfall.esm.js +1 -1
- package/dist/features/waterfall.js +1 -1
- package/dist/features/weave.common.js +2 -2
- package/dist/features/weave.esm.js +180 -2
- package/dist/features/weave.js +2 -2
- package/dist/heatmap.common.js +1 -1
- package/dist/heatmap.esm.js +1 -1
- package/dist/heatmap.js +1 -1
- package/dist/histogram.common.js +2 -2
- package/dist/histogram.esm.js +20 -10
- package/dist/line.common.js +1 -1
- package/dist/line.esm.js +1 -1
- package/dist/line.js +1 -1
- 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 +1 -1
- package/dist/pie.esm.js +1 -1
- package/dist/pie.js +1 -1
- package/dist/polarArea.common.js +1 -1
- package/dist/polarArea.esm.js +1 -1
- package/dist/radar.common.js +1 -1
- package/dist/radar.esm.js +1 -1
- package/dist/radar.js +1 -1
- package/dist/radialBar.common.js +1 -1
- package/dist/radialBar.esm.js +1 -1
- package/dist/radialBar.js +1 -1
- package/dist/raincloud.common.js +2 -2
- package/dist/raincloud.esm.js +20 -10
- package/dist/rangeArea.common.js +1 -1
- package/dist/rangeArea.esm.js +1 -1
- package/dist/rangeBar.common.js +2 -2
- package/dist/rangeBar.esm.js +20 -10
- package/dist/scatter.common.js +1 -1
- package/dist/scatter.esm.js +1 -1
- package/dist/streamgraph.common.js +1 -1
- package/dist/streamgraph.esm.js +1 -1
- package/dist/sunburst.common.js +1 -1
- package/dist/sunburst.esm.js +1 -1
- package/dist/sunburst.js +1 -1
- package/dist/treemap.common.js +1 -1
- package/dist/treemap.esm.js +1 -1
- package/dist/treemap.js +1 -1
- package/dist/unit-shapes.common.js +1 -1
- package/dist/unit-shapes.esm.js +1 -1
- package/dist/unit-shapes.js +1 -1
- package/dist/unit.common.js +1 -1
- package/dist/unit.esm.js +79 -79
- package/dist/unit.js +1 -1
- package/dist/violin.common.js +2 -2
- package/dist/violin.esm.js +20 -10
- package/dist/violin.js +2 -2
- package/dist/waterfall.common.js +2 -2
- package/dist/waterfall.esm.js +20 -10
- package/package.json +2 -2
- package/src/apexcharts.js +39 -15
- package/src/charts/common/bar/Helpers.js +31 -12
- package/src/modules/Data.js +8 -2
- package/src/modules/Exports.js +14 -12
- package/src/modules/Formatters.js +24 -1
- package/src/modules/Range.js +28 -1
- package/src/modules/Toolbar.js +112 -2
- package/src/modules/ZoomPanSelection.js +85 -7
- package/src/modules/accessibility/KeyboardNavigation.js +14 -0
- package/src/modules/axes/YAxis.js +12 -15
- package/src/modules/helpers/UpdateHelpers.js +25 -8
- package/src/modules/settings/Globals.js +5 -10
- package/src/modules/settings/Options.js +15 -0
- package/src/modules/weave/PluginAPI.js +57 -1
- package/src/modules/weave/WeaveHost.js +148 -0
- package/src/ssr/DOMShim.js +50 -0
- package/src/types/internal.d.ts +1 -1
- package/src/utils/Utils.js +6 -9
- package/types/apexcharts.d.ts +17 -0
|
@@ -20,12 +20,22 @@
|
|
|
20
20
|
* v3 added `api.reserve()`, for a plugin that renders its own UI inside the
|
|
21
21
|
* chart's container and needs the chart to make room for it.
|
|
22
22
|
*
|
|
23
|
+
* v4 added `api.pointer()`, so a plugin can learn which data point a viewer is
|
|
24
|
+
* pointing at or has selected. The chart already computed that for its own
|
|
25
|
+
* tooltip and its `dataPoint*` events; before this a plugin either re-derived
|
|
26
|
+
* it from raw pixels or did without.
|
|
27
|
+
*
|
|
28
|
+
* v5 added `api.info.stroke`, the caller's own `stroke.dashArray`. That option
|
|
29
|
+
* is indexed by series position, so a plugin that wants its own derived series
|
|
30
|
+
* dashed must write the whole array; reporting the current value is what lets
|
|
31
|
+
* it put back what it found instead of flattening the caller's dashed lines.
|
|
32
|
+
*
|
|
23
33
|
* Feature-detect rather than bumping `apiVersion` unless the plugin genuinely
|
|
24
34
|
* cannot work without the new surface: a plugin declaring v3 is SKIPPED
|
|
25
35
|
* outright on a v2 host, so `apiVersion: 2` plus `typeof api.reserve ===
|
|
26
36
|
* 'function'` keeps one build working on both.
|
|
27
37
|
*/
|
|
28
|
-
export const WEAVE_API_VERSION =
|
|
38
|
+
export const WEAVE_API_VERSION = 5
|
|
29
39
|
|
|
30
40
|
/**
|
|
31
41
|
* Public chart methods safe to expose to plugins (each bound to ctx). Excludes
|
|
@@ -302,6 +312,21 @@ export function buildPluginAPI(host, record) {
|
|
|
302
312
|
? w.config.dataLabels.enabledOnSeries.slice()
|
|
303
313
|
: null,
|
|
304
314
|
}),
|
|
315
|
+
// The caller's own dashing, reported for the same reason and against
|
|
316
|
+
// the same trap (v5). `stroke.dashArray` is indexed by series position
|
|
317
|
+
// with no per-series escape hatch, so a plugin that wants ITS OWN
|
|
318
|
+
// computed series dashed has to write the whole array, and writing one
|
|
319
|
+
// without knowing what was there discards the caller's dashed lines
|
|
320
|
+
// with nothing to restore them from.
|
|
321
|
+
//
|
|
322
|
+
// A scalar applies to every series and an array is per series. There is
|
|
323
|
+
// no "unset" to report: the option defaults to 0, and 0 already means
|
|
324
|
+
// no dashing, so restoring it restores exactly what was there.
|
|
325
|
+
stroke: Object.freeze({
|
|
326
|
+
dashArray: Array.isArray(w.config.stroke && w.config.stroke.dashArray)
|
|
327
|
+
? w.config.stroke.dashArray.slice()
|
|
328
|
+
: (w.config.stroke && w.config.stroke.dashArray) || 0,
|
|
329
|
+
}),
|
|
305
330
|
})
|
|
306
331
|
},
|
|
307
332
|
|
|
@@ -372,6 +397,37 @@ export function buildPluginAPI(host, record) {
|
|
|
372
397
|
return api
|
|
373
398
|
},
|
|
374
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Subscribe to the data point a viewer is pointing at.
|
|
402
|
+
*
|
|
403
|
+
* The chart already knows this: it resolves the series and point under the
|
|
404
|
+
* pointer for its own tooltip and fires `dataPointMouseEnter`,
|
|
405
|
+
* `dataPointMouseLeave` and `dataPointSelection` for the caller. This
|
|
406
|
+
* forwards the same three, so a plugin gets the host's answer rather than
|
|
407
|
+
* hit-testing the SVG itself and disagreeing with the tooltip.
|
|
408
|
+
*
|
|
409
|
+
* The payload is normalised rather than the chart's own argument list,
|
|
410
|
+
* which passes `w`. A plugin must not receive `w`, and the three things a
|
|
411
|
+
* plugin actually wants (which series, which point, what the point is
|
|
412
|
+
* called) are exactly what the chart has already resolved.
|
|
413
|
+
*
|
|
414
|
+
* `category` is the resolved display label, the same string `api.categories`
|
|
415
|
+
* carries, because a plugin coordinating two charts keys on the label
|
|
416
|
+
* rather than on an index that means something different on each chart.
|
|
417
|
+
*
|
|
418
|
+
* Nothing here gives a plugin the ability to intercept or cancel: the
|
|
419
|
+
* chart's own tooltip, selection state and caller events are unaffected,
|
|
420
|
+
* and a handler that throws is contained rather than allowed to break the
|
|
421
|
+
* interaction it was watching.
|
|
422
|
+
*
|
|
423
|
+
* @param {(e: {type: 'enter'|'leave'|'select', seriesIndex: number, dataPointIndex: number, category: string|undefined, seriesName: string|undefined, selected: boolean|undefined}) => void} fn
|
|
424
|
+
* @returns {() => void} unsubscribe
|
|
425
|
+
* @since Weave v4
|
|
426
|
+
*/
|
|
427
|
+
pointer(fn) {
|
|
428
|
+
return host._onPointer(record.def.name, fn)
|
|
429
|
+
},
|
|
430
|
+
|
|
375
431
|
// ── custom events out to the host app ──
|
|
376
432
|
/**
|
|
377
433
|
* Fires as `plugin:<pluginName>:<name>` on the chart's event bus. The
|
|
@@ -50,6 +50,10 @@ export default class WeaveHost {
|
|
|
50
50
|
this._reserved = null
|
|
51
51
|
/** @type {any} pending re-render for a changed reservation */
|
|
52
52
|
this._reserveTimer = null
|
|
53
|
+
/** @type {Map<string, Function[]>|null} plugin name -> pointer handlers */
|
|
54
|
+
this._pointerSubs = null
|
|
55
|
+
/** @type {Array<[string, Function]>|null} chart listeners to remove on teardown */
|
|
56
|
+
this._pointerWired = null
|
|
53
57
|
|
|
54
58
|
this._onUpdated = this._onUpdated.bind(this)
|
|
55
59
|
this._init()
|
|
@@ -385,6 +389,143 @@ export default class WeaveHost {
|
|
|
385
389
|
this._repairInitialSeries()
|
|
386
390
|
}
|
|
387
391
|
|
|
392
|
+
/**
|
|
393
|
+
* Subscribe a plugin to the data point the viewer is pointing at.
|
|
394
|
+
*
|
|
395
|
+
* Wired lazily: a chart whose plugins never ask pays nothing, and the chart
|
|
396
|
+
* fires these three events whether or not anyone is listening, so there is no
|
|
397
|
+
* cost to the chart either way.
|
|
398
|
+
*
|
|
399
|
+
* The chart's own handler signature is `(e, ctx, {seriesIndex,
|
|
400
|
+
* dataPointIndex, w})`. `w` stops here: what reaches a plugin is the
|
|
401
|
+
* normalised payload documented on `api.pointer`.
|
|
402
|
+
*
|
|
403
|
+
* @param {string} pluginName
|
|
404
|
+
* @param {Function} fn
|
|
405
|
+
* @returns {() => void} unsubscribe
|
|
406
|
+
*/
|
|
407
|
+
_onPointer(pluginName, fn) {
|
|
408
|
+
if (typeof fn !== 'function') return () => {}
|
|
409
|
+
if (!this._pointerSubs) this._pointerSubs = new Map()
|
|
410
|
+
const list = this._pointerSubs.get(pluginName) || []
|
|
411
|
+
list.push(fn)
|
|
412
|
+
this._pointerSubs.set(pluginName, list)
|
|
413
|
+
this._wirePointer()
|
|
414
|
+
return () => {
|
|
415
|
+
const current = this._pointerSubs && this._pointerSubs.get(pluginName)
|
|
416
|
+
if (!current) return
|
|
417
|
+
const i = current.indexOf(fn)
|
|
418
|
+
if (i > -1) current.splice(i, 1)
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Attach to the chart's own data point events, once. */
|
|
423
|
+
_wirePointer() {
|
|
424
|
+
if (this._pointerWired) return
|
|
425
|
+
if (!this.ctx || typeof this.ctx.addEventListener !== 'function') return
|
|
426
|
+
/** @type {Array<['enter'|'leave'|'select', string]>} */
|
|
427
|
+
const map = [
|
|
428
|
+
['enter', 'dataPointMouseEnter'],
|
|
429
|
+
['leave', 'dataPointMouseLeave'],
|
|
430
|
+
['select', 'dataPointSelection'],
|
|
431
|
+
]
|
|
432
|
+
this._pointerWired = []
|
|
433
|
+
for (const [type, name] of map) {
|
|
434
|
+
const handler = (/** @type {any} */ _e, /** @type {any} */ _ctx, /** @type {any} */ opts) => {
|
|
435
|
+
this._emitPointer(type, opts)
|
|
436
|
+
}
|
|
437
|
+
this.ctx.addEventListener(name, handler)
|
|
438
|
+
this._pointerWired.push([name, handler])
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Hand one pointer event to every subscribed plugin.
|
|
444
|
+
*
|
|
445
|
+
* A handler that throws is contained per plugin, on the same terms as every
|
|
446
|
+
* other plugin callback here: this runs inside the viewer's own hover, and a
|
|
447
|
+
* plugin breaking the chart's interaction would be the worst failure mode
|
|
448
|
+
* this facade has.
|
|
449
|
+
*
|
|
450
|
+
* @param {'enter'|'leave'|'select'} type
|
|
451
|
+
* @param {any} opts
|
|
452
|
+
*/
|
|
453
|
+
_emitPointer(type, opts) {
|
|
454
|
+
if (!this._pointerSubs || !this._pointerSubs.size) return
|
|
455
|
+
const seriesIndex = opts && typeof opts.seriesIndex === 'number' ? opts.seriesIndex : -1
|
|
456
|
+
const dataPointIndex =
|
|
457
|
+
opts && typeof opts.dataPointIndex === 'number' ? opts.dataPointIndex : -1
|
|
458
|
+
// The host's OWN category resolution, the same one `api.categories` reads.
|
|
459
|
+
// `globals.labels` is the raw slot list and on a category axis it is
|
|
460
|
+
// [1,2,3,4], so keying a cross-chart selection on it would key on a number
|
|
461
|
+
// that means something different on every chart. Measured: a chart with
|
|
462
|
+
// xaxis.categories ['Jan'..'Apr'] reported category 3 rather than 'Mar'.
|
|
463
|
+
const labels = this._categories() || []
|
|
464
|
+
const w = this.w
|
|
465
|
+
const config = (w && w.config && w.config.series) || []
|
|
466
|
+
const payload = {
|
|
467
|
+
type,
|
|
468
|
+
seriesIndex,
|
|
469
|
+
dataPointIndex,
|
|
470
|
+
category: dataPointIndex > -1 ? labels[dataPointIndex] : undefined,
|
|
471
|
+
// A pie/donut carries bare numbers in `series`, so there is no name to
|
|
472
|
+
// read: undefined rather than a guess, on the same terms as `category`.
|
|
473
|
+
seriesName: WeaveHost._seriesName(config, seriesIndex),
|
|
474
|
+
// Only meaningful on a select: the chart hands back its whole selection
|
|
475
|
+
// set, and what a plugin wants to know is whether THIS point is now in
|
|
476
|
+
// it, so a second click reads as a deselect rather than another select.
|
|
477
|
+
selected: type === 'select' ? WeaveHost._isSelected(opts, seriesIndex, dataPointIndex) : undefined,
|
|
478
|
+
}
|
|
479
|
+
for (const [name, handlers] of this._pointerSubs) {
|
|
480
|
+
for (const fn of handlers.slice()) {
|
|
481
|
+
try {
|
|
482
|
+
fn(payload)
|
|
483
|
+
} catch (e) {
|
|
484
|
+
console.warn(
|
|
485
|
+
'[apexcharts] plugin "' + name + '" threw in a pointer handler',
|
|
486
|
+
e
|
|
487
|
+
)
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* The configured name of series `i`, where there is one.
|
|
495
|
+
*
|
|
496
|
+
* @param {any[]} config
|
|
497
|
+
* @param {number} i
|
|
498
|
+
* @returns {string|undefined}
|
|
499
|
+
*/
|
|
500
|
+
static _seriesName(config, i) {
|
|
501
|
+
if (i < 0) return undefined
|
|
502
|
+
const entry = config[i]
|
|
503
|
+
if (!entry || typeof entry !== 'object') return undefined
|
|
504
|
+
return typeof entry.name === 'string' ? entry.name : undefined
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Whether the chart now counts this point as selected.
|
|
509
|
+
*
|
|
510
|
+
* `selectedDataPoints` is an array per series of the indexes selected in it.
|
|
511
|
+
* Absent on a chart type that does not carry point selection, in which case
|
|
512
|
+
* the answer is undefined rather than false: "not selected" and "selection
|
|
513
|
+
* does not apply here" are different, and a plugin keying on it should be
|
|
514
|
+
* able to tell.
|
|
515
|
+
*
|
|
516
|
+
* @param {any} opts
|
|
517
|
+
* @param {number} seriesIndex
|
|
518
|
+
* @param {number} dataPointIndex
|
|
519
|
+
* @returns {boolean|undefined}
|
|
520
|
+
*/
|
|
521
|
+
static _isSelected(opts, seriesIndex, dataPointIndex) {
|
|
522
|
+
const all = opts && opts.selectedDataPoints
|
|
523
|
+
if (!Array.isArray(all) || seriesIndex < 0) return undefined
|
|
524
|
+
const mine = all[seriesIndex]
|
|
525
|
+
if (!Array.isArray(mine)) return false
|
|
526
|
+
return mine.indexOf(dataPointIndex) > -1
|
|
527
|
+
}
|
|
528
|
+
|
|
388
529
|
/**
|
|
389
530
|
* Record a plugin's container reservation and re-render if it changed.
|
|
390
531
|
*
|
|
@@ -657,6 +798,13 @@ export default class WeaveHost {
|
|
|
657
798
|
this.active = []
|
|
658
799
|
this._derived = null
|
|
659
800
|
this._reserved = null
|
|
801
|
+
this._pointerSubs = null
|
|
802
|
+
if (this._pointerWired) {
|
|
803
|
+
for (const [name, handler] of this._pointerWired) {
|
|
804
|
+
this.ctx.removeEventListener && this.ctx.removeEventListener(name, handler)
|
|
805
|
+
}
|
|
806
|
+
this._pointerWired = null
|
|
807
|
+
}
|
|
660
808
|
// Nothing left to re-render for, and firing this after a destroy would
|
|
661
809
|
// call update() on a torn-down chart.
|
|
662
810
|
if (this._reserveTimer != null) {
|
package/src/ssr/DOMShim.js
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* Provides just enough SVG element emulation to create chart structure without full DOM
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
// Approximate sans-serif metrics, in em, used to estimate SVG text bounds when
|
|
8
|
+
// no font engine is available to measure the glyphs.
|
|
9
|
+
const CHAR_WIDTH_EM = 0.55
|
|
10
|
+
const ASCENT_EM = 0.917
|
|
11
|
+
const DESCENT_EM = 0.25
|
|
12
|
+
const LINE_HEIGHT_EM = 1.1
|
|
13
|
+
const DEFAULT_FONT_SIZE = 11
|
|
14
|
+
|
|
7
15
|
/**
|
|
8
16
|
* Mock SVG element for SSR environment
|
|
9
17
|
*/
|
|
@@ -148,6 +156,48 @@ class SSRElement {
|
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
|
|
159
|
+
getBBox() {
|
|
160
|
+
if (this.nodeName !== 'text' && this.nodeName !== 'tspan') {
|
|
161
|
+
return { x: 0, y: 0, width: 0, height: 0 }
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const lines = this._textLines()
|
|
165
|
+
const longest = lines.reduce((acc, line) => Math.max(acc, line.length), 0)
|
|
166
|
+
if (!longest) {
|
|
167
|
+
return { x: 0, y: 0, width: 0, height: 0 }
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const fontSize =
|
|
171
|
+
parseFloat(this.attributes.get('font-size')) || DEFAULT_FONT_SIZE
|
|
172
|
+
const width = longest * fontSize * CHAR_WIDTH_EM
|
|
173
|
+
const height =
|
|
174
|
+
fontSize * (ASCENT_EM + DESCENT_EM) +
|
|
175
|
+
(lines.length - 1) * fontSize * LINE_HEIGHT_EM
|
|
176
|
+
|
|
177
|
+
const anchor = this.attributes.get('text-anchor')
|
|
178
|
+
const x = parseFloat(this.attributes.get('x')) || 0
|
|
179
|
+
const y = parseFloat(this.attributes.get('y')) || 0
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
x: anchor === 'middle' ? x - width / 2 : anchor === 'end' ? x - width : x,
|
|
183
|
+
y: y - fontSize * ASCENT_EM,
|
|
184
|
+
width,
|
|
185
|
+
height,
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Text of this element, one entry per rendered line
|
|
191
|
+
* @returns {string[]}
|
|
192
|
+
*/
|
|
193
|
+
_textLines() {
|
|
194
|
+
const tspans = this.children.filter((child) => child.nodeName === 'tspan')
|
|
195
|
+
if (tspans.length) {
|
|
196
|
+
return tspans.map((tspan) => String(tspan.textContent ?? ''))
|
|
197
|
+
}
|
|
198
|
+
return [String(this.textContent ?? '')]
|
|
199
|
+
}
|
|
200
|
+
|
|
151
201
|
getRootNode() {
|
|
152
202
|
/** @type {SSRElement} */
|
|
153
203
|
let root = this
|
package/src/types/internal.d.ts
CHANGED
|
@@ -802,7 +802,7 @@ export interface ChartContext {
|
|
|
802
802
|
eventList: string[]
|
|
803
803
|
|
|
804
804
|
// Public methods on the ApexCharts instance
|
|
805
|
-
update(options?: any): Promise<any>
|
|
805
|
+
update(options?: any, overwriteInitialSeries?: boolean): Promise<any>
|
|
806
806
|
getSyncedCharts(): any[]
|
|
807
807
|
getGroupedCharts(): any[]
|
|
808
808
|
fastUpdate(animate?: boolean, prevAxisScaleSig?: string): Promise<any>
|
package/src/utils/Utils.js
CHANGED
|
@@ -75,15 +75,12 @@ class Utils {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// A per-series shallow copy: the series OBJECTS are copied, their data arrays
|
|
78
|
-
// are shared.
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
// this way because the series object was copied at capture time.
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
// note above defineLazyInitialSeries(). This is the same cheap shape
|
|
85
|
-
// `globals.initialSeries` captures, so snapshotting a config stays O(n)
|
|
86
|
-
// instead of deep-cloning every point.
|
|
78
|
+
// are shared. Every internal "mutation" of a series' data is a property
|
|
79
|
+
// REPLACEMENT (`series[i].data = []` on legend collapse, `series[i] = 0` for
|
|
80
|
+
// non-axis charts, appendData's concat), and those cannot reach a copy made
|
|
81
|
+
// this way because the series object was copied at capture time. This is the
|
|
82
|
+
// same cheap shape `globals.initialSeries` captures, so snapshotting a config
|
|
83
|
+
// stays O(n) instead of deep-cloning every point.
|
|
87
84
|
/**
|
|
88
85
|
* @param {any} series
|
|
89
86
|
*/
|
package/types/apexcharts.d.ts
CHANGED
|
@@ -1878,6 +1878,17 @@ type ApexChart = {
|
|
|
1878
1878
|
* @default 'auto'
|
|
1879
1879
|
*/
|
|
1880
1880
|
pinch?: boolean | 'auto'
|
|
1881
|
+
/**
|
|
1882
|
+
* The way back out of a zoom on a chart whose toolbar is hidden. While the
|
|
1883
|
+
* chart is zoomed and nothing else on screen can reset it, one reset
|
|
1884
|
+
* control is drawn where the toolbar would have been, and it goes when the
|
|
1885
|
+
* range does; `Escape` resets the zoom as well. `'auto'` supplies both only
|
|
1886
|
+
* where there is no reset button already, `true` also forces the control on
|
|
1887
|
+
* where `toolbar.tools.reset` is off, and `false` turns both off for a page
|
|
1888
|
+
* that supplies its own reset. Requires `enabled: true`.
|
|
1889
|
+
* @default 'auto'
|
|
1890
|
+
*/
|
|
1891
|
+
resetControl?: boolean | 'auto'
|
|
1881
1892
|
zoomedArea?: {
|
|
1882
1893
|
fill?: {
|
|
1883
1894
|
color?: string
|
|
@@ -2656,6 +2667,12 @@ type ApexPlotOptions = {
|
|
|
2656
2667
|
distributed?: boolean
|
|
2657
2668
|
borderRadius?: number;
|
|
2658
2669
|
borderRadiusApplication?: 'around' | 'end';
|
|
2670
|
+
/**
|
|
2671
|
+
* Which segments of a stack round. 'all' (default) caps both ends of the
|
|
2672
|
+
* stack, the baseline and the far end; 'last' caps only the far end so
|
|
2673
|
+
* the stack sits square on the baseline. Stacked bar/column only.
|
|
2674
|
+
*/
|
|
2675
|
+
borderRadiusWhenStacked?: 'all' | 'last';
|
|
2659
2676
|
hideZeroBarsWhenGrouped?: boolean
|
|
2660
2677
|
rangeBarOverlap?: boolean
|
|
2661
2678
|
rangeBarGroupRows?: boolean
|