@vielzeug/prism 26.10.20 → 26.10.22
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 +1 -1
- package/dist/charts/bar/bar-chart.cjs +1 -1
- package/dist/charts/bar/bar-chart.cjs.map +1 -1
- package/dist/charts/bar/bar-chart.d.ts.map +1 -1
- package/dist/charts/bar/bar-chart.js +136 -97
- package/dist/charts/bar/bar-chart.js.map +1 -1
- package/dist/charts/bar/bar-value-labels.cjs +2 -0
- package/dist/charts/bar/bar-value-labels.cjs.map +1 -0
- package/dist/charts/bar/bar-value-labels.d.ts +34 -0
- package/dist/charts/bar/bar-value-labels.d.ts.map +1 -0
- package/dist/charts/bar/bar-value-labels.js +55 -0
- package/dist/charts/bar/bar-value-labels.js.map +1 -0
- package/dist/charts/heatmap/heatmap-chart.cjs +2 -0
- package/dist/charts/heatmap/heatmap-chart.cjs.map +1 -0
- package/dist/charts/heatmap/heatmap-chart.d.ts +12 -0
- package/dist/charts/heatmap/heatmap-chart.d.ts.map +1 -0
- package/dist/charts/heatmap/heatmap-chart.js +282 -0
- package/dist/charts/heatmap/heatmap-chart.js.map +1 -0
- package/dist/charts/heatmap/heatmap-color.cjs +2 -0
- package/dist/charts/heatmap/heatmap-color.cjs.map +1 -0
- package/dist/charts/heatmap/heatmap-color.d.ts +32 -0
- package/dist/charts/heatmap/heatmap-color.d.ts.map +1 -0
- package/dist/charts/heatmap/heatmap-color.js +61 -0
- package/dist/charts/heatmap/heatmap-color.js.map +1 -0
- package/dist/charts/heatmap/index.d.ts +2 -0
- package/dist/charts/heatmap/index.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/prism.cjs +1 -1
- package/dist/prism.cjs.map +1 -1
- package/dist/prism.iife.js +1 -1
- package/dist/prism.iife.js.map +1 -1
- package/dist/prism.js +539 -123
- package/dist/prism.js.map +1 -1
- package/dist/theme/prism.css +47 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/prism.js
CHANGED
|
@@ -1466,6 +1466,112 @@ function renderBars(e, t, n, r, i, a) {
|
|
|
1466
1466
|
}
|
|
1467
1467
|
}
|
|
1468
1468
|
//#endregion
|
|
1469
|
+
//#region src/charts/heatmap/heatmap-color.ts
|
|
1470
|
+
var A = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i, j = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i, M = /^rgba?\(\s*(\d{1,3})\s*[,\s]\s*(\d{1,3})\s*[,\s]\s*(\d{1,3})\s*(?:[,\s][\d.]+\s*)?\)$/i;
|
|
1471
|
+
function parseColor(e) {
|
|
1472
|
+
let t = j.exec(e);
|
|
1473
|
+
if (t) return {
|
|
1474
|
+
b: Number.parseInt(t[3], 16),
|
|
1475
|
+
g: Number.parseInt(t[2], 16),
|
|
1476
|
+
r: Number.parseInt(t[1], 16)
|
|
1477
|
+
};
|
|
1478
|
+
let n = A.exec(e);
|
|
1479
|
+
if (n) return {
|
|
1480
|
+
b: Number.parseInt(n[3], 16) * 17,
|
|
1481
|
+
g: Number.parseInt(n[2], 16) * 17,
|
|
1482
|
+
r: Number.parseInt(n[1], 16) * 17
|
|
1483
|
+
};
|
|
1484
|
+
let r = M.exec(e);
|
|
1485
|
+
return r ? {
|
|
1486
|
+
b: Number(r[3]),
|
|
1487
|
+
g: Number(r[2]),
|
|
1488
|
+
r: Number(r[1])
|
|
1489
|
+
} : null;
|
|
1490
|
+
}
|
|
1491
|
+
function toCssColor({ b: e, g: t, r: n }) {
|
|
1492
|
+
return `rgb(${n} ${t} ${e})`;
|
|
1493
|
+
}
|
|
1494
|
+
function mixColors(e, t, n) {
|
|
1495
|
+
let r = Math.min(1, Math.max(0, n));
|
|
1496
|
+
return {
|
|
1497
|
+
b: Math.round(e.b + (t.b - e.b) * r),
|
|
1498
|
+
g: Math.round(e.g + (t.g - e.g) * r),
|
|
1499
|
+
r: Math.round(e.r + (t.r - e.r) * r)
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
function createRamp(e) {
|
|
1503
|
+
let t = e.map(parseColor);
|
|
1504
|
+
return (n) => {
|
|
1505
|
+
let r = Math.min(1, Math.max(0, n));
|
|
1506
|
+
if (e.length >= 2 && t.every((e) => e !== null)) {
|
|
1507
|
+
let n = r * (e.length - 1), i = Math.min(e.length - 2, Math.floor(n));
|
|
1508
|
+
return toCssColor(mixColors(t[i], t[i + 1], n - i));
|
|
1509
|
+
}
|
|
1510
|
+
return e[Math.min(e.length - 1, Math.round(r * (e.length - 1)))];
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
function relativeLuminance(e) {
|
|
1514
|
+
let t = parseColor(e);
|
|
1515
|
+
if (!t) return null;
|
|
1516
|
+
let channel = (e) => {
|
|
1517
|
+
let t = e / 255;
|
|
1518
|
+
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
1519
|
+
};
|
|
1520
|
+
return .2126 * channel(t.r) + .7152 * channel(t.g) + .0722 * channel(t.b);
|
|
1521
|
+
}
|
|
1522
|
+
function valueColorFor(e, t) {
|
|
1523
|
+
let n = relativeLuminance(e);
|
|
1524
|
+
return n === null ? t : n > .179 ? "#000" : "#fff";
|
|
1525
|
+
}
|
|
1526
|
+
//#endregion
|
|
1527
|
+
//#region src/charts/bar/bar-value-labels.ts
|
|
1528
|
+
var N = 6.6, P = 6, F = 4, I = 16;
|
|
1529
|
+
function estWidth(e) {
|
|
1530
|
+
return e.length * N + F;
|
|
1531
|
+
}
|
|
1532
|
+
function renderBarValueLabels(e, t, n) {
|
|
1533
|
+
for (; e.firstChild;) e.removeChild(e.firstChild);
|
|
1534
|
+
for (let r of t) {
|
|
1535
|
+
let t = estWidth(r.text), i = n.horizontal ? r.dir * P : -r.dir * P, a = r.valueEdge + i, o = n.horizontal ? i > 0 ? a + t <= n.areaExtent : a - t >= 0 : i < 0 ? a >= 0 : a + 11 <= n.areaExtent, s = n.horizontal ? r.bandSize > I && (i > 0 ? r.valueEdge - P - t >= 0 : r.valueEdge + P + t <= n.areaExtent) : r.barLength > I && r.bandSize >= t;
|
|
1536
|
+
if (!o && !s) continue;
|
|
1537
|
+
let c = !o, l = createSvgElement("text", { class: c ? "prism-bar-value prism-bar-value--inside" : "prism-bar-value" });
|
|
1538
|
+
if (l.textContent = r.text, n.horizontal ? setAttributes(l, {
|
|
1539
|
+
"dominant-baseline": "central",
|
|
1540
|
+
"text-anchor": c ? i > 0 ? "end" : "start" : i > 0 ? "start" : "end",
|
|
1541
|
+
x: String(c ? r.valueEdge - i : a),
|
|
1542
|
+
y: String(r.center)
|
|
1543
|
+
}) : setAttributes(l, {
|
|
1544
|
+
"dominant-baseline": c ? i < 0 ? "hanging" : "auto" : i < 0 ? "auto" : "hanging",
|
|
1545
|
+
"text-anchor": "middle",
|
|
1546
|
+
x: String(r.center),
|
|
1547
|
+
y: String(c ? r.valueEdge - i : a)
|
|
1548
|
+
}), c) {
|
|
1549
|
+
let t = barAt(e, n, r), i = t ? getComputedStyle(t).fill : "";
|
|
1550
|
+
l.style.setProperty("fill", valueColorFor(i, "var(--prism-text-color, #0f172a)"));
|
|
1551
|
+
}
|
|
1552
|
+
e.appendChild(l);
|
|
1553
|
+
}
|
|
1554
|
+
let r = resolveMotion(n.transition, { defaultStagger: 0 });
|
|
1555
|
+
r.duration > 0 && animate([{
|
|
1556
|
+
attrs: { opacity: {
|
|
1557
|
+
from: 0,
|
|
1558
|
+
to: 1
|
|
1559
|
+
} },
|
|
1560
|
+
el: e
|
|
1561
|
+
}], {
|
|
1562
|
+
...r,
|
|
1563
|
+
stagger: 0
|
|
1564
|
+
}, void 0, n.disposalSignal);
|
|
1565
|
+
}
|
|
1566
|
+
function barAt(e, t, n) {
|
|
1567
|
+
let r = [...e.parentElement?.querySelectorAll(".prism-bar") ?? []];
|
|
1568
|
+
for (let e of r) {
|
|
1569
|
+
let r = Number(e.getAttribute(t.horizontal ? "y" : "x")), i = Number(e.getAttribute(t.horizontal ? "height" : "width"));
|
|
1570
|
+
if (n.center >= r && n.center <= r + i) return e;
|
|
1571
|
+
}
|
|
1572
|
+
return r[0] ?? null;
|
|
1573
|
+
}
|
|
1574
|
+
//#endregion
|
|
1469
1575
|
//#region src/charts/bar/bar-chart.ts
|
|
1470
1576
|
function variantFlags(e) {
|
|
1471
1577
|
return {
|
|
@@ -1474,88 +1580,88 @@ function variantFlags(e) {
|
|
|
1474
1580
|
};
|
|
1475
1581
|
}
|
|
1476
1582
|
function createBarChart(e, t) {
|
|
1477
|
-
let n = t.series, r = null;
|
|
1478
|
-
return createChartScaffold(e, t, (e,
|
|
1479
|
-
let { groups:
|
|
1480
|
-
|
|
1583
|
+
let n = t.series, r = null, i = null;
|
|
1584
|
+
return createChartScaffold(e, t, (e, a) => {
|
|
1585
|
+
let { groups: o, legend: s, tooltip: c } = e;
|
|
1586
|
+
s?.update(n.map((e, t) => ({
|
|
1481
1587
|
color: seriesColor(t, e.color),
|
|
1482
1588
|
name: e.name
|
|
1483
1589
|
})));
|
|
1484
|
-
let
|
|
1590
|
+
let l = e.dimensions, u = chartArea(l.width, l.height, l.margin), d = n.map((e) => e.data), f = normalizeCartesianSeries(n, d), p = f.domain, m = f.series.map(({ byKey: e }) => p.map((t) => e.get(t))), categoryAxis = (e) => ({
|
|
1485
1591
|
...e,
|
|
1486
1592
|
tickFormat: (t) => {
|
|
1487
|
-
let n = String(t), r =
|
|
1593
|
+
let n = String(t), r = f.labels.get(n) ?? t;
|
|
1488
1594
|
return e.tickFormat ? e.tickFormat(r) : String(r);
|
|
1489
1595
|
}
|
|
1490
1596
|
});
|
|
1491
|
-
if (
|
|
1492
|
-
clearCartesianDom(
|
|
1597
|
+
if (p.length === 0) {
|
|
1598
|
+
clearCartesianDom(o, s, c), r?.remove(), r = null, i?.remove(), i = null;
|
|
1493
1599
|
return;
|
|
1494
1600
|
}
|
|
1495
|
-
let { horizontal:
|
|
1601
|
+
let { horizontal: h, stacked: g } = variantFlags(t.variant ?? "grouped"), _ = t.xAxis === !1 ? !1 : h ? {
|
|
1496
1602
|
grid: !0,
|
|
1497
1603
|
...t.xAxis
|
|
1498
|
-
} : t.xAxis ?? {},
|
|
1604
|
+
} : t.xAxis ?? {}, v = t.yAxis === !1 ? !1 : h ? t.yAxis ?? {} : {
|
|
1499
1605
|
grid: !0,
|
|
1500
1606
|
...t.yAxis
|
|
1501
|
-
},
|
|
1502
|
-
if (
|
|
1503
|
-
|
|
1504
|
-
let e =
|
|
1505
|
-
|
|
1607
|
+
}, y, b;
|
|
1608
|
+
if (g) {
|
|
1609
|
+
m.some((e) => e.some((e) => (e?.value ?? 0) < 0));
|
|
1610
|
+
let e = p.map((e, t) => m.reduce((e, n) => e + Math.max(0, n[t]?.value ?? 0), 0));
|
|
1611
|
+
y = Math.max(...e), b = 0;
|
|
1506
1612
|
} else {
|
|
1507
|
-
let e =
|
|
1508
|
-
|
|
1613
|
+
let e = m.flatMap((e) => e.flatMap((e) => e ? [e.value] : []));
|
|
1614
|
+
y = Math.max(...e), b = Math.min(0, ...e);
|
|
1509
1615
|
}
|
|
1510
|
-
let
|
|
1511
|
-
domain:
|
|
1512
|
-
range: [0,
|
|
1616
|
+
let x = bandScale(h ? {
|
|
1617
|
+
domain: p,
|
|
1618
|
+
range: [0, u.height]
|
|
1513
1619
|
} : {
|
|
1514
|
-
domain:
|
|
1515
|
-
range: [0,
|
|
1516
|
-
}),
|
|
1517
|
-
domain: [
|
|
1518
|
-
range: [0,
|
|
1620
|
+
domain: p,
|
|
1621
|
+
range: [0, u.width]
|
|
1622
|
+
}), S = linearScale(h ? {
|
|
1623
|
+
domain: [b, y],
|
|
1624
|
+
range: [0, u.width]
|
|
1519
1625
|
} : {
|
|
1520
|
-
domain: [
|
|
1521
|
-
range: [
|
|
1522
|
-
}),
|
|
1523
|
-
for (let e of
|
|
1524
|
-
let
|
|
1525
|
-
bandCenter: (e) =>
|
|
1526
|
-
bandwidth:
|
|
1527
|
-
baselinePx:
|
|
1528
|
-
horizontal:
|
|
1529
|
-
stacked:
|
|
1530
|
-
stackedTops:
|
|
1531
|
-
valueScale:
|
|
1626
|
+
domain: [b, y],
|
|
1627
|
+
range: [u.height, 0]
|
|
1628
|
+
}), C = [], w = Object.create(null);
|
|
1629
|
+
for (let e of p) w[e] = 0;
|
|
1630
|
+
let T = {
|
|
1631
|
+
bandCenter: (e) => x.map(e) + x.bandwidth() / 2,
|
|
1632
|
+
bandwidth: x.bandwidth(),
|
|
1633
|
+
baselinePx: S.map(0),
|
|
1634
|
+
horizontal: h,
|
|
1635
|
+
stacked: g,
|
|
1636
|
+
stackedTops: C,
|
|
1637
|
+
valueScale: S
|
|
1532
1638
|
};
|
|
1533
|
-
if (
|
|
1534
|
-
if (
|
|
1535
|
-
let e = categoryAxis(
|
|
1536
|
-
positionAxis(
|
|
1639
|
+
if (h) {
|
|
1640
|
+
if (_ && _.grid && renderGrid(o.grid, S, _.grid, u.height, "vertical", resolveTicks(S, _, resolveTickCount(_, u.width, "bottom"))), v !== !1) {
|
|
1641
|
+
let e = categoryAxis(v);
|
|
1642
|
+
positionAxis(o.yAxis, e.position ?? "left", u.width, u.height), renderAxis(o.yAxis, x, e, u.height, "left");
|
|
1537
1643
|
}
|
|
1538
|
-
|
|
1644
|
+
_ && (positionAxis(o.xAxis, _.position ?? "bottom", u.width, u.height), renderAxis(o.xAxis, S, _, u.width, "bottom"));
|
|
1539
1645
|
} else {
|
|
1540
|
-
if (
|
|
1541
|
-
let e = categoryAxis(
|
|
1542
|
-
positionAxis(
|
|
1646
|
+
if (v && v.grid && renderGrid(o.grid, S, v.grid, u.width, "horizontal", resolveTicks(S, v, resolveTickCount(v, u.height, "left"))), _ !== !1) {
|
|
1647
|
+
let e = categoryAxis(_);
|
|
1648
|
+
positionAxis(o.xAxis, e.position ?? "bottom", u.width, u.height), renderAxis(o.xAxis, x, e, u.width, "bottom");
|
|
1543
1649
|
}
|
|
1544
|
-
|
|
1650
|
+
v && (positionAxis(o.yAxis, v.position ?? "left", u.width, u.height), renderAxis(o.yAxis, S, v, u.height, "left"));
|
|
1545
1651
|
}
|
|
1546
|
-
let
|
|
1547
|
-
for (;
|
|
1548
|
-
let e =
|
|
1549
|
-
e &&
|
|
1652
|
+
let E = g ? 0 : Number.parseFloat(getComputedStyle(e.svg).getPropertyValue("--prism-bar-radius")) || 0;
|
|
1653
|
+
for (; o.series.children.length > n.length;) {
|
|
1654
|
+
let e = o.series.lastElementChild;
|
|
1655
|
+
e && o.series.removeChild(e);
|
|
1550
1656
|
}
|
|
1551
1657
|
for (let r = 0; r < n.length; r++) {
|
|
1552
|
-
let
|
|
1553
|
-
s || (s = createSvgElement("g", { class: "prism-bar-series" }),
|
|
1554
|
-
let c =
|
|
1555
|
-
let n =
|
|
1556
|
-
if (
|
|
1557
|
-
let t =
|
|
1558
|
-
return
|
|
1658
|
+
let i = n[r], s = o.series.children[r];
|
|
1659
|
+
s || (s = createSvgElement("g", { class: "prism-bar-series" }), o.series.appendChild(s)), s.setAttribute("data-series-id", seriesDomId(i, r));
|
|
1660
|
+
let c = p.map((e, t) => {
|
|
1661
|
+
let n = m[r]?.[t];
|
|
1662
|
+
if (g) {
|
|
1663
|
+
let t = w[e] ?? 0, r = t + Math.max(0, n?.value ?? 0);
|
|
1664
|
+
return w[e] = r, {
|
|
1559
1665
|
base: t,
|
|
1560
1666
|
dash: n?.dash,
|
|
1561
1667
|
key: e,
|
|
@@ -1573,27 +1679,65 @@ function createBarChart(e, t) {
|
|
|
1573
1679
|
y: n?.value ?? 0
|
|
1574
1680
|
};
|
|
1575
1681
|
});
|
|
1576
|
-
|
|
1577
|
-
let l =
|
|
1578
|
-
renderBars(s, c,
|
|
1682
|
+
C[r] = c.map((e) => e.y);
|
|
1683
|
+
let l = g ? c.map((e) => S.map(e.base)) : void 0;
|
|
1684
|
+
renderBars(s, c, x, S, T.baselinePx, {
|
|
1579
1685
|
baselineYs: l,
|
|
1580
|
-
borderRadius:
|
|
1581
|
-
color: seriesColor(r,
|
|
1686
|
+
borderRadius: i.borderRadius ?? E,
|
|
1687
|
+
color: seriesColor(r, i.color),
|
|
1582
1688
|
disposalSignal: e.disposalSignal,
|
|
1583
|
-
horizontal:
|
|
1689
|
+
horizontal: h,
|
|
1584
1690
|
seriesCount: n.length,
|
|
1585
1691
|
seriesIndex: r,
|
|
1586
|
-
stacked:
|
|
1587
|
-
transition:
|
|
1692
|
+
stacked: g,
|
|
1693
|
+
transition: a !== "resize" && t.transition
|
|
1588
1694
|
});
|
|
1589
1695
|
}
|
|
1590
|
-
|
|
1696
|
+
if (c?.hide(), o.series.classList.toggle("prism-bars-stacked", g), t.showValues) {
|
|
1697
|
+
(!i || !e.chartArea.contains(i)) && (i = createSvgElement("g", {
|
|
1698
|
+
"aria-hidden": "true",
|
|
1699
|
+
class: "prism-bar-values"
|
|
1700
|
+
}), e.chartArea.appendChild(i));
|
|
1701
|
+
let r = t.valueFormat ?? String, o = [];
|
|
1702
|
+
if (g) for (let e = 0; e < p.length; e++) {
|
|
1703
|
+
let t = m.reduce((t, n) => t + Math.max(0, n[e]?.value ?? 0), 0);
|
|
1704
|
+
t <= 0 || o.push({
|
|
1705
|
+
bandSize: x.bandwidth(),
|
|
1706
|
+
barLength: Math.abs(S.map(t) - S.map(0)),
|
|
1707
|
+
center: x.map(p[e]) + x.bandwidth() / 2,
|
|
1708
|
+
dir: 1,
|
|
1709
|
+
text: r(t),
|
|
1710
|
+
valueEdge: S.map(t)
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
else for (let e = 0; e < n.length; e++) {
|
|
1714
|
+
let t = x.bandwidth() / n.length;
|
|
1715
|
+
for (let n = 0; n < p.length; n++) {
|
|
1716
|
+
let i = m[e]?.[n];
|
|
1717
|
+
i && o.push({
|
|
1718
|
+
bandSize: Math.max(0, t - 1),
|
|
1719
|
+
barLength: Math.abs(S.map(i.value) - S.map(0)),
|
|
1720
|
+
center: x.map(p[n]) + t * e + t / 2,
|
|
1721
|
+
dir: i.value < 0 ? -1 : 1,
|
|
1722
|
+
text: r(i.value),
|
|
1723
|
+
valueEdge: S.map(i.value)
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
renderBarValueLabels(i, o, {
|
|
1728
|
+
areaExtent: h ? u.width : u.height,
|
|
1729
|
+
disposalSignal: e.disposalSignal,
|
|
1730
|
+
horizontal: h,
|
|
1731
|
+
transition: a !== "resize" && t.transition
|
|
1732
|
+
});
|
|
1733
|
+
} else i?.remove(), i = null;
|
|
1734
|
+
(!r || !e.chartArea.contains(r)) && (r = createSvgElement("rect", {
|
|
1591
1735
|
"aria-hidden": "true",
|
|
1592
1736
|
class: "prism-bar-band",
|
|
1593
1737
|
"pointer-events": "none"
|
|
1594
|
-
}), e.chartArea.insertBefore(r,
|
|
1595
|
-
let
|
|
1596
|
-
datum:
|
|
1738
|
+
}), e.chartArea.insertBefore(r, o.series)), r.style.display = "none";
|
|
1739
|
+
let D = n.map((e, t) => seriesColor(t, e.color)), labelOf = (e) => String(f.labels.get(p[e]) ?? p[e]), O = typeof t.tooltip == "object" ? t.tooltip : void 0, keyOf = (e) => f.labels.get(p[e]) ?? p[e], titleOf = (e) => O?.titleFormat ? O.titleFormat(keyOf(e)) : labelOf(e), k = O?.valueFormat ?? String, A = -1, valuesAt = (e) => n.map((t, n) => ({
|
|
1740
|
+
datum: m[n]?.[e],
|
|
1597
1741
|
series: t
|
|
1598
1742
|
})), eventAt = (e, t, r) => {
|
|
1599
1743
|
let i = valuesAt(e), a = i[t]?.datum ? t : i.findIndex((e) => e.datum), o = i[a]?.datum;
|
|
@@ -1604,17 +1748,17 @@ function createBarChart(e, t) {
|
|
|
1604
1748
|
values: i
|
|
1605
1749
|
} : null;
|
|
1606
1750
|
}, setActive = (t) => {
|
|
1607
|
-
|
|
1608
|
-
for (let e of
|
|
1751
|
+
A = t, o.series.classList.toggle("prism-bars-focused", t >= 0);
|
|
1752
|
+
for (let e of o.series.children) for (let [n, r] of [...e.children].entries()) r.classList.toggle("prism-bar--active", n === t);
|
|
1609
1753
|
if (!r || (r.style.display = t < 0 ? "none" : "", t < 0)) return;
|
|
1610
|
-
let n =
|
|
1611
|
-
setAttributes(r,
|
|
1754
|
+
let n = T.bandCenter(p[t]) - x.bandwidth() / 2 - x.gap() / 2, i = x.bandwidth() + x.gap(), a = chartArea(e.dimensions.width, e.dimensions.height, e.dimensions.margin);
|
|
1755
|
+
setAttributes(r, h ? {
|
|
1612
1756
|
height: i,
|
|
1613
|
-
width:
|
|
1757
|
+
width: a.width,
|
|
1614
1758
|
x: 0,
|
|
1615
1759
|
y: n
|
|
1616
1760
|
} : {
|
|
1617
|
-
height:
|
|
1761
|
+
height: a.height,
|
|
1618
1762
|
width: i,
|
|
1619
1763
|
x: n,
|
|
1620
1764
|
y: 0
|
|
@@ -1623,34 +1767,34 @@ function createBarChart(e, t) {
|
|
|
1623
1767
|
let a = eventAt(n, r, i);
|
|
1624
1768
|
if (!a) return;
|
|
1625
1769
|
setActive(n);
|
|
1626
|
-
let o = a.values ?? [],
|
|
1627
|
-
if (
|
|
1628
|
-
let t = o.map((e, t) =>
|
|
1629
|
-
color:
|
|
1770
|
+
let o = a.values ?? [], s = describeValues(titleOf(n), o, k);
|
|
1771
|
+
if (c) {
|
|
1772
|
+
let t = o.map((e, t) => g ? C[t]?.[n] ?? 0 : Math.max(0, e.datum?.value ?? 0)), r = S.map(Math.max(...t)), i = T.bandCenter(p[n]), { margin: l } = e.dimensions, u = o.flatMap((e, t) => e.datum ? [{
|
|
1773
|
+
color: D[t],
|
|
1630
1774
|
name: e.series.name,
|
|
1631
|
-
value:
|
|
1775
|
+
value: k(e.datum.value, e.datum, e.series)
|
|
1632
1776
|
}] : []);
|
|
1633
|
-
|
|
1634
|
-
} else e.announcer.announce(
|
|
1777
|
+
c.show((h ? r : i) + l.left, (h ? i : r) + l.top, a.datum, a.series, comparisonContent(e.svg.ownerDocument, titleOf(n), u, s));
|
|
1778
|
+
} else e.announcer.announce(s);
|
|
1635
1779
|
t.onHover?.(a);
|
|
1636
1780
|
}, deactivate = () => {
|
|
1637
|
-
setActive(-1),
|
|
1781
|
+
setActive(-1), c?.hide(), e.announcer.clear(), t.onHover?.(null);
|
|
1638
1782
|
}, hit = (t) => {
|
|
1639
1783
|
let r = e.dimensions, i = getMousePosition(e.svg, t, r.margin.left, r.margin.top), a = chartArea(r.width, r.height, r.margin);
|
|
1640
1784
|
if (i.x < 0 || i.x > a.width || i.y < 0 || i.y > a.height) return null;
|
|
1641
|
-
let o = findCatIdx(
|
|
1785
|
+
let o = findCatIdx(h ? i.y : i.x, p, T);
|
|
1642
1786
|
return o === -1 ? null : {
|
|
1643
1787
|
catIdx: o,
|
|
1644
|
-
seriesIdx: findSeriesIdx(i, o,
|
|
1788
|
+
seriesIdx: findSeriesIdx(i, o, p, T, n.length)
|
|
1645
1789
|
};
|
|
1646
1790
|
}, onMouseMove = (e) => {
|
|
1647
1791
|
let t = hit(e);
|
|
1648
|
-
t ? activate(t.catIdx, t.seriesIdx, e) :
|
|
1792
|
+
t ? activate(t.catIdx, t.seriesIdx, e) : A >= 0 && deactivate();
|
|
1649
1793
|
}, onClick = (e) => {
|
|
1650
1794
|
let n = t.onClick && hit(e), r = n && eventAt(n.catIdx, n.seriesIdx, e);
|
|
1651
1795
|
r && t.onClick?.(r);
|
|
1652
1796
|
}, onKeyDown = (e) => {
|
|
1653
|
-
let n =
|
|
1797
|
+
let n = p.length - 1, r = A < 0 ? n : Math.max(0, A - 1), i = A < 0 ? 0 : Math.min(n, A + 1), a = {
|
|
1654
1798
|
ArrowDown: i,
|
|
1655
1799
|
ArrowLeft: r,
|
|
1656
1800
|
ArrowRight: i,
|
|
@@ -1659,9 +1803,9 @@ function createBarChart(e, t) {
|
|
|
1659
1803
|
Home: 0
|
|
1660
1804
|
};
|
|
1661
1805
|
if (e.key in a) e.preventDefault(), activate(a[e.key], 0, e);
|
|
1662
|
-
else if ((e.key === "Enter" || e.key === " ") &&
|
|
1806
|
+
else if ((e.key === "Enter" || e.key === " ") && A >= 0 && t.onClick) {
|
|
1663
1807
|
e.preventDefault();
|
|
1664
|
-
let n = eventAt(
|
|
1808
|
+
let n = eventAt(A, 0, e);
|
|
1665
1809
|
n && t.onClick(n);
|
|
1666
1810
|
} else e.key === "Escape" && deactivate();
|
|
1667
1811
|
};
|
|
@@ -1676,8 +1820,280 @@ function createBarChart(e, t) {
|
|
|
1676
1820
|
});
|
|
1677
1821
|
}
|
|
1678
1822
|
//#endregion
|
|
1823
|
+
//#region src/charts/heatmap/heatmap-chart.ts
|
|
1824
|
+
var L = {
|
|
1825
|
+
ArrowDown: 1,
|
|
1826
|
+
ArrowLeft: -1,
|
|
1827
|
+
ArrowRight: 1,
|
|
1828
|
+
ArrowUp: -1
|
|
1829
|
+
}, R = [
|
|
1830
|
+
"#e0f2fe",
|
|
1831
|
+
"#7dd3fc",
|
|
1832
|
+
"#0ea5e9",
|
|
1833
|
+
"#0369a1",
|
|
1834
|
+
"#082f49"
|
|
1835
|
+
], ee = "var(--prism-grid-color, #e2e8f0)", z = 11, B = 8, V = .4, H = 96, te = .71;
|
|
1836
|
+
function createHeatmapChart(e, t) {
|
|
1837
|
+
let n = t.rows, r = t.columns, i = t.cells, a = t.domain, o = t.rowSummary, s = resolveMargin({
|
|
1838
|
+
bottom: 8,
|
|
1839
|
+
left: 8,
|
|
1840
|
+
right: 8,
|
|
1841
|
+
top: 8,
|
|
1842
|
+
...t.margin
|
|
1843
|
+
}), c = Math.max(0, t.gap ?? 2), l = t.showValues ?? !0, u = t.valueFormat ?? String, d = createRamp(t.colorRange ?? R), f = t.emptyColor ?? ee, p = buildBinBounds(t.bins), m = p.length, h = /* @__PURE__ */ new Map(), cellKey = (e, t) => `${e}\u0000${t}`, g = null, _ = -1, v = null, positionOf = () => .5, y = createSvgElement("g"), add = (e, t, n) => {
|
|
1844
|
+
let r = createSvgElement(e, n);
|
|
1845
|
+
return t.appendChild(r), r;
|
|
1846
|
+
};
|
|
1847
|
+
function currentDomain() {
|
|
1848
|
+
if (a) return a;
|
|
1849
|
+
let e = i.filter((e) => e.value !== null).map((e) => e.value);
|
|
1850
|
+
return e.length === 0 ? [0, 1] : [Math.min(...e), Math.max(...e)];
|
|
1851
|
+
}
|
|
1852
|
+
function computePositionOf() {
|
|
1853
|
+
if (m === 0) {
|
|
1854
|
+
let [e, t] = currentDomain();
|
|
1855
|
+
return (n) => t === e ? 1 : Math.min(1, Math.max(0, (n - e) / (t - e)));
|
|
1856
|
+
}
|
|
1857
|
+
return (e) => {
|
|
1858
|
+
let t = m - 1;
|
|
1859
|
+
for (let n = 0; n < m; n += 1) {
|
|
1860
|
+
let r = p[n][1];
|
|
1861
|
+
if (r !== null && e < r) {
|
|
1862
|
+
t = n;
|
|
1863
|
+
break;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
return m === 1 ? .5 : t / (m - 1);
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
function render(e) {
|
|
1870
|
+
let { legend: a, svg: b } = e;
|
|
1871
|
+
b.contains(y) || b.appendChild(y), removeChildren(y), v = null, _ = -1, g = null, h.clear();
|
|
1872
|
+
for (let e of i) h.set(cellKey(e.row, e.column), e);
|
|
1873
|
+
if (positionOf = computePositionOf(), m > 0 && a) {
|
|
1874
|
+
let e = p.map((e, n) => ({
|
|
1875
|
+
color: d(m === 1 ? .5 : n / (m - 1)),
|
|
1876
|
+
name: (t.binLabel ?? defaultBinLabel(u))(e[0], e[1])
|
|
1877
|
+
}));
|
|
1878
|
+
t.emptyLabel && e.push({
|
|
1879
|
+
color: f,
|
|
1880
|
+
name: t.emptyLabel
|
|
1881
|
+
}), a.update(e);
|
|
1882
|
+
}
|
|
1883
|
+
if (n.length === 0 || r.length === 0) {
|
|
1884
|
+
a?.update([]);
|
|
1885
|
+
return;
|
|
1886
|
+
}
|
|
1887
|
+
let x = chartArea(e.dimensions.width, e.dimensions.height, s), S = o && o.values.length > 0 ? o : null, C = Math.min(Math.max(...n.map((e) => estimateTextWidth(e, z))) + 16, x.width * V), w = 0;
|
|
1888
|
+
if (S) {
|
|
1889
|
+
let e = S.values.filter((e) => e !== null), t = Math.max(estimateTextWidth(S.header ?? "", z), ...e.map((e) => estimateTextWidth(e, z)));
|
|
1890
|
+
w = Math.min(t + 16, x.width * V);
|
|
1891
|
+
}
|
|
1892
|
+
let T = Math.max(...r.map((e) => estimateTextWidth(e, z))), E = T > x.width / r.length - B, D = E ? Math.min(T * te + B, H) : 19, O = s.left + C, k = s.top + D, A = Math.max(0, x.width - C - w) / r.length, j = Math.max(0, x.height - D) / n.length, M = [];
|
|
1893
|
+
for (let e = 0; e < n.length; e += 1) for (let t = 0; t < r.length; t += 1) {
|
|
1894
|
+
let i = n[e], a = r[t], o = h.get(cellKey(i, a))?.value ?? null;
|
|
1895
|
+
M.push({
|
|
1896
|
+
column: a,
|
|
1897
|
+
columnWidth: A,
|
|
1898
|
+
fill: o === null ? f : d(positionOf(o)),
|
|
1899
|
+
row: i,
|
|
1900
|
+
rowHeight: j,
|
|
1901
|
+
x: O + t * A,
|
|
1902
|
+
y: k + e * j
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
g = {
|
|
1906
|
+
cells: M,
|
|
1907
|
+
columnCount: r.length,
|
|
1908
|
+
colWidth: A,
|
|
1909
|
+
gridX: O,
|
|
1910
|
+
gridY: k,
|
|
1911
|
+
rowCount: n.length,
|
|
1912
|
+
rowHeight: j
|
|
1913
|
+
};
|
|
1914
|
+
for (let e = 0; e < r.length; e += 1) {
|
|
1915
|
+
let t = O + e * A + A / 2, n = add("text", y, {
|
|
1916
|
+
"aria-hidden": "true",
|
|
1917
|
+
class: "prism-heatmap-column-label",
|
|
1918
|
+
x: String(t),
|
|
1919
|
+
y: String(s.top + D - 4)
|
|
1920
|
+
});
|
|
1921
|
+
n.textContent = r[e], E ? setAttributes(n, {
|
|
1922
|
+
"text-anchor": "start",
|
|
1923
|
+
transform: `rotate(-45 ${t} ${s.top + D - 4})`
|
|
1924
|
+
}) : setAttributes(n, { "text-anchor": "middle" });
|
|
1925
|
+
}
|
|
1926
|
+
for (let e = 0; e < n.length; e += 1) {
|
|
1927
|
+
let t = add("text", y, {
|
|
1928
|
+
"aria-hidden": "true",
|
|
1929
|
+
class: "prism-heatmap-row-label",
|
|
1930
|
+
"dominant-baseline": "central",
|
|
1931
|
+
"text-anchor": "end",
|
|
1932
|
+
x: String(O - B),
|
|
1933
|
+
y: String(k + e * j + j / 2)
|
|
1934
|
+
});
|
|
1935
|
+
t.textContent = n[e];
|
|
1936
|
+
}
|
|
1937
|
+
if (S) {
|
|
1938
|
+
let e = s.left + x.width - w / 2;
|
|
1939
|
+
if (S.header) {
|
|
1940
|
+
let t = add("text", y, {
|
|
1941
|
+
"aria-hidden": "true",
|
|
1942
|
+
class: "prism-heatmap-summary-header",
|
|
1943
|
+
"text-anchor": "middle",
|
|
1944
|
+
x: String(e),
|
|
1945
|
+
y: String(s.top + D - 4)
|
|
1946
|
+
});
|
|
1947
|
+
t.textContent = S.header;
|
|
1948
|
+
}
|
|
1949
|
+
for (let t = 0; t < n.length; t += 1) {
|
|
1950
|
+
let n = add("text", y, {
|
|
1951
|
+
"aria-hidden": "true",
|
|
1952
|
+
class: "prism-heatmap-summary",
|
|
1953
|
+
"dominant-baseline": "central",
|
|
1954
|
+
"text-anchor": "middle",
|
|
1955
|
+
x: String(e),
|
|
1956
|
+
y: String(k + t * j + j / 2)
|
|
1957
|
+
});
|
|
1958
|
+
n.textContent = S.values[t] ?? "—";
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
for (let e of M) {
|
|
1962
|
+
let t = h.get(cellKey(e.row, e.column))?.value ?? null, n = add("g", y, {
|
|
1963
|
+
"aria-hidden": "true",
|
|
1964
|
+
class: "prism-heatmap-cell"
|
|
1965
|
+
});
|
|
1966
|
+
if (add("rect", n, {
|
|
1967
|
+
class: "prism-heatmap-cell-rect",
|
|
1968
|
+
height: String(Math.max(0, e.rowHeight - c)),
|
|
1969
|
+
rx: "2",
|
|
1970
|
+
width: String(Math.max(0, e.columnWidth - c)),
|
|
1971
|
+
x: String(e.x + c / 2),
|
|
1972
|
+
y: String(e.y + c / 2)
|
|
1973
|
+
}).style.setProperty("fill", e.fill), l && t !== null && A > 28 && j > 16) {
|
|
1974
|
+
let r = add("text", n, {
|
|
1975
|
+
class: "prism-heatmap-value",
|
|
1976
|
+
"dominant-baseline": "central",
|
|
1977
|
+
"text-anchor": "middle",
|
|
1978
|
+
x: String(e.x + A / 2),
|
|
1979
|
+
y: String(e.y + j / 2)
|
|
1980
|
+
});
|
|
1981
|
+
r.textContent = u(t), r.style.setProperty("fill", valueColorFor(e.fill, "var(--prism-text-color, #0f172a)"));
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
v = add("rect", y, {
|
|
1985
|
+
class: "prism-heatmap-highlight",
|
|
1986
|
+
height: "0",
|
|
1987
|
+
rx: "2",
|
|
1988
|
+
visibility: "hidden",
|
|
1989
|
+
width: "0",
|
|
1990
|
+
x: "0",
|
|
1991
|
+
y: "0"
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
function eventFor(e, t) {
|
|
1995
|
+
return {
|
|
1996
|
+
cell: h.get(cellKey(e.row, e.column)),
|
|
1997
|
+
column: e.column,
|
|
1998
|
+
originalEvent: t,
|
|
1999
|
+
row: e.row
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
function indexAt(e, t) {
|
|
2003
|
+
if (!g) return -1;
|
|
2004
|
+
let n = e.getBoundingClientRect(), r = t.clientX - n.left, i = t.clientY - n.top, a = Math.floor((r - g.gridX) / g.colWidth), o = Math.floor((i - g.gridY) / g.rowHeight);
|
|
2005
|
+
return a < 0 || o < 0 || a >= g.columnCount || o >= g.rowCount ? -1 : o * g.columnCount + a;
|
|
2006
|
+
}
|
|
2007
|
+
function describe(e) {
|
|
2008
|
+
let t = g.cells[e], n = h.get(cellKey(t.row, t.column))?.value ?? null;
|
|
2009
|
+
return `${t.row} \u00b7 ${t.column}: ${n === null ? "—" : u(n)}`;
|
|
2010
|
+
}
|
|
2011
|
+
function activate(e, n, r) {
|
|
2012
|
+
if (!g || !v) return;
|
|
2013
|
+
let i = g.cells[n];
|
|
2014
|
+
if (!i) return;
|
|
2015
|
+
_ = n;
|
|
2016
|
+
let a = h.get(cellKey(i.row, i.column))?.value ?? null;
|
|
2017
|
+
setAttributes(v, {
|
|
2018
|
+
height: String(Math.max(0, i.rowHeight - c)),
|
|
2019
|
+
visibility: "visible",
|
|
2020
|
+
width: String(Math.max(0, i.columnWidth - c)),
|
|
2021
|
+
x: String(i.x + c / 2),
|
|
2022
|
+
y: String(i.y + c / 2)
|
|
2023
|
+
}), t.onCellHover?.(eventFor(i, r));
|
|
2024
|
+
let o = describe(n);
|
|
2025
|
+
if (!e.tooltip) {
|
|
2026
|
+
e.announcer.announce(o);
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
let s = e.svg.getBoundingClientRect(), l = e.container.getBoundingClientRect();
|
|
2030
|
+
e.tooltip.show(i.x + i.columnWidth / 2 + (s.left - l.left), i.y + (s.top - l.top), {
|
|
2031
|
+
key: cellKey(i.row, i.column),
|
|
2032
|
+
meta: { text: o },
|
|
2033
|
+
value: a ?? 0
|
|
2034
|
+
}, {
|
|
2035
|
+
color: i.fill,
|
|
2036
|
+
data: [],
|
|
2037
|
+
name: `${i.row} \u00b7 ${i.column}`
|
|
2038
|
+
}, comparisonContent(e.svg.ownerDocument, `${i.row} \u00b7 ${i.column}`, [{
|
|
2039
|
+
color: i.fill,
|
|
2040
|
+
name: i.column,
|
|
2041
|
+
value: a === null ? "—" : u(a)
|
|
2042
|
+
}], o));
|
|
2043
|
+
}
|
|
2044
|
+
function deactivate(e) {
|
|
2045
|
+
_ !== -1 && (_ = -1, v?.setAttribute("visibility", "hidden"), t.onCellHover?.(null), e.tooltip?.hide(), e.announcer.clear());
|
|
2046
|
+
}
|
|
2047
|
+
return createRadialScaffold(e, {
|
|
2048
|
+
a11y: t.a11y,
|
|
2049
|
+
legend: m > 0 && t.legend !== !1 && {},
|
|
2050
|
+
margin: t.margin,
|
|
2051
|
+
tooltip: t.tooltip
|
|
2052
|
+
}, (e) => {
|
|
2053
|
+
if (render(e), g) return {
|
|
2054
|
+
onClick(n) {
|
|
2055
|
+
let r = indexAt(e.svg, n);
|
|
2056
|
+
r >= 0 && t.onCellClick?.(eventFor(g.cells[r], n));
|
|
2057
|
+
},
|
|
2058
|
+
onKeyDown(n) {
|
|
2059
|
+
let r = L[n.key];
|
|
2060
|
+
if (r !== void 0) {
|
|
2061
|
+
if (n.preventDefault(), _ < 0) {
|
|
2062
|
+
activate(e, 0, n);
|
|
2063
|
+
return;
|
|
2064
|
+
}
|
|
2065
|
+
let t = g.columnCount, i = Math.floor(_ / t), a = _ % t;
|
|
2066
|
+
if (n.key === "ArrowUp" || n.key === "ArrowDown") {
|
|
2067
|
+
let o = i + r;
|
|
2068
|
+
o >= 0 && o < g.rowCount && activate(e, o * t + a, n);
|
|
2069
|
+
} else {
|
|
2070
|
+
let o = a + r;
|
|
2071
|
+
o >= 0 && o < g.columnCount && activate(e, i * t + o, n);
|
|
2072
|
+
}
|
|
2073
|
+
} else (n.key === "Enter" || n.key === " ") && _ >= 0 ? (n.preventDefault(), t.onCellClick?.(eventFor(g.cells[_], n))) : n.key === "Escape" && deactivate(e);
|
|
2074
|
+
},
|
|
2075
|
+
onMouseLeave: () => deactivate(e),
|
|
2076
|
+
onMouseMove(t) {
|
|
2077
|
+
let n = indexAt(e.svg, t);
|
|
2078
|
+
n < 0 ? _ >= 0 && deactivate(e) : n !== _ && activate(e, n, t);
|
|
2079
|
+
}
|
|
2080
|
+
};
|
|
2081
|
+
}, (e) => {
|
|
2082
|
+
e.rows && (n = e.rows), e.columns && (r = e.columns), i = e.cells, e.domain && (a = e.domain), "rowSummary" in e && (o = e.rowSummary);
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
function buildBinBounds(e) {
|
|
2086
|
+
if (!e || e.length === 0) return [];
|
|
2087
|
+
let t = [...e].sort((e, t) => e - t), n = [], r = null;
|
|
2088
|
+
for (let e of t) n.push([r, e]), r = e;
|
|
2089
|
+
return n.push([r, null]), n;
|
|
2090
|
+
}
|
|
2091
|
+
function defaultBinLabel(e) {
|
|
2092
|
+
return (t, n) => t === null && n !== null ? `<${e(n)}` : t !== null && n === null ? `\u2265${e(t)}` : t !== null && n !== null ? `${e(t)}\u2013${e(n)}` : "—";
|
|
2093
|
+
}
|
|
2094
|
+
//#endregion
|
|
1679
2095
|
//#region src/charts/line/line-renderer.ts
|
|
1680
|
-
var
|
|
2096
|
+
var U = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap();
|
|
1681
2097
|
function buildPath(e, t) {
|
|
1682
2098
|
return t === "monotone" ? monotonePath(e) : t === "step" ? stepPath(e) : linePath(e);
|
|
1683
2099
|
}
|
|
@@ -1721,7 +2137,7 @@ function renderLine(e, t, n) {
|
|
|
1721
2137
|
else setAttributes(c, { d: buildPath(e, n.curve) });
|
|
1722
2138
|
}, d = e.querySelector(".prism-line-dots");
|
|
1723
2139
|
if (n.showPoints ? d || (d = createSvgElement("g", { class: "prism-line-dots" }), e.appendChild(d)) : d &&= (d.remove(), null), o === 0) {
|
|
1724
|
-
if (
|
|
2140
|
+
if (U.get(e)?.(), cancelReveal(e), draw(t), W.set(e, t), d) {
|
|
1725
2141
|
for (; d.children.length > t.length;) d.removeChild(d.lastChild);
|
|
1726
2142
|
for (let e = 0; e < t.length; e++) {
|
|
1727
2143
|
let r = d.children[e];
|
|
@@ -1736,8 +2152,8 @@ function renderLine(e, t, n) {
|
|
|
1736
2152
|
}
|
|
1737
2153
|
return;
|
|
1738
2154
|
}
|
|
1739
|
-
|
|
1740
|
-
let f = !
|
|
2155
|
+
U.get(e)?.(), cancelReveal(e);
|
|
2156
|
+
let f = !W.has(e);
|
|
1741
2157
|
if (d) {
|
|
1742
2158
|
for (; d.children.length > t.length;) d.removeChild(d.lastChild);
|
|
1743
2159
|
for (let e = d.children.length; e < t.length; e++) {
|
|
@@ -1751,7 +2167,7 @@ function renderLine(e, t, n) {
|
|
|
1751
2167
|
for (let e = 0; e < d.children.length; e++) setAttributes(d.children[e], { opacity: i[e]?.opacity });
|
|
1752
2168
|
}
|
|
1753
2169
|
if (f) {
|
|
1754
|
-
if (draw(t),
|
|
2170
|
+
if (draw(t), W.set(e, t), d) for (let [e, n] of t.entries()) {
|
|
1755
2171
|
let t = d.children[e];
|
|
1756
2172
|
t && setAttributes(t, {
|
|
1757
2173
|
cx: n.x,
|
|
@@ -1772,7 +2188,7 @@ function renderLine(e, t, n) {
|
|
|
1772
2188
|
}
|
|
1773
2189
|
return;
|
|
1774
2190
|
}
|
|
1775
|
-
let p = [], m =
|
|
2191
|
+
let p = [], m = W.get(e) ?? t;
|
|
1776
2192
|
for (let [e, n] of t.entries()) p.push(m[e] ?? m.at(-1) ?? n);
|
|
1777
2193
|
let paintFrame = (n) => {
|
|
1778
2194
|
let r = t.map((e, t) => {
|
|
@@ -1782,7 +2198,7 @@ function renderLine(e, t, n) {
|
|
|
1782
2198
|
y: tweenNumber(r.y, e.y, n)
|
|
1783
2199
|
};
|
|
1784
2200
|
});
|
|
1785
|
-
if (
|
|
2201
|
+
if (W.set(e, r), draw(r), d) for (let e = 0; e < t.length; e++) {
|
|
1786
2202
|
let t = d.children[e];
|
|
1787
2203
|
t && setAttributes(t, {
|
|
1788
2204
|
cx: r[e].x,
|
|
@@ -1790,12 +2206,12 @@ function renderLine(e, t, n) {
|
|
|
1790
2206
|
});
|
|
1791
2207
|
}
|
|
1792
2208
|
};
|
|
1793
|
-
paintFrame(0),
|
|
2209
|
+
paintFrame(0), U.set(e, startTween({
|
|
1794
2210
|
count: 1,
|
|
1795
2211
|
duration: o,
|
|
1796
2212
|
easing: s,
|
|
1797
2213
|
onComplete: () => {
|
|
1798
|
-
|
|
2214
|
+
U.delete(e), W.set(e, t);
|
|
1799
2215
|
},
|
|
1800
2216
|
onFrame: (e) => paintFrame(e(0)),
|
|
1801
2217
|
signal: n.disposalSignal
|
|
@@ -1965,18 +2381,18 @@ function arcCentroid(e) {
|
|
|
1965
2381
|
}
|
|
1966
2382
|
//#endregion
|
|
1967
2383
|
//#region src/charts/pie/pie-chart.ts
|
|
1968
|
-
var
|
|
2384
|
+
var G = 2 * Math.PI, K = 12;
|
|
1969
2385
|
function labelFits(e, t) {
|
|
1970
2386
|
let n = e.outerRadius - e.innerRadius, r = (e.outerRadius + e.innerRadius) / 2, i = (e.endAngle - e.startAngle - 2 * e.padAngle) * r;
|
|
1971
|
-
return n >=
|
|
2387
|
+
return n >= K * 1.4 && i >= estimateTextWidth(t, K) + 8;
|
|
1972
2388
|
}
|
|
1973
|
-
var
|
|
2389
|
+
var ne = -Math.PI / 2, re = Math.PI / 2;
|
|
1974
2390
|
function semiAngles(e) {
|
|
1975
2391
|
return e === "semi" ? {
|
|
1976
|
-
end:
|
|
1977
|
-
start:
|
|
2392
|
+
end: re,
|
|
2393
|
+
start: ne
|
|
1978
2394
|
} : {
|
|
1979
|
-
end:
|
|
2395
|
+
end: G,
|
|
1980
2396
|
start: 0
|
|
1981
2397
|
};
|
|
1982
2398
|
}
|
|
@@ -2152,7 +2568,7 @@ function hitTestArc(e, t, n, r) {
|
|
|
2152
2568
|
if (r === "semi") {
|
|
2153
2569
|
if (e >= a.startAngle - 1e-9 && e <= a.endAngle + 1e-9) return i;
|
|
2154
2570
|
} else {
|
|
2155
|
-
let t = e < 0 ? e +
|
|
2571
|
+
let t = e < 0 ? e + G : e;
|
|
2156
2572
|
if (t >= a.startAngle - 1e-9 && t <= a.endAngle + 1e-9) return i;
|
|
2157
2573
|
}
|
|
2158
2574
|
}
|
|
@@ -2161,12 +2577,12 @@ function hitTestArc(e, t, n, r) {
|
|
|
2161
2577
|
}
|
|
2162
2578
|
//#endregion
|
|
2163
2579
|
//#region src/charts/radar/radar-geometry.ts
|
|
2164
|
-
var
|
|
2580
|
+
var q = 2 * Math.PI;
|
|
2165
2581
|
function toRadians(e) {
|
|
2166
2582
|
return e * Math.PI / 180;
|
|
2167
2583
|
}
|
|
2168
2584
|
function axisAngles(e, t = 0) {
|
|
2169
|
-
return Array.from({ length: e }, (n, r) => t + r *
|
|
2585
|
+
return Array.from({ length: e }, (n, r) => t + r * q / e);
|
|
2170
2586
|
}
|
|
2171
2587
|
function resolveAxisDomains(e, t, n) {
|
|
2172
2588
|
let r = n;
|
|
@@ -2220,12 +2636,12 @@ function fitRadius(e, t, n, r, i, a) {
|
|
|
2220
2636
|
}
|
|
2221
2637
|
function nearestAxis(e, t, n, r = 0) {
|
|
2222
2638
|
if (n === 0) return -1;
|
|
2223
|
-
let i =
|
|
2639
|
+
let i = q / n, a = ((Math.atan2(e, -t) - r) % q + q) % q;
|
|
2224
2640
|
return Math.round(a / i) % n;
|
|
2225
2641
|
}
|
|
2226
2642
|
//#endregion
|
|
2227
2643
|
//#region src/charts/radar/radar-chart.ts
|
|
2228
|
-
var
|
|
2644
|
+
var J = 11, Y = 12, X = 10, Z = {
|
|
2229
2645
|
ArrowDown: 1,
|
|
2230
2646
|
ArrowLeft: -1,
|
|
2231
2647
|
ArrowRight: 1,
|
|
@@ -2241,7 +2657,7 @@ function resolveGrid(e) {
|
|
|
2241
2657
|
};
|
|
2242
2658
|
}
|
|
2243
2659
|
function createRadarChart(e, t) {
|
|
2244
|
-
let { axes: n } = t, r = t.curve ?? "linear", i = t.fill ?? "solid", a = t.showPoints ?? !0, o = resolveGrid(t.grid), s = toRadians(t.startAngle ?? 0), c = axisAngles(n.length, s), l =
|
|
2660
|
+
let { axes: n } = t, r = t.curve ?? "linear", i = t.fill ?? "solid", a = t.showPoints ?? !0, o = resolveGrid(t.grid), s = toRadians(t.startAngle ?? 0), c = axisAngles(n.length, s), l = Y + (t.showValues ? X : 0), u = uniqueId("prism-radar"), d = t.series, f = createSvgElement("g", { class: "prism-radar" }), p = createSvgElement("defs"), m = createSvgElement("g", {
|
|
2245
2661
|
"aria-hidden": "true",
|
|
2246
2662
|
class: "prism-radar-grid"
|
|
2247
2663
|
}), h = createSvgElement("g", { class: "prism-radar-series-group" }), g = createSvgElement("g", {
|
|
@@ -2269,7 +2685,7 @@ function createRadarChart(e, t) {
|
|
|
2269
2685
|
cy: s[t].y
|
|
2270
2686
|
});
|
|
2271
2687
|
}), o.querySelectorAll(".prism-radar-value").forEach((r, a) => {
|
|
2272
|
-
let o = i * e[a] +
|
|
2688
|
+
let o = i * e[a] + X;
|
|
2273
2689
|
setAttributes(r, {
|
|
2274
2690
|
x: polarX(t, o, c[a]),
|
|
2275
2691
|
y: polarY(n, o, c[a])
|
|
@@ -2422,7 +2838,7 @@ function createRadarChart(e, t) {
|
|
|
2422
2838
|
_ = [];
|
|
2423
2839
|
return;
|
|
2424
2840
|
}
|
|
2425
|
-
let { height: u, width: v } = r.dimensions, x = fitRadius(v, u, n.map((e) => e.label), c,
|
|
2841
|
+
let { height: u, width: v } = r.dimensions, x = fitRadius(v, u, n.map((e) => e.label), c, J, l);
|
|
2426
2842
|
b = {
|
|
2427
2843
|
cx: v / 2,
|
|
2428
2844
|
cy: u / 2,
|
|
@@ -2475,7 +2891,7 @@ function createRadarChart(e, t) {
|
|
|
2475
2891
|
n >= 0 && t.onClick?.(eventFor(n, e));
|
|
2476
2892
|
},
|
|
2477
2893
|
onKeyDown(e) {
|
|
2478
|
-
let r =
|
|
2894
|
+
let r = Z[e.key];
|
|
2479
2895
|
r === void 0 ? (e.key === "Enter" || e.key === " ") && y >= 0 && t.onClick ? (e.preventDefault(), t.onClick(eventFor(y, e))) : e.key === "Escape" && deactivate() : (e.preventDefault(), activate(y < 0 ? 0 : (y + r + n.length) % n.length, e));
|
|
2480
2896
|
},
|
|
2481
2897
|
onMouseLeave: deactivate,
|
|
@@ -2587,7 +3003,7 @@ function createScatterInteraction(e) {
|
|
|
2587
3003
|
}
|
|
2588
3004
|
//#endregion
|
|
2589
3005
|
//#region src/charts/scatter/scatter-renderer.ts
|
|
2590
|
-
var
|
|
3006
|
+
var ie = 400, Q = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakMap();
|
|
2591
3007
|
function computeScatterPoints(e, t, n) {
|
|
2592
3008
|
return e.some((e) => e.key == null) || e.some((e) => typeof e.key == "string"), e.map((e) => ({
|
|
2593
3009
|
x: t.map(e.key),
|
|
@@ -2596,8 +3012,8 @@ function computeScatterPoints(e, t, n) {
|
|
|
2596
3012
|
}
|
|
2597
3013
|
function renderScatterPoints(e, t, n) {
|
|
2598
3014
|
let r = resolveMotion(n.transition), i = n.marks ?? [], a = n.pointRadius;
|
|
2599
|
-
for (
|
|
2600
|
-
let o =
|
|
3015
|
+
for (Q.get(e)?.(), Q.delete(e); e.children.length > t.length;) e.lastChild.remove();
|
|
3016
|
+
let o = $.get(e) ?? [], s = [], c = t.map((t, r) => {
|
|
2601
3017
|
let a = e.children[r];
|
|
2602
3018
|
return a ? s.push(Number(a.getAttribute("r")) || 0) : (a = createSvgElement("circle", { class: "prism-scatter-point" }), e.appendChild(a), s.push(0)), setAttributes(a, {
|
|
2603
3019
|
fill: n.color,
|
|
@@ -2609,25 +3025,25 @@ function renderScatterPoints(e, t, n) {
|
|
|
2609
3025
|
cy: t[e].y,
|
|
2610
3026
|
r: n(e)
|
|
2611
3027
|
});
|
|
2612
|
-
|
|
3028
|
+
$.set(e, t);
|
|
2613
3029
|
};
|
|
2614
3030
|
if (r.duration === 0) {
|
|
2615
3031
|
paint(t, () => a);
|
|
2616
3032
|
return;
|
|
2617
3033
|
}
|
|
2618
|
-
let l = t.map((e, t) => o[t] ?? e), u = t.map((e, t) => t).filter((e) => e >= o.length), d = new Map([...u].sort((e, n) => t[e].x - t[n].x).map((e, t) => [e, t])), f = Math.min(r.stagger,
|
|
3034
|
+
let l = t.map((e, t) => o[t] ?? e), u = t.map((e, t) => t).filter((e) => e >= o.length), d = new Map([...u].sort((e, n) => t[e].x - t[n].x).map((e, t) => [e, t])), f = Math.min(r.stagger, ie / Math.max(1, u.length)), paintFrame = (e) => {
|
|
2619
3035
|
let n = t.map((t, n) => e(d.get(n) ?? 0));
|
|
2620
3036
|
paint(t.map((e, t) => ({
|
|
2621
3037
|
x: tweenNumber(l[t].x, e.x, n[t]),
|
|
2622
3038
|
y: tweenNumber(l[t].y, e.y, n[t])
|
|
2623
3039
|
})), (e) => tweenNumber(s[e], a, n[e]));
|
|
2624
3040
|
};
|
|
2625
|
-
paintFrame(() => 0),
|
|
3041
|
+
paintFrame(() => 0), Q.set(e, startTween({
|
|
2626
3042
|
count: Math.max(1, u.length),
|
|
2627
3043
|
duration: r.duration,
|
|
2628
3044
|
easing: resolveEasing(r.easing),
|
|
2629
3045
|
onComplete: () => {
|
|
2630
|
-
|
|
3046
|
+
Q.delete(e), paint(t, () => a);
|
|
2631
3047
|
},
|
|
2632
3048
|
onFrame: paintFrame,
|
|
2633
3049
|
signal: n.disposalSignal,
|
|
@@ -2691,7 +3107,7 @@ function createScatterChart(e, t) {
|
|
|
2691
3107
|
}
|
|
2692
3108
|
//#endregion
|
|
2693
3109
|
//#region src/charts/sparkline/sparkline.ts
|
|
2694
|
-
var
|
|
3110
|
+
var ae = 5;
|
|
2695
3111
|
function buildTopPoints(e, t, n) {
|
|
2696
3112
|
if (e.length === 0) return [];
|
|
2697
3113
|
let r = t / Math.max(1, e.length - 1), i = Math.min(...e), a = Math.max(...e) - i || 1;
|
|
@@ -2751,7 +3167,7 @@ function createSparkline(e, t) {
|
|
|
2751
3167
|
g.appendChild(_);
|
|
2752
3168
|
let cleanupInteraction;
|
|
2753
3169
|
function plotArea() {
|
|
2754
|
-
let { height: e, width: t } = h.dimensions, r = n === "line" || n === "area" ?
|
|
3170
|
+
let { height: e, width: t } = h.dimensions, r = n === "line" || n === "area" ? ae : 0;
|
|
2755
3171
|
return {
|
|
2756
3172
|
h: Math.max(1, e - r * 2),
|
|
2757
3173
|
inset: r,
|
|
@@ -2926,6 +3342,6 @@ function createSparkline(e, t) {
|
|
|
2926
3342
|
}
|
|
2927
3343
|
}
|
|
2928
3344
|
//#endregion
|
|
2929
|
-
export { PrismError, PrismRenderError, bandScale, createAreaChart, createBarChart, createLineChart, createPieChart, createRadarChart, createScatterChart, createSparkline, linearScale, resetTheme, seriesColor, setTheme, timeScale };
|
|
3345
|
+
export { PrismError, PrismRenderError, bandScale, createAreaChart, createBarChart, createHeatmapChart, createLineChart, createPieChart, createRadarChart, createScatterChart, createSparkline, linearScale, resetTheme, seriesColor, setTheme, timeScale };
|
|
2930
3346
|
|
|
2931
3347
|
//# sourceMappingURL=prism.js.map
|