@martinomagnifico/tablechart 1.0.5 → 1.0.7
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 +29 -0
- package/README.md +1 -1
- package/dist/tablechart-core.d.mts +1 -1
- package/dist/tablechart-shared.d.mts +4 -2
- package/dist/tablechart-shared.mjs +184 -151
- package/dist/tablechart.css +1 -1
- package/dist/tablechart.js +1 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-value", r = "tablec
|
|
|
10
10
|
shape: "straight",
|
|
11
11
|
legend: !1,
|
|
12
12
|
tooltip: "auto",
|
|
13
|
+
tooltipparent: null,
|
|
13
14
|
table: "never",
|
|
14
15
|
totallabel: "Total",
|
|
15
16
|
controls: !0,
|
|
@@ -1202,9 +1203,13 @@ var Te = (e) => e.map((e) => ({
|
|
|
1202
1203
|
]), i;
|
|
1203
1204
|
};
|
|
1204
1205
|
return r.append(i("previous"), i("next")), r;
|
|
1205
|
-
}, We = (e, t, n, r =
|
|
1206
|
-
|
|
1207
|
-
|
|
1206
|
+
}, We = (e, t, n, r = {
|
|
1207
|
+
x: 0,
|
|
1208
|
+
y: 0,
|
|
1209
|
+
scale: 1
|
|
1210
|
+
}, i = 2, a = 8, o = 12) => {
|
|
1211
|
+
let s = e.getBoundingClientRect(), c = s.width, l = s.height, u = Number.parseFloat(getComputedStyle(e).borderLeftWidth) || 0, d = t.getBoundingClientRect().height / 2 + (i - u) * r.scale, f = o * r.scale, { clientWidth: p, clientHeight: m } = document.documentElement, h = n.top - a, g = m - n.bottom - a, _ = l + d <= h ? !0 : l + d <= g ? !1 : h >= g, v = _ ? n.top - d - l : n.bottom + d, y = n.left + n.width / 2, b = Math.max(a, Math.min(y - c / 2, p - c - a));
|
|
1212
|
+
e.style.left = `${(b - r.x) / r.scale}px`, e.style.top = `${(Math.max(a, Math.min(v, m - l - a)) - r.y) / r.scale}px`, e.dataset.side = _ ? "top" : "bottom", t.style.left = `${Math.max(f, Math.min(y - b, c - f)) / r.scale - u}px`;
|
|
1208
1213
|
}, Ge = "tablechart-tooltip", Ke = [
|
|
1209
1214
|
"--tablechart-surface",
|
|
1210
1215
|
"--tablechart-tooltip-surface",
|
|
@@ -1215,34 +1220,49 @@ var Te = (e) => e.map((e) => ({
|
|
|
1215
1220
|
"--tablechart-tooltip-shadow"
|
|
1216
1221
|
], Z = null, qe, Je, Q = null, Ye = null, Xe = 0, $ = () => {
|
|
1217
1222
|
clearTimeout(Xe), Z && Q && (Z.hidden = !0, Q = null, Ye = null);
|
|
1218
|
-
}, Ze = () => {
|
|
1223
|
+
}, Ze = !1, Qe = !0, $e = NaN, et = NaN, tt = !1, nt = () => {
|
|
1224
|
+
if (tt) return;
|
|
1225
|
+
tt = !0, document.addEventListener("pointermove", (e) => {
|
|
1226
|
+
e.pointerType === "mouse" && (Qe = e.screenX !== $e || e.screenY !== et, $e = e.screenX, et = e.screenY, Qe && (Ze = !1));
|
|
1227
|
+
}, {
|
|
1228
|
+
capture: !0,
|
|
1229
|
+
passive: !0
|
|
1230
|
+
});
|
|
1231
|
+
let e = () => {
|
|
1232
|
+
Ze = !0, $();
|
|
1233
|
+
};
|
|
1234
|
+
document.addEventListener("keydown", e, !0), window.addEventListener("scroll", e, {
|
|
1235
|
+
capture: !0,
|
|
1236
|
+
passive: !0
|
|
1237
|
+
});
|
|
1238
|
+
}, rt = (e, t) => t / Number.parseFloat(getComputedStyle(e).width) || 1, it = (e) => {
|
|
1239
|
+
let t = e.tooltipparent;
|
|
1240
|
+
return (typeof t == "string" ? document.querySelector(t) : t) ?? document.body;
|
|
1241
|
+
}, at = () => {
|
|
1219
1242
|
clearTimeout(Xe), Xe = window.setTimeout($, 120);
|
|
1220
|
-
},
|
|
1243
|
+
}, ot = () => {
|
|
1221
1244
|
let e = document.createElement("div");
|
|
1222
|
-
return e.className = Ge, e.setAttribute("aria-hidden", "true"), e.hidden = !0, qe = document.createElement("div"), Je = document.createElement("div"), Je.className = `${Ge}-arrow`, e.append(qe, Je), document.body.append(e), e.addEventListener("pointerenter", () => clearTimeout(Xe)), e.addEventListener("pointerleave", (e) => e.pointerType === "mouse" &&
|
|
1245
|
+
return e.className = Ge, e.setAttribute("aria-hidden", "true"), e.hidden = !0, qe = document.createElement("div"), Je = document.createElement("div"), Je.className = `${Ge}-arrow`, e.append(qe, Je), document.body.append(e), e.addEventListener("pointerenter", () => clearTimeout(Xe)), e.addEventListener("pointerleave", (e) => e.pointerType === "mouse" && at()), document.addEventListener("pointerdown", (t) => {
|
|
1223
1246
|
let n = t.target;
|
|
1224
1247
|
Q && !Q.plot.contains(n) && !e.contains(n) && $();
|
|
1225
|
-
}), window.addEventListener("scroll", $, {
|
|
1226
|
-
capture: !0,
|
|
1227
|
-
passive: !0
|
|
1228
1248
|
}), window.addEventListener("resize", $), e;
|
|
1229
|
-
},
|
|
1249
|
+
}, st = (e, t) => {
|
|
1230
1250
|
let n = t ? t.style.getPropertyValue("--step") : "x";
|
|
1231
1251
|
return n === "" || Number(n) < e.step;
|
|
1232
|
-
},
|
|
1252
|
+
}, ct = (e, t) => {
|
|
1233
1253
|
let n = e.svg.querySelector(`[data-series="${t + 1}"]:not(.tablechart-hole)`);
|
|
1234
1254
|
if (!n) return;
|
|
1235
1255
|
let r = getComputedStyle(n);
|
|
1236
1256
|
return r.fill && r.fill !== "none" ? r.fill : r.stroke;
|
|
1237
|
-
},
|
|
1257
|
+
}, lt = (e, t, n) => {
|
|
1238
1258
|
let r = e.series.length > 1, i = [];
|
|
1239
1259
|
for (let [n, a] of e.seriesValues.entries()) {
|
|
1240
|
-
if (
|
|
1260
|
+
if (!st(e, a[t])) continue;
|
|
1241
1261
|
let o = r ? e.figure.querySelector(`.tablechart-name[data-series="${n + 1}"]`) : null;
|
|
1242
1262
|
i.push({
|
|
1243
1263
|
name: r ? o?.textContent ?? e.series[n].name : "",
|
|
1244
1264
|
value: a[t].textContent ?? "",
|
|
1245
|
-
colour: r ?
|
|
1265
|
+
colour: r ? ct(e, n) : void 0,
|
|
1246
1266
|
sample: o ? {
|
|
1247
1267
|
marker: o.dataset.marker ?? null,
|
|
1248
1268
|
open: o.hasAttribute("data-open"),
|
|
@@ -1252,11 +1272,11 @@ var Te = (e) => e.map((e) => ({
|
|
|
1252
1272
|
});
|
|
1253
1273
|
}
|
|
1254
1274
|
let a = e.totals[t];
|
|
1255
|
-
return i.length > 1 &&
|
|
1275
|
+
return i.length > 1 && st(e, a) && i.push({
|
|
1256
1276
|
name: n.totallabel,
|
|
1257
1277
|
value: a.textContent ?? ""
|
|
1258
1278
|
}), i;
|
|
1259
|
-
},
|
|
1279
|
+
}, ut = (e, t) => {
|
|
1260
1280
|
if (e.type.centre && e.values[t]) return e.values[t].getBoundingClientRect();
|
|
1261
1281
|
let n = e.svg.querySelectorAll(`[data-row="${t + 1}"]:not(.tablechart-connector, .tablechart-leader)`), r = null;
|
|
1262
1282
|
for (let e of n) {
|
|
@@ -1271,11 +1291,11 @@ var Te = (e) => e.map((e) => ({
|
|
|
1271
1291
|
100
|
|
1272
1292
|
];
|
|
1273
1293
|
return new DOMRect(i.left + i.width * a / 100, i.top + i.height * o / 100, i.width * s / 100, i.height * c / 100);
|
|
1274
|
-
},
|
|
1294
|
+
}, dt = (e, t, n) => {
|
|
1275
1295
|
if (clearTimeout(Xe), Q === e && Ye === t) return;
|
|
1276
|
-
let r = (e.type.tooltip ??
|
|
1296
|
+
let r = (e.type.tooltip ?? lt)(e, t, n);
|
|
1277
1297
|
if (!r.length) return $();
|
|
1278
|
-
Q && Q !== e && $(), Z ?? (Z =
|
|
1298
|
+
Q && Q !== e && $(), Z ?? (Z = ot());
|
|
1279
1299
|
let i = (e, t, n, r = !1, i) => {
|
|
1280
1300
|
let a = document.createElement("div");
|
|
1281
1301
|
if (a.className = `${Ge}-line`, n) {
|
|
@@ -1296,13 +1316,21 @@ var Te = (e) => e.map((e) => ({
|
|
|
1296
1316
|
let t = s.getPropertyValue(e).trim();
|
|
1297
1317
|
t ? Z.style.setProperty(e, t) : Z.style.removeProperty(e);
|
|
1298
1318
|
}
|
|
1299
|
-
Z.style.setProperty("--_color", s.color), Z.style.colorScheme = s.colorScheme, Z.style.fontFamily = s.fontFamily
|
|
1300
|
-
|
|
1319
|
+
Z.style.setProperty("--_color", s.color), Z.style.colorScheme = s.colorScheme, Z.style.fontFamily = s.fontFamily;
|
|
1320
|
+
let c = it(n);
|
|
1321
|
+
Z.parentElement !== c && c.append(Z), Q = e, Ye = t, Z.hidden = !1, Z.style.left = "0px", Z.style.top = "0px";
|
|
1322
|
+
let l = Z.getBoundingClientRect(), u = {
|
|
1323
|
+
x: l.left,
|
|
1324
|
+
y: l.top,
|
|
1325
|
+
scale: rt(Z, l.width)
|
|
1326
|
+
}, d = rt(e.plot, e.plot.getBoundingClientRect().width);
|
|
1327
|
+
Z.style.fontSize = `${Number.parseFloat(s.fontSize) * d / u.scale}px`, We(Z, Je, ut(e, t), u);
|
|
1328
|
+
}, ft = (e, t, n = !1) => {
|
|
1301
1329
|
let { plot: r } = e;
|
|
1302
|
-
r.setAttribute("data-hover", "");
|
|
1330
|
+
r.setAttribute("data-hover", ""), nt();
|
|
1303
1331
|
let i = (t) => {
|
|
1304
1332
|
if (e.rowAt) {
|
|
1305
|
-
let n = r.getBoundingClientRect(), i = n.width
|
|
1333
|
+
let n = r.getBoundingClientRect(), i = rt(r, n.width);
|
|
1306
1334
|
return e.rowAt((t.clientX - n.left) / i, (t.clientY - n.top) / i);
|
|
1307
1335
|
}
|
|
1308
1336
|
let n = t.target.closest?.("[data-row]")?.getAttribute("data-row");
|
|
@@ -1312,11 +1340,13 @@ var Te = (e) => e.map((e) => ({
|
|
|
1312
1340
|
else if (t.getAttribute("data-row") === String(e + 1)) return !0;
|
|
1313
1341
|
return !1;
|
|
1314
1342
|
}, s = null, c = (a) => {
|
|
1343
|
+
if (a.type === "pointerdown") Ze = !1;
|
|
1344
|
+
else if (a.pointerType === "mouse" && (!Qe || Ze)) return;
|
|
1315
1345
|
if (!r.classList.contains("is-placed") || !e.figure.classList.contains("is-shown")) return;
|
|
1316
1346
|
if (n && !e.figure.hasAttribute("data-left-out")) return Q === e ? $() : void 0;
|
|
1317
1347
|
let c = i(a);
|
|
1318
|
-
if (s = c, c === null || o(c)) return Q === e ?
|
|
1319
|
-
|
|
1348
|
+
if (s = c, c === null || o(c)) return Q === e ? at() : void 0;
|
|
1349
|
+
dt(e, c, t);
|
|
1320
1350
|
}, l = (t) => {
|
|
1321
1351
|
let n = t.target;
|
|
1322
1352
|
return e.svg.contains(n) && n.hasAttribute("data-row") ? n : null;
|
|
@@ -1330,42 +1360,42 @@ var Te = (e) => e.map((e) => ({
|
|
|
1330
1360
|
if (!r) return;
|
|
1331
1361
|
a.delete(r);
|
|
1332
1362
|
let i = Number(r.getAttribute("data-row")) - 1;
|
|
1333
|
-
s === i && !o(i) &&
|
|
1363
|
+
s === i && !o(i) && !Ze && dt(e, i, t);
|
|
1334
1364
|
};
|
|
1335
1365
|
e.svg.addEventListener("transitionend", u), e.svg.addEventListener("transitioncancel", u), r.addEventListener("pointermove", c), r.addEventListener("pointerdown", c), r.addEventListener("pointerleave", (t) => {
|
|
1336
|
-
t.pointerType === "mouse" && (s = null, Q === e &&
|
|
1366
|
+
t.pointerType === "mouse" && (s = null, Q === e && at());
|
|
1337
1367
|
});
|
|
1338
|
-
},
|
|
1368
|
+
}, pt = (e) => {
|
|
1339
1369
|
Q === e && $();
|
|
1340
|
-
},
|
|
1370
|
+
}, mt = {
|
|
1341
1371
|
area: Oe,
|
|
1342
1372
|
bar: pe,
|
|
1343
1373
|
column: me,
|
|
1344
1374
|
donut: _e,
|
|
1345
1375
|
line: De,
|
|
1346
1376
|
waterfall: je
|
|
1347
|
-
},
|
|
1377
|
+
}, ht = {
|
|
1348
1378
|
"axis-break": M,
|
|
1349
1379
|
trend: te,
|
|
1350
1380
|
bracket: H
|
|
1351
|
-
},
|
|
1381
|
+
}, gt = Object.keys(ht), _t = (e) => {
|
|
1352
1382
|
let t = "";
|
|
1353
1383
|
for (let n = e.previousSibling; n && (t = (n.textContent ?? "") + t, !t.trim()); n = n.previousSibling);
|
|
1354
1384
|
return t.trim();
|
|
1355
|
-
},
|
|
1385
|
+
}, vt = [
|
|
1356
1386
|
"straight",
|
|
1357
1387
|
"step",
|
|
1358
1388
|
"smooth"
|
|
1359
|
-
],
|
|
1389
|
+
], yt = (e, t) => {
|
|
1360
1390
|
let n = e.dataset.chartShape;
|
|
1361
|
-
return n &&
|
|
1362
|
-
},
|
|
1391
|
+
return n && vt.includes(n) ? n : vt.includes(t.shape) ? t.shape : "straight";
|
|
1392
|
+
}, bt = (e) => {
|
|
1363
1393
|
for (let t of e.querySelectorAll("br")) {
|
|
1364
|
-
if (t.previousElementSibling?.classList.contains("tablechart-sr") || /[.!?:;,…]$/.test(
|
|
1394
|
+
if (t.previousElementSibling?.classList.contains("tablechart-sr") || /[.!?:;,…]$/.test(_t(t))) continue;
|
|
1365
1395
|
let e = document.createElement("span");
|
|
1366
1396
|
e.className = p, e.textContent = ". ", t.before(e);
|
|
1367
1397
|
}
|
|
1368
|
-
},
|
|
1398
|
+
}, xt = (e, t, n) => {
|
|
1369
1399
|
let r = e.querySelector("table");
|
|
1370
1400
|
if (!r) return null;
|
|
1371
1401
|
let i = r.querySelector("tfoot [data-chart-total]");
|
|
@@ -1376,22 +1406,22 @@ var Te = (e) => e.map((e) => ({
|
|
|
1376
1406
|
s && n.langattribute && o.setAttribute(n.langattribute, `${s}-total`);
|
|
1377
1407
|
let c = a.insertCell();
|
|
1378
1408
|
return c.setAttribute("data-chart-total", ""), c.dataset.value = t.dataset.value ?? "0", a.prepend(o), c;
|
|
1379
|
-
},
|
|
1409
|
+
}, St = 0, Ct = (e) => {
|
|
1380
1410
|
let t = e.querySelector(":scope > figcaption");
|
|
1381
1411
|
if (!t) return;
|
|
1382
|
-
|
|
1412
|
+
bt(t);
|
|
1383
1413
|
let n = (e) => e.hasAttribute("aria-label") || e.hasAttribute("aria-labelledby"), r = (e) => {
|
|
1384
|
-
t.id || (t.id = `tablechart-caption-${++
|
|
1414
|
+
t.id || (t.id = `tablechart-caption-${++St}`), e.setAttribute("aria-labelledby", t.id);
|
|
1385
1415
|
};
|
|
1386
1416
|
e.tagName === "FIGURE" && !n(e) && r(e);
|
|
1387
1417
|
let i = e.querySelector("table");
|
|
1388
1418
|
i && !n(i) && !i.querySelector(":scope > caption") && r(i);
|
|
1389
|
-
},
|
|
1390
|
-
let o = a ?? (r.getAttribute("data-chart") || "column"), s =
|
|
1391
|
-
if (!s) return console.warn(`[${e}] Unknown chart type "${o}". Known types: ${Object.keys(
|
|
1419
|
+
}, wt = (r, i, a = null) => {
|
|
1420
|
+
let o = a ?? (r.getAttribute("data-chart") || "column"), s = mt[o];
|
|
1421
|
+
if (!s) return console.warn(`[${e}] Unknown chart type "${o}". Known types: ${Object.keys(mt).join(", ")}.`), r.setAttribute("data-chart-empty", ""), null;
|
|
1392
1422
|
let l = Ne(r, i.langattribute);
|
|
1393
|
-
if (!l.length) return console.warn(`[${e}] A chart has no rows in its table, so there is nothing to draw.`), r.setAttribute("data-chart-empty", ""), null;
|
|
1394
|
-
|
|
1423
|
+
if (!l.length) return console.warn(r.querySelector("table") ? `[${e}] A chart has no rows in its table, so there is nothing to draw.` : `[${e}] A chart has no table, so there is nothing to draw.`, r), r.setAttribute("data-chart-empty", ""), null;
|
|
1424
|
+
Ct(r);
|
|
1395
1425
|
let d = Ie(r, l, i.langattribute);
|
|
1396
1426
|
d.length > 1 && !s.series && (console.warn(`[${e}] A ${o} chart uses only the first of its ${d.length} value columns.`), d = d.slice(0, 1));
|
|
1397
1427
|
let f = d.length > 1;
|
|
@@ -1419,7 +1449,7 @@ var Te = (e) => e.map((e) => ({
|
|
|
1419
1449
|
let n = E("tablechart-name", D ?? h);
|
|
1420
1450
|
D && (n.dataset.place = "legend");
|
|
1421
1451
|
let a = s.legend ?? s.swatch;
|
|
1422
|
-
if (a && (n.dataset.swatch = a), n.textContent = e.name, !a &&
|
|
1452
|
+
if (a && (n.dataset.swatch = a), n.textContent = e.name, !a && yt(r, i) !== "step") {
|
|
1423
1453
|
let e = ye(d, t);
|
|
1424
1454
|
n.dataset.marker = e.shape, n.toggleAttribute("data-open", e.open);
|
|
1425
1455
|
}
|
|
@@ -1429,7 +1459,7 @@ var Te = (e) => e.map((e) => ({
|
|
|
1429
1459
|
let e = l.find((e) => e.isTotal), t = e ? e.value : l.reduce((e, t) => e + Math.abs(t.value), 0);
|
|
1430
1460
|
k.dataset.value = String(t), e && (k.dataset.decimals = String(P(e.number)));
|
|
1431
1461
|
}
|
|
1432
|
-
let A = k && !l.some((e) => e.isTotal) ?
|
|
1462
|
+
let A = k && !l.some((e) => e.isTotal) ? xt(r, k, i) : null, j = s.categories === "beside", M = document.createElement("div");
|
|
1433
1463
|
M.className = "tablechart-categories", M.setAttribute("aria-hidden", "true"), M.inert = !0, j ? M.dataset.place = "beside" : s.centre && (M.dataset.place = "key"), M.style.setProperty("--_columns", String(l.length));
|
|
1434
1464
|
let F = 0;
|
|
1435
1465
|
for (let [e, t] of l.entries()) {
|
|
@@ -1449,7 +1479,7 @@ var Te = (e) => e.map((e) => ({
|
|
|
1449
1479
|
hint: L && `${L}-step`
|
|
1450
1480
|
}, i.langattribute) : null;
|
|
1451
1481
|
R && r.appendChild(R);
|
|
1452
|
-
let z = r.getAttribute("data-chart-table"), B = z &&
|
|
1482
|
+
let z = r.getAttribute("data-chart-table"), B = z && Et.includes(z) ? z : i.table;
|
|
1453
1483
|
if (B === "never") r.removeAttribute("data-table");
|
|
1454
1484
|
else {
|
|
1455
1485
|
r.setAttribute("data-table", B);
|
|
@@ -1457,8 +1487,8 @@ var Te = (e) => e.map((e) => ({
|
|
|
1457
1487
|
e && r.append(e);
|
|
1458
1488
|
}
|
|
1459
1489
|
let V = Array.from(r.querySelectorAll("[data-annotation]")).map((t) => {
|
|
1460
|
-
let n = t.getAttribute("data-annotation"), r =
|
|
1461
|
-
if (!r) return console.warn(`[${e}] Unknown annotation "${n}". Known annotations: ${Object.keys(
|
|
1490
|
+
let n = t.getAttribute("data-annotation"), r = ht[n];
|
|
1491
|
+
if (!r) return console.warn(`[${e}] Unknown annotation "${n}". Known annotations: ${Object.keys(ht).join(", ")}.`), null;
|
|
1462
1492
|
let i = Number.parseInt(t.getAttribute("data-series") ?? "1", 10), a = i >= 1 && i <= d.length ? i - 1 : 0;
|
|
1463
1493
|
return i !== a + 1 && console.warn(`[${e}] An annotation reads line ${i}, which is not there; it reads line 1.`), {
|
|
1464
1494
|
spec: t,
|
|
@@ -1468,7 +1498,7 @@ var Te = (e) => e.map((e) => ({
|
|
|
1468
1498
|
after: l.length
|
|
1469
1499
|
};
|
|
1470
1500
|
}).filter((e) => e !== null);
|
|
1471
|
-
i.animate && r.setAttribute("data-animate",
|
|
1501
|
+
i.animate && r.setAttribute("data-animate", Ot(r, o, i, !!I));
|
|
1472
1502
|
let H = {
|
|
1473
1503
|
figure: r,
|
|
1474
1504
|
plot: h,
|
|
@@ -1498,31 +1528,31 @@ var Te = (e) => e.map((e) => ({
|
|
|
1498
1528
|
t && He(H, H.step + (t === "next" ? 1 : -1));
|
|
1499
1529
|
}), He(H, 0, !0);
|
|
1500
1530
|
let U = r.getAttribute("data-chart-tooltip") ?? r.getAttribute("data-chart-hover"), ee = U === "false" ? !1 : U === "auto" ? "auto" : U !== null || i.hover !== !1 && i.tooltip;
|
|
1501
|
-
return ee &&
|
|
1502
|
-
},
|
|
1531
|
+
return ee && ft(H, i, ee === "auto"), Nt(H, i), H;
|
|
1532
|
+
}, Tt = {
|
|
1503
1533
|
grow: "grow",
|
|
1504
1534
|
sweep: "sweep"
|
|
1505
|
-
},
|
|
1535
|
+
}, Et = [
|
|
1506
1536
|
"never",
|
|
1507
1537
|
"auto",
|
|
1508
1538
|
"print",
|
|
1509
1539
|
"always"
|
|
1510
|
-
],
|
|
1511
|
-
...
|
|
1540
|
+
], Dt = {
|
|
1541
|
+
...Tt,
|
|
1512
1542
|
up: "grow",
|
|
1513
1543
|
across: "sweep"
|
|
1514
|
-
},
|
|
1515
|
-
let i = t === "line" || t === "area", a = i ?
|
|
1544
|
+
}, Ot = (e, t, n, r) => {
|
|
1545
|
+
let i = t === "line" || t === "area", a = i ? Dt : Tt, o = a[e.getAttribute("data-chart-animate") ?? ""] ?? a[String(n.animate)];
|
|
1516
1546
|
return i ? r ? "sweep" : o ?? "sweep" : t === "donut" || t === "waterfall" ? o ?? "grow" : "grow";
|
|
1517
|
-
},
|
|
1547
|
+
}, kt = (e) => {
|
|
1518
1548
|
let t = getComputedStyle(e), n = (t.getPropertyValue("--tablechart-value-align") || t.getPropertyValue("--tablechart-inside-align")).trim();
|
|
1519
1549
|
return n === "start" || n === "center" || n === "end" ? n : null;
|
|
1520
|
-
},
|
|
1550
|
+
}, At = (e, t, n, r) => {
|
|
1521
1551
|
let i = getComputedStyle(e), a = (i.getPropertyValue(n).trim() || r).match(/^(\d+(?:\.\d+)?)(px|%|em|rem)$/);
|
|
1522
1552
|
if (!a) return null;
|
|
1523
1553
|
let o = Number(a[1]);
|
|
1524
1554
|
return a[2] === "%" ? o / 100 * _ : o * (a[2] === "em" ? Number.parseFloat(i.fontSize) : a[2] === "rem" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) : 1) * t;
|
|
1525
|
-
},
|
|
1555
|
+
}, jt = (e, t) => At(e, t, "--tablechart-bar-max", "60px") ?? Infinity, Mt = (t, n) => {
|
|
1526
1556
|
let { plot: r, svg: i, rows: a, type: o, values: s, series: c, seriesValues: u, names: d, annotations: p } = t, m = r.clientWidth;
|
|
1527
1557
|
if (!m) return !1;
|
|
1528
1558
|
let h = _ / m, g = Number.parseFloat(t.figure.dataset.chartAspect ?? ""), v = _ * (g > 0 ? g : o.aspect ?? n.aspect);
|
|
@@ -1535,7 +1565,7 @@ var Te = (e) => e.map((e) => ({
|
|
|
1535
1565
|
...t.categories,
|
|
1536
1566
|
...p.map((e) => e.badge)
|
|
1537
1567
|
]);
|
|
1538
|
-
let y = (s[0] ? W(s[0]).height : 0) * h, b = p[0]?.badge ? W(p[0].badge).height * h : 0, x = Math.max(v,
|
|
1568
|
+
let y = (s[0] ? W(s[0]).height : 0) * h, b = p[0]?.badge ? W(p[0].badge).height * h : 0, x = Math.max(v, At(t.figure, h, "--tablechart-min-height", "200px") ?? 0, o.minHeight?.({
|
|
1539
1569
|
labelHeight: y,
|
|
1540
1570
|
nameHeight: Math.max(0, N(t.categories.map((e) => W(e).height))) * h,
|
|
1541
1571
|
unit: h,
|
|
@@ -1587,7 +1617,7 @@ var Te = (e) => e.map((e) => ({
|
|
|
1587
1617
|
share: s
|
|
1588
1618
|
} : console.warn(`[${e}] This kind of chart cannot break its scale.`);
|
|
1589
1619
|
}
|
|
1590
|
-
let H = V ? V.gap : null, U = (V &&
|
|
1620
|
+
let H = V ? V.gap : null, U = (V && At(t.figure, h, "--tablechart-break-gap", "")) ?? 13, G = x - M, te = F - I || 1, ne = (e) => G - (e - I) / te * P;
|
|
1591
1621
|
if (V) {
|
|
1592
1622
|
let { lo: e, hi: t, gap: n, share: r } = V, i = P * r, a = (P - i - U) / (e + (F - t)), o = i / (t - e);
|
|
1593
1623
|
ne = (r) => r <= e ? G - r * a : r <= n ? G - e * a - (r - e) * o : r <= t ? G - e * a - (r - e) * o - U : G - e * a - i - U - (r - t) * a;
|
|
@@ -1613,8 +1643,8 @@ var Te = (e) => e.map((e) => ({
|
|
|
1613
1643
|
segments: T,
|
|
1614
1644
|
cx: oe,
|
|
1615
1645
|
y: ne,
|
|
1616
|
-
barWidth: Math.min(K * n.barfill,
|
|
1617
|
-
barMax:
|
|
1646
|
+
barWidth: Math.min(K * n.barfill, jt(t.figure, h)),
|
|
1647
|
+
barMax: jt(t.figure, h),
|
|
1618
1648
|
height: x,
|
|
1619
1649
|
unit: h,
|
|
1620
1650
|
labelHeight: y,
|
|
@@ -1622,12 +1652,12 @@ var Te = (e) => e.map((e) => ({
|
|
|
1622
1652
|
after: a.length,
|
|
1623
1653
|
note: 0,
|
|
1624
1654
|
labels: t.figure.dataset.chartLabels === "inside" || t.figure.dataset.chartLabels !== "outside" && n.labels === "inside" ? "inside" : "outside",
|
|
1625
|
-
insideAlign:
|
|
1655
|
+
insideAlign: kt(t.figure),
|
|
1626
1656
|
breakAt: H,
|
|
1627
1657
|
squeeze: V,
|
|
1628
1658
|
breakGap: U,
|
|
1629
1659
|
stacked: t.stacked,
|
|
1630
|
-
shape:
|
|
1660
|
+
shape: yt(t.figure, n),
|
|
1631
1661
|
totals: t.totals,
|
|
1632
1662
|
svg: i,
|
|
1633
1663
|
plot: r,
|
|
@@ -1694,7 +1724,7 @@ var Te = (e) => e.map((e) => ({
|
|
|
1694
1724
|
return t.some((e) => pe(e) && Number(e.dataset.row) <= n && n <= Number(e.dataset.rowEnd ?? e.dataset.row));
|
|
1695
1725
|
};
|
|
1696
1726
|
return t.figure.toggleAttribute("data-left-out", [...u, t.totals].some((e) => e.some((t) => !fe(t) && !pe(t) && !me(t, e)))), !0;
|
|
1697
|
-
},
|
|
1727
|
+
}, Nt = (e, t) => {
|
|
1698
1728
|
let n = [
|
|
1699
1729
|
...e.seriesValues.flat(),
|
|
1700
1730
|
...e.totals,
|
|
@@ -1712,29 +1742,29 @@ var Te = (e) => e.map((e) => ({
|
|
|
1712
1742
|
e.className = "tablechart-minus", e.textContent = o, r.prepend(e);
|
|
1713
1743
|
}
|
|
1714
1744
|
}
|
|
1715
|
-
},
|
|
1716
|
-
|
|
1717
|
-
},
|
|
1745
|
+
}, Pt = (e) => {
|
|
1746
|
+
pt(e), e.plot.remove(), e.categories[0]?.parentElement?.remove(), e.figure.querySelector(`:scope > .${c}`)?.remove(), e.controls?.remove();
|
|
1747
|
+
}, Ft = (e, t) => {
|
|
1718
1748
|
e.figure.classList.toggle(m, t);
|
|
1719
|
-
},
|
|
1749
|
+
}, It = (e) => e === "id" || e === "style" || e.startsWith("data-chart"), Lt = /^\s*(?:Table)?:\s+/, Rt = (e) => e?.tagName === "P" && Lt.test(e.textContent ?? ""), zt = (e) => {
|
|
1720
1750
|
let t = document.createElement("figcaption");
|
|
1721
1751
|
for (let { name: n, value: r } of Array.from(e.attributes)) t.setAttribute(n, r);
|
|
1722
1752
|
let n = e.firstChild;
|
|
1723
|
-
n?.nodeType === Node.TEXT_NODE && (n.textContent = (n.textContent ?? "").replace(
|
|
1753
|
+
n?.nodeType === Node.TEXT_NODE && (n.textContent = (n.textContent ?? "").replace(Lt, ""), n.textContent || n.remove());
|
|
1724
1754
|
let r = Array.from(e.childNodes), i = r.findIndex((e) => e.nodeName === "BR");
|
|
1725
1755
|
if (t.append(...i === -1 ? r : r.slice(0, i + 1)), i !== -1 && i < r.length - 1) {
|
|
1726
1756
|
let e = document.createElement("span");
|
|
1727
1757
|
e.append(...r.slice(i + 1)), t.append(e);
|
|
1728
1758
|
}
|
|
1729
1759
|
return e.remove(), t;
|
|
1730
|
-
},
|
|
1731
|
-
let t =
|
|
1760
|
+
}, Bt = /^\s*([a-z][\w-]*)((?:\s+[\w-]+=[^\s:]+)*)\s*(:\s*|$)/, Vt = (e) => {
|
|
1761
|
+
let t = Yt(e);
|
|
1732
1762
|
return t?.tagName === "P" ? t : e;
|
|
1733
|
-
},
|
|
1734
|
-
let t =
|
|
1763
|
+
}, Ht = (e) => {
|
|
1764
|
+
let t = Vt(e).firstChild;
|
|
1735
1765
|
if (t?.nodeType !== Node.TEXT_NODE) return null;
|
|
1736
|
-
let n =
|
|
1737
|
-
if (!n || !
|
|
1766
|
+
let n = Bt.exec(t.textContent ?? "");
|
|
1767
|
+
if (!n || !gt.includes(n[1]) || !n[3] && t.nextSibling) return null;
|
|
1738
1768
|
let r = n[2].trim().split(/\s+/).filter(Boolean).map((e) => e.split("="));
|
|
1739
1769
|
return {
|
|
1740
1770
|
name: n[1],
|
|
@@ -1742,11 +1772,11 @@ var Te = (e) => e.map((e) => ({
|
|
|
1742
1772
|
text: t,
|
|
1743
1773
|
length: n[0].length
|
|
1744
1774
|
};
|
|
1745
|
-
},
|
|
1775
|
+
}, Ut = (e) => {
|
|
1746
1776
|
if (e?.tagName !== "UL" && e?.tagName !== "OL") return null;
|
|
1747
|
-
let t = Array.from(e.children), n = t.map((e) => e.hasAttribute("data-annotation") ? null :
|
|
1777
|
+
let t = Array.from(e.children), n = t.map((e) => e.hasAttribute("data-annotation") ? null : Ht(e));
|
|
1748
1778
|
return !t.length || t.some((e, t) => !n[t] && !e.hasAttribute("data-annotation")) ? null : (t.forEach((e, t) => {
|
|
1749
|
-
let r = n[t], i =
|
|
1779
|
+
let r = n[t], i = Vt(e);
|
|
1750
1780
|
if (i !== e && i.replaceWith(...i.childNodes), r) {
|
|
1751
1781
|
e.setAttribute("data-annotation", r.name);
|
|
1752
1782
|
for (let [t, n] of r.options) e.setAttribute(`data-${t}`, n);
|
|
@@ -1757,18 +1787,18 @@ var Te = (e) => e.map((e) => ({
|
|
|
1757
1787
|
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));
|
|
1758
1788
|
});
|
|
1759
1789
|
}), e.classList.add("chart-annotations"), e);
|
|
1760
|
-
},
|
|
1761
|
-
for (let { name: n, value: r } of Array.from(e.attributes)) (n === "class" ||
|
|
1762
|
-
},
|
|
1763
|
-
let t = e.closest("p"), n =
|
|
1790
|
+
}, Wt = (e, t) => {
|
|
1791
|
+
for (let { name: n, value: r } of Array.from(e.attributes)) (n === "class" || It(n)) && (t.setAttribute(n, r), e.removeAttribute(n));
|
|
1792
|
+
}, Gt = (e) => e.map((e) => {
|
|
1793
|
+
let t = e.closest("p"), n = Rt(t) ? t : e;
|
|
1764
1794
|
if (n.tagName !== "TABLE" && n.tagName !== "P") return n;
|
|
1765
|
-
let r = document.createElement("
|
|
1766
|
-
|
|
1767
|
-
let i = n.tagName === "TABLE" ? n : null, a = n.previousElementSibling, o = n.nextElementSibling, s = i ?
|
|
1795
|
+
let r = document.createElement("figure");
|
|
1796
|
+
Wt(e, r), e.classList.length || e.removeAttribute("class");
|
|
1797
|
+
let i = n.tagName === "TABLE" ? n : null, a = n.previousElementSibling, o = n.nextElementSibling, s = i ? Rt(a) ? a : Rt(o) ? o : null : n;
|
|
1768
1798
|
i && s === o && (o = o?.nextElementSibling ?? null);
|
|
1769
|
-
let c = o?.classList.contains("chart-annotations") ? o :
|
|
1770
|
-
return n.replaceWith(r), s && r.append(
|
|
1771
|
-
}),
|
|
1799
|
+
let c = o?.classList.contains("chart-annotations") ? o : Ut(o);
|
|
1800
|
+
return n.replaceWith(r), s && r.append(zt(s)), i && r.append(i), c && r.append(c), X?.log?.(`A ${i ? "table" : "caption"} with chart attributes was wrapped in a figure of its own`), r;
|
|
1801
|
+
}), Kt = (e, t, n, r = document.createElement("table")) => {
|
|
1772
1802
|
for (let e of r.querySelectorAll(":scope > tbody, :scope > tfoot, :scope > tr")) e.remove();
|
|
1773
1803
|
if (!r.tHead && (t.length || n)) {
|
|
1774
1804
|
let e = r.createTHead().insertRow(), i = document.createElement("th");
|
|
@@ -1788,7 +1818,7 @@ var Te = (e) => e.map((e) => ({
|
|
|
1788
1818
|
for (let n of t.values ?? [t.value ?? null]) e.insertCell().textContent = n === null ? "" : String(n);
|
|
1789
1819
|
}
|
|
1790
1820
|
return r;
|
|
1791
|
-
},
|
|
1821
|
+
}, qt = (e) => {
|
|
1792
1822
|
if (!e || typeof e != "object") return;
|
|
1793
1823
|
let t = Object.entries(e), n = (e) => e === null || typeof e == "string" || typeof e == "number";
|
|
1794
1824
|
if (t.length && t.every(([, e]) => n(e) || Array.isArray(e) && e.every(n))) return t.map(([e, t]) => Array.isArray(t) ? {
|
|
@@ -1798,16 +1828,16 @@ var Te = (e) => e.map((e) => ({
|
|
|
1798
1828
|
label: e,
|
|
1799
1829
|
value: t
|
|
1800
1830
|
});
|
|
1801
|
-
},
|
|
1831
|
+
}, Jt = async (t) => {
|
|
1802
1832
|
await Promise.all(t.filter((e) => e.hasAttribute("data-chart-src")).map(async (t) => {
|
|
1803
1833
|
let n = t.getAttribute("data-chart-src"), r = Array.from(t.querySelectorAll("table")).find((e) => e.tHead) ?? null;
|
|
1804
1834
|
for (let e of t.querySelectorAll("table")) e !== r && e.remove();
|
|
1805
1835
|
try {
|
|
1806
1836
|
let e = await fetch(n);
|
|
1807
1837
|
if (!e.ok) throw Error(`${e.status} ${e.statusText}`);
|
|
1808
|
-
let i = await e.json(), a = Array.isArray(i) ? i : i?.rows ? Array.isArray(i.rows) ? i.rows :
|
|
1838
|
+
let i = await e.json(), a = Array.isArray(i) ? i : i?.rows ? Array.isArray(i.rows) ? i.rows : qt(i.rows) : qt(i);
|
|
1809
1839
|
if (!Array.isArray(a)) throw Error("no rows in it: a list of rows, an object with rows, or names with their values");
|
|
1810
|
-
let o =
|
|
1840
|
+
let o = Kt(a, Array.isArray(i?.series) ? i.series.map(String) : [], typeof i?.label == "string" ? i.label : "", r ?? void 0);
|
|
1811
1841
|
if (!r) {
|
|
1812
1842
|
let e = t.querySelector(":scope > figcaption");
|
|
1813
1843
|
e ? e.after(o) : t.prepend(o);
|
|
@@ -1818,10 +1848,10 @@ var Te = (e) => e.map((e) => ({
|
|
|
1818
1848
|
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." : ""));
|
|
1819
1849
|
}
|
|
1820
1850
|
}));
|
|
1821
|
-
},
|
|
1851
|
+
}, Yt = (e) => {
|
|
1822
1852
|
let t = Array.from(e.childNodes).filter((e) => e.nodeType === Node.ELEMENT_NODE || e.nodeType === Node.TEXT_NODE && e.textContent?.trim());
|
|
1823
1853
|
return t.length === 1 && t[0] instanceof HTMLElement ? t[0] : null;
|
|
1824
|
-
},
|
|
1854
|
+
}, Xt = "strong, b, span.total", Zt = (e) => {
|
|
1825
1855
|
for (let t of e) {
|
|
1826
1856
|
for (let e of t.querySelectorAll("tbody tr")) {
|
|
1827
1857
|
let t = e.cells[0];
|
|
@@ -1829,16 +1859,16 @@ var Te = (e) => e.map((e) => ({
|
|
|
1829
1859
|
let n = document.createElement("th");
|
|
1830
1860
|
for (let { name: e, value: r } of Array.from(t.attributes)) n.setAttribute(e, r);
|
|
1831
1861
|
n.append(...t.childNodes), t.replaceWith(n);
|
|
1832
|
-
for (let t =
|
|
1862
|
+
for (let t = Yt(n); t?.matches(Xt); t = Yt(n)) e.dataset.kind = "total", t.replaceWith(...t.childNodes);
|
|
1833
1863
|
}
|
|
1834
1864
|
let e = Array.from(t.querySelector("thead tr:last-child")?.children ?? []);
|
|
1835
|
-
for (let t of e.slice(1)) for (let e =
|
|
1865
|
+
for (let t of e.slice(1)) for (let e = Yt(t); e?.matches(Xt); e = Yt(t)) t.setAttribute("data-kind", "focus"), e.replaceWith(...e.childNodes);
|
|
1836
1866
|
}
|
|
1837
|
-
},
|
|
1867
|
+
}, Qt = "data-chart-made", $t = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches, en = (e) => new Promise((t) => setTimeout(t, e)), tn = (e, t) => {
|
|
1838
1868
|
let n = Number.parseFloat(e.dataset.chartEntrance ?? ""), r = Number.isFinite(n) ? n : t.entrance;
|
|
1839
1869
|
return Math.min(Math.max(r, 0), 1);
|
|
1840
|
-
},
|
|
1841
|
-
if (
|
|
1870
|
+
}, nn = async (e, t) => {
|
|
1871
|
+
if ($t()) return;
|
|
1842
1872
|
await new Promise(requestAnimationFrame);
|
|
1843
1873
|
let n = e.getAnimations().filter((e) => e instanceof CSSAnimation);
|
|
1844
1874
|
for (let t = e.parentElement; t && t !== document.body; t = t.parentElement) n.push(...t.getAnimations());
|
|
@@ -1849,11 +1879,11 @@ var Te = (e) => e.map((e) => ({
|
|
|
1849
1879
|
let a = Number(n.delay ?? 0) + i * t;
|
|
1850
1880
|
r = Math.max(r, a - Number(e.currentTime ?? 0));
|
|
1851
1881
|
}
|
|
1852
|
-
r > 0 && await
|
|
1853
|
-
},
|
|
1882
|
+
r > 0 && await en(r);
|
|
1883
|
+
}, rn = (e) => {
|
|
1854
1884
|
for (let t = e; t && t !== document.body; t = t.parentElement) if (getComputedStyle(t).opacity === "0") return t;
|
|
1855
1885
|
return null;
|
|
1856
|
-
},
|
|
1886
|
+
}, an = (e) => new Promise((t) => {
|
|
1857
1887
|
let n = ["animationstart", "transitionrun"], r = () => {
|
|
1858
1888
|
for (let e of n) document.removeEventListener(e, i, !0);
|
|
1859
1889
|
a.disconnect(), t();
|
|
@@ -1867,41 +1897,41 @@ var Te = (e) => e.map((e) => ({
|
|
|
1867
1897
|
attributes: !0,
|
|
1868
1898
|
attributeFilter: ["class", "style"]
|
|
1869
1899
|
});
|
|
1870
|
-
}),
|
|
1871
|
-
|
|
1872
|
-
for (let e of
|
|
1900
|
+
}), on = /* @__PURE__ */ new Set(), sn = null, cn = (e) => {
|
|
1901
|
+
on.add(e), !sn && (sn = new MutationObserver(() => {
|
|
1902
|
+
for (let e of on) e.relabel();
|
|
1873
1903
|
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
1874
|
-
for (let e of
|
|
1904
|
+
for (let e of on) e.refresh();
|
|
1875
1905
|
}));
|
|
1876
|
-
}),
|
|
1906
|
+
}), sn.observe(document.documentElement, {
|
|
1877
1907
|
attributes: !0,
|
|
1878
1908
|
attributeFilter: ["lang"]
|
|
1879
1909
|
}));
|
|
1880
|
-
},
|
|
1881
|
-
|
|
1882
|
-
},
|
|
1910
|
+
}, ln = (e) => {
|
|
1911
|
+
on.delete(e), !on.size && sn && (sn.disconnect(), sn = null);
|
|
1912
|
+
}, un = ["column", "bar"], dn = (e) => {
|
|
1883
1913
|
let t = e.getAttribute("data-chart") || "column";
|
|
1884
|
-
if (!
|
|
1914
|
+
if (!un.includes(t)) return null;
|
|
1885
1915
|
let n = getComputedStyle(e).getPropertyValue("--tablechart-type").trim();
|
|
1886
|
-
return
|
|
1887
|
-
},
|
|
1888
|
-
let n = e, r =
|
|
1889
|
-
if (!t.animate) return
|
|
1916
|
+
return un.includes(n) ? n : t;
|
|
1917
|
+
}, fn = (e, t) => {
|
|
1918
|
+
let n = e, r = dn(n.figure), i = null, a = !1, o = !1, s = async () => {
|
|
1919
|
+
if (!t.animate) return Ft(n, !0);
|
|
1890
1920
|
let e = n.figure.classList.contains("is-shown");
|
|
1891
1921
|
if (a && i !== null && !e && !o) {
|
|
1892
1922
|
o = !0;
|
|
1893
|
-
let e =
|
|
1894
|
-
e && await
|
|
1895
|
-
} else !a && t.replay && e &&
|
|
1923
|
+
let e = $t() ? null : rn(n.figure);
|
|
1924
|
+
e && await an(e), await nn(n.figure, tn(n.figure, t)), o = !1, (a || !t.replay) && Ft(n, !0);
|
|
1925
|
+
} else !a && t.replay && e && Ft(n, !1);
|
|
1896
1926
|
}, c = () => {
|
|
1897
|
-
let e =
|
|
1927
|
+
let e = dn(n.figure);
|
|
1898
1928
|
if (!e || e === r) return;
|
|
1899
|
-
let a = X.timed("Building", n.figure, () =>
|
|
1900
|
-
a && (
|
|
1929
|
+
let a = X.timed("Building", n.figure, () => wt(n.figure, t, e));
|
|
1930
|
+
a && (Pt(n), He(a, n.step, !0), n = a, r = e, i = null);
|
|
1901
1931
|
}, l = () => {
|
|
1902
1932
|
c();
|
|
1903
1933
|
let e = n.plot.clientWidth;
|
|
1904
|
-
e && e !== i && X.timed("Layout", n.figure, () =>
|
|
1934
|
+
e && e !== i && X.timed("Layout", n.figure, () => Mt(n, t)) && (i = e, s());
|
|
1905
1935
|
}, u = !1, d = new ResizeObserver(() => {
|
|
1906
1936
|
u || (u = !0, requestAnimationFrame(() => {
|
|
1907
1937
|
u = !1, l();
|
|
@@ -1909,14 +1939,14 @@ var Te = (e) => e.map((e) => ({
|
|
|
1909
1939
|
}), f = new IntersectionObserver((e) => {
|
|
1910
1940
|
for (let t of e) a = t.isIntersecting, s();
|
|
1911
1941
|
}, { threshold: t.threshold }), p = () => {
|
|
1912
|
-
n.figure.classList.add(h),
|
|
1942
|
+
n.figure.classList.add(h), Ft(n, !0), n.figure.offsetWidth;
|
|
1913
1943
|
}, m = () => n.figure.classList.remove(h), g = () => {
|
|
1914
1944
|
i = null, l();
|
|
1915
1945
|
}, _ = {
|
|
1916
|
-
relabel: () =>
|
|
1946
|
+
relabel: () => Nt(n, t),
|
|
1917
1947
|
refresh: g
|
|
1918
1948
|
};
|
|
1919
|
-
c(), l(), d.observe(n.figure), f.observe(n.figure), window.addEventListener("beforeprint", p), window.addEventListener("afterprint", m),
|
|
1949
|
+
c(), l(), d.observe(n.figure), f.observe(n.figure), window.addEventListener("beforeprint", p), window.addEventListener("afterprint", m), cn(_);
|
|
1920
1950
|
let v = {
|
|
1921
1951
|
figure: n.figure,
|
|
1922
1952
|
refresh: g,
|
|
@@ -1930,26 +1960,29 @@ var Te = (e) => e.map((e) => ({
|
|
|
1930
1960
|
return n.plan?.count ?? 0;
|
|
1931
1961
|
},
|
|
1932
1962
|
destroy() {
|
|
1933
|
-
d.disconnect(), f.disconnect(), window.removeEventListener("beforeprint", p), window.removeEventListener("afterprint", m),
|
|
1963
|
+
d.disconnect(), f.disconnect(), window.removeEventListener("beforeprint", p), window.removeEventListener("afterprint", m), ln(_), pt(n), n.figure.tablechart === v && delete n.figure.tablechart;
|
|
1934
1964
|
}
|
|
1935
1965
|
};
|
|
1936
1966
|
return n.figure.tablechart = v, v;
|
|
1937
|
-
},
|
|
1938
|
-
let n =
|
|
1939
|
-
|
|
1940
|
-
},
|
|
1941
|
-
let n =
|
|
1942
|
-
return n
|
|
1943
|
-
},
|
|
1967
|
+
}, pn = !1, mn = (t) => {
|
|
1968
|
+
let n = t.find((e) => e.tagName !== "FIGURE");
|
|
1969
|
+
!pn && n && (pn = !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));
|
|
1970
|
+
}, hn = async (e, t) => {
|
|
1971
|
+
let n = Gt(e.filter((e) => !e.hasAttribute(Qt)));
|
|
1972
|
+
return mn(n), await Jt(n), Zt(n), Le(n, t.langattribute), n;
|
|
1973
|
+
}, gn = (e, t) => {
|
|
1974
|
+
let n = X.timed("Building", e, () => wt(e, t));
|
|
1975
|
+
return n ? (e.setAttribute(Qt, ""), fn(n, t)) : null;
|
|
1976
|
+
}, _n = async (e, t = {}) => {
|
|
1944
1977
|
if (e.tablechart) return e.tablechart;
|
|
1945
1978
|
let n = {
|
|
1946
1979
|
...v,
|
|
1947
1980
|
...t
|
|
1948
1981
|
};
|
|
1949
1982
|
n.debug && (X.enabled = !0);
|
|
1950
|
-
let [r] = await
|
|
1951
|
-
return r ?
|
|
1952
|
-
},
|
|
1983
|
+
let [r] = await hn([e], n);
|
|
1984
|
+
return r ? gn(r, n) : null;
|
|
1985
|
+
}, vn = [
|
|
1953
1986
|
["--tablechart-duration", "--tablechart-animation-element-duration"],
|
|
1954
1987
|
["--tablechart-stagger", "--tablechart-animation-stagger, a share of the element time"],
|
|
1955
1988
|
["--tablechart-easing", "--tablechart-animation-ease"],
|
|
@@ -1972,32 +2005,32 @@ var Te = (e) => e.map((e) => ({
|
|
|
1972
2005
|
["--tablechart-key-size", "--tablechart-legend-key-size"],
|
|
1973
2006
|
["--tablechart-controls-justify", "--tablechart-control-justify"],
|
|
1974
2007
|
["--tablechart-controls-gap", "--tablechart-control-gap"]
|
|
1975
|
-
],
|
|
2008
|
+
], yn = {
|
|
1976
2009
|
up: "grow",
|
|
1977
2010
|
across: "sweep"
|
|
1978
|
-
},
|
|
1979
|
-
if (
|
|
2011
|
+
}, bn = !1, xn = (t, n) => {
|
|
2012
|
+
if (bn) return;
|
|
1980
2013
|
let r = (e) => {
|
|
1981
|
-
let t =
|
|
2014
|
+
let t = yn[String(e)];
|
|
1982
2015
|
return t ? [`"${e}" is now "${t}"`] : [];
|
|
1983
2016
|
}, i = new Set(r(n.animate));
|
|
1984
2017
|
n.hover !== void 0 && i.add("the \"hover\" option is now \"tooltip\"");
|
|
1985
2018
|
for (let e of t) {
|
|
1986
2019
|
e.hasAttribute("data-chart-hover") && i.add("data-chart-hover is now data-chart-tooltip");
|
|
1987
2020
|
let t = getComputedStyle(e);
|
|
1988
|
-
for (let [e, n] of
|
|
2021
|
+
for (let [e, n] of vn) t.getPropertyValue(e).trim() && i.add(`${e} is now ${n}`);
|
|
1989
2022
|
for (let t of r(e.getAttribute("data-chart-animate"))) i.add(t);
|
|
1990
2023
|
}
|
|
1991
|
-
i.size && (
|
|
1992
|
-
},
|
|
2024
|
+
i.size && (bn = !0, console.warn(`[${e}] ${[...i].join("; ")}. The old names work until the next minor version.`));
|
|
2025
|
+
}, Sn = async (e = {}, t = document) => {
|
|
1993
2026
|
let n = {
|
|
1994
2027
|
...v,
|
|
1995
2028
|
...e
|
|
1996
2029
|
};
|
|
1997
2030
|
n.debug && (X.enabled = !0);
|
|
1998
|
-
let r = await
|
|
1999
|
-
|
|
2000
|
-
let i = r.map((e) =>
|
|
2031
|
+
let r = await hn(Array.from(t.querySelectorAll(n.selector)), n);
|
|
2032
|
+
xn(r, n);
|
|
2033
|
+
let i = r.map((e) => gn(e, n)).filter((e) => e !== null);
|
|
2001
2034
|
return X.log(`Made ${i.length} chart(s).`), {
|
|
2002
2035
|
charts: i,
|
|
2003
2036
|
refresh: () => {
|
|
@@ -2009,4 +2042,4 @@ var Te = (e) => e.map((e) => ({
|
|
|
2009
2042
|
};
|
|
2010
2043
|
};
|
|
2011
2044
|
//#endregion
|
|
2012
|
-
export { h as _,
|
|
2045
|
+
export { h as _, Gt as a, v as b, wt as c, Ft as d, Pt as f, t as g, f as h, hn as i, Mt as l, Le as m, tn as n, Jt as o, He as p, Sn as r, Zt as s, _n as t, Nt as u, g as v, m as y };
|