apexcharts 8.2.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/apexcharts.common.js +2 -2
- package/dist/apexcharts.core.js +271 -173
- package/dist/apexcharts.core.min.js +2 -2
- package/dist/apexcharts.css +35 -0
- package/dist/apexcharts.esm.js +1722 -1527
- package/dist/apexcharts.full.js +1459 -1075
- package/dist/apexcharts.full.min.js +2 -2
- package/dist/apexcharts.js +994 -715
- package/dist/apexcharts.min.js +2 -2
- package/dist/apexcharts.ssr.common.js +2 -2
- package/dist/apexcharts.ssr.esm.js +994 -715
- 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 +433 -394
- package/dist/bar.js +2 -2
- package/dist/boxPlot.common.js +2 -2
- package/dist/boxPlot.esm.js +364 -322
- 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 +364 -322
- package/dist/candlestick.js +2 -2
- package/dist/column.common.js +2 -2
- package/dist/column.esm.js +433 -394
- package/dist/core.common.js +2 -2
- package/dist/core.esm.js +271 -173
- package/dist/donut.common.js +1 -1
- package/dist/donut.esm.js +1 -1
- package/dist/dumbbell.common.js +2 -2
- package/dist/dumbbell.esm.js +433 -394
- package/dist/features/all.common.js +2 -2
- package/dist/features/all.esm.js +250 -187
- package/dist/features/annotations.common.js +1 -1
- package/dist/features/annotations.esm.js +1 -1
- package/dist/features/annotations.js +1 -1
- package/dist/features/context-menu.common.js +1 -1
- package/dist/features/context-menu.esm.js +1 -1
- package/dist/features/context-menu.js +1 -1
- package/dist/features/drilldown.common.js +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 +1 -1
- package/dist/features/exports.esm.js +1 -1
- package/dist/features/exports.js +1 -1
- package/dist/features/facet.common.js +1 -1
- package/dist/features/facet.esm.js +1 -1
- package/dist/features/facet.js +1 -1
- package/dist/features/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 +63 -43
- 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 +1 -1
- package/dist/features/morph.esm.js +1 -1
- package/dist/features/morph.js +1 -1
- package/dist/features/perspectives.common.js +1 -1
- package/dist/features/perspectives.esm.js +1 -1
- package/dist/features/perspectives.js +1 -1
- package/dist/features/raincloud.common.js +1 -1
- package/dist/features/raincloud.esm.js +1 -1
- package/dist/features/raincloud.js +1 -1
- package/dist/features/renderer-canvas.common.js +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 +1 -1
- package/dist/features/stats.esm.js +1 -1
- package/dist/features/stats.js +1 -1
- package/dist/features/storyboard.common.js +1 -1
- package/dist/features/storyboard.esm.js +1 -1
- package/dist/features/storyboard.js +1 -1
- package/dist/features/streamgraph.common.js +2 -2
- package/dist/features/streamgraph.esm.js +3 -2
- package/dist/features/streamgraph.js +2 -2
- package/dist/features/toolbar.common.js +2 -2
- package/dist/features/toolbar.esm.js +92 -2
- package/dist/features/toolbar.js +2 -2
- package/dist/features/trellis.common.js +2 -2
- package/dist/features/trellis.esm.js +83 -47
- 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 +1 -1
- package/dist/features/weave.esm.js +1 -1
- package/dist/features/weave.js +1 -1
- package/dist/full.common.js +2 -2
- package/dist/full.esm.js +950 -795
- 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 +433 -394
- package/dist/icicle.common.js +2 -2
- package/dist/icicle.esm.js +54 -38
- 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 +1 -1
- package/dist/pie.esm.js +1 -1
- package/dist/pie.js +1 -1
- package/dist/polarArea.common.js +1 -1
- package/dist/polarArea.esm.js +1 -1
- package/dist/radar.common.js +2 -2
- package/dist/radar.esm.js +5 -4
- package/dist/radar.js +2 -2
- package/dist/radialBar.common.js +1 -1
- package/dist/radialBar.esm.js +1 -1
- package/dist/radialBar.js +1 -1
- package/dist/raincloud.common.js +2 -2
- package/dist/raincloud.esm.js +72 -26
- 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 +433 -394
- 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 +93 -41
- package/dist/sunburst.common.js +2 -2
- package/dist/sunburst.esm.js +103 -93
- package/dist/sunburst.js +2 -2
- package/dist/treemap.common.js +2 -2
- package/dist/treemap.esm.js +105 -86
- 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 +432 -393
- package/package.json +1 -1
- package/src/apexcharts.js +13 -6
- package/src/assets/apexcharts.css +35 -0
- 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 +37 -37
- package/src/charts/Line.js +118 -42
- package/src/charts/Radar.js +5 -7
- package/src/charts/RangeBar.js +47 -43
- package/src/charts/Sunburst.js +101 -98
- package/src/charts/Treemap.js +108 -66
- 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/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 +8 -1
- package/src/charts/common/partition/Partition.js +33 -1
- package/src/charts/common/treemap/Helpers.js +3 -11
- package/src/locales/en.json +2 -1
- package/src/locales/ro.json +3 -2
- 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/Graphics.js +62 -49
- package/src/modules/Markers.js +3 -1
- 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 +39 -18
- package/src/modules/Theme.js +1 -1
- package/src/modules/ZoomPanSelection.js +119 -2
- package/src/modules/accessibility/KeyboardNavigation.js +114 -186
- package/src/modules/animations/LengthTransition.js +22 -2
- package/src/modules/drilldown/Breadcrumb.js +5 -2
- package/src/modules/helpers/Destroy.js +1 -1
- 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 +2 -0
- package/src/modules/legend/Legend.js +11 -12
- package/src/modules/settings/Options.js +7 -0
- package/src/modules/streamgraph/StreamLabels.js +1 -0
- package/src/modules/tooltip/Tooltip.js +20 -4
- package/src/modules/tooltip/Utils.js +8 -0
- 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/renderers/canvas/CanvasGraphics.js +1 -0
- package/src/ssr/DOMShim.js +10 -0
- package/src/types/internal.d.ts +9 -3
- package/types/apexcharts.d.ts +31 -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.0
|
|
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;
|
|
@@ -760,7 +755,7 @@ function renderBreadcrumb(w, opts) {
|
|
|
760
755
|
text.setAttribute("class", "apexcharts-breadcrumb-label");
|
|
761
756
|
text.textContent = String(label);
|
|
762
757
|
btn.appendChild(text);
|
|
763
|
-
btn.addEventListener("click", () => opts.onNavigate(i, crumb));
|
|
758
|
+
btn.addEventListener("click", (e) => opts.onNavigate(i, crumb, e));
|
|
764
759
|
nav.appendChild(btn);
|
|
765
760
|
});
|
|
766
761
|
elWrap.appendChild(nav);
|
|
@@ -868,7 +863,7 @@ class TreemapChart {
|
|
|
868
863
|
if (w.config.chart.dropShadow.enabled) {
|
|
869
864
|
const shadow = w.config.chart.dropShadow;
|
|
870
865
|
const filters = new Filters(this.w);
|
|
871
|
-
filters.dropShadow(
|
|
866
|
+
filters.dropShadow(elSeries, shadow, i);
|
|
872
867
|
}
|
|
873
868
|
const elDataLabelWrap = graphics.group({
|
|
874
869
|
class: "apexcharts-data-labels"
|
|
@@ -962,6 +957,7 @@ class TreemapChart {
|
|
|
962
957
|
});
|
|
963
958
|
elRect.node.classList.add("apexcharts-treemap-rect");
|
|
964
959
|
elRect.node.setAttribute("data:key", morphKey(leaf._key));
|
|
960
|
+
let tileTween = null;
|
|
965
961
|
let fromRect = {
|
|
966
962
|
x: x1 + (x2 - x1) / 2,
|
|
967
963
|
y: y1 + (y2 - y1) / 2,
|
|
@@ -987,7 +983,7 @@ class TreemapChart {
|
|
|
987
983
|
if (w.globals.resized) {
|
|
988
984
|
w.globals.animationEnded = true;
|
|
989
985
|
} else {
|
|
990
|
-
this.animateTreemap(
|
|
986
|
+
tileTween = this.animateTreemap(
|
|
991
987
|
elRect,
|
|
992
988
|
fromRect,
|
|
993
989
|
toRect,
|
|
@@ -998,7 +994,6 @@ class TreemapChart {
|
|
|
998
994
|
);
|
|
999
995
|
}
|
|
1000
996
|
}
|
|
1001
|
-
let tileTween = null;
|
|
1002
997
|
let labelFrom = null;
|
|
1003
998
|
let prevLook = null;
|
|
1004
999
|
if (w.globals.dataChanged) {
|
|
@@ -1380,7 +1375,7 @@ class TreemapChart {
|
|
|
1380
1375
|
const elGroup = graphics.group({
|
|
1381
1376
|
class: "apexcharts-treemap-parent",
|
|
1382
1377
|
"data:depth": depth,
|
|
1383
|
-
"data:name":
|
|
1378
|
+
"data:name": node.name
|
|
1384
1379
|
});
|
|
1385
1380
|
const key = morphKey(node._key);
|
|
1386
1381
|
const morphFrom = this._morphKeyed() ? this.ctx.morphTypeChange.getInitialPathForKey(key) : null;
|
|
@@ -1489,7 +1484,7 @@ class TreemapChart {
|
|
|
1489
1484
|
if (typeof header.formatter === "function") {
|
|
1490
1485
|
text = String(
|
|
1491
1486
|
header.formatter(node.name, {
|
|
1492
|
-
value: node.
|
|
1487
|
+
value: node._area,
|
|
1493
1488
|
depth,
|
|
1494
1489
|
seriesIndex: i,
|
|
1495
1490
|
node,
|
|
@@ -1497,7 +1492,7 @@ class TreemapChart {
|
|
|
1497
1492
|
})
|
|
1498
1493
|
);
|
|
1499
1494
|
} else if (header.showValue) {
|
|
1500
|
-
text = `${text} ${this._formatValue(node.
|
|
1495
|
+
text = `${text} ${this._formatValue(node._area, node._si)}`;
|
|
1501
1496
|
}
|
|
1502
1497
|
headerText = text;
|
|
1503
1498
|
const offsetX = Number(header.offsetX) || 0;
|
|
@@ -1508,7 +1503,9 @@ class TreemapChart {
|
|
|
1508
1503
|
const clipped = graphics.getTextBasedOnMaxWidth({
|
|
1509
1504
|
text,
|
|
1510
1505
|
maxWidth,
|
|
1511
|
-
fontSize
|
|
1506
|
+
fontSize,
|
|
1507
|
+
fontFamily: chrome.headerFontFamily,
|
|
1508
|
+
fontWeight: chrome.headerFontWeight
|
|
1512
1509
|
});
|
|
1513
1510
|
if (clipped) {
|
|
1514
1511
|
let tx = x1 + pad + offsetX;
|
|
@@ -1583,7 +1580,7 @@ class TreemapChart {
|
|
|
1583
1580
|
const total = this._drawnTotal();
|
|
1584
1581
|
const pct = total > 0 ? (node._area / total * 100).toFixed(1) : "0";
|
|
1585
1582
|
const n = this._countLeaves(node);
|
|
1586
|
-
const lead = visibleText && String(visibleText).trim() ? String(visibleText).replace(/\s+/g, " ").trim() : `${node.name}, ${this._formatValue(node._area)}`;
|
|
1583
|
+
const lead = visibleText && String(visibleText).trim() ? String(visibleText).replace(/\s+/g, " ").trim() : `${node.name}, ${this._formatValue(node._area, node._si)}`;
|
|
1587
1584
|
return `${lead}, ${n} ${n === 1 ? "item" : "items"}, ${pct}% of total`;
|
|
1588
1585
|
}
|
|
1589
1586
|
/**
|
|
@@ -1602,15 +1599,18 @@ class TreemapChart {
|
|
|
1602
1599
|
* @param {string} [visibleText] the header's rendered text, unclipped
|
|
1603
1600
|
*/
|
|
1604
1601
|
_makeParentAccessible(el, node, chrome, elRect, visibleText) {
|
|
1602
|
+
const a11y = this.w.config.chart.accessibility;
|
|
1605
1603
|
if (!el || !el.setAttribute) return;
|
|
1606
|
-
if (!this._zoomEnabled()) return;
|
|
1604
|
+
if (!a11y.enabled || !a11y.keyboard.enabled || !this._zoomEnabled()) return;
|
|
1605
|
+
const open = this.w.globals.treemapFocusKey === node._key;
|
|
1606
|
+
el.tmKey = node._key;
|
|
1607
1607
|
el.setAttribute("role", "button");
|
|
1608
1608
|
el.setAttribute("tabindex", "0");
|
|
1609
1609
|
el.setAttribute(
|
|
1610
1610
|
"aria-label",
|
|
1611
|
-
`${this._parentLabel(node, visibleText)}. Zoom in`
|
|
1611
|
+
`${this._parentLabel(node, visibleText)}. Zoom ${open ? "out" : "in"}`
|
|
1612
1612
|
);
|
|
1613
|
-
el.setAttribute("aria-expanded",
|
|
1613
|
+
el.setAttribute("aria-expanded", open);
|
|
1614
1614
|
if (!Environment.isBrowser() || !el.addEventListener) return;
|
|
1615
1615
|
el.addEventListener("focus", () => {
|
|
1616
1616
|
elRect.node.setAttribute("stroke", chrome.hoverColor);
|
|
@@ -1677,15 +1677,17 @@ class TreemapChart {
|
|
|
1677
1677
|
* @returns {boolean}
|
|
1678
1678
|
*/
|
|
1679
1679
|
_zoomEnabled() {
|
|
1680
|
+
var _a;
|
|
1680
1681
|
const w = this.w;
|
|
1681
1682
|
const z = w.config.plotOptions.treemap.zoom;
|
|
1682
1683
|
if (!z || !z.enabled || !this.showParents) return false;
|
|
1683
1684
|
const dd = w.config.drilldown;
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1685
|
+
const d = this.ctx.drilldown;
|
|
1686
|
+
if (d && dd && dd.enabled && (((_a = dd.series) == null ? void 0 : _a.length) || dd.onDrillDown)) {
|
|
1687
|
+
if (!d.zoomWarned) {
|
|
1688
|
+
d.zoomWarned = true;
|
|
1687
1689
|
console.warn(
|
|
1688
|
-
"ApexCharts treemap:
|
|
1690
|
+
"ApexCharts treemap: zoom is ignored while drilldown is active (plotOptions.treemap.zoom vs drilldown series or onDrillDown)."
|
|
1689
1691
|
);
|
|
1690
1692
|
}
|
|
1691
1693
|
return false;
|
|
@@ -1695,8 +1697,8 @@ class TreemapChart {
|
|
|
1695
1697
|
/**
|
|
1696
1698
|
* The focused branch for this render, looked up by the key stashed on the
|
|
1697
1699
|
* 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)
|
|
1700
|
+
* survives a re-render; a key that no longer resolves, or a branch left with
|
|
1701
|
+
* nothing to draw (the data changed under it), falls back to the whole tree.
|
|
1700
1702
|
* @param {any[]} drawn
|
|
1701
1703
|
* @returns {any}
|
|
1702
1704
|
*/
|
|
@@ -1713,7 +1715,11 @@ class TreemapChart {
|
|
|
1713
1715
|
if (node.children) node.children.forEach(walk);
|
|
1714
1716
|
};
|
|
1715
1717
|
drawn.forEach(walk);
|
|
1716
|
-
|
|
1718
|
+
if (found && found.children && found.children.length && this._subtreeArea(found) > 0) {
|
|
1719
|
+
return found;
|
|
1720
|
+
}
|
|
1721
|
+
this.w.globals.treemapFocusKey = null;
|
|
1722
|
+
return null;
|
|
1717
1723
|
}
|
|
1718
1724
|
/**
|
|
1719
1725
|
* @param {any} node
|
|
@@ -1726,28 +1732,7 @@ class TreemapChart {
|
|
|
1726
1732
|
const w = this.w;
|
|
1727
1733
|
if (!node || !node.children || !node.children.length) return;
|
|
1728
1734
|
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
|
-
});
|
|
1735
|
+
this._refocus(next, restoreFocus);
|
|
1751
1736
|
}
|
|
1752
1737
|
/**
|
|
1753
1738
|
* Re-render focused on another branch (null: the whole tree).
|
|
@@ -1758,22 +1743,34 @@ class TreemapChart {
|
|
|
1758
1743
|
* left, which replayed the mount animation (every tile growing from
|
|
1759
1744
|
* nothing) or snapped, while the containers, headers and labels jumped.
|
|
1760
1745
|
* @param {string | null} next
|
|
1761
|
-
* @
|
|
1746
|
+
* @param {boolean} [restoreFocus] see _zoomTo
|
|
1762
1747
|
*/
|
|
1763
|
-
_refocus(next) {
|
|
1764
|
-
var _a;
|
|
1748
|
+
_refocus(next, restoreFocus) {
|
|
1765
1749
|
const w = this.w;
|
|
1766
1750
|
const gl = w.globals;
|
|
1751
|
+
const from = gl.treemapFocusKey;
|
|
1767
1752
|
const anim = w.config.chart.animations;
|
|
1768
1753
|
const animate = !!(anim.enabled && anim.dynamicAnimation.enabled);
|
|
1769
|
-
gl.treemapZoom = animate && Environment.isBrowser() ? { from:
|
|
1754
|
+
gl.treemapZoom = animate && Environment.isBrowser() ? { from: from != null ? from : null, to: next } : null;
|
|
1770
1755
|
gl.treemapFocusKey = next;
|
|
1771
1756
|
this._hideParentTooltip();
|
|
1772
1757
|
gl.shouldAnimate = animate;
|
|
1773
1758
|
gl.resized = true;
|
|
1774
1759
|
gl.dataChanged = true;
|
|
1775
1760
|
if (gl.treemapZoom) this.ctx.series.getPreviousPaths();
|
|
1776
|
-
|
|
1761
|
+
const done = this.ctx.update();
|
|
1762
|
+
if (restoreFocus) {
|
|
1763
|
+
done.then(() => {
|
|
1764
|
+
const b = w.dom.baseEl;
|
|
1765
|
+
const heads = (
|
|
1766
|
+
/** @type {any[]} */
|
|
1767
|
+
Array.from(
|
|
1768
|
+
b.querySelectorAll(".apexcharts-treemap-parent-header[tabindex]")
|
|
1769
|
+
)
|
|
1770
|
+
);
|
|
1771
|
+
(b.querySelector(".apexcharts-breadcrumb-item") || heads.find((h) => h.tmKey === from) || heads[0] || b).focus();
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1777
1774
|
}
|
|
1778
1775
|
/**
|
|
1779
1776
|
* A zoom reframes one tree, so it moves like a camera: one map takes the
|
|
@@ -2085,8 +2082,9 @@ class TreemapChart {
|
|
|
2085
2082
|
crumbs: [{ label: "All", data: null }].concat(
|
|
2086
2083
|
chain.map((n) => ({ label: n.name, data: n }))
|
|
2087
2084
|
),
|
|
2088
|
-
|
|
2089
|
-
|
|
2085
|
+
// A keyboard click (detail 0) keeps focus in the chart.
|
|
2086
|
+
onNavigate: (_i, crumb, e) => {
|
|
2087
|
+
this._refocus(crumb.data ? crumb.data._key : null, !e.detail);
|
|
2090
2088
|
}
|
|
2091
2089
|
});
|
|
2092
2090
|
if (!nav) return;
|
|
@@ -2135,7 +2133,7 @@ class TreemapChart {
|
|
|
2135
2133
|
const t = this._tip();
|
|
2136
2134
|
if (!t) return;
|
|
2137
2135
|
const total = this._drawnTotal();
|
|
2138
|
-
const parentVal = node._parent ? node._parent
|
|
2136
|
+
const parentVal = node._parent ? this._subtreeArea(node._parent) : total;
|
|
2139
2137
|
const pctTotal = total > 0 ? (node._area / total * 100).toFixed(1) : "0.0";
|
|
2140
2138
|
const pctParent = parentVal > 0 ? (node._area / parentVal * 100).toFixed(1) : pctTotal;
|
|
2141
2139
|
const cfg = this.w.config.plotOptions.treemap.parents;
|
|
@@ -2156,10 +2154,9 @@ class TreemapChart {
|
|
|
2156
2154
|
} else {
|
|
2157
2155
|
const marker = this._parentChrome(node.depth || 0).headerBg;
|
|
2158
2156
|
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
|
|
2157
|
+
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(
|
|
2158
|
+
node._area,
|
|
2159
|
+
node._si
|
|
2163
2160
|
)}</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
2161
|
}
|
|
2165
2162
|
t.innerHTML = html;
|
|
@@ -2255,17 +2252,21 @@ class TreemapChart {
|
|
|
2255
2252
|
}
|
|
2256
2253
|
/**
|
|
2257
2254
|
* Format an aggregate the way the chart formats its own y values, so a
|
|
2258
|
-
* parent's total reads like the tiles it contains.
|
|
2255
|
+
* parent's total reads like the tiles it contains. A branch is no data
|
|
2256
|
+
* point, so dataPointIndex is -1.
|
|
2259
2257
|
* @param {number} v
|
|
2258
|
+
* @param {number} [si] the branch's series index
|
|
2260
2259
|
* @returns {string}
|
|
2261
2260
|
*/
|
|
2262
|
-
_formatValue(v) {
|
|
2261
|
+
_formatValue(v, si) {
|
|
2263
2262
|
var _a, _b, _c, _d, _e;
|
|
2264
2263
|
const w = this.w;
|
|
2265
2264
|
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
2265
|
if (typeof fmt === "function") {
|
|
2267
2266
|
try {
|
|
2268
|
-
return String(
|
|
2267
|
+
return String(
|
|
2268
|
+
fmt(v, { seriesIndex: si || 0, dataPointIndex: -1, w })
|
|
2269
|
+
);
|
|
2269
2270
|
} catch (_) {
|
|
2270
2271
|
}
|
|
2271
2272
|
}
|
|
@@ -2346,7 +2347,7 @@ class TreemapChart {
|
|
|
2346
2347
|
*/
|
|
2347
2348
|
rotateToFitLabel(elText, fontSize, text, x1, y1, x2, y2) {
|
|
2348
2349
|
const graphics = new Graphics(this.w);
|
|
2349
|
-
const textRect =
|
|
2350
|
+
const textRect = this._labelRect(graphics, text, fontSize);
|
|
2350
2351
|
if (textRect.width + this.w.config.stroke.width + 5 > x2 - x1 && textRect.width <= y2 - y1) {
|
|
2351
2352
|
const labelRotatingCenter = graphics.rotateAroundCenter(elText.node);
|
|
2352
2353
|
elText.node.setAttribute(
|
|
@@ -2355,6 +2356,24 @@ class TreemapChart {
|
|
|
2355
2356
|
);
|
|
2356
2357
|
}
|
|
2357
2358
|
}
|
|
2359
|
+
/**
|
|
2360
|
+
* A tile label's box, measured at the family and weight it is drawn at
|
|
2361
|
+
* (bold is wider than the default regular).
|
|
2362
|
+
* @param {Graphics} graphics
|
|
2363
|
+
* @param {string} text
|
|
2364
|
+
* @param {string | number} fontSize
|
|
2365
|
+
*/
|
|
2366
|
+
_labelRect(graphics, text, fontSize) {
|
|
2367
|
+
const st = this.w.config.dataLabels.style;
|
|
2368
|
+
return graphics.getTextRects(
|
|
2369
|
+
text,
|
|
2370
|
+
String(fontSize),
|
|
2371
|
+
st.fontFamily,
|
|
2372
|
+
"",
|
|
2373
|
+
true,
|
|
2374
|
+
st.fontWeight
|
|
2375
|
+
);
|
|
2376
|
+
}
|
|
2358
2377
|
// This is an alternative label formatting method that uses a
|
|
2359
2378
|
// consistent font size, and trims the edge of long labels
|
|
2360
2379
|
/**
|
|
@@ -2367,13 +2386,13 @@ class TreemapChart {
|
|
|
2367
2386
|
*/
|
|
2368
2387
|
truncateLabels(text, fontSize, x1, y1, x2, y2) {
|
|
2369
2388
|
const graphics = new Graphics(this.w);
|
|
2370
|
-
const textRect =
|
|
2389
|
+
const textRect = this._labelRect(graphics, text, fontSize);
|
|
2371
2390
|
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({
|
|
2391
|
+
const truncatedText = graphics.getTextBasedOnMaxWidth(__spreadProps(__spreadValues({}, this.w.config.dataLabels.style), {
|
|
2373
2392
|
text,
|
|
2374
2393
|
maxWidth: labelMaxWidth,
|
|
2375
2394
|
fontSize
|
|
2376
|
-
});
|
|
2395
|
+
}));
|
|
2377
2396
|
if (text.length !== truncatedText.length && labelMaxWidth / fontSize < 5) {
|
|
2378
2397
|
return "";
|
|
2379
2398
|
} else {
|