apexcharts 8.2.0 → 8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/apexcharts.common.js +2 -2
- package/dist/apexcharts.core.js +19793 -19713
- package/dist/apexcharts.core.min.js +2 -2
- package/dist/apexcharts.css +38 -8
- package/dist/apexcharts.esm.js +1882 -1625
- package/dist/apexcharts.full.js +22044 -21634
- package/dist/apexcharts.full.min.js +2 -2
- package/dist/apexcharts.js +21414 -21124
- package/dist/apexcharts.min.js +2 -2
- package/dist/apexcharts.ssr.common.js +2 -2
- package/dist/apexcharts.ssr.esm.js +21413 -21123
- package/dist/area.common.js +2 -2
- package/dist/area.esm.js +91 -40
- package/dist/bar.common.js +2 -2
- package/dist/bar.esm.js +478 -406
- package/dist/bar.js +2 -2
- package/dist/boxPlot.common.js +2 -2
- package/dist/boxPlot.esm.js +409 -334
- package/dist/bubble.common.js +2 -2
- package/dist/bubble.esm.js +91 -40
- package/dist/candlestick.common.js +2 -2
- package/dist/candlestick.esm.js +409 -334
- package/dist/candlestick.js +2 -2
- package/dist/column.common.js +2 -2
- package/dist/column.esm.js +478 -406
- package/dist/core.common.js +2 -2
- package/dist/core.esm.js +19793 -19713
- package/dist/donut.common.js +2 -2
- package/dist/donut.esm.js +3 -9
- package/dist/dumbbell.common.js +2 -2
- package/dist/dumbbell.esm.js +478 -406
- package/dist/features/all.common.js +2 -2
- package/dist/features/all.esm.js +442 -324
- package/dist/features/annotations.common.js +2 -2
- package/dist/features/annotations.esm.js +65 -48
- package/dist/features/annotations.js +2 -2
- package/dist/features/context-menu.common.js +1 -1
- package/dist/features/context-menu.esm.js +1 -1
- package/dist/features/context-menu.js +1 -1
- package/dist/features/drilldown.common.js +2 -2
- package/dist/features/drilldown.esm.js +4 -2
- package/dist/features/drilldown.js +2 -2
- package/dist/features/dumbbell.common.js +1 -1
- package/dist/features/dumbbell.esm.js +1 -1
- package/dist/features/dumbbell.js +1 -1
- package/dist/features/exports.common.js +2 -2
- package/dist/features/exports.esm.js +10 -4
- 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 +14 -9
- package/dist/features/highlight-filter.js +2 -2
- package/dist/features/history.common.js +1 -1
- package/dist/features/history.esm.js +1 -1
- package/dist/features/history.js +1 -1
- package/dist/features/ink.common.js +1 -1
- package/dist/features/ink.esm.js +1 -1
- package/dist/features/ink.js +1 -1
- package/dist/features/keyboard.common.js +2 -2
- package/dist/features/keyboard.esm.js +97 -145
- package/dist/features/keyboard.js +2 -2
- package/dist/features/legend.common.js +2 -2
- package/dist/features/legend.esm.js +64 -44
- package/dist/features/legend.js +2 -2
- package/dist/features/link.common.js +1 -1
- package/dist/features/link.esm.js +1 -1
- package/dist/features/link.js +1 -1
- package/dist/features/marks.common.js +1 -1
- package/dist/features/marks.esm.js +1 -1
- package/dist/features/marks.js +1 -1
- package/dist/features/measure.common.js +1 -1
- package/dist/features/measure.esm.js +1 -1
- package/dist/features/measure.js +1 -1
- package/dist/features/morph.common.js +2 -2
- package/dist/features/morph.esm.js +9 -5
- package/dist/features/morph.js +2 -2
- package/dist/features/perspectives.common.js +2 -2
- package/dist/features/perspectives.esm.js +4 -1
- package/dist/features/perspectives.js +2 -2
- package/dist/features/raincloud.common.js +2 -2
- package/dist/features/raincloud.esm.js +26 -27
- package/dist/features/raincloud.js +2 -2
- package/dist/features/renderer-canvas.common.js +2 -2
- package/dist/features/renderer-canvas.esm.js +2 -1
- package/dist/features/renderer-canvas.js +2 -2
- package/dist/features/stats.common.js +2 -2
- package/dist/features/stats.esm.js +52 -59
- package/dist/features/stats.js +2 -2
- package/dist/features/storyboard.common.js +2 -2
- package/dist/features/storyboard.esm.js +4 -1
- package/dist/features/storyboard.js +2 -2
- package/dist/features/streamgraph.common.js +2 -2
- package/dist/features/streamgraph.esm.js +48 -14
- package/dist/features/streamgraph.js +2 -2
- package/dist/features/toolbar.common.js +2 -2
- package/dist/features/toolbar.esm.js +148 -18
- package/dist/features/toolbar.js +2 -2
- package/dist/features/trellis.common.js +2 -2
- package/dist/features/trellis.esm.js +150 -63
- package/dist/features/trellis.js +2 -2
- 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 +13 -12
- package/dist/features/weave.js +2 -2
- package/dist/full.common.js +2 -2
- package/dist/full.esm.js +1068 -842
- package/dist/heatmap.common.js +2 -2
- package/dist/heatmap.esm.js +3 -17
- package/dist/heatmap.js +2 -2
- package/dist/histogram.common.js +2 -2
- package/dist/histogram.esm.js +529 -464
- package/dist/icicle.common.js +2 -2
- package/dist/icicle.esm.js +80 -46
- package/dist/icicle.js +2 -2
- package/dist/line.common.js +2 -2
- package/dist/line.esm.js +91 -40
- package/dist/line.js +2 -2
- package/dist/locales/en.json +2 -1
- package/dist/locales/ro.json +3 -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 +3 -9
- package/dist/pie.js +2 -2
- package/dist/polarArea.common.js +2 -2
- package/dist/polarArea.esm.js +3 -9
- package/dist/radar.common.js +2 -2
- package/dist/radar.esm.js +5 -4
- package/dist/radar.js +2 -2
- package/dist/radialBar.common.js +2 -2
- package/dist/radialBar.esm.js +5 -12
- package/dist/radialBar.js +2 -2
- package/dist/raincloud.common.js +2 -2
- package/dist/raincloud.esm.js +97 -52
- package/dist/rangeArea.common.js +2 -2
- package/dist/rangeArea.esm.js +91 -40
- package/dist/rangeBar.common.js +2 -2
- package/dist/rangeBar.esm.js +478 -406
- package/dist/scatter.common.js +2 -2
- package/dist/scatter.esm.js +91 -40
- package/dist/streamgraph.common.js +2 -2
- package/dist/streamgraph.esm.js +138 -53
- package/dist/sunburst.common.js +2 -2
- package/dist/sunburst.esm.js +116 -94
- package/dist/sunburst.js +2 -2
- package/dist/treemap.common.js +2 -2
- package/dist/treemap.esm.js +138 -104
- package/dist/treemap.js +2 -2
- 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 +2 -2
- package/dist/unit.esm.js +280 -202
- package/dist/unit.js +2 -2
- package/dist/violin.common.js +2 -2
- package/dist/violin.esm.js +72 -26
- package/dist/violin.js +2 -2
- package/dist/waterfall.common.js +2 -2
- package/dist/waterfall.esm.js +477 -405
- package/package.json +1 -1
- package/src/apexcharts.js +40 -59
- package/src/assets/apexcharts.css +38 -8
- package/src/charts/Bar.js +62 -55
- package/src/charts/BarStacked.js +80 -88
- package/src/charts/BoxCandleStick.js +28 -31
- package/src/charts/Icicle.js +68 -47
- package/src/charts/Line.js +118 -42
- package/src/charts/Pie.js +2 -8
- package/src/charts/Radar.js +5 -7
- package/src/charts/Radial.js +2 -6
- package/src/charts/RangeBar.js +47 -43
- package/src/charts/Sunburst.js +101 -98
- package/src/charts/Treemap.js +150 -88
- package/src/charts/Unit.js +368 -250
- package/src/charts/Violin.js +48 -30
- package/src/charts/common/Breadcrumb.js +2 -2
- package/src/charts/common/Hierarchy.js +32 -11
- package/src/charts/common/Jitter.js +32 -7
- package/src/charts/common/Stats.js +30 -23
- package/src/charts/common/bar/DataLabels.js +76 -81
- package/src/charts/common/bar/Helpers.js +43 -7
- package/src/charts/common/line/Helpers.js +12 -15
- package/src/charts/common/partition/NodeTooltip.js +29 -7
- package/src/charts/common/partition/Partition.js +33 -1
- package/src/charts/common/treemap/Helpers.js +3 -11
- package/src/charts/common/treemap/Nested.js +2 -3
- package/src/features/raincloud.js +16 -10
- package/src/features/stats.js +67 -62
- package/src/locales/en.json +2 -1
- package/src/locales/ro.json +3 -2
- package/src/modules/Animations.js +102 -95
- package/src/modules/AxisMapping.js +47 -12
- package/src/modules/Core.js +4 -0
- package/src/modules/CoreUtils.js +18 -42
- package/src/modules/Data.js +23 -24
- package/src/modules/DataLabels.js +6 -6
- package/src/modules/Exports.js +12 -5
- package/src/modules/Fill.js +17 -8
- package/src/modules/Filters.js +50 -50
- package/src/modules/Graphics.js +69 -51
- package/src/modules/Markers.js +3 -1
- package/src/modules/MorphTypeChange.js +13 -7
- package/src/modules/Range.js +44 -29
- package/src/modules/RendererController.js +17 -3
- package/src/modules/Scales.js +32 -9
- package/src/modules/Series.js +41 -19
- package/src/modules/Theme.js +1 -1
- package/src/modules/Toolbar.js +3 -2
- package/src/modules/UnitMarkRegistry.js +0 -5
- package/src/modules/ZoomPanSelection.js +123 -2
- package/src/modules/accessibility/KeyboardNavigation.js +114 -186
- package/src/modules/animations/Easing.js +2 -1
- package/src/modules/animations/LengthTransition.js +22 -2
- package/src/modules/annotations/Helpers.js +68 -52
- package/src/modules/axes/Grid.js +21 -7
- package/src/modules/axes/YAxis.js +8 -9
- package/src/modules/dimensions/Dimensions.js +9 -3
- package/src/modules/dimensions/Grid.js +2 -2
- package/src/modules/dimensions/XAxis.js +2 -5
- package/src/modules/drilldown/Breadcrumb.js +5 -2
- package/src/modules/helpers/Destroy.js +1 -1
- package/src/modules/helpers/UpdateHelpers.js +33 -15
- package/src/modules/highlightFilter/HighlightFilter.js +8 -9
- package/src/modules/highlightFilter/TreemapPart.js +2 -2
- package/src/modules/legend/HeatmapGradientLegend.js +76 -45
- package/src/modules/legend/Helpers.js +8 -1
- package/src/modules/legend/Legend.js +11 -12
- package/src/modules/license/LicenseEnforcer.js +5 -0
- package/src/modules/settings/Defaults.js +28 -56
- package/src/modules/settings/Globals.js +5 -0
- package/src/modules/settings/Options.js +7 -7
- package/src/modules/settings/TypeAliases.js +33 -16
- package/src/modules/streamgraph/StreamLabels.js +1 -0
- package/src/modules/tooltip/Labels.js +73 -76
- package/src/modules/tooltip/Marker.js +25 -21
- package/src/modules/tooltip/Position.js +88 -51
- package/src/modules/tooltip/Tooltip.js +242 -255
- package/src/modules/tooltip/Utils.js +71 -130
- package/src/modules/tooltip/constants.js +5 -5
- package/src/modules/trellis/Trellis.js +6 -0
- package/src/modules/trellis/TrellisChrome.js +18 -7
- package/src/modules/trellis/TrellisSync.js +2 -0
- package/src/modules/trellis/TrellisTooltip.js +2 -11
- package/src/modules/weave/WeaveHost.js +18 -12
- package/src/renderers/canvas/CanvasGraphics.js +1 -0
- package/src/ssr/DOMShim.js +10 -0
- package/src/svg/SVGFilter.js +26 -17
- package/src/types/internal.d.ts +9 -3
- package/src/utils/Utils.js +0 -14
- package/types/apexcharts.d.ts +33 -12
package/dist/sunburst.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ApexCharts v8.
|
|
2
|
+
* ApexCharts v8.3.1
|
|
3
3
|
* (c) 2018-2026 ApexCharts
|
|
4
4
|
*/
|
|
5
5
|
import * as _core from "apexcharts/core";
|
|
@@ -106,26 +106,33 @@ function drilldownById(w, id) {
|
|
|
106
106
|
const list = dd && Array.isArray(dd.series) ? dd.series : [];
|
|
107
107
|
return list.find((s) => s && s.id === id);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function segment(name, seen) {
|
|
110
|
+
var _a;
|
|
111
|
+
const n = String(name).replace(/\//g, "%2F");
|
|
112
|
+
const o = ((_a = seen.get(n)) != null ? _a : -1) + 1;
|
|
113
|
+
seen.set(n, o);
|
|
114
|
+
return `${o}:${n}`;
|
|
115
|
+
}
|
|
116
|
+
function toNode(w, d, i, paletteFromParent, parentKey, seenIds = null, opts = {}, seen = /* @__PURE__ */ new Map()) {
|
|
110
117
|
var _a, _b, _c;
|
|
111
118
|
const isObj = d && typeof d === "object";
|
|
112
119
|
const name = isObj ? (_b = (_a = d.x) != null ? _a : d.name) != null ? _b : "" : "";
|
|
113
|
-
const
|
|
120
|
+
const raw = isObj ? (_c = d.y) != null ? _c : d.value : d;
|
|
121
|
+
const value = raw == null || raw === "" ? NaN : Number(raw);
|
|
114
122
|
const node = {
|
|
115
123
|
name: String(name),
|
|
116
124
|
value: isNaN(value) ? null : value,
|
|
117
125
|
color: isObj && d.color ? d.color : void 0,
|
|
118
|
-
|
|
119
|
-
// siblings stay distinct). Update animations morph matched keys in place.
|
|
120
|
-
_key: `${parentKey}/${i}:${name}`
|
|
126
|
+
_key: `${parentKey}/${segment(name, seen)}`
|
|
121
127
|
};
|
|
122
128
|
if (paletteFromParent && !node.color) {
|
|
123
129
|
node.color = paletteFromParent[i % paletteFromParent.length];
|
|
124
130
|
}
|
|
125
131
|
if (opts.keepDatum) node._datum = d;
|
|
132
|
+
const kids = /* @__PURE__ */ new Map();
|
|
126
133
|
if (isObj && Array.isArray(d.children) && d.children.length) {
|
|
127
134
|
node.children = d.children.map(
|
|
128
|
-
(c, j) => toNode(w, c, j, null, node._key, seenIds, opts)
|
|
135
|
+
(c, j) => toNode(w, c, j, null, node._key, seenIds, opts, kids)
|
|
129
136
|
);
|
|
130
137
|
} else if (isObj && d.drilldown != null && opts.expandDrilldown !== false) {
|
|
131
138
|
const visited = seenIds || /* @__PURE__ */ new Set();
|
|
@@ -136,7 +143,7 @@ function toNode(w, d, i, paletteFromParent, parentKey, seenIds = null, opts = {}
|
|
|
136
143
|
nextSeen.add(d.drilldown);
|
|
137
144
|
const palette = Array.isArray(dd.colors) ? dd.colors : null;
|
|
138
145
|
node.children = dd.data.map(
|
|
139
|
-
(c, j) => toNode(w, c, j, palette, node._key, nextSeen, opts)
|
|
146
|
+
(c, j) => toNode(w, c, j, palette, node._key, nextSeen, opts, kids)
|
|
140
147
|
);
|
|
141
148
|
}
|
|
142
149
|
}
|
|
@@ -151,8 +158,9 @@ function buildHierarchy(w, opts = {}) {
|
|
|
151
158
|
const first = cfgSeries && cfgSeries[0];
|
|
152
159
|
const data = first && Array.isArray(first.data) ? first.data : cfgSeries;
|
|
153
160
|
if (!Array.isArray(data)) return [];
|
|
161
|
+
const seen = /* @__PURE__ */ new Map();
|
|
154
162
|
return data.map(
|
|
155
|
-
(d, i) => toNode(w, d, i, null, "", null, opts)
|
|
163
|
+
(d, i) => toNode(w, d, i, null, "", null, opts, seen)
|
|
156
164
|
);
|
|
157
165
|
}
|
|
158
166
|
function fillValues(node) {
|
|
@@ -277,9 +285,19 @@ function resolveFocus(node, current, roots) {
|
|
|
277
285
|
if (next && !(next.children && next.children.length)) {
|
|
278
286
|
next = next._parent || null;
|
|
279
287
|
}
|
|
288
|
+
if (roots && roots.length === 1 && next === roots[0]) next = null;
|
|
280
289
|
if (next === current) return { changed: false, focus: current };
|
|
281
290
|
return { changed: true, focus: next };
|
|
282
291
|
}
|
|
292
|
+
function focusByKey(key, nodesAll, roots) {
|
|
293
|
+
var _a;
|
|
294
|
+
const f = key && nodesAll.find((n) => n._key === key);
|
|
295
|
+
return f && ((_a = f.children) == null ? void 0 : _a.length) && !(roots.length === 1 && f === roots[0]) ? f : null;
|
|
296
|
+
}
|
|
297
|
+
function setZoomCursor(chart, node) {
|
|
298
|
+
if (!Environment.isBrowser() || chart.cfg.zoomOnClick === false) return;
|
|
299
|
+
node._el.node.style.cursor = resolveFocus(node, chart._focus, chart._roots).changed ? "pointer" : "default";
|
|
300
|
+
}
|
|
283
301
|
function parseSize(size, max, fallbackRatio = 0) {
|
|
284
302
|
if (typeof size === "number") return size;
|
|
285
303
|
const s = String(size).trim();
|
|
@@ -314,6 +332,7 @@ function colorPass(node, color, tint, out) {
|
|
|
314
332
|
}
|
|
315
333
|
}
|
|
316
334
|
}
|
|
335
|
+
const escapeHtml = (s) => String(s).replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
317
336
|
class NodeTooltip {
|
|
318
337
|
/**
|
|
319
338
|
* @param {any} w
|
|
@@ -351,14 +370,29 @@ class NodeTooltip {
|
|
|
351
370
|
* @param {any} node
|
|
352
371
|
*/
|
|
353
372
|
show(e, node) {
|
|
373
|
+
var _a;
|
|
354
374
|
const t = this._tip();
|
|
355
375
|
if (!t) return;
|
|
356
376
|
const w = this.w;
|
|
357
377
|
const pctTotal = (node.value / this.total * 100).toFixed(1);
|
|
358
378
|
const parentVal = node._parent ? node._parent.value : this.total;
|
|
359
379
|
const pctParent = parentVal > 0 ? (node.value / parentVal * 100).toFixed(1) : pctTotal;
|
|
360
|
-
const
|
|
361
|
-
|
|
380
|
+
const ty = w.config.tooltip.y;
|
|
381
|
+
const fmt = (_a = Array.isArray(ty) ? ty[0] : ty) == null ? void 0 : _a.formatter;
|
|
382
|
+
const val = fmt ? fmt(node.value, { seriesIndex: 0, dataPointIndex: -1, w, node }) : +node.value.toPrecision(12);
|
|
383
|
+
t.innerHTML = `<div class="apexcharts-tooltip-series-group apexcharts-active" style="display:flex"><span class="apexcharts-tooltip-marker"></span><div class="apexcharts-tooltip-text"><div class="apexcharts-tooltip-y-group"><span class="apexcharts-tooltip-text-y-label">${escapeHtml(node.name)}: </span><span class="apexcharts-tooltip-text-y-value">${val} (${pctParent}% of parent, ${pctTotal}% of total)</span></div></div></div>`;
|
|
384
|
+
const group = (
|
|
385
|
+
/** @type {HTMLElement} */
|
|
386
|
+
t.firstChild
|
|
387
|
+
);
|
|
388
|
+
const marker = (
|
|
389
|
+
/** @type {HTMLElement} */
|
|
390
|
+
group.firstChild
|
|
391
|
+
);
|
|
392
|
+
marker.style.backgroundColor = node._color;
|
|
393
|
+
if (w.config.tooltip.fillSeriesColor) {
|
|
394
|
+
group.style.backgroundColor = node._color;
|
|
395
|
+
}
|
|
362
396
|
t.classList.add("apexcharts-active");
|
|
363
397
|
t.style.opacity = "1";
|
|
364
398
|
this.position(e);
|
|
@@ -446,14 +480,19 @@ class SunburstChart {
|
|
|
446
480
|
this.centerY = gh / 2 + (this.cfg.offsetY || 0);
|
|
447
481
|
this.maxRadius = Math.min(gw, gh) / 2.05 - this.strokeWidth - (!w.config.chart.sparkline.enabled ? w.config.chart.dropShadow.blur : 0);
|
|
448
482
|
if (this.maxRadius < 5) return g;
|
|
449
|
-
this._roots =
|
|
483
|
+
this._roots = buildHierarchy(w);
|
|
450
484
|
if (!this._roots.length) return g;
|
|
451
|
-
this._roots.forEach(
|
|
485
|
+
this._roots.forEach(fillValues);
|
|
452
486
|
this._validateStrict();
|
|
453
487
|
this._nodesAll = [];
|
|
454
488
|
const colors = w.globals.colors || [];
|
|
455
489
|
this._roots.forEach((r, i) => {
|
|
456
|
-
|
|
490
|
+
colorPass(
|
|
491
|
+
r,
|
|
492
|
+
r.color || colors[i % colors.length] || "#008FFB",
|
|
493
|
+
this.cfg.tint,
|
|
494
|
+
this._nodesAll
|
|
495
|
+
);
|
|
457
496
|
});
|
|
458
497
|
this.total = this._roots.reduce((s, r) => s + Math.max(0, r.value), 0) || 1;
|
|
459
498
|
this._tooltip.total = this.total;
|
|
@@ -461,13 +500,17 @@ class SunburstChart {
|
|
|
461
500
|
this._labelsG = graphics.group({ class: "apexcharts-sunburst-labels" });
|
|
462
501
|
g.add(this._ringsG);
|
|
463
502
|
g.add(this._labelsG);
|
|
464
|
-
this._focus =
|
|
503
|
+
this._focus = focusByKey(
|
|
504
|
+
w.globals.sunburstFocusKey,
|
|
505
|
+
this._nodesAll,
|
|
506
|
+
this._roots
|
|
507
|
+
);
|
|
465
508
|
this._relayout(this._focus);
|
|
466
509
|
const anims = w.config.chart.animations;
|
|
467
510
|
let mode = "none";
|
|
468
511
|
if (anims.enabled) {
|
|
469
512
|
if (w.globals.dataChanged) {
|
|
470
|
-
if (
|
|
513
|
+
if (w.globals.shouldAnimate !== false) mode = "update";
|
|
471
514
|
} else if (!w.globals.resized) {
|
|
472
515
|
mode = "intro";
|
|
473
516
|
}
|
|
@@ -477,22 +520,6 @@ class SunburstChart {
|
|
|
477
520
|
return g;
|
|
478
521
|
}
|
|
479
522
|
// ------------------------------------------------------------------ data
|
|
480
|
-
/**
|
|
481
|
-
* Resolve the config into root nodes `{ name, value, color?, children? }`.
|
|
482
|
-
* Each datum may carry `children` (native) or `drilldown: '<id>'` (adapter).
|
|
483
|
-
* Shared with the treemap - see charts/common/Hierarchy.
|
|
484
|
-
* @returns {any[]}
|
|
485
|
-
*/
|
|
486
|
-
_buildHierarchy() {
|
|
487
|
-
return buildHierarchy(this.w);
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Fill a parent's value from its children when missing.
|
|
491
|
-
* @param {any} node
|
|
492
|
-
*/
|
|
493
|
-
_fillValues(node) {
|
|
494
|
-
fillValues(node);
|
|
495
|
-
}
|
|
496
523
|
/**
|
|
497
524
|
* With `partition: 'strict'`, warn (once) when a parent's value does not
|
|
498
525
|
* match the sum of its children. The angles are still normalized to fill the
|
|
@@ -506,22 +533,13 @@ class SunburstChart {
|
|
|
506
533
|
remedy: "Angles are normalized to fill the wedge."
|
|
507
534
|
});
|
|
508
535
|
}
|
|
509
|
-
/**
|
|
510
|
-
* Assign a colour to every node (explicit `color` wins, else the parent's
|
|
511
|
-
* colour tinted lighter). Done once so zoom preserves colours.
|
|
512
|
-
* Shared with the icicle - see charts/common/partition/Tint.
|
|
513
|
-
* @param {any} node
|
|
514
|
-
* @param {string} color
|
|
515
|
-
*/
|
|
516
|
-
_colorPass(node, color) {
|
|
517
|
-
colorPass(node, color, this.cfg.tint, this._nodesAll);
|
|
518
|
-
}
|
|
519
536
|
// ---------------------------------------------------------------- layout
|
|
520
537
|
/**
|
|
521
538
|
* Recompute visibility + angles + radii for a focus node (null = whole tree).
|
|
522
539
|
* @param {any} focus
|
|
523
540
|
*/
|
|
524
541
|
_relayout(focus) {
|
|
542
|
+
this.w.globals.sunburstFocusKey = focus && focus._key;
|
|
525
543
|
this._focusMaxDepth = placeTree({
|
|
526
544
|
roots: this._roots,
|
|
527
545
|
nodesAll: this._nodesAll,
|
|
@@ -562,14 +580,15 @@ class SunburstChart {
|
|
|
562
580
|
* @param {'intro'|'zoom'|'update'|'none'} mode
|
|
563
581
|
*/
|
|
564
582
|
_applyLayout(mode) {
|
|
565
|
-
var _a;
|
|
583
|
+
var _a, _b, _c;
|
|
566
584
|
const w = this.w;
|
|
567
585
|
const anims = w.config.chart.animations;
|
|
568
|
-
const
|
|
586
|
+
const dyn = anims.dynamicAnimation;
|
|
587
|
+
const dur = !anims.enabled || mode === "none" ? 0 : mode === "intro" ? (_a = anims.speed) != null ? _a : 500 : dyn.enabled ? (_b = dyn.speed) != null ? _b : 350 : 0;
|
|
569
588
|
const gen = ++this._zoomGen;
|
|
570
589
|
const morph = (
|
|
571
590
|
/** @type {any} */
|
|
572
|
-
(
|
|
591
|
+
(_c = this.ctx) == null ? void 0 : _c.morphTypeChange
|
|
573
592
|
);
|
|
574
593
|
const morphActive = !!morph && typeof morph.isActive === "function" && morph.isActive() && typeof morph.getInitialPathAt === "function";
|
|
575
594
|
const morphDur = morphActive ? morph.getSpeed() : 0;
|
|
@@ -578,6 +597,11 @@ class SunburstChart {
|
|
|
578
597
|
/** @type {any} */
|
|
579
598
|
this.ctx._sunburstPrevGeoms
|
|
580
599
|
) : null;
|
|
600
|
+
const geo = (n) => n._cur || { a0: n._t0, a1: n._t1, iR: n._iR, oR: n._oR };
|
|
601
|
+
const pinch = (c) => {
|
|
602
|
+
const m = (c.a0 + c.a1) / 2;
|
|
603
|
+
return { a0: m, a1: m, iR: c.iR, oR: c.iR };
|
|
604
|
+
};
|
|
581
605
|
this._nodesAll.forEach((node) => {
|
|
582
606
|
if (node._show) {
|
|
583
607
|
const target = {
|
|
@@ -587,36 +611,55 @@ class SunburstChart {
|
|
|
587
611
|
oR: node._oR
|
|
588
612
|
};
|
|
589
613
|
if (!node._el) node._el = this._createArcEl(node);
|
|
614
|
+
setZoomCursor(this, node);
|
|
590
615
|
const morphFrom = morphActive ? this._morphSourceFor(node) : null;
|
|
591
616
|
if (morphFrom && morphDur > 0) {
|
|
592
617
|
this._morphArcFrom(node, morphFrom, target, morphDur, gen);
|
|
593
618
|
} else if ((mode === "intro" || morphActive) && dur > 0) {
|
|
594
619
|
this._sweepArc(node, target, morphActive ? morphDur : dur, gen);
|
|
595
620
|
} else {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
from = node._cur;
|
|
600
|
-
} else if (prev && prev.get(node._key)) {
|
|
601
|
-
from = prev.get(node._key);
|
|
602
|
-
} else {
|
|
603
|
-
const mid = (target.a0 + target.a1) / 2;
|
|
604
|
-
from = { a0: mid, a1: mid, iR: target.iR, oR: target.iR };
|
|
605
|
-
isNew = true;
|
|
606
|
-
}
|
|
607
|
-
this._animateArc(node, from, target, dur, false, isNew, gen);
|
|
621
|
+
const p = prev && prev.get(node._key);
|
|
622
|
+
const from = node._cur || (p ? geo(p) : pinch(target));
|
|
623
|
+
this._animateArc(node, from, target, dur, false, !node._cur && !p, gen);
|
|
608
624
|
}
|
|
609
625
|
} else if (node._el && node._cur) {
|
|
610
|
-
|
|
611
|
-
const target = { a0: mid, a1: mid, iR: node._cur.iR, oR: node._cur.iR };
|
|
612
|
-
this._animateArc(node, node._cur, target, dur, true, false, gen);
|
|
626
|
+
this._animateArc(node, node._cur, pinch(node._cur), dur, true, false, gen);
|
|
613
627
|
}
|
|
614
628
|
});
|
|
629
|
+
if (prev && dur && !morphActive) {
|
|
630
|
+
const keys = new Set(this._nodesAll.map((n) => n._show && n._key));
|
|
631
|
+
prev.forEach((p, k) => {
|
|
632
|
+
if (keys.has(k) || !(p._show || p._cur)) return;
|
|
633
|
+
const el = this._graphics.drawPath({
|
|
634
|
+
fill: p._color,
|
|
635
|
+
stroke: this.strokeColor,
|
|
636
|
+
strokeWidth: this.strokeWidth,
|
|
637
|
+
classes: "apexcharts-sunburst-arc"
|
|
638
|
+
});
|
|
639
|
+
el.node.setAttribute("data:name", p.name);
|
|
640
|
+
this._ringsG.add(el.attr({ opacity: p._el.attr("opacity") }));
|
|
641
|
+
const c = geo(p);
|
|
642
|
+
const g = { _el: el, _color: p._color, name: p.name, _key: k, _cur: c };
|
|
643
|
+
this._nodesAll.push(g);
|
|
644
|
+
this._animateArc(g, c, pinch(c), dur, true, false, gen);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
const end = Math.max(dur, morphDur);
|
|
648
|
+
if (end) {
|
|
649
|
+
this._ringsG.animate(end).after(() => {
|
|
650
|
+
if (this._zoomGen === gen && this._ringsG.node.isConnected)
|
|
651
|
+
new Animations(
|
|
652
|
+
w,
|
|
653
|
+
/** @type {any} */
|
|
654
|
+
this.ctx
|
|
655
|
+
).animationCompleted(
|
|
656
|
+
this._ringsG.node
|
|
657
|
+
);
|
|
658
|
+
});
|
|
659
|
+
} else w.globals.animationEnded = true;
|
|
615
660
|
const geoms = /* @__PURE__ */ new Map();
|
|
616
661
|
this._nodesAll.forEach((n) => {
|
|
617
|
-
if (n._show)
|
|
618
|
-
geoms.set(n._key, { a0: n._t0, a1: n._t1, iR: n._iR, oR: n._oR });
|
|
619
|
-
}
|
|
662
|
+
if (n._show || n._cur) geoms.set(n._key, n);
|
|
620
663
|
});
|
|
621
664
|
this.ctx._sunburstPrevGeoms = geoms;
|
|
622
665
|
this._renderLabels(dur);
|
|
@@ -733,11 +776,9 @@ class SunburstChart {
|
|
|
733
776
|
*/
|
|
734
777
|
_createArcEl(node) {
|
|
735
778
|
const path = this._graphics.drawPath({
|
|
736
|
-
d: "",
|
|
737
779
|
fill: node._color,
|
|
738
780
|
stroke: this.strokeColor,
|
|
739
781
|
strokeWidth: this.strokeWidth,
|
|
740
|
-
fillOpacity: 1,
|
|
741
782
|
classes: "apexcharts-sunburst-arc"
|
|
742
783
|
});
|
|
743
784
|
const el = path.node;
|
|
@@ -749,9 +790,8 @@ class SunburstChart {
|
|
|
749
790
|
String(!(node.children && node.children.length))
|
|
750
791
|
);
|
|
751
792
|
this._tooltip.attach(el, node);
|
|
752
|
-
if (Environment.isBrowser()) {
|
|
793
|
+
if (Environment.isBrowser() && this.cfg.zoomOnClick !== false) {
|
|
753
794
|
el.addEventListener("click", () => this._zoomTo(node));
|
|
754
|
-
el.style.cursor = "pointer";
|
|
755
795
|
}
|
|
756
796
|
this._ringsG.add(path);
|
|
757
797
|
return path;
|
|
@@ -815,11 +855,12 @@ class SunburstChart {
|
|
|
815
855
|
if (node._t1 - node._t0 < this.cfg.dataLabels.minAngleToShow) return;
|
|
816
856
|
this._renderCurvedLabel(node);
|
|
817
857
|
});
|
|
858
|
+
const gen = this._zoomGen;
|
|
859
|
+
labelsG.attr({ opacity: dur > 0 ? 0 : 1 });
|
|
818
860
|
if (dur > 0) {
|
|
819
|
-
labelsG.
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
labelsG.attr({ opacity: 1 });
|
|
861
|
+
labelsG.animate(250, dur).during((p) => {
|
|
862
|
+
if (this._zoomGen === gen) labelsG.attr({ opacity: p });
|
|
863
|
+
});
|
|
823
864
|
}
|
|
824
865
|
}
|
|
825
866
|
/**
|
|
@@ -828,11 +869,10 @@ class SunburstChart {
|
|
|
828
869
|
* @param {any} node
|
|
829
870
|
*/
|
|
830
871
|
_renderCurvedLabel(node) {
|
|
831
|
-
if (!Environment.isBrowser()) return;
|
|
832
872
|
const style = this.cfg.dataLabels.style;
|
|
833
873
|
const w = this.w;
|
|
834
874
|
const r = (node._iR + node._oR) / 2;
|
|
835
|
-
const mid = (node._t0 + node._t1) / 2;
|
|
875
|
+
const mid = ((node._t0 + node._t1) / 2 % 360 + 360) % 360;
|
|
836
876
|
const flip = mid > 90 && mid < 270;
|
|
837
877
|
const padDeg = Math.min(r > 0 ? 4 / r * R2D : 0, (node._t1 - node._t0) / 2);
|
|
838
878
|
const from = flip ? node._t1 - padDeg : node._t0 + padDeg;
|
|
@@ -893,17 +933,13 @@ class SunburstChart {
|
|
|
893
933
|
*/
|
|
894
934
|
_zoomTo(node) {
|
|
895
935
|
if (this.cfg.zoomOnClick === false) return;
|
|
896
|
-
const next = resolveFocus(node, this._focus);
|
|
936
|
+
const next = resolveFocus(node, this._focus, this._roots);
|
|
897
937
|
if (!next.changed) return;
|
|
898
938
|
this._focus = next.focus;
|
|
899
939
|
this._relayout(this._focus);
|
|
900
940
|
this._applyLayout("zoom");
|
|
901
941
|
this._renderBreadcrumb();
|
|
902
942
|
}
|
|
903
|
-
/** Root -> focus chain of nodes. */
|
|
904
|
-
_focusChain() {
|
|
905
|
-
return focusChain(this._focus);
|
|
906
|
-
}
|
|
907
943
|
/**
|
|
908
944
|
* Minimal self-contained breadcrumb (reuses the shared `.apexcharts-breadcrumb`
|
|
909
945
|
* CSS classes, but does NOT depend on the drilldown feature).
|
|
@@ -923,7 +959,7 @@ class SunburstChart {
|
|
|
923
959
|
nav.style.top = "0px";
|
|
924
960
|
nav.style.left = "0px";
|
|
925
961
|
const crumbs = [{ name: "All", node: null }].concat(
|
|
926
|
-
this.
|
|
962
|
+
focusChain(this._focus).map((n) => ({ name: n.name, node: n }))
|
|
927
963
|
);
|
|
928
964
|
crumbs.forEach((crumb, i) => {
|
|
929
965
|
if (i > 0) {
|
|
@@ -965,21 +1001,7 @@ class SunburstChart {
|
|
|
965
1001
|
}
|
|
966
1002
|
});
|
|
967
1003
|
elWrap.appendChild(nav);
|
|
968
|
-
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* The breadcrumb is an absolute overlay at top-left, so it can sit on top of
|
|
972
|
-
* a left-aligned title (or subtitle). After mounting, push it below any chart
|
|
973
|
-
* chrome it intersects. (Duplicated from drilldown's Breadcrumb on purpose —
|
|
974
|
-
* sunburst must not import the drilldown feature.)
|
|
975
|
-
* @param {any} nav
|
|
976
|
-
*/
|
|
977
|
-
/**
|
|
978
|
-
* Shared with the treemap - see charts/common/Breadcrumb.
|
|
979
|
-
* @param {any} nav
|
|
980
|
-
*/
|
|
981
|
-
_avoidChromeOverlap(nav) {
|
|
982
|
-
avoidChromeOverlap(this.w, nav);
|
|
1004
|
+
avoidChromeOverlap(w, nav);
|
|
983
1005
|
}
|
|
984
1006
|
// ------------------------------------------------------------ geometry
|
|
985
1007
|
/**
|
package/dist/sunburst.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ApexCharts v8.
|
|
2
|
+
* ApexCharts v8.3.1
|
|
3
3
|
* (c) 2018-2026 ApexCharts
|
|
4
4
|
*/
|
|
5
|
-
!function(t){var e="undefined"!=typeof globalThis?globalThis:self,s=e.ApexCharts;if(s&&s.__internals)return t.call(e);if(s)throw new Error("ApexCharts: dist/sunburst.js cannot register: the ApexCharts on this page has no add-on surface (a script before 7.0, or a bundled apexcharts/core class). Load apexcharts.min.js, apexcharts.core.min.js or apexcharts.full.min.js.");if("function"==typeof define&&define.amd)return t.call(e);if("object"==typeof exports&&"undefined"!=typeof module||"undefined"==typeof window||"undefined"==typeof document)throw new Error("ApexCharts: dist/sunburst.js is a script-tag add-on and needs the ApexCharts script on the page. A bundler imports the matching apexcharts/ sub-path instead.");var r={file:"dist/sunburst.js",run:t,done:!1},a=e.__apexcharts_pending_addons__||(e.__apexcharts_pending_addons__=[]);a.push(r),"complete"!==document.readyState&&window.addEventListener("load",function(){if(!r.done){var s=e.ApexCharts;if(s)if(s.__internals){r.done=!0;var n=a.indexOf(r);-1!==n&&a.splice(n,1);try{t.call(e),s.__drainsAddons||e.console.warn("ApexCharts: dist/sunburst.js loaded before the ApexCharts script, which is older than 8.0 and does not pick up add-ons loaded first, so it registered only when the page finished loading. Put its tag after the ApexCharts script.")}catch(t){e.console.error("ApexCharts: dist/sunburst.js could not register with the ApexCharts script on this page: "+(t&&t.message))}}else e.console.error("ApexCharts: dist/sunburst.js cannot register: the ApexCharts on this page has no add-on surface (a script before 7.0, or a bundled apexcharts/core class). Load apexcharts.min.js, apexcharts.core.min.js or apexcharts.full.min.js.");else e.console.warn("ApexCharts: dist/sunburst.js is waiting for the ApexCharts script, which had not loaded when the page finished loading. It registers when an ApexCharts 8.0 or later script loads; if the page has none, add apexcharts.min.js (or apexcharts.core.min.js, or apexcharts.full.min.js).")}})}(function(){var t,e;t=this,e=function(t){"use strict";const e=globalThis.ApexCharts,s=globalThis.ApexCharts.__internals.__apex_Graphics,r=globalThis.ApexCharts.__internals.__apex_BrowserAPIs_BrowserAPIs,a=globalThis.ApexCharts.__internals.__apex_Environment_Environment,n=Math.PI/180,i=180/Math.PI;function o(t,e,s,r){return{x:t+s*Math.cos((r-90)*n),y:e+s*Math.sin((r-90)*n)}}const l=t=>`${t.x} ${t.y}`,h=globalThis.ApexCharts.__internals,c=h.__apex_Animations;function u(t,e,s,r,a,n=null,i={}){var o,l,h;const c=e&&"object"==typeof e,d=c&&null!=(l=null!=(o=e.x)?o:e.name)?l:"",p=Number(c?null!=(h=e.y)?h:e.value:e),_={name:String(d),value:isNaN(p)?null:p,color:c&&e.color?e.color:void 0,_key:`${a}/${s}:${d}`};if(r&&!_.color&&(_.color=r[s%r.length]),i.keepDatum&&(_._datum=e),c&&Array.isArray(e.children)&&e.children.length)_.children=e.children.map((e,s)=>u(t,e,s,null,_._key,n,i));else if(c&&null!=e.drilldown&&!1!==i.expandDrilldown){const s=n||new Set;if(!s.has(e.drilldown)){const r=function(t,e){const s=t.config.drilldown;return(s&&Array.isArray(s.series)?s.series:[]).find(t=>t&&t.id===e)}(t,e.drilldown);if(r&&Array.isArray(r.data)&&r.data.length){const a=new Set(s);a.add(e.drilldown);const n=Array.isArray(r.colors)?r.colors:null;_.children=r.data.map((e,s)=>u(t,e,s,n,_._key,a,i))}}}return _}function d(t){t.children&&t.children.length&&(t.children.forEach(t=>d(t)),(null==t.value||isNaN(t.value))&&(t.value=t.children.reduce((t,e)=>t+Math.max(0,e.value||0),0))),(null==t.value||isNaN(t.value))&&(t.value=0)}function p(t){if("string"!=typeof t)return"";const e=t.indexOf("/");return-1===e?"":t.slice(e)}function _(t,e,s,r,a,n){if(t._show=!0,t._vDepth=e,t._t0=s,t._t1=r,t._parent=a,t._leaf=!(t.children&&t.children.length),t._clipped=!t._leaf&&null!=n.cap&&e>=n.cap,e>n.maxDepth&&(n.maxDepth=e),t._leaf||t._clipped)return;const i=t.children.reduce((t,e)=>t+Math.max(0,e.value),0)||1;let o=s;for(let a=0;a<t.children.length;a++){const l=t.children[a],h=(r-s)*Math.max(0,l.value)/i;_(l,e+1,o,o+h,t,n),o+=h}}function f(t,e){if("string"!=typeof t||"#"!==t[0])return t;let s=t.slice(1);if(3===s.length&&(s=s.split("").map(t=>t+t).join("")),6!==s.length)return t;const r=parseInt(s,16);if(isNaN(r))return t;let a=r>>16&255,n=r>>8&255,i=255&r;return a=Math.round(a+(255-a)*e),n=Math.round(n+(255-n)*e),i=Math.round(i+(255-i)*e),"#"+((1<<24)+(a<<16)+(n<<8)+i).toString(16).slice(1)}function m(t,e,s,r){if(t._color=t.color||e,r.push(t),t.children)for(let e=0;e<t.children.length;e++){const a=t.children[e];m(a,a.color||f(t._color,s),s,r)}}h.__apex_Animations_computeStagger,h.__apex_Animations_applyAnimationPolicy,h.__apex_Animations_prefersReducedMotion,h.__apex_Animations_applyProgressiveReveal;class g{constructor(t){this.w=t,this.total=1,this._el=null}_tip(){return this._el||(this._el=this.w.dom.baseEl.querySelector(".apexcharts-tooltip")),this._el}attach(t,e){this.w.config.tooltip.enabled&&a.isBrowser()&&(t.addEventListener("mouseenter",t=>this.show(t,e)),t.addEventListener("mousemove",t=>this.position(t)),t.addEventListener("mouseleave",()=>this.hide()))}show(t,e){const s=this._tip();if(!s)return;const r=this.w,a=(e.value/this.total*100).toFixed(1),n=e._parent?e._parent.value:this.total,i=n>0?(e.value/n*100).toFixed(1):a,o=r.config.tooltip.fillSeriesColor?`background-color:${e._color};`:"";s.innerHTML=`<div class="apexcharts-tooltip-series-group apexcharts-active" style="display:flex;${o}"><span class="apexcharts-tooltip-marker" style="background-color:${e._color}"></span><div class="apexcharts-tooltip-text"><div class="apexcharts-tooltip-y-group"><span class="apexcharts-tooltip-text-y-label">${e.name}: </span><span class="apexcharts-tooltip-text-y-value">${e.value} (${i}% of parent, ${a}% of total)</span></div></div></div>`,s.classList.add("apexcharts-active"),s.style.opacity="1",this.position(t)}position(t){const e=this._tip();if(!e)return;const s=this.w.dom.elWrap.getBoundingClientRect(),r=e.offsetWidth,a=e.offsetHeight;let n=t.clientX-s.left+12;n+r>s.width&&(n=t.clientX-s.left-r-12),n=Math.max(0,Math.min(n,s.width-r));let i=t.clientY-s.top+12;i+a>s.height&&(i=t.clientY-s.top-a-12),i=Math.max(0,Math.min(i,s.height-a)),e.style.left=n+"px",e.style.top=i+"px"}hide(){const t=this._tip();t&&(t.classList.remove("apexcharts-active"),t.style.opacity="0")}}const x=Math.PI/180,b=180/Math.PI,y="http://www.w3.org/2000/svg",A="http://www.w3.org/1999/xhtml",w=(t,e,s)=>t+(e-t)*s;e.use({sunburst:class{constructor(t,e){this.ctx=e,this.w=t;const s=t.config;this.cfg=s.plotOptions.sunburst,this.strokeWidth=s.stroke.show?s.stroke.width:0,this.strokeColor=Array.isArray(s.stroke.colors)?s.stroke.colors[0]:s.stroke.colors||"#fff",this.startAngle=this.cfg.startAngle,this.endAngle=this.cfg.endAngle,this.maxDepth=0,this.centerX=0,this.centerY=0,this.maxRadius=0,this.total=1,this._focusMaxDepth=0,this._focus=null,this._zoomGen=0,this._roots=[],this._nodesAll=[],this._innerR=()=>0,this._outerR=()=>0,this._tooltip=new g(t),this._lblSeq=0,this._morphLeafIndex=0,this._graphics=null,this._ringsG=null,this._labelsG=null}draw(t){const e=this.w,r=new s(this.w);this._graphics=r;const a=r.group({class:"apexcharts-sunburst"});if(e.globals.noData||!t||!t.length)return a;const n=e.layout.gridWidth,i=e.layout.gridHeight;if(this.centerX=n/2+(this.cfg.offsetX||0),this.centerY=i/2+(this.cfg.offsetY||0),this.maxRadius=Math.min(n,i)/2.05-this.strokeWidth-(e.config.chart.sparkline.enabled?0:e.config.chart.dropShadow.blur),this.maxRadius<5)return a;if(this._roots=this._buildHierarchy(),!this._roots.length)return a;this._roots.forEach(t=>this._fillValues(t)),this._validateStrict(),this._nodesAll=[];const o=e.globals.colors||[];this._roots.forEach((t,e)=>{this._colorPass(t,t.color||o[e%o.length]||"#008FFB")}),this.total=this._roots.reduce((t,e)=>t+Math.max(0,e.value),0)||1,this._tooltip.total=this.total,this._ringsG=r.group({class:"apexcharts-sunburst-rings"}),this._labelsG=r.group({class:"apexcharts-sunburst-labels"}),a.add(this._ringsG),a.add(this._labelsG),this._focus=null,this._relayout(this._focus);const l=e.config.chart.animations;let h="none";return l.enabled&&(e.globals.dataChanged?l.dynamicAnimation.enabled&&(h="update"):e.globals.resized||(h="intro")),this._applyLayout(h),this._renderBreadcrumb(),a}_buildHierarchy(){return function(t,e={}){const s=t.config.series,r=s&&s[0],a=r&&Array.isArray(r.data)?r.data:s;return Array.isArray(a)?a.map((s,r)=>u(t,s,r,null,"",null,e)):[]}(this.w)}_fillValues(t){d(t)}_validateStrict(){"strict"===this.cfg.partition&&function(t,{type:e,remedy:s}){let r=!1;const a=t=>{if(t.children&&t.children.length){const n=t.children.reduce((t,e)=>t+Math.max(0,e.value||0),0);!r&&null!=t.value&&Math.abs(n-t.value)>.5&&(console.warn(`ApexCharts ${e}: partition 'strict' but "${t.name}" (${t.value}) != sum of its children (${n}). ${s}`),r=!0),t.children.forEach(a)}};t.forEach(a)}(this._roots,{type:"sunburst",remedy:"Angles are normalized to fill the wedge."})}_colorPass(t,e){m(t,e,this.cfg.tint,this._nodesAll)}_relayout(t){this._focusMaxDepth=function({roots:t,nodesAll:e,focus:s,t0:r,t1:a,cap:n}){for(let t=0;t<e.length;t++)e[t]._show=!1;const i={maxDepth:0,cap:n};if(s)return _(s,0,r,a,s._parent,i),i.maxDepth;const o=t.reduce((t,e)=>t+Math.max(0,e.value),0)||1;let l=r;for(let e=0;e<t.length;e++){const s=(a-r)*Math.max(0,t[e].value)/o;_(t[e],0,l,l+s,null,i),l+=s}return i.maxDepth}({roots:this._roots,nodesAll:this._nodesAll,focus:t,t0:this.startAngle,t1:this.endAngle});const e=function(t,e,s=0){if("number"==typeof t)return t;const r=String(t).trim();if(r.endsWith("%"))return parseFloat(r)/100*e;const a=parseFloat(r);return isNaN(a)?s*e:a}(this.cfg.innerSize,this.maxRadius,.15),s=function({maxDepth:t,near:e,far:s,gap:r=0}){const a=t+1,n=(s-e)/a,i=a>1?r:0;return{near:t=>e+t*n+(t>0?i/2:0),far:t=>e+(t+1)*n-i/2}}({maxDepth:this._focusMaxDepth,near:e,far:this.maxRadius,gap:1});this._innerR=s.near,this._outerR=s.far,this._nodesAll.forEach(t=>{t._show&&(t._iR=s.near(t._vDepth),t._oR=function(t,e,s,r,a){return t._leaf&&"extend"===r&&t._vDepth<s?a:e.far(t._vDepth)}(t,s,this._focusMaxDepth,this.cfg.leaf,this.maxRadius))})}_applyLayout(t){var e;const s=this.w.config.chart.animations,r=s.enabled?"none"===t?0:"update"===t?s.dynamicAnimation.speed||350:s.speed||500:0,a=++this._zoomGen,n=null==(e=this.ctx)?void 0:e.morphTypeChange,i=!!n&&"function"==typeof n.isActive&&n.isActive()&&"function"==typeof n.getInitialPathAt,o=i?n.getSpeed():0;this._morphLeafIndex=0;const l="update"===t?this.ctx._sunburstPrevGeoms:null;this._nodesAll.forEach(e=>{if(e._show){const s={a0:e._t0,a1:e._t1,iR:e._iR,oR:e._oR};e._el||(e._el=this._createArcEl(e));const n=i?this._morphSourceFor(e):null;if(n&&o>0)this._morphArcFrom(e,n,s,o,a);else if(("intro"===t||i)&&r>0)this._sweepArc(e,s,i?o:r,a);else{let t,n=!1;if(e._cur)t=e._cur;else if(l&&l.get(e._key))t=l.get(e._key);else{const e=(s.a0+s.a1)/2;t={a0:e,a1:e,iR:s.iR,oR:s.iR},n=!0}this._animateArc(e,t,s,r,!1,n,a)}}else if(e._el&&e._cur){const t=(e._cur.a0+e._cur.a1)/2,s={a0:t,a1:t,iR:e._cur.iR,oR:e._cur.iR};this._animateArc(e,e._cur,s,r,!0,!1,a)}});const h=new Map;this._nodesAll.forEach(t=>{t._show&&h.set(t._key,{a0:t._t0,a1:t._t1,iR:t._iR,oR:t._oR})}),this.ctx._sunburstPrevGeoms=h,this._renderLabels(r)}_morphSourceFor(t){const e=this.ctx,s=e&&e.morphTypeChange;return s?"function"==typeof s.hasKeyedMarks&&s.hasKeyedMarks()&&"function"==typeof s.getInitialPathForKey?s.getInitialPathForKey(p(t._key)):t.children&&t.children.length?null:s.getInitialPathAt(this._morphLeafIndex++):null}_morphArcFrom(t,e,s,r,a){const n=t._el,i=this._arcPath(s.iR,s.oR,s.a0,s.a1,this.cfg.borderRadius);n.node.style.display="",n.attr({d:e,opacity:1}),t._cur=s,this._zoomGen===a&&new c(this.w,this.ctx).morphSVG(n,0,null,t._color,e,i,r,0)}_sweepArc(t,e,s,r){const a=t._el,n=this.cfg.borderRadius,i=this.startAngle,o=this.endAngle;a.node.style.display="",a.attr({d:"",opacity:1}),a.animate(s).during(s=>{if(this._zoomGen!==r)return;const l=i+(o-i)*s;if(l<=e.a0+.01)return void a.attr({d:""});const h=Math.min(e.a1,l);a.attr({d:this._arcPath(e.iR,e.oR,e.a0,h,n)}),t._cur={a0:e.a0,a1:h,iR:e.iR,oR:e.oR}}).after(()=>{this._zoomGen===r&&(t._cur=e)})}_createArcEl(t){const e=this._graphics.drawPath({d:"",fill:t._color,stroke:this.strokeColor,strokeWidth:this.strokeWidth,fillOpacity:1,classes:"apexcharts-sunburst-arc"}),s=e.node;return s.setAttribute("data:name",t.name),s.setAttribute("data:value",String(t.value)),s.setAttribute("data:key",p(t._key)),s.setAttribute("data:leaf",String(!(t.children&&t.children.length))),this._tooltip.attach(s,t),a.isBrowser()&&(s.addEventListener("click",()=>this._zoomTo(t)),s.style.cursor="pointer"),this._ringsG.add(e),e}_animateArc(t,e,s,r,a,n,i){const o=t._el,l=this.cfg.borderRadius;if(o.attr({fill:t._color}),0===r)return o.attr({d:this._arcPath(s.iR,s.oR,s.a0,s.a1,l),opacity:a?0:1}),o.node.style.display=a?"none":"",void(t._cur=a?null:s);o.node.style.display="";const h=a?Number(o.attr("opacity"))||1:n?0:1,c=a?0:1;o.attr({opacity:h}),o.animate(r).during(r=>{if(this._zoomGen!==i)return;const a=w(e.a0,s.a0,r),n=w(e.a1,s.a1,r),u=w(e.iR,s.iR,r),d=w(e.oR,s.oR,r);o.attr({d:this._arcPath(u,d,a,n,l),opacity:w(h,c,r)}),t._cur={a0:a,a1:n,iR:u,oR:d}}).after(()=>{this._zoomGen===i&&(a?(o.node.style.display="none",t._cur=null):t._cur=s)})}_renderLabels(t){const e=this._labelsG;for(;e.node.firstChild;)e.node.removeChild(e.node.firstChild);this.cfg.dataLabels.show&&(this._nodesAll.forEach(t=>{t._show&&(t._t1-t._t0<this.cfg.dataLabels.minAngleToShow||this._renderCurvedLabel(t))}),t>0?(e.attr({opacity:0}),e.animate(250,t).attr({opacity:1})):e.attr({opacity:1}))}_renderCurvedLabel(t){if(!a.isBrowser())return;const e=this.cfg.dataLabels.style,s=this.w,n=(t._iR+t._oR)/2,i=(t._t0+t._t1)/2,o=i>90&&i<270,l=Math.min(n>0?4/n*b:0,(t._t1-t._t0)/2),h=o?t._t1-l:t._t0+l,c=o?t._t0+l:t._t1-l,u=this._ptAt(n,h),d=this._ptAt(n,c),p=Math.abs(c-h)>180?1:0,_=o?0:1,f=`apx-sb-lbl-${s.globals.cuid}-${this._lblSeq++}`,m=r.createElementNS(y,"path");m.setAttribute("id",f),m.setAttribute("d",`M ${u.x} ${u.y} A ${n} ${n} 0 ${p} ${_} ${d.x} ${d.y}`),m.setAttribute("fill","none"),m.setAttribute("stroke","none");const g=e.colors,x=(Array.isArray(g)?g[0]:g)||"#fff",A=r.createElementNS(y,"text");A.setAttribute("font-size",e.fontSize||"12px"),e.fontFamily&&A.setAttribute("font-family",e.fontFamily),A.setAttribute("font-weight",String(e.fontWeight||400)),A.setAttribute("fill",x),A.setAttribute("dominant-baseline","central"),A.style.pointerEvents="none";const w=r.createElementNS(y,"textPath");w.setAttribute("href","#"+f),w.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#"+f),w.setAttribute("startOffset","50%"),w.setAttribute("text-anchor","middle"),w.textContent=this._truncate(t.name,n,t._t1-t._t0,e.fontSize),A.appendChild(w),this._labelsG.node.appendChild(m),this._labelsG.node.appendChild(A)}_truncate(t,e,s,r){const a=e*s*x-8,n=.58*(parseFloat(r)||12),i=Math.floor(a/n);return i>=t.length?t:i<=1?"":t.slice(0,Math.max(1,i-1))+"\u2026"}_zoomTo(t){if(!1===this.cfg.zoomOnClick)return;const e=function(t,e){let s=t===e?t._parent||null:t;return!s||s.children&&s.children.length||(s=s._parent||null),s===e?{changed:!1,focus:e}:{changed:!0,focus:s}}(t,this._focus);e.changed&&(this._focus=e.focus,this._relayout(this._focus),this._applyLayout("zoom"),this._renderBreadcrumb())}_focusChain(){return function(t){const e=[];let s=t;for(;s;)e.unshift(s),s=s._parent;return e}(this._focus)}_renderBreadcrumb(){if(!a.isBrowser())return;const t=this.w.dom.elWrap;if(!t)return;const e=t.querySelector(".apexcharts-breadcrumb");if(e&&e.parentNode&&e.parentNode.removeChild(e),!this._focus)return;const s=r.createElementNS(A,"nav");s.setAttribute("class","apexcharts-breadcrumb"),s.setAttribute("aria-label","Sunburst breadcrumb"),s.style.position="absolute",s.style.top="0px",s.style.left="0px";const n=[{name:"All",node:null}].concat(this._focusChain().map(t=>({name:t.name,node:t})));n.forEach((t,e)=>{if(e>0){const t=r.createElementNS(A,"span");t.setAttribute("class","apexcharts-breadcrumb-separator"),t.textContent=" / ",s.appendChild(t)}if(e===n.length-1){const e=r.createElementNS(A,"span");e.setAttribute("class","apexcharts-breadcrumb-item apexcharts-breadcrumb-current"),e.textContent=t.name,s.appendChild(e)}else{const a=r.createElementNS(A,"button");if(a.setAttribute("type","button"),a.setAttribute("class","apexcharts-breadcrumb-item"),0===e){const t=r.createElementNS(A,"span");t.setAttribute("class","apexcharts-breadcrumb-arrow"),t.textContent="\u2190",a.appendChild(t)}const n=r.createElementNS(A,"span");n.setAttribute("class","apexcharts-breadcrumb-label"),n.textContent=t.name,a.appendChild(n),a.addEventListener("click",()=>{this._focus=t.node,this._relayout(this._focus),this._applyLayout("zoom"),this._renderBreadcrumb()}),s.appendChild(a)}}),t.appendChild(s),this._avoidChromeOverlap(s)}_avoidChromeOverlap(t){!function(t,e){const s=[".apexcharts-title-text",".apexcharts-subtitle-text"].map(e=>t.dom.baseEl.querySelector(e)).filter(t=>null!==t);if(!s.length)return;const r=t.dom.elWrap.getBoundingClientRect().top;for(let t=0;t<s.length+1;t++){const t=e.getBoundingClientRect(),a=s.find(e=>{const s=e.getBoundingClientRect();return t.left<s.right&&t.right>s.left&&t.top<s.bottom&&t.bottom>s.top});if(!a)break;e.style.top=a.getBoundingClientRect().bottom-r+4+"px"}}(this.w,t)}_ptAt(t,e){return{x:this.centerX+t*Math.cos((e-90)*x),y:this.centerY+t*Math.sin((e-90)*x)}}_arcPath(t,e,s,r,a){if(e<=t+.01)return"";let n=r-s;const h=this.cfg.spacing;if(h>0&&n>0&&e>0){const t=h/e*b,a=Math.min(t/2,Math.max(0,n/2-.25));n=(r-=a)-(s+=a)}if(n<=0)return"";const c=n*x,u=this.centerX,d=this.centerY;let p=a;return p=Math.min(p,c*t/2,c*e/2,(e-t)/2),p>.5?function({cx:t,cy:e,rIn:s,rOut:r,a0:a,a1:n,r:h,spanDeg:c}){const u=(s,r)=>o(t,e,s,r),d=h/r*i,p=h/s*i,_=u(r,a+d),f=u(r,n-d),m=c-2*d>180?1:0,g=u(r,n),x=u(r-h,n),b=u(r,a),y=u(r-h,a),A=u(s,n-p),w=u(s,a+p),v=c-2*p>180?1:0,C=u(s,n),R=u(s+h,n),M=u(s,a),S=u(s+h,a);return["M",l(_),"A",r,r,0,m,1,l(f),"Q",l(g),l(x),"L",l(R),"Q",l(C),l(A),"A",s,s,0,v,0,l(w),"Q",l(M),l(S),"L",l(y),"Q",l(b),l(_),"Z"].join(" ")}({cx:u,cy:d,rIn:t,rOut:e,a0:s,a1:r,r:p,spanDeg:n}):function({cx:t,cy:e,rIn:s,rOut:r,a0:a,a1:n,spanDeg:i}){const h=(s,r)=>o(t,e,s,r),c=i>180?1:0,u=h(r,a),d=h(r,n),p=h(s,n),_=h(s,a);return["M",l(u),"A",r,r,0,c,1,l(d),"L",l(p),"A",s,s,0,c,0,l(_),"Z"].join(" ")}({cx:u,cy:d,rIn:t,rOut:e,a0:s,a1:r,spanDeg:n})}}}),t.default=e,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ApexSunburst={})});
|
|
5
|
+
!function(t){var e="undefined"!=typeof globalThis?globalThis:self,s=e.ApexCharts;if(s&&s.__internals)return t.call(e);if(s)throw new Error("ApexCharts: dist/sunburst.js cannot register: the ApexCharts on this page has no add-on surface (a script before 7.0, or a bundled apexcharts/core class). Load apexcharts.min.js, apexcharts.core.min.js or apexcharts.full.min.js.");if("function"==typeof define&&define.amd)return t.call(e);if("object"==typeof exports&&"undefined"!=typeof module||"undefined"==typeof window||"undefined"==typeof document)throw new Error("ApexCharts: dist/sunburst.js is a script-tag add-on and needs the ApexCharts script on the page. A bundler imports the matching apexcharts/ sub-path instead.");var n={file:"dist/sunburst.js",run:t,done:!1},r=e.__apexcharts_pending_addons__||(e.__apexcharts_pending_addons__=[]);r.push(n),"complete"!==document.readyState&&window.addEventListener("load",function(){if(!n.done){var s=e.ApexCharts;if(s)if(s.__internals){n.done=!0;var a=r.indexOf(n);-1!==a&&r.splice(a,1);try{t.call(e),s.__drainsAddons||e.console.warn("ApexCharts: dist/sunburst.js loaded before the ApexCharts script, which is older than 8.0 and does not pick up add-ons loaded first, so it registered only when the page finished loading. Put its tag after the ApexCharts script.")}catch(t){e.console.error("ApexCharts: dist/sunburst.js could not register with the ApexCharts script on this page: "+(t&&t.message))}}else e.console.error("ApexCharts: dist/sunburst.js cannot register: the ApexCharts on this page has no add-on surface (a script before 7.0, or a bundled apexcharts/core class). Load apexcharts.min.js, apexcharts.core.min.js or apexcharts.full.min.js.");else e.console.warn("ApexCharts: dist/sunburst.js is waiting for the ApexCharts script, which had not loaded when the page finished loading. It registers when an ApexCharts 8.0 or later script loads; if the page has none, add apexcharts.min.js (or apexcharts.core.min.js, or apexcharts.full.min.js).")}})}(function(){var t,e;t=this,e=function(t){"use strict";const e=globalThis.ApexCharts,s=globalThis.ApexCharts.__internals.__apex_Graphics,n=globalThis.ApexCharts.__internals.__apex_BrowserAPIs_BrowserAPIs,r=globalThis.ApexCharts.__internals.__apex_Environment_Environment,a=Math.PI/180,i=180/Math.PI;function o(t,e,s,n){return{x:t+s*Math.cos((n-90)*a),y:e+s*Math.sin((n-90)*a)}}const l=t=>`${t.x} ${t.y}`,h=globalThis.ApexCharts.__internals,c=h.__apex_Animations;function d(t,e){var s;const n=String(t).replace(/\//g,"%2F"),r=(null!=(s=e.get(n))?s:-1)+1;return e.set(n,r),`${r}:${n}`}function u(t,e,s,n,r,a=null,i={},o=new Map){var l,h,c;const p=e&&"object"==typeof e,_=p&&null!=(h=null!=(l=e.x)?l:e.name)?h:"",f=p?null!=(c=e.y)?c:e.value:e,m=null==f||""===f?NaN:Number(f),g={name:String(_),value:isNaN(m)?null:m,color:p&&e.color?e.color:void 0,_key:`${r}/${d(_,o)}`};n&&!g.color&&(g.color=n[s%n.length]),i.keepDatum&&(g._datum=e);const x=new Map;if(p&&Array.isArray(e.children)&&e.children.length)g.children=e.children.map((e,s)=>u(t,e,s,null,g._key,a,i,x));else if(p&&null!=e.drilldown&&!1!==i.expandDrilldown){const s=a||new Set;if(!s.has(e.drilldown)){const n=function(t,e){const s=t.config.drilldown;return(s&&Array.isArray(s.series)?s.series:[]).find(t=>t&&t.id===e)}(t,e.drilldown);if(n&&Array.isArray(n.data)&&n.data.length){const r=new Set(s);r.add(e.drilldown);const a=Array.isArray(n.colors)?n.colors:null;g.children=n.data.map((e,s)=>u(t,e,s,a,g._key,r,i,x))}}}return g}function p(t){t.children&&t.children.length&&(t.children.forEach(t=>p(t)),(null==t.value||isNaN(t.value))&&(t.value=t.children.reduce((t,e)=>t+Math.max(0,e.value||0),0))),(null==t.value||isNaN(t.value))&&(t.value=0)}function _(t){if("string"!=typeof t)return"";const e=t.indexOf("/");return-1===e?"":t.slice(e)}function f(t,e,s,n,r,a){if(t._show=!0,t._vDepth=e,t._t0=s,t._t1=n,t._parent=r,t._leaf=!(t.children&&t.children.length),t._clipped=!t._leaf&&null!=a.cap&&e>=a.cap,e>a.maxDepth&&(a.maxDepth=e),t._leaf||t._clipped)return;const i=t.children.reduce((t,e)=>t+Math.max(0,e.value),0)||1;let o=s;for(let r=0;r<t.children.length;r++){const l=t.children[r],h=(n-s)*Math.max(0,l.value)/i;f(l,e+1,o,o+h,t,a),o+=h}}function m(t,e,s){let n=t===e?t._parent||null:t;return!n||n.children&&n.children.length||(n=n._parent||null),s&&1===s.length&&n===s[0]&&(n=null),n===e?{changed:!1,focus:e}:{changed:!0,focus:n}}function g(t,e){if("string"!=typeof t||"#"!==t[0])return t;let s=t.slice(1);if(3===s.length&&(s=s.split("").map(t=>t+t).join("")),6!==s.length)return t;const n=parseInt(s,16);if(isNaN(n))return t;let r=n>>16&255,a=n>>8&255,i=255&n;return r=Math.round(r+(255-r)*e),a=Math.round(a+(255-a)*e),i=Math.round(i+(255-i)*e),"#"+((1<<24)+(r<<16)+(a<<8)+i).toString(16).slice(1)}function x(t,e,s,n){if(t._color=t.color||e,n.push(t),t.children)for(let e=0;e<t.children.length;e++){const r=t.children[e];x(r,r.color||g(t._color,s),s,n)}}h.__apex_Animations_computeStagger,h.__apex_Animations_applyAnimationPolicy,h.__apex_Animations_prefersReducedMotion,h.__apex_Animations_applyProgressiveReveal;class b{constructor(t){this.w=t,this.total=1,this._el=null}_tip(){return this._el||(this._el=this.w.dom.baseEl.querySelector(".apexcharts-tooltip")),this._el}attach(t,e){this.w.config.tooltip.enabled&&r.isBrowser()&&(t.addEventListener("mouseenter",t=>this.show(t,e)),t.addEventListener("mousemove",t=>this.position(t)),t.addEventListener("mouseleave",()=>this.hide()))}show(t,e){var s;const n=this._tip();if(!n)return;const r=this.w,a=(e.value/this.total*100).toFixed(1),i=e._parent?e._parent.value:this.total,o=i>0?(e.value/i*100).toFixed(1):a,l=r.config.tooltip.y,h=null==(s=Array.isArray(l)?l[0]:l)?void 0:s.formatter,c=h?h(e.value,{seriesIndex:0,dataPointIndex:-1,w:r,node:e}):+e.value.toPrecision(12);var d;n.innerHTML=`<div class="apexcharts-tooltip-series-group apexcharts-active" style="display:flex"><span class="apexcharts-tooltip-marker"></span><div class="apexcharts-tooltip-text"><div class="apexcharts-tooltip-y-group"><span class="apexcharts-tooltip-text-y-label">${d=e.name,String(d).replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`)}: </span><span class="apexcharts-tooltip-text-y-value">${c} (${o}% of parent, ${a}% of total)</span></div></div></div>`;const u=n.firstChild;u.firstChild.style.backgroundColor=e._color,r.config.tooltip.fillSeriesColor&&(u.style.backgroundColor=e._color),n.classList.add("apexcharts-active"),n.style.opacity="1",this.position(t)}position(t){const e=this._tip();if(!e)return;const s=this.w.dom.elWrap.getBoundingClientRect(),n=e.offsetWidth,r=e.offsetHeight;let a=t.clientX-s.left+12;a+n>s.width&&(a=t.clientX-s.left-n-12),a=Math.max(0,Math.min(a,s.width-n));let i=t.clientY-s.top+12;i+r>s.height&&(i=t.clientY-s.top-r-12),i=Math.max(0,Math.min(i,s.height-r)),e.style.left=a+"px",e.style.top=i+"px"}hide(){const t=this._tip();t&&(t.classList.remove("apexcharts-active"),t.style.opacity="0")}}const y=Math.PI/180,A=180/Math.PI,w="http://www.w3.org/2000/svg",v="http://www.w3.org/1999/xhtml",C=(t,e,s)=>t+(e-t)*s;e.use({sunburst:class{constructor(t,e){this.ctx=e,this.w=t;const s=t.config;this.cfg=s.plotOptions.sunburst,this.strokeWidth=s.stroke.show?s.stroke.width:0,this.strokeColor=Array.isArray(s.stroke.colors)?s.stroke.colors[0]:s.stroke.colors||"#fff",this.startAngle=this.cfg.startAngle,this.endAngle=this.cfg.endAngle,this.maxDepth=0,this.centerX=0,this.centerY=0,this.maxRadius=0,this.total=1,this._focusMaxDepth=0,this._focus=null,this._zoomGen=0,this._roots=[],this._nodesAll=[],this._innerR=()=>0,this._outerR=()=>0,this._tooltip=new b(t),this._lblSeq=0,this._morphLeafIndex=0,this._graphics=null,this._ringsG=null,this._labelsG=null}draw(t){const e=this.w,n=new s(this.w);this._graphics=n;const r=n.group({class:"apexcharts-sunburst"});if(e.globals.noData||!t||!t.length)return r;const a=e.layout.gridWidth,i=e.layout.gridHeight;if(this.centerX=a/2+(this.cfg.offsetX||0),this.centerY=i/2+(this.cfg.offsetY||0),this.maxRadius=Math.min(a,i)/2.05-this.strokeWidth-(e.config.chart.sparkline.enabled?0:e.config.chart.dropShadow.blur),this.maxRadius<5)return r;if(this._roots=function(t,e={}){const s=t.config.series,n=s&&s[0],r=n&&Array.isArray(n.data)?n.data:s;if(!Array.isArray(r))return[];const a=new Map;return r.map((s,n)=>u(t,s,n,null,"",null,e,a))}(e),!this._roots.length)return r;this._roots.forEach(p),this._validateStrict(),this._nodesAll=[];const o=e.globals.colors||[];this._roots.forEach((t,e)=>{x(t,t.color||o[e%o.length]||"#008FFB",this.cfg.tint,this._nodesAll)}),this.total=this._roots.reduce((t,e)=>t+Math.max(0,e.value),0)||1,this._tooltip.total=this.total,this._ringsG=n.group({class:"apexcharts-sunburst-rings"}),this._labelsG=n.group({class:"apexcharts-sunburst-labels"}),r.add(this._ringsG),r.add(this._labelsG),this._focus=function(t,e,s){var n;const r=t&&e.find(e=>e._key===t);return r&&(null==(n=r.children)?void 0:n.length)&&(1!==s.length||r!==s[0])?r:null}(e.globals.sunburstFocusKey,this._nodesAll,this._roots),this._relayout(this._focus);let l="none";return e.config.chart.animations.enabled&&(e.globals.dataChanged?!1!==e.globals.shouldAnimate&&(l="update"):e.globals.resized||(l="intro")),this._applyLayout(l),this._renderBreadcrumb(),r}_validateStrict(){"strict"===this.cfg.partition&&function(t,{type:e,remedy:s}){let n=!1;const r=t=>{if(t.children&&t.children.length){const a=t.children.reduce((t,e)=>t+Math.max(0,e.value||0),0);!n&&null!=t.value&&Math.abs(a-t.value)>.5&&(console.warn(`ApexCharts ${e}: partition 'strict' but "${t.name}" (${t.value}) != sum of its children (${a}). ${s}`),n=!0),t.children.forEach(r)}};t.forEach(r)}(this._roots,{type:"sunburst",remedy:"Angles are normalized to fill the wedge."})}_relayout(t){this.w.globals.sunburstFocusKey=t&&t._key,this._focusMaxDepth=function({roots:t,nodesAll:e,focus:s,t0:n,t1:r,cap:a}){for(let t=0;t<e.length;t++)e[t]._show=!1;const i={maxDepth:0,cap:a};if(s)return f(s,0,n,r,s._parent,i),i.maxDepth;const o=t.reduce((t,e)=>t+Math.max(0,e.value),0)||1;let l=n;for(let e=0;e<t.length;e++){const s=(r-n)*Math.max(0,t[e].value)/o;f(t[e],0,l,l+s,null,i),l+=s}return i.maxDepth}({roots:this._roots,nodesAll:this._nodesAll,focus:t,t0:this.startAngle,t1:this.endAngle});const e=function(t,e,s=0){if("number"==typeof t)return t;const n=String(t).trim();if(n.endsWith("%"))return parseFloat(n)/100*e;const r=parseFloat(n);return isNaN(r)?s*e:r}(this.cfg.innerSize,this.maxRadius,.15),s=function({maxDepth:t,near:e,far:s,gap:n=0}){const r=t+1,a=(s-e)/r,i=r>1?n:0;return{near:t=>e+t*a+(t>0?i/2:0),far:t=>e+(t+1)*a-i/2}}({maxDepth:this._focusMaxDepth,near:e,far:this.maxRadius,gap:1});this._innerR=s.near,this._outerR=s.far,this._nodesAll.forEach(t=>{t._show&&(t._iR=s.near(t._vDepth),t._oR=function(t,e,s,n,r){return t._leaf&&"extend"===n&&t._vDepth<s?r:e.far(t._vDepth)}(t,s,this._focusMaxDepth,this.cfg.leaf,this.maxRadius))})}_applyLayout(t){var e,s,n;const a=this.w,i=a.config.chart.animations,o=i.dynamicAnimation,l=i.enabled&&"none"!==t?"intro"===t?null!=(e=i.speed)?e:500:o.enabled?null!=(s=o.speed)?s:350:0:0,h=++this._zoomGen,d=null==(n=this.ctx)?void 0:n.morphTypeChange,u=!!d&&"function"==typeof d.isActive&&d.isActive()&&"function"==typeof d.getInitialPathAt,p=u?d.getSpeed():0;this._morphLeafIndex=0;const _="update"===t?this.ctx._sunburstPrevGeoms:null,f=t=>t._cur||{a0:t._t0,a1:t._t1,iR:t._iR,oR:t._oR},g=t=>{const e=(t.a0+t.a1)/2;return{a0:e,a1:e,iR:t.iR,oR:t.iR}};if(this._nodesAll.forEach(e=>{if(e._show){const s={a0:e._t0,a1:e._t1,iR:e._iR,oR:e._oR};e._el||(e._el=this._createArcEl(e)),function(t,e){r.isBrowser()&&!1!==t.cfg.zoomOnClick&&(e._el.node.style.cursor=m(e,t._focus,t._roots).changed?"pointer":"default")}(this,e);const n=u?this._morphSourceFor(e):null;if(n&&p>0)this._morphArcFrom(e,n,s,p,h);else if(("intro"===t||u)&&l>0)this._sweepArc(e,s,u?p:l,h);else{const t=_&&_.get(e._key),n=e._cur||(t?f(t):g(s));this._animateArc(e,n,s,l,!1,!e._cur&&!t,h)}}else e._el&&e._cur&&this._animateArc(e,e._cur,g(e._cur),l,!0,!1,h)}),_&&l&&!u){const t=new Set(this._nodesAll.map(t=>t._show&&t._key));_.forEach((e,s)=>{if(t.has(s)||!e._show&&!e._cur)return;const n=this._graphics.drawPath({fill:e._color,stroke:this.strokeColor,strokeWidth:this.strokeWidth,classes:"apexcharts-sunburst-arc"});n.node.setAttribute("data:name",e.name),this._ringsG.add(n.attr({opacity:e._el.attr("opacity")}));const r=f(e),a={_el:n,_color:e._color,name:e.name,_key:s,_cur:r};this._nodesAll.push(a),this._animateArc(a,r,g(r),l,!0,!1,h)})}const x=Math.max(l,p);x?this._ringsG.animate(x).after(()=>{this._zoomGen===h&&this._ringsG.node.isConnected&&new c(a,this.ctx).animationCompleted(this._ringsG.node)}):a.globals.animationEnded=!0;const b=new Map;this._nodesAll.forEach(t=>{(t._show||t._cur)&&b.set(t._key,t)}),this.ctx._sunburstPrevGeoms=b,this._renderLabels(l)}_morphSourceFor(t){const e=this.ctx,s=e&&e.morphTypeChange;return s?"function"==typeof s.hasKeyedMarks&&s.hasKeyedMarks()&&"function"==typeof s.getInitialPathForKey?s.getInitialPathForKey(_(t._key)):t.children&&t.children.length?null:s.getInitialPathAt(this._morphLeafIndex++):null}_morphArcFrom(t,e,s,n,r){const a=t._el,i=this._arcPath(s.iR,s.oR,s.a0,s.a1,this.cfg.borderRadius);a.node.style.display="",a.attr({d:e,opacity:1}),t._cur=s,this._zoomGen===r&&new c(this.w,this.ctx).morphSVG(a,0,null,t._color,e,i,n,0)}_sweepArc(t,e,s,n){const r=t._el,a=this.cfg.borderRadius,i=this.startAngle,o=this.endAngle;r.node.style.display="",r.attr({d:"",opacity:1}),r.animate(s).during(s=>{if(this._zoomGen!==n)return;const l=i+(o-i)*s;if(l<=e.a0+.01)return void r.attr({d:""});const h=Math.min(e.a1,l);r.attr({d:this._arcPath(e.iR,e.oR,e.a0,h,a)}),t._cur={a0:e.a0,a1:h,iR:e.iR,oR:e.oR}}).after(()=>{this._zoomGen===n&&(t._cur=e)})}_createArcEl(t){const e=this._graphics.drawPath({fill:t._color,stroke:this.strokeColor,strokeWidth:this.strokeWidth,classes:"apexcharts-sunburst-arc"}),s=e.node;return s.setAttribute("data:name",t.name),s.setAttribute("data:value",String(t.value)),s.setAttribute("data:key",_(t._key)),s.setAttribute("data:leaf",String(!(t.children&&t.children.length))),this._tooltip.attach(s,t),r.isBrowser()&&!1!==this.cfg.zoomOnClick&&s.addEventListener("click",()=>this._zoomTo(t)),this._ringsG.add(e),e}_animateArc(t,e,s,n,r,a,i){const o=t._el,l=this.cfg.borderRadius;if(o.attr({fill:t._color}),0===n)return o.attr({d:this._arcPath(s.iR,s.oR,s.a0,s.a1,l),opacity:r?0:1}),o.node.style.display=r?"none":"",void(t._cur=r?null:s);o.node.style.display="";const h=r?Number(o.attr("opacity"))||1:a?0:1,c=r?0:1;o.attr({opacity:h}),o.animate(n).during(n=>{if(this._zoomGen!==i)return;const r=C(e.a0,s.a0,n),a=C(e.a1,s.a1,n),d=C(e.iR,s.iR,n),u=C(e.oR,s.oR,n);o.attr({d:this._arcPath(d,u,r,a,l),opacity:C(h,c,n)}),t._cur={a0:r,a1:a,iR:d,oR:u}}).after(()=>{this._zoomGen===i&&(r?(o.node.style.display="none",t._cur=null):t._cur=s)})}_renderLabels(t){const e=this._labelsG;for(;e.node.firstChild;)e.node.removeChild(e.node.firstChild);if(!this.cfg.dataLabels.show)return;this._nodesAll.forEach(t=>{t._show&&(t._t1-t._t0<this.cfg.dataLabels.minAngleToShow||this._renderCurvedLabel(t))});const s=this._zoomGen;e.attr({opacity:t>0?0:1}),t>0&&e.animate(250,t).during(t=>{this._zoomGen===s&&e.attr({opacity:t})})}_renderCurvedLabel(t){const e=this.cfg.dataLabels.style,s=this.w,r=(t._iR+t._oR)/2,a=((t._t0+t._t1)/2%360+360)%360,i=a>90&&a<270,o=Math.min(r>0?4/r*A:0,(t._t1-t._t0)/2),l=i?t._t1-o:t._t0+o,h=i?t._t0+o:t._t1-o,c=this._ptAt(r,l),d=this._ptAt(r,h),u=Math.abs(h-l)>180?1:0,p=i?0:1,_=`apx-sb-lbl-${s.globals.cuid}-${this._lblSeq++}`,f=n.createElementNS(w,"path");f.setAttribute("id",_),f.setAttribute("d",`M ${c.x} ${c.y} A ${r} ${r} 0 ${u} ${p} ${d.x} ${d.y}`),f.setAttribute("fill","none"),f.setAttribute("stroke","none");const m=e.colors,g=(Array.isArray(m)?m[0]:m)||"#fff",x=n.createElementNS(w,"text");x.setAttribute("font-size",e.fontSize||"12px"),e.fontFamily&&x.setAttribute("font-family",e.fontFamily),x.setAttribute("font-weight",String(e.fontWeight||400)),x.setAttribute("fill",g),x.setAttribute("dominant-baseline","central"),x.style.pointerEvents="none";const b=n.createElementNS(w,"textPath");b.setAttribute("href","#"+_),b.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#"+_),b.setAttribute("startOffset","50%"),b.setAttribute("text-anchor","middle"),b.textContent=this._truncate(t.name,r,t._t1-t._t0,e.fontSize),x.appendChild(b),this._labelsG.node.appendChild(f),this._labelsG.node.appendChild(x)}_truncate(t,e,s,n){const r=e*s*y-8,a=.58*(parseFloat(n)||12),i=Math.floor(r/a);return i>=t.length?t:i<=1?"":t.slice(0,Math.max(1,i-1))+"\u2026"}_zoomTo(t){if(!1===this.cfg.zoomOnClick)return;const e=m(t,this._focus,this._roots);e.changed&&(this._focus=e.focus,this._relayout(this._focus),this._applyLayout("zoom"),this._renderBreadcrumb())}_renderBreadcrumb(){if(!r.isBrowser())return;const t=this.w,e=t.dom.elWrap;if(!e)return;const s=e.querySelector(".apexcharts-breadcrumb");if(s&&s.parentNode&&s.parentNode.removeChild(s),!this._focus)return;const a=n.createElementNS(v,"nav");a.setAttribute("class","apexcharts-breadcrumb"),a.setAttribute("aria-label","Sunburst breadcrumb"),a.style.position="absolute",a.style.top="0px",a.style.left="0px";const i=[{name:"All",node:null}].concat(function(t){const e=[];let s=t;for(;s;)e.unshift(s),s=s._parent;return e}(this._focus).map(t=>({name:t.name,node:t})));i.forEach((t,e)=>{if(e>0){const t=n.createElementNS(v,"span");t.setAttribute("class","apexcharts-breadcrumb-separator"),t.textContent=" / ",a.appendChild(t)}if(e===i.length-1){const e=n.createElementNS(v,"span");e.setAttribute("class","apexcharts-breadcrumb-item apexcharts-breadcrumb-current"),e.textContent=t.name,a.appendChild(e)}else{const s=n.createElementNS(v,"button");if(s.setAttribute("type","button"),s.setAttribute("class","apexcharts-breadcrumb-item"),0===e){const t=n.createElementNS(v,"span");t.setAttribute("class","apexcharts-breadcrumb-arrow"),t.textContent="\u2190",s.appendChild(t)}const r=n.createElementNS(v,"span");r.setAttribute("class","apexcharts-breadcrumb-label"),r.textContent=t.name,s.appendChild(r),s.addEventListener("click",()=>{this._focus=t.node,this._relayout(this._focus),this._applyLayout("zoom"),this._renderBreadcrumb()}),a.appendChild(s)}}),e.appendChild(a),function(t,e){const s=[".apexcharts-title-text",".apexcharts-subtitle-text"].map(e=>t.dom.baseEl.querySelector(e)).filter(t=>null!==t);if(!s.length)return;const n=t.dom.elWrap.getBoundingClientRect().top;for(let t=0;t<s.length+1;t++){const t=e.getBoundingClientRect(),r=s.find(e=>{const s=e.getBoundingClientRect();return t.left<s.right&&t.right>s.left&&t.top<s.bottom&&t.bottom>s.top});if(!r)break;e.style.top=r.getBoundingClientRect().bottom-n+4+"px"}}(t,a)}_ptAt(t,e){return{x:this.centerX+t*Math.cos((e-90)*y),y:this.centerY+t*Math.sin((e-90)*y)}}_arcPath(t,e,s,n,r){if(e<=t+.01)return"";let a=n-s;const h=this.cfg.spacing;if(h>0&&a>0&&e>0){const t=h/e*A,r=Math.min(t/2,Math.max(0,a/2-.25));a=(n-=r)-(s+=r)}if(a<=0)return"";const c=a*y,d=this.centerX,u=this.centerY;let p=r;return p=Math.min(p,c*t/2,c*e/2,(e-t)/2),p>.5?function({cx:t,cy:e,rIn:s,rOut:n,a0:r,a1:a,r:h,spanDeg:c}){const d=(s,n)=>o(t,e,s,n),u=h/n*i,p=h/s*i,_=d(n,r+u),f=d(n,a-u),m=c-2*u>180?1:0,g=d(n,a),x=d(n-h,a),b=d(n,r),y=d(n-h,r),A=d(s,a-p),w=d(s,r+p),v=c-2*p>180?1:0,C=d(s,a),R=d(s+h,a),M=d(s,r),k=d(s+h,r);return["M",l(_),"A",n,n,0,m,1,l(f),"Q",l(g),l(x),"L",l(R),"Q",l(C),l(A),"A",s,s,0,v,0,l(w),"Q",l(M),l(k),"L",l(y),"Q",l(b),l(_),"Z"].join(" ")}({cx:d,cy:u,rIn:t,rOut:e,a0:s,a1:n,r:p,spanDeg:a}):function({cx:t,cy:e,rIn:s,rOut:n,a0:r,a1:a,spanDeg:i}){const h=(s,n)=>o(t,e,s,n),c=i>180?1:0,d=h(n,r),u=h(n,a),p=h(s,a),_=h(s,r);return["M",l(d),"A",n,n,0,c,1,l(u),"L",l(p),"A",s,s,0,c,0,l(_),"Z"].join(" ")}({cx:d,cy:u,rIn:t,rOut:e,a0:s,a1:n,spanDeg:a})}}}),t.default=e,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ApexSunburst={})});
|