@martinomagnifico/tablechart 1.2.5 → 1.2.6
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/CHANGELOG.md +7 -3
- package/dist/tablechart-shared.d.mts +2 -0
- package/dist/tablechart-shared.mjs +158 -158
- package/dist/tablechart.css +1 -1
- package/dist/tablechart.js +1 -1
- package/package.json +1 -1
|
@@ -921,44 +921,44 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-value", r = "tablec
|
|
|
921
921
|
to: e.value,
|
|
922
922
|
kind: "bar"
|
|
923
923
|
})),
|
|
924
|
-
draw({ rows: e, height: t, unit: n, labelHeight: r, svg: i, values: a, config: o, centre: s }) {
|
|
925
|
-
let
|
|
926
|
-
if (!
|
|
927
|
-
let
|
|
924
|
+
draw({ rows: e, height: t, unit: n, labelHeight: r, svg: i, values: a, config: o, centre: s, sliceRadius: c }) {
|
|
925
|
+
let u = O / 2, d = t / 2, f = qe(e).reduce((e, t) => e + Math.abs(t.value), 0);
|
|
926
|
+
if (!f) return;
|
|
927
|
+
let p = r * 1.2 + 10 * n, m = Math.max(Math.min(O, t) / 2 - p, 10), h = m * o.ringfill, g = m - h / 2, _ = 2 * Math.PI * g, v = [], y = [], b = 0, x = 0, S = 0;
|
|
928
928
|
if (e.forEach((e, o) => {
|
|
929
929
|
let s = a[o];
|
|
930
930
|
if (e.isTotal) {
|
|
931
931
|
s.dataset.place = "none";
|
|
932
932
|
return;
|
|
933
933
|
}
|
|
934
|
-
let
|
|
935
|
-
|
|
934
|
+
let c = Math.abs(e.value) / f, p = j(S, c), C = `--share:${c.toFixed(4)}; --start:${p.start.toFixed(4)}; --span:${p.span.toFixed(4)};`, w = c * _, T = b / _ * 2 * Math.PI - Math.PI / 2;
|
|
935
|
+
v.push(T), y.push(w / _ * 2 * Math.PI), i.appendChild(F("circle", {
|
|
936
936
|
class: I(l, e),
|
|
937
|
-
"data-slice":
|
|
937
|
+
"data-slice": x + 1,
|
|
938
938
|
"data-row": o + 1,
|
|
939
|
-
cx:
|
|
940
|
-
cy:
|
|
941
|
-
r:
|
|
942
|
-
"stroke-width":
|
|
943
|
-
transform: `rotate(-90 ${
|
|
944
|
-
"stroke-dasharray": `${w.toFixed(1)} ${(
|
|
945
|
-
"stroke-dashoffset": (-
|
|
946
|
-
style: `--n:${
|
|
939
|
+
cx: u,
|
|
940
|
+
cy: d,
|
|
941
|
+
r: g,
|
|
942
|
+
"stroke-width": h,
|
|
943
|
+
transform: `rotate(-90 ${u} ${d})`,
|
|
944
|
+
"stroke-dasharray": `${w.toFixed(1)} ${(_ - w).toFixed(1)}`,
|
|
945
|
+
"stroke-dashoffset": (-b).toFixed(1),
|
|
946
|
+
style: `--n:${x}; --palette:var(--tablechart-color-${x + 1}); --arc:${w.toFixed(1)}; --circ:${_.toFixed(1)}; ${C} --ease:${p.easing}; ${M("--i", e.slot)}`
|
|
947
947
|
}));
|
|
948
|
-
let E = T + w /
|
|
948
|
+
let E = T + w / _ * Math.PI, D = Math.cos(E), k = Math.sin(E);
|
|
949
949
|
i.appendChild(F("line", {
|
|
950
950
|
class: "tablechart-leader",
|
|
951
|
-
x1:
|
|
952
|
-
y1:
|
|
953
|
-
x2:
|
|
954
|
-
y2:
|
|
951
|
+
x1: u + D * (m + 2 * n),
|
|
952
|
+
y1: d + k * (m + 2 * n),
|
|
953
|
+
x2: u + D * (m + 7 * n),
|
|
954
|
+
y2: d + k * (m + 7 * n),
|
|
955
955
|
"data-row": o + 1,
|
|
956
956
|
style: `${C} ${M("--i", e.slot)}`
|
|
957
|
-
})), s.style.setProperty("--start",
|
|
958
|
-
let A =
|
|
959
|
-
R(s,
|
|
960
|
-
}),
|
|
961
|
-
let e =
|
|
957
|
+
})), s.style.setProperty("--start", p.start.toFixed(4)), s.style.setProperty("--span", p.span.toFixed(4));
|
|
958
|
+
let A = m + 9 * n, N = J(s).width * n / 2;
|
|
959
|
+
R(s, u + D * (A + Math.abs(D) * N), d + k * (A + Math.abs(k) * r * .7), O, t), s.dataset.place = "around", b += w, S += c, x += 1;
|
|
960
|
+
}), v.length > 1) {
|
|
961
|
+
let e = g - h / 2 - 1, n = g + h / 2 + 1, r = `tablechart-slices-${++Y}`, a = F("mask", {
|
|
962
962
|
id: r,
|
|
963
963
|
maskUnits: "userSpaceOnUse"
|
|
964
964
|
});
|
|
@@ -969,30 +969,29 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-value", r = "tablec
|
|
|
969
969
|
height: t,
|
|
970
970
|
fill: "white"
|
|
971
971
|
}));
|
|
972
|
-
for (let t of
|
|
972
|
+
for (let t of v) a.appendChild(F("line", {
|
|
973
973
|
class: "tablechart-divide",
|
|
974
|
-
x1:
|
|
975
|
-
y1:
|
|
976
|
-
x2:
|
|
977
|
-
y2:
|
|
974
|
+
x1: u + Math.cos(t) * e,
|
|
975
|
+
y1: d + Math.sin(t) * e,
|
|
976
|
+
x2: u + Math.cos(t) * n,
|
|
977
|
+
y2: d + Math.sin(t) * n
|
|
978
978
|
}));
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
let
|
|
984
|
-
|
|
985
|
-
d: Ke(c, u, r, n, s, e / 2, l, n === t[1]),
|
|
979
|
+
if (c > 0) {
|
|
980
|
+
let e = Number.parseFloat(getComputedStyle(i).getPropertyValue("--tablechart-slice-gap").trim() || "4"), t = [g - h / 2, g + h / 2], n = (n) => Math.min(c, h / 2, Math.max((y[n] * t[0] - e) / 2, 0));
|
|
981
|
+
v.forEach((r, i) => {
|
|
982
|
+
let o = n((i - 1 + v.length) % v.length);
|
|
983
|
+
for (let [s, c] of [[1, n(i)], [-1, o]]) if (c > 0) for (let n of t) a.appendChild(F("path", {
|
|
984
|
+
d: Ke(u, d, r, n, s, e / 2, c, n === t[1]),
|
|
986
985
|
fill: "black"
|
|
987
986
|
}));
|
|
988
987
|
});
|
|
989
988
|
}
|
|
990
|
-
let
|
|
991
|
-
for (let e of Array.from(i.querySelectorAll(`.${l}`)))
|
|
992
|
-
let
|
|
993
|
-
|
|
989
|
+
let o = F("g", { mask: `url(#${r})` });
|
|
990
|
+
for (let e of Array.from(i.querySelectorAll(`.${l}`))) o.appendChild(e);
|
|
991
|
+
let s = F("defs");
|
|
992
|
+
s.appendChild(a), i.prepend(s, o);
|
|
994
993
|
}
|
|
995
|
-
s && R(s,
|
|
994
|
+
s && R(s, u, d, O, t);
|
|
996
995
|
}
|
|
997
996
|
}, X = [
|
|
998
997
|
"circle",
|
|
@@ -2436,13 +2435,13 @@ var tt = (e) => {
|
|
|
2436
2435
|
plan: te,
|
|
2437
2436
|
step: 0,
|
|
2438
2437
|
controls: re
|
|
2439
|
-
}, ae = () =>
|
|
2438
|
+
}, ae = () => cr(r, v);
|
|
2440
2439
|
v.addEventListener("transitionend", ae), v.addEventListener("transitioncancel", ae), re?.addEventListener("click", (e) => {
|
|
2441
2440
|
let t = e.target.closest("button")?.dataset.go;
|
|
2442
2441
|
t && Yt(K, K.step + (t === "next" ? 1 : -1));
|
|
2443
2442
|
}), Yt(K, 0, !0);
|
|
2444
2443
|
let oe = r.getAttribute("data-chart-tooltip"), se = oe === "false" ? !1 : oe === "auto" ? "auto" : oe !== null || i.tooltip;
|
|
2445
|
-
return se && Sn(K, i, se === "auto"),
|
|
2444
|
+
return se && Sn(K, i, se === "auto"), rr(K, i), K;
|
|
2446
2445
|
}, Wn = {
|
|
2447
2446
|
grow: "grow",
|
|
2448
2447
|
sweep: "sweep"
|
|
@@ -2462,7 +2461,7 @@ var tt = (e) => {
|
|
|
2462
2461
|
if (!a) return null;
|
|
2463
2462
|
let o = Number(a[1]);
|
|
2464
2463
|
return a[2] === "%" ? o / 100 * O : o * (a[2] === "em" ? Number.parseFloat(i.fontSize) : a[2] === "rem" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) : 1) * t;
|
|
2465
|
-
}, Xn = (e, t) => Yn(e, t, "--tablechart-bar-max", "60px") ?? Infinity,
|
|
2464
|
+
}, Xn = (e, t, n) => Yn(e, t, getComputedStyle(e).getPropertyValue(n).trim() ? n : "--tablechart-corner-radius", "0px") ?? 0, Zn = (e, t) => Yn(e, t, "--tablechart-bar-max", "60px") ?? Infinity, Qn = (e, t) => {
|
|
2466
2465
|
let n = e.getBoundingClientRect(), r = O / n.width, i = getComputedStyle(e), a = Number.parseFloat(i.lineHeight) / Number.parseFloat(i.fontSize) || 1.2;
|
|
2467
2466
|
return (e) => {
|
|
2468
2467
|
if (e.dataset.place === "none" || e.hidden || e.hasAttribute("data-left-out")) return [];
|
|
@@ -2477,21 +2476,21 @@ var tt = (e) => {
|
|
|
2477
2476
|
style: s.join("; ")
|
|
2478
2477
|
})] : [];
|
|
2479
2478
|
};
|
|
2480
|
-
},
|
|
2479
|
+
}, $n = [
|
|
2481
2480
|
"first",
|
|
2482
2481
|
"last",
|
|
2483
2482
|
"highest",
|
|
2484
2483
|
"lowest",
|
|
2485
2484
|
"outliers"
|
|
2486
|
-
],
|
|
2485
|
+
], er = (t, n) => {
|
|
2487
2486
|
let r = (t.getAttribute("data-chart-values") ?? n.values).trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
2488
2487
|
for (let t of r) [
|
|
2489
2488
|
"auto",
|
|
2490
2489
|
"all",
|
|
2491
2490
|
"none",
|
|
2492
|
-
|
|
2493
|
-
].includes(t) || console.warn(`[${e}] data-chart-values knows no "${t}". It takes auto, all, none, ${
|
|
2494
|
-
let i = r.filter((e) =>
|
|
2491
|
+
...$n
|
|
2492
|
+
].includes(t) || console.warn(`[${e}] data-chart-values knows no "${t}". It takes auto, all, none, ${$n.join(", ")}.`);
|
|
2493
|
+
let i = r.filter((e) => $n.includes(e));
|
|
2495
2494
|
return r.includes("all") ? {
|
|
2496
2495
|
mode: "all",
|
|
2497
2496
|
keys: []
|
|
@@ -2500,19 +2499,19 @@ var tt = (e) => {
|
|
|
2500
2499
|
keys: []
|
|
2501
2500
|
} : r.includes("auto") || !i.length ? {
|
|
2502
2501
|
mode: "auto",
|
|
2503
|
-
keys: i.length ? i :
|
|
2502
|
+
keys: i.length ? i : $n
|
|
2504
2503
|
} : {
|
|
2505
2504
|
mode: "set",
|
|
2506
2505
|
keys: i
|
|
2507
2506
|
};
|
|
2508
|
-
},
|
|
2507
|
+
}, tr = ({ figure: e, rows: t, series: n }, r) => {
|
|
2509
2508
|
let i = e.getAttribute("data-chart-table"), a = i && Gn.includes(i) ? i : r.table;
|
|
2510
2509
|
a === "never" ? e.removeAttribute("data-table") : e.setAttribute("data-table", a);
|
|
2511
2510
|
let o = e.getAttribute("data-chart-summary");
|
|
2512
2511
|
e.setAttribute("data-summary", o && Gn.includes(o) ? o : r.summary), e.toggleAttribute("data-long", t.length * n.filter((e) => !e.group).length > r.tablelimit);
|
|
2513
|
-
},
|
|
2512
|
+
}, nr = (t, n) => {
|
|
2514
2513
|
let { plot: r, svg: i, rows: l, type: m, values: g, series: _, seriesValues: y, names: b, annotations: x } = t;
|
|
2515
|
-
|
|
2514
|
+
tr(t, n);
|
|
2516
2515
|
let S = getComputedStyle(t.figure);
|
|
2517
2516
|
t.figure.toggleAttribute("data-series-range", !!S.getPropertyValue("--tablechart-series-color-end").trim()), t.figure.toggleAttribute("data-slice-range", !!S.getPropertyValue("--tablechart-slice-color-end").trim());
|
|
2518
2517
|
let C = Number.parseFloat(t.figure.dataset.chartAspect ?? ""), w = C > 0 ? C : m.aspect ?? n.aspect, k = m.categories === "beside", A = t.axes && !m.axes ? t.axes : null, j = k ? null : t.categories[0]?.parentElement, M = null;
|
|
@@ -2540,7 +2539,7 @@ var tt = (e) => {
|
|
|
2540
2539
|
let p = l.find((e) => !e.missing), h = q(M.ticks.map((e) => ie(String(e))));
|
|
2541
2540
|
for (let e of M.ticks) {
|
|
2542
2541
|
let t = L(E, A.ticks);
|
|
2543
|
-
t.dataset.value = String(e), t.dataset.place = "none", p?.prefix && (t.dataset.prefix = p.prefix), p?.suffix && (t.dataset.suffix = p.suffix),
|
|
2542
|
+
t.dataset.value = String(e), t.dataset.place = "none", p?.prefix && (t.dataset.prefix = p.prefix), p?.suffix && (t.dataset.suffix = p.suffix), ir(t, h, n.locale);
|
|
2544
2543
|
}
|
|
2545
2544
|
if (A.numbers) {
|
|
2546
2545
|
let e = Array.from(A.ticks.children);
|
|
@@ -2562,7 +2561,7 @@ var tt = (e) => {
|
|
|
2562
2561
|
let r = a[0]?.cells[i[t]], o = q(e.ticks.map((e) => ie(String(e))));
|
|
2563
2562
|
for (let i of e.ticks) {
|
|
2564
2563
|
let e = L(E, V.ticks);
|
|
2565
|
-
e.dataset.axis = t ? "y" : "x", e.dataset.value = String(i), r?.prefix && (e.dataset.prefix = r.prefix), r?.suffix && (e.dataset.suffix = r.suffix),
|
|
2564
|
+
e.dataset.axis = t ? "y" : "x", e.dataset.value = String(i), r?.prefix && (e.dataset.prefix = r.prefix), r?.suffix && (e.dataset.suffix = r.suffix), ir(e, o, n.locale);
|
|
2566
2565
|
}
|
|
2567
2566
|
});
|
|
2568
2567
|
}
|
|
@@ -2655,7 +2654,7 @@ var tt = (e) => {
|
|
|
2655
2654
|
}
|
|
2656
2655
|
t && R(t, u + f / 2, G - i(t), O, G), n && R(n, 0, d + p / 2, O, G);
|
|
2657
2656
|
}
|
|
2658
|
-
let Pe =
|
|
2657
|
+
let Pe = er(t.figure, n), Fe = In(t.figure, n), Ie = !!m.running && b.length > 0 && !t.stacked && Fe !== "step" && Pe.mode === "set" && Pe.keys.includes("last"), Le = Ie ? q(y.flat().map((e) => J(e).width)) * I : 0, Be = b.length ? q(b.map((e) => J(e).width)) * I + 12 * I + Le : 0, Ve = t.categories[0]?.parentElement;
|
|
2659
2658
|
Ve && (Ve.style.paddingRight = Be ? `${Be / O * 100}%` : "");
|
|
2660
2659
|
let He = (O - Be) / l.length, Ue = (e) => (e + .5) * He, We = (e) => e >= 0 && e < l.length ? e : null;
|
|
2661
2660
|
t.rowAt = m.centre ? null : m.categories === "beside" ? (e, t) => We(Math.floor(t * I / (G / l.length))) : (e) => We(Math.floor(e * I / He));
|
|
@@ -2693,9 +2692,10 @@ var tt = (e) => {
|
|
|
2693
2692
|
x: je,
|
|
2694
2693
|
frame: Me,
|
|
2695
2694
|
length: (e, n) => Yn(t.figure, I, e, n),
|
|
2696
|
-
barWidth: Math.min(He * n.barfill,
|
|
2697
|
-
barMax:
|
|
2698
|
-
barRadius:
|
|
2695
|
+
barWidth: Math.min(He * n.barfill, Zn(t.figure, I)),
|
|
2696
|
+
barMax: Zn(t.figure, I),
|
|
2697
|
+
barRadius: Xn(t.figure, I, "--tablechart-bar-radius"),
|
|
2698
|
+
sliceRadius: Xn(t.figure, I, "--tablechart-slice-radius"),
|
|
2699
2699
|
height: G,
|
|
2700
2700
|
unit: I,
|
|
2701
2701
|
labelHeight: ee,
|
|
@@ -2848,7 +2848,7 @@ var tt = (e) => {
|
|
|
2848
2848
|
ry: o === null ? s : n * o,
|
|
2849
2849
|
style: ["--after", "--step"].map((t) => e.style.getPropertyValue(t) && `${t}:${e.style.getPropertyValue(t)}`).filter(Boolean).join("; ")
|
|
2850
2850
|
})];
|
|
2851
|
-
}), Xe = i.querySelector(`.${D}`), Z = Array.from(i.querySelectorAll(`.${o}`)), Ze = [...Xe ? [Xe] : [], ...i.querySelectorAll(`:scope > .${s}`)], Qe =
|
|
2851
|
+
}), Xe = i.querySelector(`.${D}`), Z = Array.from(i.querySelectorAll(`.${o}`)), Ze = [...Xe ? [Xe] : [], ...i.querySelectorAll(`:scope > .${s}`)], Qe = Qn(r, I), $e = t.figure.getAttribute("data-animate") === "grow", et = y.flat().filter((e) => e.hasAttribute("data-cut")).flatMap(Qe), tt = [...ue.flatMap((e) => y[e].flatMap(Qe)), ...$e ? et : []];
|
|
2852
2852
|
if (Ze.length || Z.length) {
|
|
2853
2853
|
let e = [
|
|
2854
2854
|
...y.flat(),
|
|
@@ -2889,43 +2889,43 @@ var tt = (e) => {
|
|
|
2889
2889
|
c,
|
|
2890
2890
|
D
|
|
2891
2891
|
];
|
|
2892
|
-
ne(i, [...Ye, ...tt], O, G, void 0, nt.map((e) => `.${e}`).join(", ")), t.figure.hasAttribute("data-animate") && !t.figure.hasAttribute("data-steps") && !t.figure.classList.contains("is-shown") &&
|
|
2892
|
+
ne(i, [...Ye, ...tt], O, G, void 0, nt.map((e) => `.${e}`).join(", ")), t.figure.hasAttribute("data-animate") && !t.figure.hasAttribute("data-steps") && !t.figure.classList.contains("is-shown") && lr(i);
|
|
2893
2893
|
let rt = (e) => e.dataset.missing !== void 0 || m.centre && l[Number(e.dataset.row) - 1]?.isTotal, it = (e) => e.dataset.place !== "none" && !e.hasAttribute("data-left-out"), at = (e, t) => {
|
|
2894
2894
|
let n = Number(e.dataset.row);
|
|
2895
2895
|
return t.some((e) => it(e) && Number(e.dataset.row) <= n && n <= Number(e.dataset.rowEnd ?? e.dataset.row));
|
|
2896
2896
|
};
|
|
2897
2897
|
return t.figure.toggleAttribute("data-left-out", (m.columns ? [t.categories] : [...y, t.totals]).some((e) => e.some((t) => !rt(t) && !it(t) && !at(t, e)))), Y.barRadius && U(i, Y.barRadius), Lt(t.figure), Ut(t.figure), Wt(t.figure), !0;
|
|
2898
|
-
},
|
|
2898
|
+
}, rr = (e, t) => {
|
|
2899
2899
|
let n = [
|
|
2900
2900
|
...e.seriesValues.flat(),
|
|
2901
2901
|
...e.totals,
|
|
2902
2902
|
...e.totalCell ? [e.totalCell] : []
|
|
2903
2903
|
];
|
|
2904
|
-
for (let r of e.centre ? [...n, e.centre] : n) r.dataset.missing === void 0 ?
|
|
2905
|
-
},
|
|
2904
|
+
for (let r of e.centre ? [...n, e.centre] : n) r.dataset.missing === void 0 ? ir(r, r.dataset.decimals ? Number(r.dataset.decimals) : e.decimals, t.locale) : r.textContent = r.dataset.missing;
|
|
2905
|
+
}, ir = (e, t, n) => {
|
|
2906
2906
|
let { prefix: r = "", suffix: i = "" } = e.dataset, [a, o] = oe(Number.parseFloat(e.dataset.value || "0"), t, n);
|
|
2907
2907
|
if (e.textContent = r + (r ? a : "") + o + i, a && !r) {
|
|
2908
2908
|
let t = document.createElement("span");
|
|
2909
2909
|
t.className = "tablechart-minus", t.textContent = a, e.prepend(t);
|
|
2910
2910
|
}
|
|
2911
|
-
},
|
|
2911
|
+
}, ar = (e) => {
|
|
2912
2912
|
Cn(e), e.plot.remove(), e.categories[0]?.parentElement?.remove(), e.figure.querySelector(`:scope > .${p}`)?.remove(), e.controls?.remove();
|
|
2913
|
-
},
|
|
2914
|
-
!t && !e.figure.hasAttribute("data-steps") &&
|
|
2915
|
-
|
|
2913
|
+
}, or = (e, t, n = !1) => {
|
|
2914
|
+
!t && !e.figure.hasAttribute("data-steps") && lr(e.svg), e.figure.classList.remove(C), n ? (e.figure.classList.add(S), e.figure.classList.toggle(b, t), e.figure.offsetWidth, t && ur(e.svg), e.figure.classList.toggle(C, t), requestAnimationFrame(() => e.figure.classList.remove(S))) : (e.figure.classList.toggle(b, t), t && requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
2915
|
+
cr(e.figure, e.svg), sr(e.figure);
|
|
2916
2916
|
})));
|
|
2917
|
-
},
|
|
2917
|
+
}, sr = (e) => {
|
|
2918
2918
|
let t = e.getAnimations({ subtree: !0 }).map((e) => e.finished.catch(() => void 0));
|
|
2919
2919
|
Promise.all(t).then(() => {
|
|
2920
2920
|
e.classList.contains("is-shown") && e.classList.add(C);
|
|
2921
2921
|
});
|
|
2922
|
-
},
|
|
2923
|
-
e.classList.contains("is-shown") && Array.from(t.querySelectorAll("[data-mask]")).every((e) => !e.getAnimations({ subtree: !0 }).length) &&
|
|
2924
|
-
}, cr = (e) => {
|
|
2925
|
-
for (let t of e.querySelectorAll("[mask^=\"url(#tablechart-cut-\"]")) t.dataset.mask = t.getAttribute("mask") ?? "", t.removeAttribute("mask");
|
|
2922
|
+
}, cr = (e, t) => {
|
|
2923
|
+
e.classList.contains("is-shown") && Array.from(t.querySelectorAll("[data-mask]")).every((e) => !e.getAnimations({ subtree: !0 }).length) && ur(t);
|
|
2926
2924
|
}, lr = (e) => {
|
|
2925
|
+
for (let t of e.querySelectorAll("[mask^=\"url(#tablechart-cut-\"]")) t.dataset.mask = t.getAttribute("mask") ?? "", t.removeAttribute("mask");
|
|
2926
|
+
}, ur = (e) => {
|
|
2927
2927
|
for (let t of e.querySelectorAll("[data-mask]")) t.setAttribute("mask", t.dataset.mask ?? ""), t.removeAttribute("data-mask");
|
|
2928
|
-
},
|
|
2928
|
+
}, dr = {
|
|
2929
2929
|
2: {
|
|
2930
2930
|
part: 3,
|
|
2931
2931
|
text: 4.5,
|
|
@@ -2944,8 +2944,8 @@ var tt = (e) => {
|
|
|
2944
2944
|
partRule: "APCA, WCAG 3 draft",
|
|
2945
2945
|
textRule: "APCA, WCAG 3 draft"
|
|
2946
2946
|
}
|
|
2947
|
-
},
|
|
2948
|
-
let n = Rt(t), r =
|
|
2947
|
+
}, fr = (t) => {
|
|
2948
|
+
let n = Rt(t), r = dr[jt(t)], i = Array.from(t.querySelectorAll("table thead tr:first-child > *")).map((e) => (e.textContent ?? "").trim()), a = Array.from(t.querySelectorAll("tbody tr > :first-child")).map((e) => (e.textContent ?? "").trim()), o = [
|
|
2949
2949
|
[
|
|
2950
2950
|
".tablechart-series",
|
|
2951
2951
|
"Line",
|
|
@@ -2985,14 +2985,14 @@ var tt = (e) => {
|
|
|
2985
2985
|
let s = Array.from(a).filter(Boolean).map((e) => `"${e}"`), l = s.join(", "), u = s.length > 1, d = n === "Line" ? i ? `Line "${i}" has` : "The line has" : n === "Slice" ? `${u ? "Slices" : "Slice"} ${l} ${u ? "have" : "has"}` : a.size >= o || !l ? `The bars${i ? ` of column "${i}"` : ""} have` : `${u ? "Bars" : "Bar"} ${l}${i ? ` in column "${i}"` : ""} ${u ? "have" : "has"}`;
|
|
2986
2986
|
console.warn(`[${e}] ${d} a contrast of ${r.show(c)} with the background. It needs at least ${r.need(r.part)} (${r.partRule}).`, t);
|
|
2987
2987
|
}
|
|
2988
|
-
},
|
|
2988
|
+
}, pr = ".tablechart-name, .tablechart-value:not([data-place='inside'], [data-place='middle']), .tablechart-categories span, .tablechart-centre, .tablechart-tick, .tablechart-quadrant-name, figcaption b, figcaption span", mr = (t) => {
|
|
2989
2989
|
let n = 0, r = () => {
|
|
2990
|
-
let r = Array.from(t.querySelectorAll(".tablechart-value[data-place='inside'], .tablechart-value[data-place='middle']")).filter((e) => !e.hasAttribute("data-left-out") && !e.hidden), a = Array.from(t.querySelectorAll(
|
|
2990
|
+
let r = Array.from(t.querySelectorAll(".tablechart-value[data-place='inside'], .tablechart-value[data-place='middle']")).filter((e) => !e.hasAttribute("data-left-out") && !e.hidden), a = Array.from(t.querySelectorAll(pr)).filter((e) => !e.hasAttribute("data-left-out") && !e.hidden && e.style.getPropertyValue("--m") !== "1" && (e.textContent ?? "").trim() && getComputedStyle(e).visibility !== "hidden");
|
|
2991
2991
|
if ([...r, ...a].some((e) => kt(getComputedStyle(e).color)[3] === 0 && n < 20)) {
|
|
2992
2992
|
n++, setTimeout(i, 500);
|
|
2993
2993
|
return;
|
|
2994
2994
|
}
|
|
2995
|
-
let o = Array.from(t.querySelectorAll("tbody tr > :first-child")).map((e) => (e.textContent ?? "").trim()), s =
|
|
2995
|
+
let o = Array.from(t.querySelectorAll("tbody tr > :first-child")).map((e) => (e.textContent ?? "").trim()), s = dr[jt(t)], c = t.dataset.chart === "bar" ? "bar" : "column", l = /* @__PURE__ */ new Map();
|
|
2996
2996
|
for (let e of r) {
|
|
2997
2997
|
let n = zt(t, e);
|
|
2998
2998
|
if (!n) continue;
|
|
@@ -3038,33 +3038,33 @@ var tt = (e) => {
|
|
|
3038
3038
|
attributes: !0,
|
|
3039
3039
|
attributeFilter: ["class"]
|
|
3040
3040
|
});
|
|
3041
|
-
},
|
|
3041
|
+
}, hr = [
|
|
3042
3042
|
"bar",
|
|
3043
3043
|
"piece",
|
|
3044
3044
|
"up",
|
|
3045
3045
|
"down",
|
|
3046
3046
|
"total"
|
|
3047
|
-
].map((e) => `--tablechart-${e}-value-color`),
|
|
3047
|
+
].map((e) => `--tablechart-${e}-value-color`), gr = /* @__PURE__ */ new Set(), _r = (t) => {
|
|
3048
3048
|
let n = getComputedStyle(t);
|
|
3049
|
-
for (let r of
|
|
3050
|
-
},
|
|
3049
|
+
for (let r of hr) !gr.has(r) && n.getPropertyValue(r).trim() && (gr.add(r), console.warn(`[${e}] ${r} is old and goes in 1.3.0. --tablechart-value-on-dark and --tablechart-value-on-light set the colour of the numbers inside bars, with a contrast check.`, t));
|
|
3050
|
+
}, vr = (e) => e === "id" || e === "style" || e.startsWith("data-chart"), yr = /^\s*(?:Table)?:\s+/, br = (e) => e?.tagName === "P" && yr.test(e.textContent ?? ""), xr = (e) => {
|
|
3051
3051
|
let t = document.createElement("figcaption");
|
|
3052
3052
|
for (let { name: n, value: r } of Array.from(e.attributes)) t.setAttribute(n, r);
|
|
3053
3053
|
let n = e.firstChild;
|
|
3054
|
-
n?.nodeType === Node.TEXT_NODE && (n.textContent = (n.textContent ?? "").replace(
|
|
3054
|
+
n?.nodeType === Node.TEXT_NODE && (n.textContent = (n.textContent ?? "").replace(yr, ""), n.textContent || n.remove());
|
|
3055
3055
|
let r = Array.from(e.childNodes), i = r.findIndex((e) => e.nodeName === "BR");
|
|
3056
3056
|
if (t.append(...i === -1 ? r : r.slice(0, i + 1)), i !== -1 && i < r.length - 1) {
|
|
3057
3057
|
let e = document.createElement("span");
|
|
3058
3058
|
e.append(...r.slice(i + 1)), t.append(e);
|
|
3059
3059
|
}
|
|
3060
3060
|
return e.remove(), t;
|
|
3061
|
-
},
|
|
3062
|
-
let t =
|
|
3061
|
+
}, Sr = /^\s*([a-z][\w-]*)((?:\s+[\w-]+=[^\s:]+)*)\s*(:\s*|$)/, Cr = (e) => {
|
|
3062
|
+
let t = jr(e);
|
|
3063
3063
|
return t?.tagName === "P" ? t : e;
|
|
3064
|
-
},
|
|
3065
|
-
let t =
|
|
3064
|
+
}, wr = (e) => {
|
|
3065
|
+
let t = Cr(e).firstChild;
|
|
3066
3066
|
if (t?.nodeType !== Node.TEXT_NODE) return null;
|
|
3067
|
-
let n =
|
|
3067
|
+
let n = Sr.exec(t.textContent ?? "");
|
|
3068
3068
|
if (!n || !Dn.includes(n[1]) || !n[3] && t.nextSibling) return null;
|
|
3069
3069
|
let r = n[2].trim().split(/\s+/).filter(Boolean).map((e) => e.split("="));
|
|
3070
3070
|
return {
|
|
@@ -3073,11 +3073,11 @@ var tt = (e) => {
|
|
|
3073
3073
|
text: t,
|
|
3074
3074
|
length: n[0].length
|
|
3075
3075
|
};
|
|
3076
|
-
},
|
|
3076
|
+
}, Tr = (e) => {
|
|
3077
3077
|
if (e?.tagName !== "UL" && e?.tagName !== "OL") return null;
|
|
3078
|
-
let t = Array.from(e.children), n = t.map((e) => e.hasAttribute("data-annotation") ? null :
|
|
3078
|
+
let t = Array.from(e.children), n = t.map((e) => e.hasAttribute("data-annotation") ? null : wr(e));
|
|
3079
3079
|
return !t.length || t.some((e, t) => !n[t] && !e.hasAttribute("data-annotation")) ? null : (t.forEach((e, t) => {
|
|
3080
|
-
let r = n[t], i =
|
|
3080
|
+
let r = n[t], i = Cr(e);
|
|
3081
3081
|
if (i !== e && i.replaceWith(...i.childNodes), r) {
|
|
3082
3082
|
e.setAttribute("data-annotation", r.name);
|
|
3083
3083
|
for (let [t, n] of r.options) e.setAttribute(`data-${t}`, n);
|
|
@@ -3088,18 +3088,18 @@ var tt = (e) => {
|
|
|
3088
3088
|
t === 0 && e instanceof HTMLElement && e.matches("em, i") ? (n.className = "tablechart-caption", n.append(...e.childNodes), e.replaceWith(n)) : e.nodeType === Node.TEXT_NODE && (n.textContent = (e.textContent ?? "").trim(), e.replaceWith(n));
|
|
3089
3089
|
});
|
|
3090
3090
|
}), e.classList.add("chart-annotations"), e);
|
|
3091
|
-
},
|
|
3092
|
-
for (let { name: n, value: r } of Array.from(e.attributes)) (n === "class" ||
|
|
3093
|
-
},
|
|
3094
|
-
let t = e.closest("p"), n =
|
|
3091
|
+
}, Er = (e, t) => {
|
|
3092
|
+
for (let { name: n, value: r } of Array.from(e.attributes)) (n === "class" || vr(n)) && (t.setAttribute(n, r), e.removeAttribute(n));
|
|
3093
|
+
}, Dr = (e) => e.map((e) => {
|
|
3094
|
+
let t = e.closest("p"), n = br(t) ? t : e;
|
|
3095
3095
|
if (n.tagName !== "TABLE" && n.tagName !== "P") return n;
|
|
3096
3096
|
let r = document.createElement("figure");
|
|
3097
|
-
|
|
3098
|
-
let i = n.tagName === "TABLE" ? n : null, a = n.previousElementSibling, o = n.nextElementSibling, s = i ?
|
|
3097
|
+
Er(e, r), e.classList.length || e.removeAttribute("class");
|
|
3098
|
+
let i = n.tagName === "TABLE" ? n : null, a = n.previousElementSibling, o = n.nextElementSibling, s = i ? br(a) ? a : br(o) ? o : null : n;
|
|
3099
3099
|
i && s === o && (o = o?.nextElementSibling ?? null);
|
|
3100
|
-
let c = o?.classList.contains("chart-annotations") ? o :
|
|
3101
|
-
return n.replaceWith(r), s && r.append(
|
|
3102
|
-
}),
|
|
3100
|
+
let c = o?.classList.contains("chart-annotations") ? o : Tr(o);
|
|
3101
|
+
return n.replaceWith(r), s && r.append(xr(s)), i && r.append(i), c && r.append(c), Q?.log?.(`A ${i ? "table" : "caption"} with chart attributes was wrapped in a figure of its own`), r;
|
|
3102
|
+
}), Or = (e, t, n, r = document.createElement("table"), i = "Note") => {
|
|
3103
3103
|
for (let e of r.querySelectorAll(":scope > tbody, :scope > tfoot, :scope > tr")) e.remove();
|
|
3104
3104
|
let a = e.some((e) => e.note);
|
|
3105
3105
|
if (!r.tHead && (t.length || n || a)) {
|
|
@@ -3128,7 +3128,7 @@ var tt = (e) => {
|
|
|
3128
3128
|
n.dataset.note = "", n.textContent = i, s.append(n);
|
|
3129
3129
|
}
|
|
3130
3130
|
return r;
|
|
3131
|
-
},
|
|
3131
|
+
}, kr = (e) => {
|
|
3132
3132
|
if (!e || typeof e != "object") return;
|
|
3133
3133
|
let t = Object.entries(e), n = (e) => e === null || typeof e == "string" || typeof e == "number";
|
|
3134
3134
|
if (t.length && t.every(([, e]) => n(e) || Array.isArray(e) && e.every(n))) return t.map(([e, t]) => Array.isArray(t) ? {
|
|
@@ -3138,16 +3138,16 @@ var tt = (e) => {
|
|
|
3138
3138
|
label: e,
|
|
3139
3139
|
value: t
|
|
3140
3140
|
});
|
|
3141
|
-
},
|
|
3141
|
+
}, Ar = async (t) => {
|
|
3142
3142
|
await Promise.all(t.filter((e) => e.hasAttribute("data-chart-src")).map(async (t) => {
|
|
3143
3143
|
let n = t.getAttribute("data-chart-src"), r = Array.from(t.querySelectorAll("table")).find((e) => e.tHead) ?? null;
|
|
3144
3144
|
for (let e of t.querySelectorAll("table")) e !== r && e.remove();
|
|
3145
3145
|
try {
|
|
3146
3146
|
let e = await fetch(n);
|
|
3147
3147
|
if (!e.ok) throw Error(`${e.status} ${e.statusText}`);
|
|
3148
|
-
let i = await e.json(), a = Array.isArray(i) ? i : i?.rows ? Array.isArray(i.rows) ? i.rows :
|
|
3148
|
+
let i = await e.json(), a = Array.isArray(i) ? i : i?.rows ? Array.isArray(i.rows) ? i.rows : kr(i.rows) : kr(i);
|
|
3149
3149
|
if (!Array.isArray(a)) throw Error("no rows in it: a list of rows, an object with rows, or names with their values");
|
|
3150
|
-
let o =
|
|
3150
|
+
let o = Or(a, Array.isArray(i?.series) ? i.series.map(String) : [], typeof i?.label == "string" ? i.label : "", r ?? void 0, typeof i?.note == "string" ? i.note : void 0);
|
|
3151
3151
|
if (!r) {
|
|
3152
3152
|
let e = t.querySelector(":scope > figcaption");
|
|
3153
3153
|
e ? e.after(o) : t.prepend(o);
|
|
@@ -3158,10 +3158,10 @@ var tt = (e) => {
|
|
|
3158
3158
|
console.warn(`[${e}] Could not read the chart data in "${n}": ${t.message}.` + (r ? " A page opened as a file cannot fetch files; open it from a server." : ""));
|
|
3159
3159
|
}
|
|
3160
3160
|
}));
|
|
3161
|
-
},
|
|
3161
|
+
}, jr = (e) => {
|
|
3162
3162
|
let t = Array.from(e.childNodes).filter((e) => e.nodeType === Node.ELEMENT_NODE || e.nodeType === Node.TEXT_NODE && e.textContent?.trim());
|
|
3163
3163
|
return t.length === 1 && t[0] instanceof HTMLElement ? t[0] : null;
|
|
3164
|
-
},
|
|
3164
|
+
}, Mr = "strong, b, span.total", Nr = (e) => {
|
|
3165
3165
|
for (let t of e) {
|
|
3166
3166
|
for (let e of t.querySelectorAll("tbody tr")) {
|
|
3167
3167
|
let t = e.cells[0];
|
|
@@ -3169,16 +3169,16 @@ var tt = (e) => {
|
|
|
3169
3169
|
let n = document.createElement("th");
|
|
3170
3170
|
for (let { name: e, value: r } of Array.from(t.attributes)) n.setAttribute(e, r);
|
|
3171
3171
|
n.append(...t.childNodes), t.replaceWith(n);
|
|
3172
|
-
for (let t =
|
|
3172
|
+
for (let t = jr(n); t?.matches(Mr); t = jr(n)) e.dataset.kind = "total", t.replaceWith(...t.childNodes);
|
|
3173
3173
|
}
|
|
3174
3174
|
let e = Array.from(t.querySelector("thead tr:last-child")?.children ?? []);
|
|
3175
|
-
for (let t of e.slice(1)) for (let e =
|
|
3175
|
+
for (let t of e.slice(1)) for (let e = jr(t); e?.matches(Mr); e = jr(t)) t.setAttribute("data-kind", "focus"), e.replaceWith(...e.childNodes);
|
|
3176
3176
|
}
|
|
3177
|
-
},
|
|
3177
|
+
}, Pr = "data-chart-made", Fr = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches, Ir = (e) => new Promise((t) => setTimeout(t, e)), Lr = (e, t) => {
|
|
3178
3178
|
let n = Number.parseFloat(e.dataset.chartEntrance ?? ""), r = Number.isFinite(n) ? n : t.entrance;
|
|
3179
3179
|
return Math.min(Math.max(r, 0), 1);
|
|
3180
|
-
},
|
|
3181
|
-
if (
|
|
3180
|
+
}, Rr = async (e, t) => {
|
|
3181
|
+
if (Fr()) return;
|
|
3182
3182
|
await new Promise(requestAnimationFrame);
|
|
3183
3183
|
let n = e.getAnimations().filter((e) => e instanceof CSSAnimation);
|
|
3184
3184
|
for (let t = e.parentElement; t && t !== document.body; t = t.parentElement) n.push(...t.getAnimations());
|
|
@@ -3189,11 +3189,11 @@ var tt = (e) => {
|
|
|
3189
3189
|
let a = Number(n.delay ?? 0) + i * t;
|
|
3190
3190
|
r = Math.max(r, a - Number(e.currentTime ?? 0));
|
|
3191
3191
|
}
|
|
3192
|
-
r > 0 && await
|
|
3193
|
-
},
|
|
3192
|
+
r > 0 && await Ir(r);
|
|
3193
|
+
}, zr = (e) => {
|
|
3194
3194
|
for (let t = e; t && t !== document.body; t = t.parentElement) if (getComputedStyle(t).opacity === "0") return t;
|
|
3195
3195
|
return null;
|
|
3196
|
-
},
|
|
3196
|
+
}, Br = (e) => new Promise((t) => {
|
|
3197
3197
|
let n = ["animationstart", "transitionrun"], r = () => {
|
|
3198
3198
|
for (let e of n) document.removeEventListener(e, i, !0);
|
|
3199
3199
|
a.disconnect(), t();
|
|
@@ -3207,54 +3207,54 @@ var tt = (e) => {
|
|
|
3207
3207
|
attributes: !0,
|
|
3208
3208
|
attributeFilter: ["class", "style"]
|
|
3209
3209
|
});
|
|
3210
|
-
}),
|
|
3211
|
-
|
|
3212
|
-
for (let e of
|
|
3210
|
+
}), Vr = /* @__PURE__ */ new Set(), Hr = null, Ur = (e) => {
|
|
3211
|
+
Vr.add(e), !Hr && (Hr = new MutationObserver(() => {
|
|
3212
|
+
for (let e of Vr) e.relabel();
|
|
3213
3213
|
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
3214
|
-
for (let e of
|
|
3214
|
+
for (let e of Vr) e.refresh();
|
|
3215
3215
|
}));
|
|
3216
|
-
}),
|
|
3216
|
+
}), Hr.observe(document.documentElement, {
|
|
3217
3217
|
attributes: !0,
|
|
3218
3218
|
attributeFilter: ["lang"]
|
|
3219
3219
|
}));
|
|
3220
|
-
},
|
|
3221
|
-
|
|
3222
|
-
},
|
|
3220
|
+
}, Wr = (e) => {
|
|
3221
|
+
Vr.delete(e), !Vr.size && Hr && (Hr.disconnect(), Hr = null);
|
|
3222
|
+
}, Gr = ["column", "bar"], Kr = (e) => {
|
|
3223
3223
|
let t = e.getAttribute("data-chart") || "column";
|
|
3224
|
-
if (!
|
|
3224
|
+
if (!Gr.includes(t)) return null;
|
|
3225
3225
|
let n = getComputedStyle(e).getPropertyValue("--tablechart-type").trim();
|
|
3226
|
-
return
|
|
3227
|
-
},
|
|
3228
|
-
let n = e, r =
|
|
3229
|
-
if (!Fn(n.figure, t)) return
|
|
3226
|
+
return Gr.includes(n) ? n : t;
|
|
3227
|
+
}, qr = (e, t) => {
|
|
3228
|
+
let n = e, r = Kr(n.figure), i = null, a = !1, o = !1, s = !1, c = async () => {
|
|
3229
|
+
if (!Fn(n.figure, t)) return or(n, !0);
|
|
3230
3230
|
let e = n.figure.classList.contains("is-shown");
|
|
3231
3231
|
if (o && i !== null && !e && !s) {
|
|
3232
3232
|
s = !0;
|
|
3233
|
-
let e =
|
|
3234
|
-
e && await
|
|
3235
|
-
} else !o && t.replay && e &&
|
|
3233
|
+
let e = Fr() ? null : zr(n.figure);
|
|
3234
|
+
e && await Br(e), await Rr(n.figure, Lr(n.figure, t)), s = !1, (o || !t.replay) && or(n, !0);
|
|
3235
|
+
} else !o && t.replay && e && or(n, !1);
|
|
3236
3236
|
}, l = () => {
|
|
3237
|
-
let e =
|
|
3237
|
+
let e = Kr(n.figure);
|
|
3238
3238
|
if (!e || e === r) return;
|
|
3239
3239
|
let a = Q.timed("Building", n.figure, () => Un(n.figure, t, e));
|
|
3240
|
-
a && (
|
|
3240
|
+
a && (ar(n), Yt(a, n.step, !0), n = a, r = e, i = null);
|
|
3241
3241
|
}, u = () => {
|
|
3242
3242
|
l();
|
|
3243
3243
|
let e = n.plot.clientWidth;
|
|
3244
|
-
e && e !== i && Q.timed("Layout", n.figure, () =>
|
|
3244
|
+
e && e !== i && Q.timed("Layout", n.figure, () => nr(n, t)) && (a || (a = !0, fr(n.figure), mr(n.figure), _r(n.figure)), i = e, c());
|
|
3245
3245
|
}, d = !1, f = new ResizeObserver(() => {
|
|
3246
3246
|
u(), f.unobserve(n.figure), requestAnimationFrame(() => d || f.observe(n.figure));
|
|
3247
3247
|
}), p = new IntersectionObserver((e) => {
|
|
3248
3248
|
for (let t of e) o = t.isIntersecting, c();
|
|
3249
3249
|
}, { threshold: t.threshold }), m = () => {
|
|
3250
|
-
n.figure.classList.add(x),
|
|
3250
|
+
n.figure.classList.add(x), or(n, !0), ur(n.svg), n.figure.offsetWidth;
|
|
3251
3251
|
}, h = () => n.figure.classList.remove(x), g = () => {
|
|
3252
3252
|
i = null, u();
|
|
3253
3253
|
}, _ = {
|
|
3254
|
-
relabel: () =>
|
|
3254
|
+
relabel: () => rr(n, t),
|
|
3255
3255
|
refresh: g
|
|
3256
3256
|
};
|
|
3257
|
-
l(), u(), f.observe(n.figure), p.observe(n.figure), window.addEventListener("beforeprint", m), window.addEventListener("afterprint", h),
|
|
3257
|
+
l(), u(), f.observe(n.figure), p.observe(n.figure), window.addEventListener("beforeprint", m), window.addEventListener("afterprint", h), Ur(_);
|
|
3258
3258
|
let v = {
|
|
3259
3259
|
figure: n.figure,
|
|
3260
3260
|
refresh: g,
|
|
@@ -3268,28 +3268,28 @@ var tt = (e) => {
|
|
|
3268
3268
|
return n.plan?.count ?? 0;
|
|
3269
3269
|
},
|
|
3270
3270
|
destroy() {
|
|
3271
|
-
d = !0, f.disconnect(), p.disconnect(), window.removeEventListener("beforeprint", m), window.removeEventListener("afterprint", h),
|
|
3271
|
+
d = !0, f.disconnect(), p.disconnect(), window.removeEventListener("beforeprint", m), window.removeEventListener("afterprint", h), Wr(_), Cn(n), n.figure.tablechart === v && delete n.figure.tablechart;
|
|
3272
3272
|
}
|
|
3273
3273
|
};
|
|
3274
3274
|
return n.figure.tablechart = v, v;
|
|
3275
|
-
},
|
|
3275
|
+
}, Jr = !1, Yr = (t) => {
|
|
3276
3276
|
let n = t.find((e) => e.tagName !== "FIGURE");
|
|
3277
|
-
!
|
|
3278
|
-
},
|
|
3279
|
-
let n =
|
|
3280
|
-
|
|
3277
|
+
!Jr && n && (Jr = !0, console.warn(`[${e}] A chart is a <${n.tagName.toLowerCase()}>. Use a <figure> with a <figcaption>, so the chart has a title, also for screen readers.`, n));
|
|
3278
|
+
}, Xr = async (e, t) => {
|
|
3279
|
+
let n = Dr(e.filter((e) => !e.hasAttribute(Pr) && e.tagName !== "TH"));
|
|
3280
|
+
Yr(n), await Ar(n), Nr(n), bt(n, t.langattribute);
|
|
3281
3281
|
for (let e of n) e.dispatchEvent(new CustomEvent("tablechart:table", { bubbles: !0 }));
|
|
3282
3282
|
return n;
|
|
3283
|
-
},
|
|
3283
|
+
}, Zr = (e, t) => {
|
|
3284
3284
|
let n = Q.timed("Building", e, () => Un(e, t));
|
|
3285
|
-
return n ? (e.setAttribute(
|
|
3286
|
-
},
|
|
3287
|
-
if (
|
|
3288
|
-
|
|
3285
|
+
return n ? (e.setAttribute(Pr, ""), ei(), qr(n, t)) : null;
|
|
3286
|
+
}, Qr = !1, $r = /* @__PURE__ */ new WeakMap(), ei = () => {
|
|
3287
|
+
if (Qr || typeof matchMedia != "function") return;
|
|
3288
|
+
Qr = !0;
|
|
3289
3289
|
let e = () => {
|
|
3290
|
-
for (let e of document.querySelectorAll(`[${
|
|
3291
|
-
let t = getComputedStyle(e).color, n = Lt(e) ||
|
|
3292
|
-
|
|
3290
|
+
for (let e of document.querySelectorAll(`[${Pr}]`)) {
|
|
3291
|
+
let t = getComputedStyle(e).color, n = Lt(e) || $r.get(e) !== t;
|
|
3292
|
+
$r.set(e, t), n && (Ut(e), Wt(e));
|
|
3293
3293
|
}
|
|
3294
3294
|
};
|
|
3295
3295
|
matchMedia("(prefers-color-scheme: dark)").addEventListener("change", e);
|
|
@@ -3298,22 +3298,22 @@ var tt = (e) => {
|
|
|
3298
3298
|
document.addEventListener("transitionend", (t) => {
|
|
3299
3299
|
(t.target === document.documentElement || t.target === document.body) && e();
|
|
3300
3300
|
});
|
|
3301
|
-
},
|
|
3301
|
+
}, ti = async (e, t = {}) => {
|
|
3302
3302
|
if (e.tablechart) return e.tablechart;
|
|
3303
3303
|
let n = {
|
|
3304
3304
|
...k,
|
|
3305
3305
|
...t
|
|
3306
3306
|
};
|
|
3307
3307
|
n.debug && (Q.enabled = !0);
|
|
3308
|
-
let [r] = await
|
|
3309
|
-
return r ?
|
|
3310
|
-
},
|
|
3308
|
+
let [r] = await Xr([e], n);
|
|
3309
|
+
return r ? Zr(r, n) : null;
|
|
3310
|
+
}, ni = async (e = {}, t = document) => {
|
|
3311
3311
|
let n = {
|
|
3312
3312
|
...k,
|
|
3313
3313
|
...e
|
|
3314
3314
|
};
|
|
3315
3315
|
n.debug && (Q.enabled = !0);
|
|
3316
|
-
let r = (await
|
|
3316
|
+
let r = (await Xr(Array.from(t.querySelectorAll(n.selector)), n)).map((e) => Zr(e, n)).filter((e) => e !== null);
|
|
3317
3317
|
return Q.log(`Made ${r.length} chart(s).`), {
|
|
3318
3318
|
charts: r,
|
|
3319
3319
|
refresh: () => {
|
|
@@ -3324,4 +3324,4 @@ var tt = (e) => {
|
|
|
3324
3324
|
}
|
|
3325
3325
|
};
|
|
3326
3326
|
};
|
|
3327
|
-
export { L as A, t as B, Te as C, ie as D, pe as E, D as F, b as G, x as H, p as I, O as K, e as L, P as M, F as N, q as O, S as P, f as R, Xe as S, he as T, s as U, m as V, w as W, bt as _,
|
|
3327
|
+
export { L as A, t as B, Te as C, ie as D, pe as E, D as F, b as G, x as H, p as I, O as K, e as L, P as M, F as N, q as O, S as P, f as R, Xe as S, he as T, s as U, m as V, w as W, bt as _, Dr as a, it as b, fr as c, Un as d, nr as f, Yt as g, ar as h, Xr as i, R as j, oe as k, mr as l, or as m, Lr as n, Ar as o, rr as p, k as q, ni as r, Nr as s, ti as t, Tn as u, yt as v, J as w, at as x, gt as y, v as z };
|