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/treemap.esm.js
CHANGED
|
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
/*!
|
|
21
|
-
* ApexCharts v8.
|
|
21
|
+
* ApexCharts v8.3.1
|
|
22
22
|
* (c) 2018-2026 ApexCharts
|
|
23
23
|
*/
|
|
24
24
|
import * as _core from "apexcharts/core";
|
|
@@ -189,16 +189,6 @@ const Animations = _core.__apex_Animations;
|
|
|
189
189
|
const Fill = _core.__apex_Fill;
|
|
190
190
|
const Utils = _core.__apex_Utils;
|
|
191
191
|
const DataLabels = _core.__apex_DataLabels;
|
|
192
|
-
const resolveDataLabelOffset = (value, w, seriesIndex, dataPointIndex) => {
|
|
193
|
-
if (typeof value !== "function") return value;
|
|
194
|
-
const resolved = value({
|
|
195
|
-
series: w.seriesData.series,
|
|
196
|
-
seriesIndex,
|
|
197
|
-
dataPointIndex,
|
|
198
|
-
w
|
|
199
|
-
});
|
|
200
|
-
return Number.isFinite(resolved) ? resolved : 0;
|
|
201
|
-
};
|
|
202
192
|
class TreemapHelpers {
|
|
203
193
|
/**
|
|
204
194
|
* @param {import('../../../types/internal').ChartStateW} w
|
|
@@ -348,13 +338,9 @@ class TreemapHelpers {
|
|
|
348
338
|
elDataLabelsWrap = graphics.group({
|
|
349
339
|
class: "apexcharts-data-labels"
|
|
350
340
|
});
|
|
351
|
-
const offX = resolveDataLabelOffset(dataLabelsConfig.offsetX, w, i, j);
|
|
352
|
-
const offY = resolveDataLabelOffset(dataLabelsConfig.offsetY, w, i, j);
|
|
353
|
-
const dataLabelsX = x + offX;
|
|
354
|
-
const dataLabelsY = y + parseFloat(dataLabelsConfig.style.fontSize) / 3 + offY;
|
|
355
341
|
dataLabels.plotDataLabelsText({
|
|
356
|
-
x
|
|
357
|
-
y:
|
|
342
|
+
x,
|
|
343
|
+
y: y + parseFloat(dataLabelsConfig.style.fontSize) / 3,
|
|
358
344
|
text,
|
|
359
345
|
i,
|
|
360
346
|
j,
|
|
@@ -375,26 +361,33 @@ function drilldownById(w, id) {
|
|
|
375
361
|
const list = dd && Array.isArray(dd.series) ? dd.series : [];
|
|
376
362
|
return list.find((s) => s && s.id === id);
|
|
377
363
|
}
|
|
378
|
-
function
|
|
364
|
+
function segment(name, seen) {
|
|
365
|
+
var _a;
|
|
366
|
+
const n = String(name).replace(/\//g, "%2F");
|
|
367
|
+
const o = ((_a = seen.get(n)) != null ? _a : -1) + 1;
|
|
368
|
+
seen.set(n, o);
|
|
369
|
+
return `${o}:${n}`;
|
|
370
|
+
}
|
|
371
|
+
function toNode(w, d, i, paletteFromParent, parentKey, seenIds = null, opts = {}, seen = /* @__PURE__ */ new Map()) {
|
|
379
372
|
var _a, _b, _c;
|
|
380
373
|
const isObj = d && typeof d === "object";
|
|
381
374
|
const name = isObj ? (_b = (_a = d.x) != null ? _a : d.name) != null ? _b : "" : "";
|
|
382
|
-
const
|
|
375
|
+
const raw = isObj ? (_c = d.y) != null ? _c : d.value : d;
|
|
376
|
+
const value = raw == null || raw === "" ? NaN : Number(raw);
|
|
383
377
|
const node = {
|
|
384
378
|
name: String(name),
|
|
385
379
|
value: isNaN(value) ? null : value,
|
|
386
380
|
color: isObj && d.color ? d.color : void 0,
|
|
387
|
-
|
|
388
|
-
// siblings stay distinct). Update animations morph matched keys in place.
|
|
389
|
-
_key: `${parentKey}/${i}:${name}`
|
|
381
|
+
_key: `${parentKey}/${segment(name, seen)}`
|
|
390
382
|
};
|
|
391
383
|
if (paletteFromParent && !node.color) {
|
|
392
384
|
node.color = paletteFromParent[i % paletteFromParent.length];
|
|
393
385
|
}
|
|
394
386
|
if (opts.keepDatum) node._datum = d;
|
|
387
|
+
const kids = /* @__PURE__ */ new Map();
|
|
395
388
|
if (isObj && Array.isArray(d.children) && d.children.length) {
|
|
396
389
|
node.children = d.children.map(
|
|
397
|
-
(c, j) => toNode(w, c, j, null, node._key, seenIds, opts)
|
|
390
|
+
(c, j) => toNode(w, c, j, null, node._key, seenIds, opts, kids)
|
|
398
391
|
);
|
|
399
392
|
} else if (isObj && d.drilldown != null && opts.expandDrilldown !== false) {
|
|
400
393
|
const visited = seenIds || /* @__PURE__ */ new Set();
|
|
@@ -405,7 +398,7 @@ function toNode(w, d, i, paletteFromParent, parentKey, seenIds = null, opts = {}
|
|
|
405
398
|
nextSeen.add(d.drilldown);
|
|
406
399
|
const palette = Array.isArray(dd.colors) ? dd.colors : null;
|
|
407
400
|
node.children = dd.data.map(
|
|
408
|
-
(c, j) => toNode(w, c, j, palette, node._key, nextSeen, opts)
|
|
401
|
+
(c, j) => toNode(w, c, j, palette, node._key, nextSeen, opts, kids)
|
|
409
402
|
);
|
|
410
403
|
}
|
|
411
404
|
}
|
|
@@ -418,10 +411,12 @@ function buildSeriesRoots(w, series, opts = {}) {
|
|
|
418
411
|
series || w.config.series
|
|
419
412
|
);
|
|
420
413
|
if (!Array.isArray(cfgSeries)) return [];
|
|
414
|
+
const seen = /* @__PURE__ */ new Map();
|
|
421
415
|
return cfgSeries.map((s, i) => {
|
|
422
416
|
var _a, _b;
|
|
423
417
|
const data = s && Array.isArray(s.data) ? s.data : [];
|
|
424
|
-
const key =
|
|
418
|
+
const key = segment((_a = s == null ? void 0 : s.name) != null ? _a : "", seen);
|
|
419
|
+
const kids = /* @__PURE__ */ new Map();
|
|
425
420
|
const root = {
|
|
426
421
|
name: String((_b = s == null ? void 0 : s.name) != null ? _b : ""),
|
|
427
422
|
value: null,
|
|
@@ -429,7 +424,7 @@ function buildSeriesRoots(w, series, opts = {}) {
|
|
|
429
424
|
_key: key,
|
|
430
425
|
_seriesIndex: i,
|
|
431
426
|
children: data.map(
|
|
432
|
-
(d, j) => toNode(w, d, j, null, key, null, opts)
|
|
427
|
+
(d, j) => toNode(w, d, j, null, key, null, opts, kids)
|
|
433
428
|
)
|
|
434
429
|
};
|
|
435
430
|
return root;
|
|
@@ -483,8 +478,7 @@ function getTreemapRoots(w) {
|
|
|
483
478
|
if (stashed && stashed.length) {
|
|
484
479
|
return {
|
|
485
480
|
roots: stashed,
|
|
486
|
-
maxDepth: w.globals.treemapMaxDepth || 1
|
|
487
|
-
nested: true
|
|
481
|
+
maxDepth: w.globals.treemapMaxDepth || 1
|
|
488
482
|
};
|
|
489
483
|
}
|
|
490
484
|
const roots = buildSeriesRoots(w, w.config.series, {
|
|
@@ -493,7 +487,7 @@ function getTreemapRoots(w) {
|
|
|
493
487
|
});
|
|
494
488
|
roots.forEach(fillValues);
|
|
495
489
|
const { maxDepth } = annotate(roots);
|
|
496
|
-
return { roots, maxDepth
|
|
490
|
+
return { roots, maxDepth };
|
|
497
491
|
}
|
|
498
492
|
const BrowserAPIs = _core.__apex_BrowserAPIs_BrowserAPIs;
|
|
499
493
|
const resolveEasing = _core.__apex_Easing_resolveEasing;
|
|
@@ -760,7 +754,7 @@ function renderBreadcrumb(w, opts) {
|
|
|
760
754
|
text.setAttribute("class", "apexcharts-breadcrumb-label");
|
|
761
755
|
text.textContent = String(label);
|
|
762
756
|
btn.appendChild(text);
|
|
763
|
-
btn.addEventListener("click", () => opts.onNavigate(i, crumb));
|
|
757
|
+
btn.addEventListener("click", (e) => opts.onNavigate(i, crumb, e));
|
|
764
758
|
nav.appendChild(btn);
|
|
765
759
|
});
|
|
766
760
|
elWrap.appendChild(nav);
|
|
@@ -788,6 +782,11 @@ function withFills(from, to, fillWas, fillNow) {
|
|
|
788
782
|
}
|
|
789
783
|
return [from, to];
|
|
790
784
|
}
|
|
785
|
+
const showsParents = (w) => {
|
|
786
|
+
var _a;
|
|
787
|
+
const show = w.config.plotOptions.treemap.parents.show;
|
|
788
|
+
return show === true || show !== false && !!((_a = w.globals.treemapRoots) == null ? void 0 : _a.length);
|
|
789
|
+
};
|
|
791
790
|
const headerLook = (el) => Series.treemapHeaderLook(el);
|
|
792
791
|
class TreemapChart {
|
|
793
792
|
/**
|
|
@@ -803,7 +802,6 @@ class TreemapChart {
|
|
|
803
802
|
this.labels = [];
|
|
804
803
|
this.roots = [];
|
|
805
804
|
this.drawn = [];
|
|
806
|
-
this.nested = false;
|
|
807
805
|
this.showParents = false;
|
|
808
806
|
this.scale = null;
|
|
809
807
|
this._levelCache = null;
|
|
@@ -830,13 +828,11 @@ class TreemapChart {
|
|
|
830
828
|
});
|
|
831
829
|
});
|
|
832
830
|
const tree = getTreemapRoots(w);
|
|
833
|
-
this.nested = tree.nested;
|
|
834
831
|
this.roots = tree.roots;
|
|
835
832
|
this.scale = buildContinuousScale(w);
|
|
836
833
|
const drawn = tree.roots.length === 1 ? tree.roots[0].children || [] : tree.roots;
|
|
837
834
|
this.drawn = drawn;
|
|
838
|
-
|
|
839
|
-
this.showParents = parentsCfg.show === true || parentsCfg.show !== false && this.nested;
|
|
835
|
+
this.showParents = showsParents(w);
|
|
840
836
|
const focus = this._resolveFocus(drawn);
|
|
841
837
|
const layoutRoots = focus ? [focus] : drawn;
|
|
842
838
|
TreemapSquared.generateNested(
|
|
@@ -868,7 +864,7 @@ class TreemapChart {
|
|
|
868
864
|
if (w.config.chart.dropShadow.enabled) {
|
|
869
865
|
const shadow = w.config.chart.dropShadow;
|
|
870
866
|
const filters = new Filters(this.w);
|
|
871
|
-
filters.dropShadow(
|
|
867
|
+
filters.dropShadow(elSeries, shadow, i);
|
|
872
868
|
}
|
|
873
869
|
const elDataLabelWrap = graphics.group({
|
|
874
870
|
class: "apexcharts-data-labels"
|
|
@@ -962,6 +958,7 @@ class TreemapChart {
|
|
|
962
958
|
});
|
|
963
959
|
elRect.node.classList.add("apexcharts-treemap-rect");
|
|
964
960
|
elRect.node.setAttribute("data:key", morphKey(leaf._key));
|
|
961
|
+
let tileTween = null;
|
|
965
962
|
let fromRect = {
|
|
966
963
|
x: x1 + (x2 - x1) / 2,
|
|
967
964
|
y: y1 + (y2 - y1) / 2,
|
|
@@ -987,7 +984,7 @@ class TreemapChart {
|
|
|
987
984
|
if (w.globals.resized) {
|
|
988
985
|
w.globals.animationEnded = true;
|
|
989
986
|
} else {
|
|
990
|
-
this.animateTreemap(
|
|
987
|
+
tileTween = this.animateTreemap(
|
|
991
988
|
elRect,
|
|
992
989
|
fromRect,
|
|
993
990
|
toRect,
|
|
@@ -998,7 +995,6 @@ class TreemapChart {
|
|
|
998
995
|
);
|
|
999
996
|
}
|
|
1000
997
|
}
|
|
1001
|
-
let tileTween = null;
|
|
1002
998
|
let labelFrom = null;
|
|
1003
999
|
let prevLook = null;
|
|
1004
1000
|
if (w.globals.dataChanged) {
|
|
@@ -1380,7 +1376,7 @@ class TreemapChart {
|
|
|
1380
1376
|
const elGroup = graphics.group({
|
|
1381
1377
|
class: "apexcharts-treemap-parent",
|
|
1382
1378
|
"data:depth": depth,
|
|
1383
|
-
"data:name":
|
|
1379
|
+
"data:name": node.name
|
|
1384
1380
|
});
|
|
1385
1381
|
const key = morphKey(node._key);
|
|
1386
1382
|
const morphFrom = this._morphKeyed() ? this.ctx.morphTypeChange.getInitialPathForKey(key) : null;
|
|
@@ -1489,7 +1485,7 @@ class TreemapChart {
|
|
|
1489
1485
|
if (typeof header.formatter === "function") {
|
|
1490
1486
|
text = String(
|
|
1491
1487
|
header.formatter(node.name, {
|
|
1492
|
-
value: node.
|
|
1488
|
+
value: node._area,
|
|
1493
1489
|
depth,
|
|
1494
1490
|
seriesIndex: i,
|
|
1495
1491
|
node,
|
|
@@ -1497,7 +1493,7 @@ class TreemapChart {
|
|
|
1497
1493
|
})
|
|
1498
1494
|
);
|
|
1499
1495
|
} else if (header.showValue) {
|
|
1500
|
-
text = `${text} ${this._formatValue(node.
|
|
1496
|
+
text = `${text} ${this._formatValue(node._area, node._si)}`;
|
|
1501
1497
|
}
|
|
1502
1498
|
headerText = text;
|
|
1503
1499
|
const offsetX = Number(header.offsetX) || 0;
|
|
@@ -1508,7 +1504,9 @@ class TreemapChart {
|
|
|
1508
1504
|
const clipped = graphics.getTextBasedOnMaxWidth({
|
|
1509
1505
|
text,
|
|
1510
1506
|
maxWidth,
|
|
1511
|
-
fontSize
|
|
1507
|
+
fontSize,
|
|
1508
|
+
fontFamily: chrome.headerFontFamily,
|
|
1509
|
+
fontWeight: chrome.headerFontWeight
|
|
1512
1510
|
});
|
|
1513
1511
|
if (clipped) {
|
|
1514
1512
|
let tx = x1 + pad + offsetX;
|
|
@@ -1583,7 +1581,7 @@ class TreemapChart {
|
|
|
1583
1581
|
const total = this._drawnTotal();
|
|
1584
1582
|
const pct = total > 0 ? (node._area / total * 100).toFixed(1) : "0";
|
|
1585
1583
|
const n = this._countLeaves(node);
|
|
1586
|
-
const lead = visibleText && String(visibleText).trim() ? String(visibleText).replace(/\s+/g, " ").trim() : `${node.name}, ${this._formatValue(node._area)}`;
|
|
1584
|
+
const lead = visibleText && String(visibleText).trim() ? String(visibleText).replace(/\s+/g, " ").trim() : `${node.name}, ${this._formatValue(node._area, node._si)}`;
|
|
1587
1585
|
return `${lead}, ${n} ${n === 1 ? "item" : "items"}, ${pct}% of total`;
|
|
1588
1586
|
}
|
|
1589
1587
|
/**
|
|
@@ -1602,15 +1600,18 @@ class TreemapChart {
|
|
|
1602
1600
|
* @param {string} [visibleText] the header's rendered text, unclipped
|
|
1603
1601
|
*/
|
|
1604
1602
|
_makeParentAccessible(el, node, chrome, elRect, visibleText) {
|
|
1603
|
+
const a11y = this.w.config.chart.accessibility;
|
|
1605
1604
|
if (!el || !el.setAttribute) return;
|
|
1606
|
-
if (!this._zoomEnabled()) return;
|
|
1605
|
+
if (!a11y.enabled || !a11y.keyboard.enabled || !this._zoomEnabled()) return;
|
|
1606
|
+
const open = this.w.globals.treemapFocusKey === node._key;
|
|
1607
|
+
el.tmKey = node._key;
|
|
1607
1608
|
el.setAttribute("role", "button");
|
|
1608
1609
|
el.setAttribute("tabindex", "0");
|
|
1609
1610
|
el.setAttribute(
|
|
1610
1611
|
"aria-label",
|
|
1611
|
-
`${this._parentLabel(node, visibleText)}. Zoom in`
|
|
1612
|
+
`${this._parentLabel(node, visibleText)}. Zoom ${open ? "out" : "in"}`
|
|
1612
1613
|
);
|
|
1613
|
-
el.setAttribute("aria-expanded",
|
|
1614
|
+
el.setAttribute("aria-expanded", open);
|
|
1614
1615
|
if (!Environment.isBrowser() || !el.addEventListener) return;
|
|
1615
1616
|
el.addEventListener("focus", () => {
|
|
1616
1617
|
elRect.node.setAttribute("stroke", chrome.hoverColor);
|
|
@@ -1674,29 +1675,41 @@ class TreemapChart {
|
|
|
1674
1675
|
* Active means the feature is loaded as well as configured: without it the
|
|
1675
1676
|
* click navigates nowhere (the chart warns about the missing feature), so
|
|
1676
1677
|
* standing zoom down too would leave the click doing nothing at all.
|
|
1677
|
-
*
|
|
1678
|
+
*
|
|
1679
|
+
* Reads only `w`, so the layout, which runs before this renderer, asks it
|
|
1680
|
+
* through the type registry (`prototype.zoomLive`) and reserves the
|
|
1681
|
+
* breadcrumb band on the same answer: a flat treemap, with no parents to
|
|
1682
|
+
* click, used to keep an empty band. Not a static: one on this class cost
|
|
1683
|
+
* the default bundle about 290 B gzip.
|
|
1684
|
+
* @param {any} w
|
|
1685
|
+
* @param {any} drilldown the chart's drilldown feature, when loaded
|
|
1686
|
+
* @returns {any} the zoom config when live, null when drilldown is what
|
|
1687
|
+
* stands it down, else false
|
|
1678
1688
|
*/
|
|
1679
|
-
|
|
1680
|
-
|
|
1689
|
+
zoomLive(w, drilldown) {
|
|
1690
|
+
var _a;
|
|
1681
1691
|
const z = w.config.plotOptions.treemap.zoom;
|
|
1682
|
-
if (!z
|
|
1692
|
+
if (!(z == null ? void 0 : z.enabled) || !showsParents(w)) return false;
|
|
1683
1693
|
const dd = w.config.drilldown;
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1694
|
+
return drilldown && (dd == null ? void 0 : dd.enabled) && (((_a = dd.series) == null ? void 0 : _a.length) || dd.onDrillDown) ? null : z;
|
|
1695
|
+
}
|
|
1696
|
+
/** @returns {boolean} */
|
|
1697
|
+
_zoomEnabled() {
|
|
1698
|
+
const d = this.ctx.drilldown;
|
|
1699
|
+
const live = this.zoomLive(this.w, d);
|
|
1700
|
+
if (live === null && !d.zoomWarned) {
|
|
1701
|
+
d.zoomWarned = true;
|
|
1702
|
+
console.warn(
|
|
1703
|
+
"ApexCharts treemap: zoom is ignored while drilldown is active (plotOptions.treemap.zoom vs drilldown series or onDrillDown)."
|
|
1704
|
+
);
|
|
1692
1705
|
}
|
|
1693
|
-
return
|
|
1706
|
+
return !!live;
|
|
1694
1707
|
}
|
|
1695
1708
|
/**
|
|
1696
1709
|
* The focused branch for this render, looked up by the key stashed on the
|
|
1697
1710
|
* last click. Keys are rebuilt identically from the same data, so the focus
|
|
1698
|
-
* survives a re-render; a key that no longer resolves
|
|
1699
|
-
* it)
|
|
1711
|
+
* survives a re-render; a key that no longer resolves, or a branch left with
|
|
1712
|
+
* nothing to draw (the data changed under it), falls back to the whole tree.
|
|
1700
1713
|
* @param {any[]} drawn
|
|
1701
1714
|
* @returns {any}
|
|
1702
1715
|
*/
|
|
@@ -1713,7 +1726,11 @@ class TreemapChart {
|
|
|
1713
1726
|
if (node.children) node.children.forEach(walk);
|
|
1714
1727
|
};
|
|
1715
1728
|
drawn.forEach(walk);
|
|
1716
|
-
|
|
1729
|
+
if (found && found.children && found.children.length && this._subtreeArea(found) > 0) {
|
|
1730
|
+
return found;
|
|
1731
|
+
}
|
|
1732
|
+
this.w.globals.treemapFocusKey = null;
|
|
1733
|
+
return null;
|
|
1717
1734
|
}
|
|
1718
1735
|
/**
|
|
1719
1736
|
* @param {any} node
|
|
@@ -1726,28 +1743,7 @@ class TreemapChart {
|
|
|
1726
1743
|
const w = this.w;
|
|
1727
1744
|
if (!node || !node.children || !node.children.length) return;
|
|
1728
1745
|
const next = w.globals.treemapFocusKey === node._key ? null : node._key;
|
|
1729
|
-
|
|
1730
|
-
if (!restoreFocus || !done || typeof done.then !== "function") return;
|
|
1731
|
-
done.then(() => {
|
|
1732
|
-
if (!Environment.isBrowser()) return;
|
|
1733
|
-
const crumb = (
|
|
1734
|
-
/** @type {any} */
|
|
1735
|
-
w.dom.baseEl.querySelector(
|
|
1736
|
-
".apexcharts-breadcrumb .apexcharts-breadcrumb-item"
|
|
1737
|
-
)
|
|
1738
|
-
);
|
|
1739
|
-
if (crumb && crumb.focus) {
|
|
1740
|
-
crumb.focus();
|
|
1741
|
-
return;
|
|
1742
|
-
}
|
|
1743
|
-
const header = (
|
|
1744
|
-
/** @type {any} */
|
|
1745
|
-
w.dom.baseEl.querySelector(
|
|
1746
|
-
".apexcharts-treemap-parent-header[tabindex]"
|
|
1747
|
-
)
|
|
1748
|
-
);
|
|
1749
|
-
if (header && header.focus) header.focus();
|
|
1750
|
-
});
|
|
1746
|
+
this._refocus(next, restoreFocus);
|
|
1751
1747
|
}
|
|
1752
1748
|
/**
|
|
1753
1749
|
* Re-render focused on another branch (null: the whole tree).
|
|
@@ -1758,22 +1754,34 @@ class TreemapChart {
|
|
|
1758
1754
|
* left, which replayed the mount animation (every tile growing from
|
|
1759
1755
|
* nothing) or snapped, while the containers, headers and labels jumped.
|
|
1760
1756
|
* @param {string | null} next
|
|
1761
|
-
* @
|
|
1757
|
+
* @param {boolean} [restoreFocus] see _zoomTo
|
|
1762
1758
|
*/
|
|
1763
|
-
_refocus(next) {
|
|
1764
|
-
var _a;
|
|
1759
|
+
_refocus(next, restoreFocus) {
|
|
1765
1760
|
const w = this.w;
|
|
1766
1761
|
const gl = w.globals;
|
|
1762
|
+
const from = gl.treemapFocusKey;
|
|
1767
1763
|
const anim = w.config.chart.animations;
|
|
1768
1764
|
const animate = !!(anim.enabled && anim.dynamicAnimation.enabled);
|
|
1769
|
-
gl.treemapZoom = animate && Environment.isBrowser() ? { from:
|
|
1765
|
+
gl.treemapZoom = animate && Environment.isBrowser() ? { from: from != null ? from : null, to: next } : null;
|
|
1770
1766
|
gl.treemapFocusKey = next;
|
|
1771
1767
|
this._hideParentTooltip();
|
|
1772
1768
|
gl.shouldAnimate = animate;
|
|
1773
1769
|
gl.resized = true;
|
|
1774
1770
|
gl.dataChanged = true;
|
|
1775
1771
|
if (gl.treemapZoom) this.ctx.series.getPreviousPaths();
|
|
1776
|
-
|
|
1772
|
+
const done = this.ctx.update();
|
|
1773
|
+
if (restoreFocus) {
|
|
1774
|
+
done.then(() => {
|
|
1775
|
+
const b = w.dom.baseEl;
|
|
1776
|
+
const heads = (
|
|
1777
|
+
/** @type {any[]} */
|
|
1778
|
+
Array.from(
|
|
1779
|
+
b.querySelectorAll(".apexcharts-treemap-parent-header[tabindex]")
|
|
1780
|
+
)
|
|
1781
|
+
);
|
|
1782
|
+
(b.querySelector(".apexcharts-breadcrumb-item") || heads.find((h) => h.tmKey === from) || heads[0] || b).focus();
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1777
1785
|
}
|
|
1778
1786
|
/**
|
|
1779
1787
|
* A zoom reframes one tree, so it moves like a camera: one map takes the
|
|
@@ -2085,8 +2093,9 @@ class TreemapChart {
|
|
|
2085
2093
|
crumbs: [{ label: "All", data: null }].concat(
|
|
2086
2094
|
chain.map((n) => ({ label: n.name, data: n }))
|
|
2087
2095
|
),
|
|
2088
|
-
|
|
2089
|
-
|
|
2096
|
+
// A keyboard click (detail 0) keeps focus in the chart.
|
|
2097
|
+
onNavigate: (_i, crumb, e) => {
|
|
2098
|
+
this._refocus(crumb.data ? crumb.data._key : null, !e.detail);
|
|
2090
2099
|
}
|
|
2091
2100
|
});
|
|
2092
2101
|
if (!nav) return;
|
|
@@ -2103,6 +2112,9 @@ class TreemapChart {
|
|
|
2103
2112
|
* that grows the font - where a readable chip over the tiles beats a
|
|
2104
2113
|
* breadcrumb clipped by the plot.
|
|
2105
2114
|
*
|
|
2115
|
+
* Breadcrumb.placeInReservedBand does the same plus a y-axis label ceiling
|
|
2116
|
+
* a treemap has no use for, which would cost the default bundle its bytes.
|
|
2117
|
+
*
|
|
2106
2118
|
* @param {any} nav
|
|
2107
2119
|
*/
|
|
2108
2120
|
_placeBreadcrumb(nav) {
|
|
@@ -2112,11 +2124,12 @@ class TreemapChart {
|
|
|
2112
2124
|
const dimHelpers = (_b = (_a = this.ctx) == null ? void 0 : _a.dimensions) == null ? void 0 : _b.dimHelpers;
|
|
2113
2125
|
const titleArea = dimHelpers ? dimHelpers.getTitleSubtitleCoords("title").height + dimHelpers.getTitleSubtitleCoords("subtitle").height : 0;
|
|
2114
2126
|
const navH = nav.getBoundingClientRect().height || BREADCRUMB_HEIGHT;
|
|
2127
|
+
const oy = this._breadcrumbCfg().offsetY || 0;
|
|
2115
2128
|
if (gridTop - titleArea >= navH + 1) {
|
|
2116
|
-
nav.style.top = `${gridTop - navH - 1}px`;
|
|
2129
|
+
nav.style.top = `${gridTop - navH - 1 + oy}px`;
|
|
2117
2130
|
return;
|
|
2118
2131
|
}
|
|
2119
|
-
nav.style.top = `${titleArea}px`;
|
|
2132
|
+
nav.style.top = `${titleArea + oy}px`;
|
|
2120
2133
|
const dark = w.config.theme.mode === "dark";
|
|
2121
2134
|
nav.style.background = dark ? "rgba(20,24,30,0.82)" : "rgba(255,255,255,0.86)";
|
|
2122
2135
|
nav.style.borderRadius = "4px";
|
|
@@ -2135,7 +2148,7 @@ class TreemapChart {
|
|
|
2135
2148
|
const t = this._tip();
|
|
2136
2149
|
if (!t) return;
|
|
2137
2150
|
const total = this._drawnTotal();
|
|
2138
|
-
const parentVal = node._parent ? node._parent
|
|
2151
|
+
const parentVal = node._parent ? this._subtreeArea(node._parent) : total;
|
|
2139
2152
|
const pctTotal = total > 0 ? (node._area / total * 100).toFixed(1) : "0.0";
|
|
2140
2153
|
const pctParent = parentVal > 0 ? (node._area / parentVal * 100).toFixed(1) : pctTotal;
|
|
2141
2154
|
const cfg = this.w.config.plotOptions.treemap.parents;
|
|
@@ -2156,10 +2169,9 @@ class TreemapChart {
|
|
|
2156
2169
|
} else {
|
|
2157
2170
|
const marker = this._parentChrome(node.depth || 0).headerBg;
|
|
2158
2171
|
const groupBg = w.config.tooltip.fillSeriesColor ? `background-color:${marker};` : "";
|
|
2159
|
-
html = `<div class="apexcharts-tooltip-series-group apexcharts-active" style="display:flex;${groupBg}"><div class="apexcharts-tooltip-text"><div class="apexcharts-tooltip-y-group"><span class="apexcharts-tooltip-text-y-label">${
|
|
2160
|
-
node.
|
|
2161
|
-
|
|
2162
|
-
node._area
|
|
2172
|
+
html = `<div class="apexcharts-tooltip-series-group apexcharts-active" style="display:flex;${groupBg}"><div class="apexcharts-tooltip-text"><div class="apexcharts-tooltip-y-group"><span class="apexcharts-tooltip-text-y-label">${String(node.name).replace(/&/g, "&").replace(/</g, "<")}: </span><span class="apexcharts-tooltip-text-y-value">${this._formatValue(
|
|
2173
|
+
node._area,
|
|
2174
|
+
node._si
|
|
2163
2175
|
)}</span></div><div class="apexcharts-tooltip-y-group"><span class="apexcharts-tooltip-text-y-label">${leafCount} items, </span><span class="apexcharts-tooltip-text-y-value">${pctParent}% of parent, ${pctTotal}% of total</span></div></div></div>`;
|
|
2164
2176
|
}
|
|
2165
2177
|
t.innerHTML = html;
|
|
@@ -2255,17 +2267,21 @@ class TreemapChart {
|
|
|
2255
2267
|
}
|
|
2256
2268
|
/**
|
|
2257
2269
|
* Format an aggregate the way the chart formats its own y values, so a
|
|
2258
|
-
* parent's total reads like the tiles it contains.
|
|
2270
|
+
* parent's total reads like the tiles it contains. A branch is no data
|
|
2271
|
+
* point, so dataPointIndex is -1.
|
|
2259
2272
|
* @param {number} v
|
|
2273
|
+
* @param {number} [si] the branch's series index
|
|
2260
2274
|
* @returns {string}
|
|
2261
2275
|
*/
|
|
2262
|
-
_formatValue(v) {
|
|
2276
|
+
_formatValue(v, si) {
|
|
2263
2277
|
var _a, _b, _c, _d, _e;
|
|
2264
2278
|
const w = this.w;
|
|
2265
2279
|
const fmt = ((_b = (_a = w.config.tooltip) == null ? void 0 : _a.y) == null ? void 0 : _b.formatter) || ((_e = (_d = (_c = w.config.yaxis) == null ? void 0 : _c[0]) == null ? void 0 : _d.labels) == null ? void 0 : _e.formatter);
|
|
2266
2280
|
if (typeof fmt === "function") {
|
|
2267
2281
|
try {
|
|
2268
|
-
return String(
|
|
2282
|
+
return String(
|
|
2283
|
+
fmt(v, { seriesIndex: si || 0, dataPointIndex: -1, w })
|
|
2284
|
+
);
|
|
2269
2285
|
} catch (_) {
|
|
2270
2286
|
}
|
|
2271
2287
|
}
|
|
@@ -2346,7 +2362,7 @@ class TreemapChart {
|
|
|
2346
2362
|
*/
|
|
2347
2363
|
rotateToFitLabel(elText, fontSize, text, x1, y1, x2, y2) {
|
|
2348
2364
|
const graphics = new Graphics(this.w);
|
|
2349
|
-
const textRect =
|
|
2365
|
+
const textRect = this._labelRect(graphics, text, fontSize);
|
|
2350
2366
|
if (textRect.width + this.w.config.stroke.width + 5 > x2 - x1 && textRect.width <= y2 - y1) {
|
|
2351
2367
|
const labelRotatingCenter = graphics.rotateAroundCenter(elText.node);
|
|
2352
2368
|
elText.node.setAttribute(
|
|
@@ -2355,6 +2371,24 @@ class TreemapChart {
|
|
|
2355
2371
|
);
|
|
2356
2372
|
}
|
|
2357
2373
|
}
|
|
2374
|
+
/**
|
|
2375
|
+
* A tile label's box, measured at the family and weight it is drawn at
|
|
2376
|
+
* (bold is wider than the default regular).
|
|
2377
|
+
* @param {Graphics} graphics
|
|
2378
|
+
* @param {string} text
|
|
2379
|
+
* @param {string | number} fontSize
|
|
2380
|
+
*/
|
|
2381
|
+
_labelRect(graphics, text, fontSize) {
|
|
2382
|
+
const st = this.w.config.dataLabels.style;
|
|
2383
|
+
return graphics.getTextRects(
|
|
2384
|
+
text,
|
|
2385
|
+
String(fontSize),
|
|
2386
|
+
st.fontFamily,
|
|
2387
|
+
"",
|
|
2388
|
+
true,
|
|
2389
|
+
st.fontWeight
|
|
2390
|
+
);
|
|
2391
|
+
}
|
|
2358
2392
|
// This is an alternative label formatting method that uses a
|
|
2359
2393
|
// consistent font size, and trims the edge of long labels
|
|
2360
2394
|
/**
|
|
@@ -2367,13 +2401,13 @@ class TreemapChart {
|
|
|
2367
2401
|
*/
|
|
2368
2402
|
truncateLabels(text, fontSize, x1, y1, x2, y2) {
|
|
2369
2403
|
const graphics = new Graphics(this.w);
|
|
2370
|
-
const textRect =
|
|
2404
|
+
const textRect = this._labelRect(graphics, text, fontSize);
|
|
2371
2405
|
const labelMaxWidth = textRect.width + this.w.config.stroke.width + 5 > x2 - x1 && y2 - y1 > x2 - x1 ? y2 - y1 : x2 - x1;
|
|
2372
|
-
const truncatedText = graphics.getTextBasedOnMaxWidth({
|
|
2406
|
+
const truncatedText = graphics.getTextBasedOnMaxWidth(__spreadProps(__spreadValues({}, this.w.config.dataLabels.style), {
|
|
2373
2407
|
text,
|
|
2374
2408
|
maxWidth: labelMaxWidth,
|
|
2375
2409
|
fontSize
|
|
2376
|
-
});
|
|
2410
|
+
}));
|
|
2377
2411
|
if (text.length !== truncatedText.length && labelMaxWidth / fontSize < 5) {
|
|
2378
2412
|
return "";
|
|
2379
2413
|
} else {
|