apexcharts 7.2.0 → 7.3.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/dist/apexcharts.common.js +2 -2
- package/dist/apexcharts.core.js +1 -1
- package/dist/apexcharts.core.min.js +1 -1
- package/dist/apexcharts.esm.js +167 -2
- package/dist/apexcharts.js +167 -2
- package/dist/apexcharts.min.js +2 -2
- package/dist/apexcharts.ssr.common.js +2 -2
- package/dist/apexcharts.ssr.esm.js +167 -2
- package/dist/area.common.js +1 -1
- package/dist/area.esm.js +1 -1
- package/dist/bar.common.js +1 -1
- package/dist/bar.esm.js +1 -1
- package/dist/bar.js +1 -1
- package/dist/boxPlot.common.js +1 -1
- package/dist/boxPlot.esm.js +1 -1
- package/dist/bubble.common.js +1 -1
- package/dist/bubble.esm.js +1 -1
- package/dist/candlestick.common.js +1 -1
- package/dist/candlestick.esm.js +1 -1
- package/dist/candlestick.js +1 -1
- package/dist/column.common.js +1 -1
- package/dist/column.esm.js +1 -1
- package/dist/core.common.js +1 -1
- package/dist/core.esm.js +1 -1
- package/dist/donut.common.js +1 -1
- package/dist/donut.esm.js +1 -1
- package/dist/dumbbell.common.js +1 -1
- package/dist/dumbbell.esm.js +1 -1
- package/dist/features/all.common.js +2 -2
- package/dist/features/all.esm.js +167 -2
- 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 +1 -1
- package/dist/features/exports.esm.js +1 -1
- package/dist/features/exports.js +1 -1
- 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 +1 -1
- package/dist/features/keyboard.esm.js +1 -1
- package/dist/features/keyboard.js +1 -1
- 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 +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 +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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/features/toolbar.esm.js +1 -1
- package/dist/features/toolbar.js +1 -1
- 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 +167 -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 +1 -1
- package/dist/histogram.esm.js +1 -1
- 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 +1 -1
- package/dist/raincloud.esm.js +1 -1
- package/dist/rangeArea.common.js +1 -1
- package/dist/rangeArea.esm.js +1 -1
- package/dist/rangeBar.common.js +1 -1
- package/dist/rangeBar.esm.js +1 -1
- 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 +1 -1
- package/dist/unit.js +1 -1
- package/dist/violin.common.js +1 -1
- package/dist/violin.esm.js +1 -1
- package/dist/violin.js +1 -1
- package/dist/waterfall.common.js +1 -1
- package/dist/waterfall.esm.js +1 -1
- package/package.json +1 -1
- package/src/modules/weave/PluginAPI.js +37 -1
- package/src/modules/weave/WeaveHost.js +148 -0
package/dist/apexcharts.esm.js
CHANGED
|
@@ -39,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
/*!
|
|
42
|
-
* ApexCharts v7.
|
|
42
|
+
* ApexCharts v7.3.0
|
|
43
43
|
* (c) 2018-2026 ApexCharts
|
|
44
44
|
*/
|
|
45
45
|
import * as _core from "apexcharts/core";
|
|
@@ -9603,7 +9603,7 @@ function getRegistry() {
|
|
|
9603
9603
|
function getPlugin(name) {
|
|
9604
9604
|
return getRegistry()[name] || null;
|
|
9605
9605
|
}
|
|
9606
|
-
const WEAVE_API_VERSION =
|
|
9606
|
+
const WEAVE_API_VERSION = 4;
|
|
9607
9607
|
const PLUGIN_CHART_METHODS = [
|
|
9608
9608
|
"updateOptions",
|
|
9609
9609
|
"updateSeries",
|
|
@@ -9901,6 +9901,36 @@ function buildPluginAPI(host, record) {
|
|
|
9901
9901
|
host._reserve(record.def.name, box);
|
|
9902
9902
|
return api;
|
|
9903
9903
|
},
|
|
9904
|
+
/**
|
|
9905
|
+
* Subscribe to the data point a viewer is pointing at.
|
|
9906
|
+
*
|
|
9907
|
+
* The chart already knows this: it resolves the series and point under the
|
|
9908
|
+
* pointer for its own tooltip and fires `dataPointMouseEnter`,
|
|
9909
|
+
* `dataPointMouseLeave` and `dataPointSelection` for the caller. This
|
|
9910
|
+
* forwards the same three, so a plugin gets the host's answer rather than
|
|
9911
|
+
* hit-testing the SVG itself and disagreeing with the tooltip.
|
|
9912
|
+
*
|
|
9913
|
+
* The payload is normalised rather than the chart's own argument list,
|
|
9914
|
+
* which passes `w`. A plugin must not receive `w`, and the three things a
|
|
9915
|
+
* plugin actually wants (which series, which point, what the point is
|
|
9916
|
+
* called) are exactly what the chart has already resolved.
|
|
9917
|
+
*
|
|
9918
|
+
* `category` is the resolved display label, the same string `api.categories`
|
|
9919
|
+
* carries, because a plugin coordinating two charts keys on the label
|
|
9920
|
+
* rather than on an index that means something different on each chart.
|
|
9921
|
+
*
|
|
9922
|
+
* Nothing here gives a plugin the ability to intercept or cancel: the
|
|
9923
|
+
* chart's own tooltip, selection state and caller events are unaffected,
|
|
9924
|
+
* and a handler that throws is contained rather than allowed to break the
|
|
9925
|
+
* interaction it was watching.
|
|
9926
|
+
*
|
|
9927
|
+
* @param {(e: {type: 'enter'|'leave'|'select', seriesIndex: number, dataPointIndex: number, category: string|undefined, seriesName: string|undefined, selected: boolean|undefined}) => void} fn
|
|
9928
|
+
* @returns {() => void} unsubscribe
|
|
9929
|
+
* @since Weave v4
|
|
9930
|
+
*/
|
|
9931
|
+
pointer(fn) {
|
|
9932
|
+
return host._onPointer(record.def.name, fn);
|
|
9933
|
+
},
|
|
9904
9934
|
// ── custom events out to the host app ──
|
|
9905
9935
|
/**
|
|
9906
9936
|
* Fires as `plugin:<pluginName>:<name>` on the chart's event bus. The
|
|
@@ -9938,6 +9968,8 @@ const _WeaveHost = class _WeaveHost {
|
|
|
9938
9968
|
this._derived = null;
|
|
9939
9969
|
this._reserved = null;
|
|
9940
9970
|
this._reserveTimer = null;
|
|
9971
|
+
this._pointerSubs = null;
|
|
9972
|
+
this._pointerWired = null;
|
|
9941
9973
|
this._onUpdated = this._onUpdated.bind(this);
|
|
9942
9974
|
this._init();
|
|
9943
9975
|
}
|
|
@@ -10180,6 +10212,132 @@ const _WeaveHost = class _WeaveHost {
|
|
|
10180
10212
|
}
|
|
10181
10213
|
this._repairInitialSeries();
|
|
10182
10214
|
}
|
|
10215
|
+
/**
|
|
10216
|
+
* Subscribe a plugin to the data point the viewer is pointing at.
|
|
10217
|
+
*
|
|
10218
|
+
* Wired lazily: a chart whose plugins never ask pays nothing, and the chart
|
|
10219
|
+
* fires these three events whether or not anyone is listening, so there is no
|
|
10220
|
+
* cost to the chart either way.
|
|
10221
|
+
*
|
|
10222
|
+
* The chart's own handler signature is `(e, ctx, {seriesIndex,
|
|
10223
|
+
* dataPointIndex, w})`. `w` stops here: what reaches a plugin is the
|
|
10224
|
+
* normalised payload documented on `api.pointer`.
|
|
10225
|
+
*
|
|
10226
|
+
* @param {string} pluginName
|
|
10227
|
+
* @param {Function} fn
|
|
10228
|
+
* @returns {() => void} unsubscribe
|
|
10229
|
+
*/
|
|
10230
|
+
_onPointer(pluginName, fn) {
|
|
10231
|
+
if (typeof fn !== "function") return () => {
|
|
10232
|
+
};
|
|
10233
|
+
if (!this._pointerSubs) this._pointerSubs = /* @__PURE__ */ new Map();
|
|
10234
|
+
const list = this._pointerSubs.get(pluginName) || [];
|
|
10235
|
+
list.push(fn);
|
|
10236
|
+
this._pointerSubs.set(pluginName, list);
|
|
10237
|
+
this._wirePointer();
|
|
10238
|
+
return () => {
|
|
10239
|
+
const current = this._pointerSubs && this._pointerSubs.get(pluginName);
|
|
10240
|
+
if (!current) return;
|
|
10241
|
+
const i = current.indexOf(fn);
|
|
10242
|
+
if (i > -1) current.splice(i, 1);
|
|
10243
|
+
};
|
|
10244
|
+
}
|
|
10245
|
+
/** Attach to the chart's own data point events, once. */
|
|
10246
|
+
_wirePointer() {
|
|
10247
|
+
if (this._pointerWired) return;
|
|
10248
|
+
if (!this.ctx || typeof this.ctx.addEventListener !== "function") return;
|
|
10249
|
+
const map = [
|
|
10250
|
+
["enter", "dataPointMouseEnter"],
|
|
10251
|
+
["leave", "dataPointMouseLeave"],
|
|
10252
|
+
["select", "dataPointSelection"]
|
|
10253
|
+
];
|
|
10254
|
+
this._pointerWired = [];
|
|
10255
|
+
for (const [type, name] of map) {
|
|
10256
|
+
const handler = (_e, _ctx, opts) => {
|
|
10257
|
+
this._emitPointer(type, opts);
|
|
10258
|
+
};
|
|
10259
|
+
this.ctx.addEventListener(name, handler);
|
|
10260
|
+
this._pointerWired.push([name, handler]);
|
|
10261
|
+
}
|
|
10262
|
+
}
|
|
10263
|
+
/**
|
|
10264
|
+
* Hand one pointer event to every subscribed plugin.
|
|
10265
|
+
*
|
|
10266
|
+
* A handler that throws is contained per plugin, on the same terms as every
|
|
10267
|
+
* other plugin callback here: this runs inside the viewer's own hover, and a
|
|
10268
|
+
* plugin breaking the chart's interaction would be the worst failure mode
|
|
10269
|
+
* this facade has.
|
|
10270
|
+
*
|
|
10271
|
+
* @param {'enter'|'leave'|'select'} type
|
|
10272
|
+
* @param {any} opts
|
|
10273
|
+
*/
|
|
10274
|
+
_emitPointer(type, opts) {
|
|
10275
|
+
if (!this._pointerSubs || !this._pointerSubs.size) return;
|
|
10276
|
+
const seriesIndex = opts && typeof opts.seriesIndex === "number" ? opts.seriesIndex : -1;
|
|
10277
|
+
const dataPointIndex = opts && typeof opts.dataPointIndex === "number" ? opts.dataPointIndex : -1;
|
|
10278
|
+
const labels = this._categories() || [];
|
|
10279
|
+
const w = this.w;
|
|
10280
|
+
const config = w && w.config && w.config.series || [];
|
|
10281
|
+
const payload = {
|
|
10282
|
+
type,
|
|
10283
|
+
seriesIndex,
|
|
10284
|
+
dataPointIndex,
|
|
10285
|
+
category: dataPointIndex > -1 ? labels[dataPointIndex] : void 0,
|
|
10286
|
+
// A pie/donut carries bare numbers in `series`, so there is no name to
|
|
10287
|
+
// read: undefined rather than a guess, on the same terms as `category`.
|
|
10288
|
+
seriesName: _WeaveHost._seriesName(config, seriesIndex),
|
|
10289
|
+
// Only meaningful on a select: the chart hands back its whole selection
|
|
10290
|
+
// set, and what a plugin wants to know is whether THIS point is now in
|
|
10291
|
+
// it, so a second click reads as a deselect rather than another select.
|
|
10292
|
+
selected: type === "select" ? _WeaveHost._isSelected(opts, seriesIndex, dataPointIndex) : void 0
|
|
10293
|
+
};
|
|
10294
|
+
for (const [name, handlers] of this._pointerSubs) {
|
|
10295
|
+
for (const fn of handlers.slice()) {
|
|
10296
|
+
try {
|
|
10297
|
+
fn(payload);
|
|
10298
|
+
} catch (e) {
|
|
10299
|
+
console.warn(
|
|
10300
|
+
'[apexcharts] plugin "' + name + '" threw in a pointer handler',
|
|
10301
|
+
e
|
|
10302
|
+
);
|
|
10303
|
+
}
|
|
10304
|
+
}
|
|
10305
|
+
}
|
|
10306
|
+
}
|
|
10307
|
+
/**
|
|
10308
|
+
* The configured name of series `i`, where there is one.
|
|
10309
|
+
*
|
|
10310
|
+
* @param {any[]} config
|
|
10311
|
+
* @param {number} i
|
|
10312
|
+
* @returns {string|undefined}
|
|
10313
|
+
*/
|
|
10314
|
+
static _seriesName(config, i) {
|
|
10315
|
+
if (i < 0) return void 0;
|
|
10316
|
+
const entry = config[i];
|
|
10317
|
+
if (!entry || typeof entry !== "object") return void 0;
|
|
10318
|
+
return typeof entry.name === "string" ? entry.name : void 0;
|
|
10319
|
+
}
|
|
10320
|
+
/**
|
|
10321
|
+
* Whether the chart now counts this point as selected.
|
|
10322
|
+
*
|
|
10323
|
+
* `selectedDataPoints` is an array per series of the indexes selected in it.
|
|
10324
|
+
* Absent on a chart type that does not carry point selection, in which case
|
|
10325
|
+
* the answer is undefined rather than false: "not selected" and "selection
|
|
10326
|
+
* does not apply here" are different, and a plugin keying on it should be
|
|
10327
|
+
* able to tell.
|
|
10328
|
+
*
|
|
10329
|
+
* @param {any} opts
|
|
10330
|
+
* @param {number} seriesIndex
|
|
10331
|
+
* @param {number} dataPointIndex
|
|
10332
|
+
* @returns {boolean|undefined}
|
|
10333
|
+
*/
|
|
10334
|
+
static _isSelected(opts, seriesIndex, dataPointIndex) {
|
|
10335
|
+
const all = opts && opts.selectedDataPoints;
|
|
10336
|
+
if (!Array.isArray(all) || seriesIndex < 0) return void 0;
|
|
10337
|
+
const mine = all[seriesIndex];
|
|
10338
|
+
if (!Array.isArray(mine)) return false;
|
|
10339
|
+
return mine.indexOf(dataPointIndex) > -1;
|
|
10340
|
+
}
|
|
10183
10341
|
/**
|
|
10184
10342
|
* Record a plugin's container reservation and re-render if it changed.
|
|
10185
10343
|
*
|
|
@@ -10404,6 +10562,13 @@ const _WeaveHost = class _WeaveHost {
|
|
|
10404
10562
|
this.active = [];
|
|
10405
10563
|
this._derived = null;
|
|
10406
10564
|
this._reserved = null;
|
|
10565
|
+
this._pointerSubs = null;
|
|
10566
|
+
if (this._pointerWired) {
|
|
10567
|
+
for (const [name, handler] of this._pointerWired) {
|
|
10568
|
+
this.ctx.removeEventListener && this.ctx.removeEventListener(name, handler);
|
|
10569
|
+
}
|
|
10570
|
+
this._pointerWired = null;
|
|
10571
|
+
}
|
|
10407
10572
|
if (this._reserveTimer != null) {
|
|
10408
10573
|
clearTimeout(this._reserveTimer);
|
|
10409
10574
|
this._reserveTimer = null;
|
package/dist/apexcharts.js
CHANGED
|
@@ -42,7 +42,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
/*!
|
|
45
|
-
* ApexCharts v7.
|
|
45
|
+
* ApexCharts v7.3.0
|
|
46
46
|
* (c) 2018-2026 ApexCharts
|
|
47
47
|
*/
|
|
48
48
|
|
|
@@ -41076,7 +41076,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41076
41076
|
}
|
|
41077
41077
|
}
|
|
41078
41078
|
ApexCharts.registerFeatures({ drilldown: Drilldown });
|
|
41079
|
-
const WEAVE_API_VERSION =
|
|
41079
|
+
const WEAVE_API_VERSION = 4;
|
|
41080
41080
|
const PLUGIN_CHART_METHODS = [
|
|
41081
41081
|
"updateOptions",
|
|
41082
41082
|
"updateSeries",
|
|
@@ -41374,6 +41374,36 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41374
41374
|
host._reserve(record.def.name, box);
|
|
41375
41375
|
return api;
|
|
41376
41376
|
},
|
|
41377
|
+
/**
|
|
41378
|
+
* Subscribe to the data point a viewer is pointing at.
|
|
41379
|
+
*
|
|
41380
|
+
* The chart already knows this: it resolves the series and point under the
|
|
41381
|
+
* pointer for its own tooltip and fires `dataPointMouseEnter`,
|
|
41382
|
+
* `dataPointMouseLeave` and `dataPointSelection` for the caller. This
|
|
41383
|
+
* forwards the same three, so a plugin gets the host's answer rather than
|
|
41384
|
+
* hit-testing the SVG itself and disagreeing with the tooltip.
|
|
41385
|
+
*
|
|
41386
|
+
* The payload is normalised rather than the chart's own argument list,
|
|
41387
|
+
* which passes `w`. A plugin must not receive `w`, and the three things a
|
|
41388
|
+
* plugin actually wants (which series, which point, what the point is
|
|
41389
|
+
* called) are exactly what the chart has already resolved.
|
|
41390
|
+
*
|
|
41391
|
+
* `category` is the resolved display label, the same string `api.categories`
|
|
41392
|
+
* carries, because a plugin coordinating two charts keys on the label
|
|
41393
|
+
* rather than on an index that means something different on each chart.
|
|
41394
|
+
*
|
|
41395
|
+
* Nothing here gives a plugin the ability to intercept or cancel: the
|
|
41396
|
+
* chart's own tooltip, selection state and caller events are unaffected,
|
|
41397
|
+
* and a handler that throws is contained rather than allowed to break the
|
|
41398
|
+
* interaction it was watching.
|
|
41399
|
+
*
|
|
41400
|
+
* @param {(e: {type: 'enter'|'leave'|'select', seriesIndex: number, dataPointIndex: number, category: string|undefined, seriesName: string|undefined, selected: boolean|undefined}) => void} fn
|
|
41401
|
+
* @returns {() => void} unsubscribe
|
|
41402
|
+
* @since Weave v4
|
|
41403
|
+
*/
|
|
41404
|
+
pointer(fn) {
|
|
41405
|
+
return host._onPointer(record.def.name, fn);
|
|
41406
|
+
},
|
|
41377
41407
|
// ── custom events out to the host app ──
|
|
41378
41408
|
/**
|
|
41379
41409
|
* Fires as `plugin:<pluginName>:<name>` on the chart's event bus. The
|
|
@@ -41411,6 +41441,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41411
41441
|
this._derived = null;
|
|
41412
41442
|
this._reserved = null;
|
|
41413
41443
|
this._reserveTimer = null;
|
|
41444
|
+
this._pointerSubs = null;
|
|
41445
|
+
this._pointerWired = null;
|
|
41414
41446
|
this._onUpdated = this._onUpdated.bind(this);
|
|
41415
41447
|
this._init();
|
|
41416
41448
|
}
|
|
@@ -41653,6 +41685,132 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41653
41685
|
}
|
|
41654
41686
|
this._repairInitialSeries();
|
|
41655
41687
|
}
|
|
41688
|
+
/**
|
|
41689
|
+
* Subscribe a plugin to the data point the viewer is pointing at.
|
|
41690
|
+
*
|
|
41691
|
+
* Wired lazily: a chart whose plugins never ask pays nothing, and the chart
|
|
41692
|
+
* fires these three events whether or not anyone is listening, so there is no
|
|
41693
|
+
* cost to the chart either way.
|
|
41694
|
+
*
|
|
41695
|
+
* The chart's own handler signature is `(e, ctx, {seriesIndex,
|
|
41696
|
+
* dataPointIndex, w})`. `w` stops here: what reaches a plugin is the
|
|
41697
|
+
* normalised payload documented on `api.pointer`.
|
|
41698
|
+
*
|
|
41699
|
+
* @param {string} pluginName
|
|
41700
|
+
* @param {Function} fn
|
|
41701
|
+
* @returns {() => void} unsubscribe
|
|
41702
|
+
*/
|
|
41703
|
+
_onPointer(pluginName, fn) {
|
|
41704
|
+
if (typeof fn !== "function") return () => {
|
|
41705
|
+
};
|
|
41706
|
+
if (!this._pointerSubs) this._pointerSubs = /* @__PURE__ */ new Map();
|
|
41707
|
+
const list = this._pointerSubs.get(pluginName) || [];
|
|
41708
|
+
list.push(fn);
|
|
41709
|
+
this._pointerSubs.set(pluginName, list);
|
|
41710
|
+
this._wirePointer();
|
|
41711
|
+
return () => {
|
|
41712
|
+
const current = this._pointerSubs && this._pointerSubs.get(pluginName);
|
|
41713
|
+
if (!current) return;
|
|
41714
|
+
const i2 = current.indexOf(fn);
|
|
41715
|
+
if (i2 > -1) current.splice(i2, 1);
|
|
41716
|
+
};
|
|
41717
|
+
}
|
|
41718
|
+
/** Attach to the chart's own data point events, once. */
|
|
41719
|
+
_wirePointer() {
|
|
41720
|
+
if (this._pointerWired) return;
|
|
41721
|
+
if (!this.ctx || typeof this.ctx.addEventListener !== "function") return;
|
|
41722
|
+
const map = [
|
|
41723
|
+
["enter", "dataPointMouseEnter"],
|
|
41724
|
+
["leave", "dataPointMouseLeave"],
|
|
41725
|
+
["select", "dataPointSelection"]
|
|
41726
|
+
];
|
|
41727
|
+
this._pointerWired = [];
|
|
41728
|
+
for (const [type, name2] of map) {
|
|
41729
|
+
const handler = (_e, _ctx, opts) => {
|
|
41730
|
+
this._emitPointer(type, opts);
|
|
41731
|
+
};
|
|
41732
|
+
this.ctx.addEventListener(name2, handler);
|
|
41733
|
+
this._pointerWired.push([name2, handler]);
|
|
41734
|
+
}
|
|
41735
|
+
}
|
|
41736
|
+
/**
|
|
41737
|
+
* Hand one pointer event to every subscribed plugin.
|
|
41738
|
+
*
|
|
41739
|
+
* A handler that throws is contained per plugin, on the same terms as every
|
|
41740
|
+
* other plugin callback here: this runs inside the viewer's own hover, and a
|
|
41741
|
+
* plugin breaking the chart's interaction would be the worst failure mode
|
|
41742
|
+
* this facade has.
|
|
41743
|
+
*
|
|
41744
|
+
* @param {'enter'|'leave'|'select'} type
|
|
41745
|
+
* @param {any} opts
|
|
41746
|
+
*/
|
|
41747
|
+
_emitPointer(type, opts) {
|
|
41748
|
+
if (!this._pointerSubs || !this._pointerSubs.size) return;
|
|
41749
|
+
const seriesIndex = opts && typeof opts.seriesIndex === "number" ? opts.seriesIndex : -1;
|
|
41750
|
+
const dataPointIndex = opts && typeof opts.dataPointIndex === "number" ? opts.dataPointIndex : -1;
|
|
41751
|
+
const labels = this._categories() || [];
|
|
41752
|
+
const w = this.w;
|
|
41753
|
+
const config = w && w.config && w.config.series || [];
|
|
41754
|
+
const payload = {
|
|
41755
|
+
type,
|
|
41756
|
+
seriesIndex,
|
|
41757
|
+
dataPointIndex,
|
|
41758
|
+
category: dataPointIndex > -1 ? labels[dataPointIndex] : void 0,
|
|
41759
|
+
// A pie/donut carries bare numbers in `series`, so there is no name to
|
|
41760
|
+
// read: undefined rather than a guess, on the same terms as `category`.
|
|
41761
|
+
seriesName: _WeaveHost._seriesName(config, seriesIndex),
|
|
41762
|
+
// Only meaningful on a select: the chart hands back its whole selection
|
|
41763
|
+
// set, and what a plugin wants to know is whether THIS point is now in
|
|
41764
|
+
// it, so a second click reads as a deselect rather than another select.
|
|
41765
|
+
selected: type === "select" ? _WeaveHost._isSelected(opts, seriesIndex, dataPointIndex) : void 0
|
|
41766
|
+
};
|
|
41767
|
+
for (const [name2, handlers] of this._pointerSubs) {
|
|
41768
|
+
for (const fn of handlers.slice()) {
|
|
41769
|
+
try {
|
|
41770
|
+
fn(payload);
|
|
41771
|
+
} catch (e2) {
|
|
41772
|
+
console.warn(
|
|
41773
|
+
'[apexcharts] plugin "' + name2 + '" threw in a pointer handler',
|
|
41774
|
+
e2
|
|
41775
|
+
);
|
|
41776
|
+
}
|
|
41777
|
+
}
|
|
41778
|
+
}
|
|
41779
|
+
}
|
|
41780
|
+
/**
|
|
41781
|
+
* The configured name of series `i`, where there is one.
|
|
41782
|
+
*
|
|
41783
|
+
* @param {any[]} config
|
|
41784
|
+
* @param {number} i
|
|
41785
|
+
* @returns {string|undefined}
|
|
41786
|
+
*/
|
|
41787
|
+
static _seriesName(config, i2) {
|
|
41788
|
+
if (i2 < 0) return void 0;
|
|
41789
|
+
const entry = config[i2];
|
|
41790
|
+
if (!entry || typeof entry !== "object") return void 0;
|
|
41791
|
+
return typeof entry.name === "string" ? entry.name : void 0;
|
|
41792
|
+
}
|
|
41793
|
+
/**
|
|
41794
|
+
* Whether the chart now counts this point as selected.
|
|
41795
|
+
*
|
|
41796
|
+
* `selectedDataPoints` is an array per series of the indexes selected in it.
|
|
41797
|
+
* Absent on a chart type that does not carry point selection, in which case
|
|
41798
|
+
* the answer is undefined rather than false: "not selected" and "selection
|
|
41799
|
+
* does not apply here" are different, and a plugin keying on it should be
|
|
41800
|
+
* able to tell.
|
|
41801
|
+
*
|
|
41802
|
+
* @param {any} opts
|
|
41803
|
+
* @param {number} seriesIndex
|
|
41804
|
+
* @param {number} dataPointIndex
|
|
41805
|
+
* @returns {boolean|undefined}
|
|
41806
|
+
*/
|
|
41807
|
+
static _isSelected(opts, seriesIndex, dataPointIndex) {
|
|
41808
|
+
const all = opts && opts.selectedDataPoints;
|
|
41809
|
+
if (!Array.isArray(all) || seriesIndex < 0) return void 0;
|
|
41810
|
+
const mine = all[seriesIndex];
|
|
41811
|
+
if (!Array.isArray(mine)) return false;
|
|
41812
|
+
return mine.indexOf(dataPointIndex) > -1;
|
|
41813
|
+
}
|
|
41656
41814
|
/**
|
|
41657
41815
|
* Record a plugin's container reservation and re-render if it changed.
|
|
41658
41816
|
*
|
|
@@ -41877,6 +42035,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41877
42035
|
this.active = [];
|
|
41878
42036
|
this._derived = null;
|
|
41879
42037
|
this._reserved = null;
|
|
42038
|
+
this._pointerSubs = null;
|
|
42039
|
+
if (this._pointerWired) {
|
|
42040
|
+
for (const [name2, handler] of this._pointerWired) {
|
|
42041
|
+
this.ctx.removeEventListener && this.ctx.removeEventListener(name2, handler);
|
|
42042
|
+
}
|
|
42043
|
+
this._pointerWired = null;
|
|
42044
|
+
}
|
|
41880
42045
|
if (this._reserveTimer != null) {
|
|
41881
42046
|
clearTimeout(this._reserveTimer);
|
|
41882
42047
|
this._reserveTimer = null;
|