@martinomagnifico/tablechart 0.1.0 → 0.1.3
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 +43 -1
- package/dist/tablechart-core.d.ts +52 -187
- package/dist/tablechart-core.mjs +2 -2
- package/dist/tablechart-shared.mjs +440 -316
- package/dist/tablechart.css +1 -1
- package/dist/tablechart.d.ts +13 -54
- package/dist/tablechart.js +1 -1
- package/dist/tablechart.mjs +2 -2
- package/package.json +4 -1
|
@@ -5,7 +5,9 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
5
5
|
barfill: .58,
|
|
6
6
|
ringfill: .42,
|
|
7
7
|
animate: !0,
|
|
8
|
+
entrance: .5,
|
|
8
9
|
labels: "outside",
|
|
10
|
+
shape: "straight",
|
|
9
11
|
legend: !1,
|
|
10
12
|
hover: !0,
|
|
11
13
|
totallabel: "Total",
|
|
@@ -21,7 +23,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
21
23
|
return n.className = e, n.inert = !0, t.appendChild(n), n;
|
|
22
24
|
}, I = (e, t, n, r, i) => {
|
|
23
25
|
e.style.left = `${t / r * 100}%`, e.style.top = `${n / i * 100}%`;
|
|
24
|
-
}, L = 0,
|
|
26
|
+
}, L = 0, ee = (e, t, n, r) => {
|
|
25
27
|
if (!t.length) return;
|
|
26
28
|
let i = `tablechart-cut-${++L}`, a = N("mask", {
|
|
27
29
|
id: i,
|
|
@@ -40,7 +42,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
40
42
|
let s = N("g", { mask: `url(#${i})` });
|
|
41
43
|
for (let t of Array.from(e.childNodes)) t !== o && s.appendChild(t);
|
|
42
44
|
e.appendChild(s);
|
|
43
|
-
},
|
|
45
|
+
}, R = 0, z = {
|
|
44
46
|
create: () => null,
|
|
45
47
|
draw(e, t, n) {
|
|
46
48
|
let { segments: r, cx: i, y: a, barWidth: o, svg: s, breakAt: c } = n;
|
|
@@ -51,7 +53,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
51
53
|
let r = u / 6, i = [[n, t]];
|
|
52
54
|
for (let e = 0; e < 6; e++) i.push([n + r * (e + 1), t + (e % 2 == 0 ? -3.38 : 3.38)]);
|
|
53
55
|
return i;
|
|
54
|
-
}, m = (e, t = !1) => e.map(([e, t], n) => `${n === 0 ? "M" : "L"} ${e.toFixed(1)} ${t.toFixed(1)}`).join(" ") + (t ? " Z" : ""), h = `tablechart-break-${++
|
|
56
|
+
}, m = (e, t = !1) => e.map(([e, t], n) => `${n === 0 ? "M" : "L"} ${e.toFixed(1)} ${t.toFixed(1)}`).join(" ") + (t ? " Z" : ""), h = `tablechart-break-${++R}`, g = N("mask", {
|
|
55
57
|
id: h,
|
|
56
58
|
maskUnits: "userSpaceOnUse"
|
|
57
59
|
});
|
|
@@ -85,6 +87,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
85
87
|
let b = N("defs");
|
|
86
88
|
b.appendChild(g), s.prepend(b, y);
|
|
87
89
|
}
|
|
90
|
+
}, B = (e) => {
|
|
91
|
+
let t = -Infinity;
|
|
92
|
+
for (let n of e) t = Math.max(t, n);
|
|
93
|
+
return t;
|
|
88
94
|
}, V = (e) => (e.split(/[.,]/)[1] || "").length, H = (e, t, n) => new Intl.NumberFormat(n || document.documentElement.lang || void 0, {
|
|
89
95
|
minimumFractionDigits: t,
|
|
90
96
|
maximumFractionDigits: t
|
|
@@ -105,16 +111,16 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
105
111
|
agrees: o
|
|
106
112
|
};
|
|
107
113
|
i.checks.push(s), o || console.warn(`[${e}] An annotation reads ${a}%, but ${r} is ${n.toFixed(1)}%. The chart shows what you wrote; this is only a check.`);
|
|
108
|
-
},
|
|
114
|
+
}, te = (e, t) => (t - e) / Math.abs(e) * 100, K = (e, t) => {
|
|
109
115
|
let n = (t, n) => {
|
|
110
116
|
let r = Number.parseInt(e.getAttribute(t) ?? "", 10);
|
|
111
117
|
return Number.isFinite(r) ? r - 1 : n;
|
|
112
118
|
};
|
|
113
119
|
return [n("data-from", 0), n("data-to", t - 1)];
|
|
114
|
-
},
|
|
120
|
+
}, ne = {
|
|
115
121
|
create: W,
|
|
116
122
|
draw(t, n, r) {
|
|
117
|
-
let { rows: i, cx: a, y: o, unit: s, labelHeight: u, badgeHeight: d, height: f, svg: p, after: m } = r, [h, g] =
|
|
123
|
+
let { rows: i, cx: a, y: o, unit: s, labelHeight: u, badgeHeight: d, height: f, svg: p, after: m } = r, [h, g] = K(t, i.length), _ = i[h], v = i[g];
|
|
118
124
|
if (!_ || !v) {
|
|
119
125
|
console.warn(`[${e}] A bracket points at a row that is not there (row ${h + 1} to ${g + 1}, of ${i.length}).`);
|
|
120
126
|
return;
|
|
@@ -132,9 +138,18 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
132
138
|
"data-note": r.note,
|
|
133
139
|
points: `${S},${D} ${S - y * .45},${D - y} ${S + y * .45},${D - y}`,
|
|
134
140
|
style: j("--after", m)
|
|
135
|
-
})), n && (I(n, (x + S) / 2, C, k, f), n.style.setProperty("--after", String(m))), G(n,
|
|
141
|
+
})), n && (I(n, (x + S) / 2, C, k, f), n.style.setProperty("--after", String(m))), G(n, te(_.value, v.value), `${_.value} to ${v.value}`, r);
|
|
136
142
|
}
|
|
137
|
-
},
|
|
143
|
+
}, q = /* @__PURE__ */ new WeakMap(), re = (e) => {
|
|
144
|
+
let t = [...e].filter((e) => !!e), n = t.map((e) => ({
|
|
145
|
+
width: e.offsetWidth,
|
|
146
|
+
height: e.offsetHeight
|
|
147
|
+
}));
|
|
148
|
+
t.forEach((e, t) => q.set(e, n[t]));
|
|
149
|
+
}, J = (e) => q.get(e) ?? {
|
|
150
|
+
width: e.offsetWidth,
|
|
151
|
+
height: e.offsetHeight
|
|
152
|
+
}, ie = (e, t, n) => ((t / e) ** (1 / n) - 1) * 100, ae = {
|
|
138
153
|
create: W,
|
|
139
154
|
draw(e, t, n) {
|
|
140
155
|
let { rows: r, cx: i, y: a, unit: o, labelHeight: s, height: u, svg: d, values: f, after: p } = n, m = r[0], h = r[r.length - 1];
|
|
@@ -148,9 +163,9 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
148
163
|
y -= D * _, b -= O * _, x += D * _, S += O * _;
|
|
149
164
|
let A = Number.parseFloat(e.getAttribute("data-at") || "0.5");
|
|
150
165
|
if (t) {
|
|
151
|
-
let e = y + (x - y) * A, n = b + (S - b) * A, c = t.
|
|
166
|
+
let e = y + (x - y) * A, n = b + (S - b) * A, c = J(t).width * o / 2, l = n + J(t).height * o / 2 + 8 * o, u = 0;
|
|
152
167
|
r.forEach((t, n) => {
|
|
153
|
-
let r = (f[n]
|
|
168
|
+
let r = (f[n] ? J(f[n]).width : 0) * o / 2;
|
|
154
169
|
if (Math.abs(i(n) - e) >= c + r) return;
|
|
155
170
|
let d = a(t.value) - 7 * o - s;
|
|
156
171
|
u = Math.max(u, l - d);
|
|
@@ -166,35 +181,35 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
166
181
|
y2: P,
|
|
167
182
|
style: `--len:${F.toFixed(1)}; ${j("--after", p)}`
|
|
168
183
|
}));
|
|
169
|
-
let L = -O,
|
|
184
|
+
let L = -O, ee = D, R = v * .42;
|
|
170
185
|
d.appendChild(N("polygon", {
|
|
171
186
|
class: l,
|
|
172
187
|
"data-note": n.note,
|
|
173
188
|
points: [
|
|
174
189
|
`${x},${S}`,
|
|
175
|
-
`${M + L *
|
|
176
|
-
`${M - L *
|
|
190
|
+
`${M + L * R},${P + ee * R}`,
|
|
191
|
+
`${M - L * R},${P - ee * R}`
|
|
177
192
|
].join(" "),
|
|
178
193
|
style: j("--after", p)
|
|
179
194
|
})), t && (I(t, y + (x - y) * A, b + (S - b) * A, k, u), t.style.setProperty("--after", String(p)));
|
|
180
|
-
let
|
|
181
|
-
!Number.isNaN(
|
|
195
|
+
let z = Number.parseFloat(e.getAttribute("data-years") || "");
|
|
196
|
+
!Number.isNaN(z) && z > 0 && G(t, ie(m.value, h.value, z), `${m.value} to ${h.value} over ${z} years`, n);
|
|
182
197
|
}
|
|
183
|
-
},
|
|
198
|
+
}, oe = (e, t, n) => {
|
|
184
199
|
let r = .15, i = Math.min(e * .7 / (t + (t - 1) * r), n), a = t * i + (t - 1) * i * r;
|
|
185
200
|
return {
|
|
186
201
|
size: i,
|
|
187
202
|
gap: i * r,
|
|
188
203
|
offset: (e) => -a / 2 + e * i * 1.15
|
|
189
204
|
};
|
|
190
|
-
},
|
|
205
|
+
}, se = (e, t, n) => {
|
|
191
206
|
let r = e.series[n], i = e.series.some((e) => e.focus) && !r.focus;
|
|
192
207
|
return {
|
|
193
208
|
"data-series": n + 1,
|
|
194
209
|
...i && { "data-muted": "" },
|
|
195
210
|
style: `--n:${n}; --m:${+!!i}; --palette:var(--tablechart-color-${n + 1}); ${j("--i", t.slot)}`
|
|
196
211
|
};
|
|
197
|
-
},
|
|
212
|
+
}, Y = (e, t) => {
|
|
198
213
|
let n = 0;
|
|
199
214
|
return Array.from({ length: t }, (t, r) => {
|
|
200
215
|
let i = e.cells[r] ?? e.cells[0], a = n;
|
|
@@ -204,10 +219,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
204
219
|
cell: i
|
|
205
220
|
};
|
|
206
221
|
});
|
|
207
|
-
},
|
|
222
|
+
}, ce = (e, t) => Y(e, t).at(-1)?.to ?? 0, le = (e, t, n) => {
|
|
208
223
|
let r = t.series.some((e) => e.focus);
|
|
209
224
|
e.style.setProperty("--n", String(n)), e.style.setProperty("--m", r && !t.series[n].focus ? "1" : "0"), e.style.setProperty("--palette", `var(--tablechart-color-${n + 1})`);
|
|
210
|
-
},
|
|
225
|
+
}, ue = (e, t, n, r = {}) => {
|
|
211
226
|
let o = N("g", {
|
|
212
227
|
class: P(i, t),
|
|
213
228
|
"data-kind": "bar",
|
|
@@ -220,10 +235,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
220
235
|
o.appendChild(N("rect", {
|
|
221
236
|
...r,
|
|
222
237
|
class: P(a, t),
|
|
223
|
-
...
|
|
238
|
+
...se(e, t, n)
|
|
224
239
|
}));
|
|
225
240
|
};
|
|
226
|
-
},
|
|
241
|
+
}, de = 6, fe = (e, t, n) => e.some((e) => J(e).width * n > t - de * n), pe = (e, t, n) => t >= J(e).height * n * 1.6, me = (e, t, n) => t >= J(e).width * n * 1.5, he = (e, t, n, r, i = .7) => {
|
|
227
242
|
e.style.setProperty(r, "1");
|
|
228
243
|
let a = 1;
|
|
229
244
|
for (let e of t) {
|
|
@@ -232,10 +247,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
232
247
|
}
|
|
233
248
|
let o = a >= i ? a : 0;
|
|
234
249
|
return e.style.setProperty(r, String(o || i)), o;
|
|
235
|
-
},
|
|
250
|
+
}, ge = (e, t) => (e.sort((e, t) => e.y - t.y), e.forEach((n, r) => {
|
|
236
251
|
let i = e[r - 1];
|
|
237
252
|
i && n.y < i.y + t && (n.y = i.y + t);
|
|
238
|
-
}), e),
|
|
253
|
+
}), e), _e = {
|
|
239
254
|
segments: (e) => e.map((e) => ({
|
|
240
255
|
...e,
|
|
241
256
|
from: 0,
|
|
@@ -254,19 +269,19 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
254
269
|
categories: "beside",
|
|
255
270
|
headroom: () => 0,
|
|
256
271
|
draw(e) {
|
|
257
|
-
let { segments: t, height: n, unit: r, svg: a, values: s, categories: c, config: l, barMax: u } = e, d = e.series.length > 1, f = Math.max(
|
|
272
|
+
let { segments: t, height: n, unit: r, svg: a, values: s, categories: c, config: l, barMax: u } = e, d = e.series.length > 1, f = Math.max(B(c.map((e) => J(e).width * r)), 0), p = Math.min(f + 10 * r, k * .42), m = k - 4 * r, h = e.stacked ? Math.max(B(e.rows.map((t) => ce(t, e.series.length))), 0) || 1 : Math.max(B(e.rows.flatMap((t) => t.cells.slice(0, e.series.length).map((e) => Math.abs(e.value)))), 0) || 1, g = (e) => J(e).width * r, _ = (e) => e.length ? B(e.map(g)) + 9 * r : 0, v = e.stacked ? _(e.totals) : d ? _(e.seriesValues.flat()) : 0;
|
|
258
273
|
if (!d) for (let e = 0; e < 3; e++) {
|
|
259
274
|
let e = m - p - v, n = _(t.map((e, t) => ({
|
|
260
275
|
seg: e,
|
|
261
276
|
label: s[t]
|
|
262
|
-
})).filter(({ seg: t, label: n }) => !
|
|
277
|
+
})).filter(({ seg: t, label: n }) => !me(n, Math.abs(t.value) / h * e, r)).map(({ label: e }) => e));
|
|
263
278
|
if (n <= v) break;
|
|
264
279
|
v = n;
|
|
265
280
|
}
|
|
266
281
|
let y = m - p - v, b = (e) => p + Math.abs(e) / h * y, x = n / t.length, S = (e) => (e + .5) * x, C = Math.min(x * l.barfill, u);
|
|
267
282
|
if (e.stacked) {
|
|
268
283
|
e.rows.forEach((t, i) => {
|
|
269
|
-
let a =
|
|
284
|
+
let a = ue(e, t, i, { "data-grow": "right" }), o = S(i) - C / 2, s = Y(t, e.series.length);
|
|
270
285
|
s.forEach(({ from: t, to: s, cell: c }, l) => {
|
|
271
286
|
let u = e.seriesValues[l][i];
|
|
272
287
|
if (u.dataset.place = "none", c.missing || s === t) return;
|
|
@@ -276,7 +291,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
276
291
|
y: o,
|
|
277
292
|
width: Math.max(f - d, 1),
|
|
278
293
|
height: C
|
|
279
|
-
}), u.dataset.place = "inside", u.toggleAttribute("data-left-out", !
|
|
294
|
+
}), u.dataset.place = "inside", u.toggleAttribute("data-left-out", !me(u, f - d, r) || J(u).height * r > C), le(u, e, l), I(u, (d + f) / 2, S(i), k, n);
|
|
280
295
|
});
|
|
281
296
|
let l = e.totals[i];
|
|
282
297
|
l && (l.dataset.place = "after", I(l, b(s.at(-1)?.to ?? 0) + 5 * r, S(i), k, n));
|
|
@@ -292,10 +307,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
292
307
|
return;
|
|
293
308
|
}
|
|
294
309
|
if (d) {
|
|
295
|
-
let t =
|
|
310
|
+
let t = oe(x, e.series.length, u);
|
|
296
311
|
e.plot.dataset.grouped = "";
|
|
297
|
-
let s = e.seriesValues.flat().filter((e) => e.dataset.missing === void 0), l =
|
|
298
|
-
size: e.
|
|
312
|
+
let s = e.seriesValues.flat().filter((e) => e.dataset.missing === void 0), l = he(e.plot, s, (e) => ({
|
|
313
|
+
size: J(e).height * r,
|
|
299
314
|
room: t.size + t.gap * .5
|
|
300
315
|
}), "--tablechart-fit");
|
|
301
316
|
e.rows.forEach((o, s) => {
|
|
@@ -315,7 +330,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
315
330
|
y: h,
|
|
316
331
|
width: Math.max(m - p, 1),
|
|
317
332
|
height: t.size,
|
|
318
|
-
...
|
|
333
|
+
...se(e, o, u)
|
|
319
334
|
})), f.dataset.place = "after", f.toggleAttribute("data-left-out", !l), I(f, m + 5 * r, h + t.size / 2, k, n);
|
|
320
335
|
});
|
|
321
336
|
let u = c[s];
|
|
@@ -342,8 +357,8 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
342
357
|
height: C,
|
|
343
358
|
style: j("--i", e.slot)
|
|
344
359
|
}));
|
|
345
|
-
let u = s[t], d =
|
|
346
|
-
u.dataset.place = d ? "inside" : "after", u.dataset.kind = e.kind, I(u, d ? o - 6 * r - u.
|
|
360
|
+
let u = s[t], d = me(u, o - p, r);
|
|
361
|
+
u.dataset.place = d ? "inside" : "after", u.dataset.kind = e.kind, I(u, d ? o - 6 * r - J(u).width * r / 2 : o + 5 * r, l, k, n);
|
|
347
362
|
let f = c[t];
|
|
348
363
|
f && I(f, p - 8 * r, l, k, n);
|
|
349
364
|
}), a.appendChild(N("line", {
|
|
@@ -354,7 +369,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
354
369
|
y2: n
|
|
355
370
|
}));
|
|
356
371
|
}
|
|
357
|
-
},
|
|
372
|
+
}, ve = {
|
|
358
373
|
segments: (e) => e.map((e) => ({
|
|
359
374
|
...e,
|
|
360
375
|
from: 0,
|
|
@@ -371,8 +386,8 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
371
386
|
let { segments: t, cx: n, y: r, barWidth: a, height: s, unit: c, svg: l, values: u, labels: d } = e, f = r(0);
|
|
372
387
|
if (e.stacked) {
|
|
373
388
|
e.rows.forEach((t, i) => {
|
|
374
|
-
let o =
|
|
375
|
-
|
|
389
|
+
let o = ue(e, t, i), l = n(i) - a / 2;
|
|
390
|
+
Y(t, e.series.length).forEach(({ from: t, to: u, cell: d }, f) => {
|
|
376
391
|
let p = e.seriesValues[f][i];
|
|
377
392
|
if (p.dataset.place = "none", d.missing || u === t) return;
|
|
378
393
|
let m = r(u), h = r(t);
|
|
@@ -381,9 +396,9 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
381
396
|
y: m,
|
|
382
397
|
width: a,
|
|
383
398
|
height: Math.max(h - m, 1)
|
|
384
|
-
}), p.dataset.place = "inside", p.toggleAttribute("data-left-out", !
|
|
399
|
+
}), p.dataset.place = "inside", p.toggleAttribute("data-left-out", !pe(p, h - m, c) || J(p).width * c > a - 4 * c), le(p, e, f), I(p, n(i), (m + h) / 2, k, s);
|
|
385
400
|
});
|
|
386
|
-
let u = e.totals[i], d =
|
|
401
|
+
let u = e.totals[i], d = Y(t, e.series.length).at(-1)?.to ?? 0;
|
|
387
402
|
u && (u.dataset.place = "outside", I(u, n(i), r(d) - 4 * c, k, s));
|
|
388
403
|
}), l.appendChild(N("line", {
|
|
389
404
|
class: o,
|
|
@@ -395,10 +410,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
395
410
|
return;
|
|
396
411
|
}
|
|
397
412
|
if (e.series.length > 1) {
|
|
398
|
-
let t =
|
|
413
|
+
let t = oe(n(1) - n(0) || n(0) * 2, e.series.length, e.barMax);
|
|
399
414
|
e.plot.dataset.grouped = "";
|
|
400
|
-
let a = e.seriesValues.flat().filter((e) => e.dataset.missing === void 0), u =
|
|
401
|
-
size: e.
|
|
415
|
+
let a = e.seriesValues.flat().filter((e) => e.dataset.missing === void 0), u = he(e.plot, a, (e) => ({
|
|
416
|
+
size: J(e).width * c,
|
|
402
417
|
room: t.size + t.gap * .5
|
|
403
418
|
}), "--tablechart-fit");
|
|
404
419
|
e.rows.forEach((a, o) => {
|
|
@@ -417,7 +432,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
417
432
|
y: _,
|
|
418
433
|
width: t.size,
|
|
419
434
|
height: Math.max(f - _, 1),
|
|
420
|
-
...
|
|
435
|
+
...se(e, a, p)
|
|
421
436
|
})), h.dataset.place = "outside", h.toggleAttribute("data-left-out", !u), I(h, g + t.size / 2, _ - 4 * c, k, s);
|
|
422
437
|
});
|
|
423
438
|
}), l.appendChild(N("line", {
|
|
@@ -429,7 +444,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
429
444
|
}));
|
|
430
445
|
return;
|
|
431
446
|
}
|
|
432
|
-
let p =
|
|
447
|
+
let p = fe(u, a, c);
|
|
433
448
|
t.forEach((e, t) => {
|
|
434
449
|
let o = r(e.value);
|
|
435
450
|
if (e.missing) {
|
|
@@ -446,7 +461,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
446
461
|
height: Math.max(f - o, 1),
|
|
447
462
|
style: j("--i", e.slot)
|
|
448
463
|
}));
|
|
449
|
-
let m = f - o, h = d === "inside" && !p &&
|
|
464
|
+
let m = f - o, h = d === "inside" && !p && pe(u[t], m, c);
|
|
450
465
|
I(u[t], n(t), h ? o + m / 2 : o - 4 * c, k, s), u[t].dataset.place = h ? "inside" : "outside";
|
|
451
466
|
}), l.appendChild(N("line", {
|
|
452
467
|
class: o,
|
|
@@ -456,7 +471,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
456
471
|
y2: f
|
|
457
472
|
}));
|
|
458
473
|
}
|
|
459
|
-
},
|
|
474
|
+
}, ye = 0, be = (e) => e.filter((e) => !e.isTotal), xe = {
|
|
460
475
|
aspect: .66,
|
|
461
476
|
centre: !0,
|
|
462
477
|
headroom: () => 0,
|
|
@@ -467,7 +482,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
467
482
|
kind: "bar"
|
|
468
483
|
})),
|
|
469
484
|
draw({ rows: e, height: t, unit: n, labelHeight: r, svg: i, values: a, config: o, centre: s }) {
|
|
470
|
-
let c = k / 2, l = t / 2, u =
|
|
485
|
+
let c = k / 2, l = t / 2, u = be(e).reduce((e, t) => e + Math.abs(t.value), 0);
|
|
471
486
|
if (!u) return;
|
|
472
487
|
let d = r * 1.2 + 10 * n, m = Math.max(Math.min(k, t) / 2 - d, 10), h = m * o.ringfill, g = m - h / 2, _ = 2 * Math.PI * g, v = [], y = 0, b = 0;
|
|
473
488
|
if (e.forEach((e, o) => {
|
|
@@ -500,10 +515,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
500
515
|
"data-row": o + 1,
|
|
501
516
|
style: j("--i", e.slot)
|
|
502
517
|
}));
|
|
503
|
-
let T = m + 9 * n, E = s.
|
|
518
|
+
let T = m + 9 * n, E = J(s).width * n / 2;
|
|
504
519
|
I(s, c + C * (T + Math.abs(C) * E), l + w * (T + Math.abs(w) * r * .7), k, t), s.dataset.place = "around", y += d, b += 1;
|
|
505
520
|
}), v.length > 1) {
|
|
506
|
-
let e = g - h / 2 - 1, n = g + h / 2 + 1, r = `tablechart-slices-${++
|
|
521
|
+
let e = g - h / 2 - 1, n = g + h / 2 + 1, r = `tablechart-slices-${++ye}`, a = N("mask", {
|
|
507
522
|
id: r,
|
|
508
523
|
maskUnits: "userSpaceOnUse"
|
|
509
524
|
});
|
|
@@ -528,17 +543,17 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
528
543
|
}
|
|
529
544
|
s && I(s, c, l, k, t);
|
|
530
545
|
}
|
|
531
|
-
},
|
|
546
|
+
}, Se = [
|
|
532
547
|
"circle",
|
|
533
548
|
"square",
|
|
534
549
|
"diamond"
|
|
535
|
-
],
|
|
536
|
-
let n = e[t]?.marker?.toLowerCase().split(/\s+/) ?? [], r =
|
|
550
|
+
], Ce = (e, t) => {
|
|
551
|
+
let n = e[t]?.marker?.toLowerCase().split(/\s+/) ?? [], r = Se.find((e) => n.includes(e));
|
|
537
552
|
return {
|
|
538
|
-
shape: r ??
|
|
553
|
+
shape: r ?? Se[Math.floor(t / 2) % Se.length],
|
|
539
554
|
open: n.includes("open") || !n.includes("filled") && !r && t % 2 == 1
|
|
540
555
|
};
|
|
541
|
-
},
|
|
556
|
+
}, we = (e, t, n, r, i = {}) => {
|
|
542
557
|
if (e === "square") {
|
|
543
558
|
let e = r * .88;
|
|
544
559
|
return N("rect", {
|
|
@@ -562,13 +577,61 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
562
577
|
r,
|
|
563
578
|
...i
|
|
564
579
|
});
|
|
565
|
-
},
|
|
580
|
+
}, X = (e) => Number(e.toFixed(2));
|
|
581
|
+
function Te(e, t) {
|
|
582
|
+
let n = e.length;
|
|
583
|
+
if (n < 2) return e.map(() => 0);
|
|
584
|
+
let r = (n) => (t[n + 1] - t[n]) / (e[n + 1] - e[n] || 1), i = Array(n).fill(0);
|
|
585
|
+
for (let t = 1; t < n - 1; t++) {
|
|
586
|
+
let n = r(t - 1), a = r(t);
|
|
587
|
+
if (n * a <= 0) continue;
|
|
588
|
+
let o = e[t] - e[t - 1], s = e[t + 1] - e[t], c = (n * s + a * o) / (o + s || 1), l = Math.min(2 * Math.abs(n), 2 * Math.abs(a), Math.abs(c));
|
|
589
|
+
i[t] = Math.sign(n) * l || 0;
|
|
590
|
+
}
|
|
591
|
+
if (n === 2) return i[0] = r(0), i[1] = r(0), i;
|
|
592
|
+
let a = (n, r, i) => {
|
|
593
|
+
let a = e[r] - e[n];
|
|
594
|
+
return a ? (3 * ((t[r] - t[n]) / a) - i) / 2 : i;
|
|
595
|
+
};
|
|
596
|
+
return i[0] = a(0, 1, i[1]), i[n - 1] = a(n - 2, n - 1, i[n - 2]), i;
|
|
597
|
+
}
|
|
598
|
+
function Ee(e, t, n, r) {
|
|
599
|
+
let i = (t[0] - e[0]) / 3;
|
|
600
|
+
return [[e[0] + i, e[1] + n * i], [t[0] - i, t[1] - r * i]];
|
|
601
|
+
}
|
|
602
|
+
function De(e, t, n, r) {
|
|
603
|
+
let [i, a] = Ee(e, t, n, r), o = ([e, t]) => `${X(e)},${X(t)}`;
|
|
604
|
+
return `C${o(i)} ${o(a)} ${o(t)}`;
|
|
605
|
+
}
|
|
606
|
+
function Oe(e, t, n, r, i = 24) {
|
|
607
|
+
let [a, o] = Ee(e, t, n, r), s = (n) => {
|
|
608
|
+
let r = 1 - n, i = (e, t, i, a) => r * r * r * e + 3 * r * r * n * t + 3 * r * n * n * i + n * n * n * a;
|
|
609
|
+
return [i(e[0], a[0], o[0], t[0]), i(e[1], a[1], o[1], t[1])];
|
|
610
|
+
}, c = 0, l = e;
|
|
611
|
+
for (let e = 1; e <= i; e++) {
|
|
612
|
+
let t = s(e / i);
|
|
613
|
+
c += Math.hypot(t[0] - l[0], t[1] - l[1]), l = t;
|
|
614
|
+
}
|
|
615
|
+
return c;
|
|
616
|
+
}
|
|
617
|
+
function ke(e, t, n) {
|
|
618
|
+
let r = Array(e).fill(0), i = [], a = () => {
|
|
619
|
+
Te(i.map((e) => n(e)[0]), i.map((e) => n(e)[1])).forEach((e, t) => {
|
|
620
|
+
r[i[t]] = e;
|
|
621
|
+
}), i = [];
|
|
622
|
+
};
|
|
623
|
+
for (let n = 0; n < e; n++) t(n) ? a() : i.push(n);
|
|
624
|
+
return a(), r;
|
|
625
|
+
}
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region src/js/charts/line.ts
|
|
628
|
+
var Ae = (e) => e.map((e) => ({
|
|
566
629
|
...e,
|
|
567
630
|
from: 0,
|
|
568
631
|
to: e.value,
|
|
569
632
|
kind: "bar"
|
|
570
|
-
})),
|
|
571
|
-
segments:
|
|
633
|
+
})), je = (e) => ({
|
|
634
|
+
segments: Ae,
|
|
572
635
|
breakable: !0,
|
|
573
636
|
series: !0,
|
|
574
637
|
stackable: !0,
|
|
@@ -576,7 +639,9 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
576
639
|
headroom: ({ labelHeight: e, unit: t }) => e * 1.6 + 6 * t,
|
|
577
640
|
footroom: ({ labelHeight: t, unit: n, series: r, focused: i, stacked: a }) => !e && !a && r === 2 && !i ? t + 7 * n : 0,
|
|
578
641
|
draw(t) {
|
|
579
|
-
let { rows: n, series: r, seriesValues: i, names: a, cx: s, y: c, height: l, unit: u, labelHeight: d, svg: f, stacked: p } = t, _ = t.shape === "step", v =
|
|
642
|
+
let { rows: n, series: r, seriesValues: i, names: a, cx: s, y: c, height: l, unit: u, labelHeight: d, svg: f, stacked: p } = t, _ = t.shape === "step", v = t.shape === "smooth", x = r.length > 1, S = r.some((e) => e.focus), C = n.length - 1, w = c(0), T = n.length > 1 ? s(1) - s(0) : s(0) * 2;
|
|
643
|
+
f.style.setProperty("--tablechart-base", `${X(w)}px`);
|
|
644
|
+
let E = (e) => `--rise:${X(w - e)}px; `, D = (e, t) => n[t]?.cells[e] ?? n[t]?.cells[0], O = (e, t) => !D(e, t) || !!D(e, t)?.missing, A = n.map((e) => p ? Y(e, r.length) : null), j = (e, t) => A[t]?.[e].to ?? D(e, t)?.value ?? 0, M = (e, t) => A[t]?.[e].from ?? 0, P = (e, t) => [s(t), c(j(e, t))], F = r.map((e, t) => {
|
|
580
645
|
if (!x) return {
|
|
581
646
|
attrs: {},
|
|
582
647
|
ink: ""
|
|
@@ -589,139 +654,172 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
589
654
|
},
|
|
590
655
|
ink: `--n:${t}; --m:${+!!n}; --palette:var(--tablechart-color-${t + 1}); `
|
|
591
656
|
};
|
|
592
|
-
}),
|
|
657
|
+
}), L = Math.min(C, 6), R = C > 0 ? L / (_ ? n.length : C) : 1, z = (e) => e * R, B = (e) => `--i:${X(z(e))}`, V = (e) => `--i:${X(z(e) + 1)}; --d:${X(z(e + 1) - z(e))}`, H = (e) => n.map((t, n) => ({
|
|
593
658
|
i: n,
|
|
594
|
-
next: n < C && !
|
|
595
|
-
})).filter(({ i: t, next: n }) => !
|
|
596
|
-
|
|
597
|
-
let r = N("g", {
|
|
659
|
+
next: n < C && !O(e, n + 1)
|
|
660
|
+
})).filter(({ i: t, next: n }) => !O(e, t) && (_ || n)), U = v ? r.map((e, t) => ke(n.length, (e) => O(t, e), (e) => P(t, e))) : [], W = v && e ? r.map((e, t) => ke(n.length, (e) => O(t, e), (e) => [s(e), c(M(t, e))])) : [], G = (e) => {
|
|
661
|
+
let t = N("g", {
|
|
598
662
|
class: h,
|
|
599
|
-
...
|
|
663
|
+
...F[e].attrs,
|
|
600
664
|
...p && { "data-stacked": "" },
|
|
601
|
-
style:
|
|
602
|
-
}),
|
|
665
|
+
style: F[e].ink
|
|
666
|
+
}), n = H(e), r = N("g", {
|
|
603
667
|
class: g,
|
|
604
|
-
style: `--rows:${
|
|
668
|
+
style: `--rows:${X(L + 1)}; ${n.length ? V(n[0].i) : ""}`
|
|
605
669
|
});
|
|
606
|
-
|
|
607
|
-
for (let { i:
|
|
608
|
-
let
|
|
670
|
+
t.appendChild(r);
|
|
671
|
+
for (let { i: t, next: i } of n) {
|
|
672
|
+
let n = _ ? s(t) - T / 2 : s(t), a = _ ? s(t) + T / 2 : s(t + 1), [o, l] = [c(j(e, t)), c(M(e, t))], [d, f] = _ ? [o, l] : [c(j(e, t + 1)), c(M(e, t + 1))], p = _ ? t + 1 : t + 2, m = _ ? i : t + 1 < C && !O(e, t + 2), h = m ? 1.5 * u : 0, g = (e, t, r, i, o) => {
|
|
673
|
+
if (!m) return t;
|
|
674
|
+
if (v) return t + i * h;
|
|
675
|
+
if (_) return o(t, r);
|
|
676
|
+
let c = (t - e) / (a - n), l = (r - t) / (s(p) - a);
|
|
677
|
+
return o(t + c * h, t + l * h);
|
|
678
|
+
}, y = g(o, d, c(j(e, p)), U[e]?.[t + 1], Math.max), b = g(l, f, c(M(e, p)), W[e]?.[t + 1], Math.min);
|
|
609
679
|
y >= b && (h = 0);
|
|
610
|
-
let x =
|
|
611
|
-
|
|
612
|
-
[
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
680
|
+
let x = h ? [`L${X(a + h)},${X(y)}`, `L${X(a + h)},${X(b)}`] : [];
|
|
681
|
+
if (v) {
|
|
682
|
+
let i = [
|
|
683
|
+
`M${X(n)},${X(l)}`,
|
|
684
|
+
`L${X(n)},${X(o)}`,
|
|
685
|
+
De([n, o], [a, d], U[e][t], U[e][t + 1]),
|
|
686
|
+
...x,
|
|
687
|
+
`L${X(a)},${X(f)}`,
|
|
688
|
+
De([a, f], [n, l], W[e][t + 1], W[e][t]),
|
|
689
|
+
"Z"
|
|
690
|
+
].join(" ");
|
|
691
|
+
r.appendChild(N("path", {
|
|
692
|
+
d: i,
|
|
693
|
+
"data-row": t + 2,
|
|
694
|
+
style: V(t)
|
|
695
|
+
}));
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
let S = _ ? [
|
|
699
|
+
[n, l],
|
|
700
|
+
[n, o],
|
|
701
|
+
[a, o],
|
|
702
|
+
[a, y],
|
|
703
|
+
[a + h, y],
|
|
704
|
+
[a + h, b],
|
|
705
|
+
[a, b],
|
|
706
|
+
[a, l]
|
|
619
707
|
] : [
|
|
620
|
-
[
|
|
621
|
-
[
|
|
622
|
-
[
|
|
623
|
-
[
|
|
624
|
-
[
|
|
625
|
-
[
|
|
708
|
+
[n, l],
|
|
709
|
+
[n, o],
|
|
710
|
+
[a, d],
|
|
711
|
+
[a + h, y],
|
|
712
|
+
[a + h, b],
|
|
713
|
+
[a, f]
|
|
626
714
|
];
|
|
627
|
-
|
|
628
|
-
points:
|
|
629
|
-
"data-row": (_ ?
|
|
630
|
-
style:
|
|
715
|
+
r.appendChild(N("polygon", {
|
|
716
|
+
points: S.map((e) => e.join(",")).join(" "),
|
|
717
|
+
"data-row": (_ ? t : t + 1) + 1,
|
|
718
|
+
style: V(t)
|
|
631
719
|
}));
|
|
632
720
|
}
|
|
633
|
-
f.appendChild(
|
|
634
|
-
}
|
|
635
|
-
let n = 0
|
|
636
|
-
|
|
637
|
-
let a = _ ? [
|
|
638
|
-
[s(r) - F / 2, c(E(t, r))],
|
|
639
|
-
[s(r) + F / 2, c(E(t, r))],
|
|
640
|
-
...i ? [[s(r) + F / 2, c(E(t, r + 1))]] : []
|
|
641
|
-
] : [O(t, r), O(t, r + 1)], o = 1;
|
|
642
|
-
for (let e = 1; e < a.length; e++) {
|
|
643
|
-
let [[t, n], [r, i]] = [a[e - 1], a[e]];
|
|
644
|
-
o += Math.hypot(r - t, i - n) / u;
|
|
645
|
-
}
|
|
646
|
-
f.appendChild(N("polyline", {
|
|
721
|
+
f.appendChild(t);
|
|
722
|
+
}, te = (e) => {
|
|
723
|
+
let t = r[e], n = 0, i = (r, i, a, o) => {
|
|
724
|
+
f.appendChild(N(r.d ? "path" : "polyline", {
|
|
647
725
|
class: m,
|
|
648
|
-
...
|
|
649
|
-
|
|
650
|
-
...
|
|
651
|
-
"data-row":
|
|
652
|
-
style: `${
|
|
653
|
-
})), n +=
|
|
726
|
+
...F[e].attrs,
|
|
727
|
+
...r,
|
|
728
|
+
...t.line && { "data-line": t.line },
|
|
729
|
+
"data-row": a,
|
|
730
|
+
style: `${F[e].ink}--len:${i.toFixed(1)}; --along:${(-n).toFixed(1)}; ${o}`
|
|
731
|
+
})), n += i - 1;
|
|
732
|
+
}, a = (e, t) => 1 + Math.hypot(t[0] - e[0], t[1] - e[1]) / u, o = (e, t) => ({ points: `${e.join(",")} ${t.join(",")}` });
|
|
733
|
+
for (let { i: t, next: n } of H(e)) if (v) {
|
|
734
|
+
let [n, r] = [P(e, t), P(e, t + 1)], [a, o] = [U[e][t], U[e][t + 1]];
|
|
735
|
+
i({ d: `M${X(n[0])},${X(n[1])} ${De(n, r, a, o)}` }, 1 + Oe(n, r, a, o) / u, t + 2, V(t));
|
|
736
|
+
} else if (_) {
|
|
737
|
+
let r = c(j(e, t)), [l, u] = [[s(t) - T / 2, r], [s(t) + T / 2, r]];
|
|
738
|
+
i(o(l, u), a(l, u), t + 1, V(t));
|
|
739
|
+
let d = c(j(e, t + 1));
|
|
740
|
+
if (n && d !== r) {
|
|
741
|
+
let e = [u[0], d];
|
|
742
|
+
i(o(u, e), a(u, e), t + 2, `--i:${X(z(t + 1) + 1)}; --d:0.25`);
|
|
743
|
+
}
|
|
744
|
+
} else {
|
|
745
|
+
let [n, r] = [P(e, t), P(e, t + 1)];
|
|
746
|
+
i(o(n, r), a(n, r), t + 2, V(t));
|
|
654
747
|
}
|
|
655
|
-
}
|
|
656
|
-
|
|
748
|
+
};
|
|
749
|
+
e && r.forEach((e, t) => G(t)), r.forEach((e, t) => te(t)), _ || (() => {
|
|
750
|
+
let e = r.map((e, t) => x ? Ce(r, t) : {
|
|
657
751
|
shape: "circle",
|
|
658
752
|
open: !1
|
|
659
|
-
})
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
class: b,
|
|
665
|
-
"data-row": n + 1,
|
|
666
|
-
...x && { "data-series": r + 1 },
|
|
667
|
-
style: P(r, n)
|
|
668
|
-
})];
|
|
669
|
-
}) : []), k, l), r.forEach((t, r) => {
|
|
670
|
-
n.forEach((t, n) => {
|
|
671
|
-
if (A(r, n)) return;
|
|
672
|
-
let [i, a] = O(r, n);
|
|
673
|
-
f.appendChild(xe(e[r].shape, i, a, 4 * u, {
|
|
674
|
-
class: y,
|
|
675
|
-
...M[r].attrs,
|
|
676
|
-
"data-marker": e[r].shape,
|
|
677
|
-
...e[r].open && { "data-open": "" },
|
|
678
|
-
"data-row": n + 1,
|
|
679
|
-
style: `${M[r].ink}${P(r, n)}`
|
|
680
|
-
}));
|
|
753
|
+
}), t = (t, n, r) => {
|
|
754
|
+
let [i, a] = P(t, n);
|
|
755
|
+
return we(e[t].shape, i, a, 4 * u, {
|
|
756
|
+
...r,
|
|
757
|
+
style: `${r.style ?? ""}${E(a)}${B(n)}`
|
|
681
758
|
});
|
|
759
|
+
}, i = (e) => n.map((e, t) => t).filter((t) => !O(e, t));
|
|
760
|
+
ee(f, r.flatMap((n, r) => e[r].open ? i(r).map((e) => t(r, e, {
|
|
761
|
+
class: b,
|
|
762
|
+
"data-row": e + 1,
|
|
763
|
+
...x && { "data-series": r + 1 }
|
|
764
|
+
})) : []), k, l), r.forEach((n, r) => {
|
|
765
|
+
for (let n of i(r)) f.appendChild(t(r, n, {
|
|
766
|
+
class: y,
|
|
767
|
+
...F[r].attrs,
|
|
768
|
+
"data-marker": e[r].shape,
|
|
769
|
+
...e[r].open && { "data-open": "" },
|
|
770
|
+
"data-row": n + 1,
|
|
771
|
+
style: F[r].ink
|
|
772
|
+
}));
|
|
682
773
|
});
|
|
683
|
-
}
|
|
684
|
-
let
|
|
774
|
+
})();
|
|
775
|
+
let K = (e, t) => {
|
|
685
776
|
let n = t;
|
|
686
|
-
for (; n < C && !
|
|
777
|
+
for (; n < C && !O(e, n + 1) && D(e, n + 1)?.value === D(e, t)?.value;) n++;
|
|
687
778
|
return n;
|
|
688
|
-
},
|
|
689
|
-
let i =
|
|
690
|
-
if (!i || i.missing || _ && n > 0 && !
|
|
779
|
+
}, ne = (t, n) => {
|
|
780
|
+
let i = D(t, n);
|
|
781
|
+
if (!i || i.missing || _ && n > 0 && !O(t, n - 1) && D(t, n - 1)?.value === i.value || S && !r[t].focus) return "none";
|
|
691
782
|
if (p) return "middle";
|
|
692
783
|
if (!x || S || r.length > 2) return "above";
|
|
693
|
-
let a =
|
|
694
|
-
return !a || a.missing || i.value > a.value || i.value === a.value && t === 0 || e &&
|
|
695
|
-
},
|
|
784
|
+
let a = D(1 - t, n);
|
|
785
|
+
return !a || a.missing || i.value > a.value || i.value === a.value && t === 0 || e && P(t, n)[1] + 7 * u + d > w ? "above" : "below";
|
|
786
|
+
}, q = (e, t) => !p && !_ ? x && !S && r.length > 2 : J(i[e][t]).width * u > (_ ? K(e, t) - t + 1 : 1) * T - 4 * u ? !0 : p && c(M(e, t)) - c(j(e, t)) < d * 1.2;
|
|
696
787
|
i.forEach((e, t) => {
|
|
697
788
|
e.forEach((e, n) => {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
789
|
+
e.style.setProperty("--i", String(X(_ ? (z(n) + z(n + 1)) / 2 : z(n))));
|
|
790
|
+
let r = ne(t, n);
|
|
791
|
+
if (e.dataset.place = r === "above" ? "outside" : r, e.toggleAttribute("data-left-out", r !== "none" && q(t, n)), _ && r !== "none" ? e.dataset.rowEnd = String(K(t, n) + 1) : delete e.dataset.rowEnd, r === "none") return;
|
|
792
|
+
let i = J(e).width * u / 2 + 4 * u, a = s(n);
|
|
793
|
+
_ ? a = (s(n) + s(K(t, n))) / 2 : r === "middle" && n === 0 ? a += i : r === "middle" && n === C && (a -= i);
|
|
794
|
+
let o = c(j(t, n)), d = {
|
|
795
|
+
middle: (c(M(t, n)) - o) / 2,
|
|
796
|
+
above: -7 * u,
|
|
797
|
+
below: 7 * u
|
|
798
|
+
};
|
|
799
|
+
I(e, a, o + d[r], k, l);
|
|
702
800
|
});
|
|
703
801
|
});
|
|
704
|
-
let
|
|
802
|
+
let re = a.map((e, t) => {
|
|
705
803
|
let n = C;
|
|
706
|
-
for (; n > 0 &&
|
|
707
|
-
let [r, i] =
|
|
804
|
+
for (; n > 0 && O(t, n);) n--;
|
|
805
|
+
let [r, i] = P(t, n);
|
|
708
806
|
return {
|
|
709
807
|
name: e,
|
|
710
|
-
x: (_ ? r +
|
|
711
|
-
y: p ? (i + c(
|
|
808
|
+
x: (_ ? r + T / 2 : r) + 10 * u,
|
|
809
|
+
y: p ? (i + c(M(t, n))) / 2 : i
|
|
712
810
|
};
|
|
713
|
-
}),
|
|
714
|
-
for (let e of
|
|
715
|
-
let
|
|
811
|
+
}), ie = (a[0] ? J(a[0]).height : 0) * u;
|
|
812
|
+
for (let e of ge(re, ie)) I(e.name, e.x, e.y, k, l);
|
|
813
|
+
let ae = !e && !p && r.length === 2 && !S ? l - 2 * u : w;
|
|
716
814
|
f.appendChild(N("line", {
|
|
717
815
|
class: o,
|
|
718
816
|
x1: 0,
|
|
719
817
|
x2: s(C) + s(0),
|
|
720
|
-
y1:
|
|
721
|
-
y2:
|
|
818
|
+
y1: ae,
|
|
819
|
+
y2: ae
|
|
722
820
|
}));
|
|
723
821
|
}
|
|
724
|
-
}),
|
|
822
|
+
}), Me = je(!1), Ne = je(!0), Pe = {
|
|
725
823
|
segments: (e) => {
|
|
726
824
|
let t = 0;
|
|
727
825
|
return e.map((e) => {
|
|
@@ -743,7 +841,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
743
841
|
breakable: !0,
|
|
744
842
|
headroom: ({ labelHeight: e, badgeHeight: t, hasAnnotations: n, unit: r }) => e + 6 * r + (n ? t * 1.6 : 0),
|
|
745
843
|
draw({ segments: e, cx: t, y: n, barWidth: r, height: a, unit: c, svg: l, values: u, breakAt: d }) {
|
|
746
|
-
let f = n(0), p =
|
|
844
|
+
let f = n(0), p = fe(u, r, c);
|
|
747
845
|
e.forEach((i, a) => {
|
|
748
846
|
let o = e[a + 1];
|
|
749
847
|
if (!o) return;
|
|
@@ -770,9 +868,9 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
770
868
|
height: Math.max(f, 1),
|
|
771
869
|
style: j("--i", e.slot)
|
|
772
870
|
}));
|
|
773
|
-
let m = u[o], h = !(d !== null && Math.min(e.from, e.to) < d && Math.max(e.from, e.to) > d) && !p &&
|
|
871
|
+
let m = u[o], h = !(d !== null && Math.min(e.from, e.to) < d && Math.max(e.from, e.to) > d) && !p && pe(m, f, c);
|
|
774
872
|
m.dataset.place = h ? "inside" : "outside", m.dataset.kind = e.kind;
|
|
775
|
-
let g = h ? s + f / 2 : e.kind === "down" ? s + f + m.
|
|
873
|
+
let g = h ? s + f / 2 : e.kind === "down" ? s + f + J(m).height * c + 3 * c : s - 3 * c;
|
|
776
874
|
I(m, t(o), g, k, a);
|
|
777
875
|
}), l.appendChild(N("line", {
|
|
778
876
|
class: o,
|
|
@@ -782,12 +880,17 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
782
880
|
y2: f
|
|
783
881
|
}));
|
|
784
882
|
}
|
|
785
|
-
},
|
|
883
|
+
}, Z = {
|
|
786
884
|
enabled: !1,
|
|
787
885
|
log(...t) {
|
|
788
|
-
|
|
886
|
+
Z.enabled && console.log(`[${e}]`, ...t);
|
|
887
|
+
},
|
|
888
|
+
timed(t, n, r) {
|
|
889
|
+
if (!Z.enabled) return r();
|
|
890
|
+
let i = performance.now(), a = r(), o = performance.now() - i, s = n.querySelectorAll("tbody tr").length;
|
|
891
|
+
return o > 50 ? console.warn(`[${e}] ${t} took ${o.toFixed(1)} ms for ${s} rows, more than 50 ms.`, n) : Z.log(`${t} took ${o.toFixed(1)} ms for ${s} rows.`, n), a;
|
|
789
892
|
}
|
|
790
|
-
},
|
|
893
|
+
}, Fe = (e) => {
|
|
791
894
|
let t = (e?.textContent || "").trim(), n = t.match(/^(.*?)(-?\d+(?:[.,]\d+)?)(.*)$/);
|
|
792
895
|
return {
|
|
793
896
|
raw: t,
|
|
@@ -797,9 +900,9 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
797
900
|
missing: !n,
|
|
798
901
|
value: n ? Number.parseFloat(n[2].replace(",", ".")) : 0
|
|
799
902
|
};
|
|
800
|
-
},
|
|
801
|
-
let r = e.querySelector("th"), i = Array.from(e.querySelectorAll("td")).map(
|
|
802
|
-
return i.length || i.push(
|
|
903
|
+
}, Ie = (e, t = "data-i18n") => Array.from(e.querySelectorAll("tbody tr")).map((e, n) => {
|
|
904
|
+
let r = e.querySelector("th"), i = Array.from(e.querySelectorAll("td")).map(Fe);
|
|
905
|
+
return i.length || i.push(Fe(null)), {
|
|
803
906
|
...i[0],
|
|
804
907
|
label: (r?.textContent || "").trim(),
|
|
805
908
|
key: t && r?.getAttribute(t) || null,
|
|
@@ -808,8 +911,8 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
808
911
|
isTotal: e.getAttribute("data-kind") === "total",
|
|
809
912
|
slot: n
|
|
810
913
|
};
|
|
811
|
-
}),
|
|
812
|
-
let r =
|
|
914
|
+
}), Le = (e) => Array.from(e.querySelector("thead tr:last-child")?.children ?? []).slice(1), Re = (e) => e === "dashed" || e === "dotted" ? e : null, ze = (e, t, n = "data-i18n") => {
|
|
915
|
+
let r = Le(e), i = Math.max(1, B(t.map((e) => e.cells.length)));
|
|
813
916
|
return Array.from({ length: i }, (e, t) => {
|
|
814
917
|
let i = r[t];
|
|
815
918
|
return {
|
|
@@ -817,10 +920,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
817
920
|
key: n && i?.getAttribute(n) || null,
|
|
818
921
|
focus: i?.getAttribute("data-kind") === "focus",
|
|
819
922
|
marker: i?.getAttribute("data-marker") ?? null,
|
|
820
|
-
line:
|
|
923
|
+
line: Re(i?.getAttribute("data-line"))
|
|
821
924
|
};
|
|
822
925
|
});
|
|
823
|
-
},
|
|
926
|
+
}, Be = (t, n) => {
|
|
824
927
|
if (!n) return;
|
|
825
928
|
let r = /* @__PURE__ */ new Map();
|
|
826
929
|
for (let i of t) {
|
|
@@ -833,33 +936,40 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
833
936
|
i.querySelectorAll("tbody th").forEach((e, r) => {
|
|
834
937
|
e.getAttribute(n) || e.setAttribute(n, `${t}-row${r + 1}`);
|
|
835
938
|
});
|
|
836
|
-
let a =
|
|
939
|
+
let a = Le(i);
|
|
837
940
|
a.length > 1 && a.forEach((e, r) => {
|
|
838
941
|
e.getAttribute(n) || e.setAttribute(n, `${t}-col${r + 1}`);
|
|
839
|
-
}),
|
|
942
|
+
}), Z?.log?.(`Keys for "${t}" written onto ${i.querySelectorAll("tbody th").length} rows`);
|
|
840
943
|
}
|
|
841
|
-
},
|
|
842
|
-
area:
|
|
843
|
-
bar:
|
|
844
|
-
column:
|
|
845
|
-
donut:
|
|
846
|
-
line:
|
|
847
|
-
waterfall:
|
|
848
|
-
},
|
|
849
|
-
"axis-break":
|
|
850
|
-
trend:
|
|
851
|
-
bracket:
|
|
852
|
-
},
|
|
944
|
+
}, Ve = {
|
|
945
|
+
area: Ne,
|
|
946
|
+
bar: _e,
|
|
947
|
+
column: ve,
|
|
948
|
+
donut: xe,
|
|
949
|
+
line: Me,
|
|
950
|
+
waterfall: Pe
|
|
951
|
+
}, He = {
|
|
952
|
+
"axis-break": z,
|
|
953
|
+
trend: ae,
|
|
954
|
+
bracket: ne
|
|
955
|
+
}, Ue = Object.keys(He), We = (e) => {
|
|
853
956
|
let t = "";
|
|
854
957
|
for (let n = e.previousSibling; n && (t = (n.textContent ?? "") + t, !t.trim()); n = n.previousSibling);
|
|
855
958
|
return t.trim();
|
|
856
|
-
},
|
|
959
|
+
}, Ge = [
|
|
960
|
+
"straight",
|
|
961
|
+
"step",
|
|
962
|
+
"smooth"
|
|
963
|
+
], Ke = (e, t) => {
|
|
964
|
+
let n = e.dataset.chartShape;
|
|
965
|
+
return n && Ge.includes(n) ? n : Ge.includes(t.shape) ? t.shape : "straight";
|
|
966
|
+
}, qe = (e) => {
|
|
857
967
|
for (let t of e.querySelectorAll("br")) {
|
|
858
|
-
if (t.previousElementSibling?.classList.contains("tablechart-sr") || /[.!?:;,…]$/.test(
|
|
968
|
+
if (t.previousElementSibling?.classList.contains("tablechart-sr") || /[.!?:;,…]$/.test(We(t))) continue;
|
|
859
969
|
let e = document.createElement("span");
|
|
860
970
|
e.className = E, e.textContent = ". ", t.before(e);
|
|
861
971
|
}
|
|
862
|
-
},
|
|
972
|
+
}, Je = (e, t, n) => {
|
|
863
973
|
let r = e.querySelector("table");
|
|
864
974
|
if (!r) return null;
|
|
865
975
|
let i = r.querySelector("tfoot [data-chart-total]");
|
|
@@ -870,23 +980,23 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
870
980
|
s && n.langattribute && o.setAttribute(n.langattribute, `${s}-total`);
|
|
871
981
|
let c = a.insertCell();
|
|
872
982
|
return c.setAttribute("data-chart-total", ""), c.dataset.value = t.dataset.value ?? "0", a.prepend(o), c;
|
|
873
|
-
},
|
|
983
|
+
}, Ye = 0, Xe = (e) => {
|
|
874
984
|
let t = e.querySelector(":scope > figcaption");
|
|
875
985
|
if (!t) return;
|
|
876
|
-
|
|
986
|
+
qe(t);
|
|
877
987
|
let n = (e) => e.hasAttribute("aria-label") || e.hasAttribute("aria-labelledby"), r = (e) => {
|
|
878
|
-
t.id || (t.id = `tablechart-caption-${++
|
|
988
|
+
t.id || (t.id = `tablechart-caption-${++Ye}`), e.setAttribute("aria-labelledby", t.id);
|
|
879
989
|
};
|
|
880
990
|
e.tagName === "FIGURE" && !n(e) && r(e);
|
|
881
991
|
let i = e.querySelector("table");
|
|
882
992
|
i && !n(i) && !i.querySelector(":scope > caption") && r(i);
|
|
883
|
-
},
|
|
884
|
-
let s = o ?? (i.getAttribute("data-chart") || "column"), c =
|
|
885
|
-
if (!c) return console.warn(`[${e}] Unknown chart type "${s}". Known types: ${Object.keys(
|
|
886
|
-
let l =
|
|
887
|
-
if (!l.length) return console.warn(`[${e}] A chart has no rows in its table, so there is nothing to draw.`), null;
|
|
888
|
-
|
|
889
|
-
let u =
|
|
993
|
+
}, Ze = (i, a, o = null) => {
|
|
994
|
+
let s = o ?? (i.getAttribute("data-chart") || "column"), c = Ve[s];
|
|
995
|
+
if (!c) return console.warn(`[${e}] Unknown chart type "${s}". Known types: ${Object.keys(Ve).join(", ")}.`), i.setAttribute("data-chart-empty", ""), null;
|
|
996
|
+
let l = Ie(i, a.langattribute);
|
|
997
|
+
if (!l.length) return console.warn(`[${e}] A chart has no rows in its table, so there is nothing to draw.`), i.setAttribute("data-chart-empty", ""), null;
|
|
998
|
+
Xe(i);
|
|
999
|
+
let u = ze(i, l, a.langattribute);
|
|
890
1000
|
u.length > 1 && !c.series && (console.warn(`[${e}] A ${s} chart draws one series; only the first of the table's ${u.length} value columns is used.`), u = u.slice(0, 1));
|
|
891
1001
|
let d = u.length > 1;
|
|
892
1002
|
d && i.style.setProperty("--tablechart-series-count", String(u.length));
|
|
@@ -901,12 +1011,12 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
901
1011
|
focusable: "false"
|
|
902
1012
|
});
|
|
903
1013
|
m.appendChild(h), i.appendChild(m);
|
|
904
|
-
let g = c.centre ? l.filter((e) => !e.isTotal) : l, y = Math.max(0,
|
|
1014
|
+
let g = c.centre ? l.filter((e) => !e.isTotal) : l, y = Math.max(0, B(g.flatMap((e) => e.cells.slice(0, u.length).map((e) => V(e.number))))), b = u.map((e, t) => l.map((e, n) => {
|
|
905
1015
|
let i = e.cells[t] ?? e.cells[0], a = F(r, m);
|
|
906
1016
|
return a.classList.add(...e.classes), a.dataset.value = String(i.value), i.prefix && (a.dataset.prefix = i.prefix), i.suffix && (a.dataset.suffix = i.suffix), i.missing && (a.dataset.missing = i.raw), d && (a.dataset.series = String(t + 1)), a.dataset.row = String(n + 1), a.style.setProperty("--i", String(e.slot)), a;
|
|
907
1017
|
})), S = b[0], C = p && c.totals ? l.map((e, t) => {
|
|
908
1018
|
let n = F(r, m);
|
|
909
|
-
n.classList.add(...e.classes), n.dataset.kind = "total", n.dataset.row = String(t + 1), n.dataset.value = String(
|
|
1019
|
+
n.classList.add(...e.classes), n.dataset.kind = "total", n.dataset.row = String(t + 1), n.dataset.value = String(ce(e, u.length));
|
|
910
1020
|
let i = e.cells[0];
|
|
911
1021
|
return i.prefix && (n.dataset.prefix = i.prefix), i.suffix && (n.dataset.suffix = i.suffix), n.style.setProperty("--i", String(e.slot)), n;
|
|
912
1022
|
}) : [], w = l[l.length - 1], T = u.some((e) => e.focus), E = i.getAttribute("data-chart-legend"), D = d && (E === null ? a.legend || c.legend !== void 0 : E !== "false") ? document.createElement("div") : null;
|
|
@@ -915,8 +1025,8 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
915
1025
|
let n = F(_, D ?? m);
|
|
916
1026
|
D && (n.dataset.place = "legend");
|
|
917
1027
|
let r = c.legend ?? c.swatch;
|
|
918
|
-
if (r && (n.dataset.swatch = r), n.textContent = e.name, !r && i
|
|
919
|
-
let e =
|
|
1028
|
+
if (r && (n.dataset.swatch = r), n.textContent = e.name, !r && Ke(i, a) !== "step") {
|
|
1029
|
+
let e = Ce(u, t);
|
|
920
1030
|
n.dataset.marker = e.shape, n.toggleAttribute("data-open", e.open);
|
|
921
1031
|
}
|
|
922
1032
|
return e.line && !r && (n.dataset.line = e.line), e.key && a.langattribute && n.setAttribute(a.langattribute, e.key), n.dataset.series = String(t + 1), n.style.setProperty("--n", String(t)), n.style.setProperty("--palette", `var(--tablechart-color-${t + 1})`), n.style.setProperty("--m", T && !e.focus ? "1" : "0"), n.style.setProperty("--i", String(w.slot)), n;
|
|
@@ -925,17 +1035,17 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
925
1035
|
let e = l.find((e) => e.isTotal), t = e ? e.value : l.reduce((e, t) => e + Math.abs(t.value), 0);
|
|
926
1036
|
k.dataset.value = String(t), e && (k.dataset.decimals = String(V(e.number)));
|
|
927
1037
|
}
|
|
928
|
-
let A = k && !l.some((e) => e.isTotal) ?
|
|
1038
|
+
let A = k && !l.some((e) => e.isTotal) ? Je(i, k, a) : null, j = c.categories === "beside", M = document.createElement("div");
|
|
929
1039
|
M.className = n, M.setAttribute("aria-hidden", "true"), M.inert = !0, j ? M.dataset.place = "beside" : c.centre && (M.dataset.place = "key"), M.style.setProperty("--tablechart-columns", String(l.length));
|
|
930
1040
|
let P = 0;
|
|
931
|
-
for (let e of l) {
|
|
932
|
-
let
|
|
933
|
-
|
|
1041
|
+
for (let [e, t] of l.entries()) {
|
|
1042
|
+
let n = document.createElement("span");
|
|
1043
|
+
n.classList.add(...t.classes), n.textContent = t.label, t.key && a.langattribute && n.setAttribute(a.langattribute, t.key), c.centre && (n.dataset.kind = t.isTotal ? "total" : "slice", t.isTotal || (n.dataset.slice = String(P + 1), n.style.setProperty("--n", String(P)), n.style.setProperty("--palette", `var(--tablechart-color-${P + 1})`), P += 1)), n.style.setProperty("--i", String(t.slot)), n.dataset.row = String(e + 1), M.appendChild(n);
|
|
934
1044
|
}
|
|
935
1045
|
(j ? m : i).appendChild(M), D && i.appendChild(D);
|
|
936
1046
|
let I = Array.from(i.querySelectorAll("[data-annotation]")).map((t) => {
|
|
937
|
-
let n = t.getAttribute("data-annotation"), r =
|
|
938
|
-
if (!r) return console.warn(`[${e}] Unknown annotation "${n}". Known annotations: ${Object.keys(
|
|
1047
|
+
let n = t.getAttribute("data-annotation"), r = He[n];
|
|
1048
|
+
if (!r) return console.warn(`[${e}] Unknown annotation "${n}". Known annotations: ${Object.keys(He).join(", ")}.`), null;
|
|
939
1049
|
let i = Number.parseInt(t.getAttribute("data-series") ?? "1", 10), a = i >= 1 && i <= u.length ? i - 1 : 0;
|
|
940
1050
|
return i !== a + 1 && console.warn(`[${e}] An annotation reads line ${i}, which the chart does not have; it reads the first.`), {
|
|
941
1051
|
spec: t,
|
|
@@ -945,7 +1055,10 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
945
1055
|
after: l.length
|
|
946
1056
|
};
|
|
947
1057
|
}).filter((e) => e !== null);
|
|
948
|
-
a.animate
|
|
1058
|
+
if (a.animate) {
|
|
1059
|
+
let e = i.getAttribute("data-chart-animate"), t = (e === "up" || e === "across" ? e : a.animate) === "up" && (s === "line" || s === "area");
|
|
1060
|
+
i.setAttribute("data-animate", t ? "up" : "");
|
|
1061
|
+
}
|
|
949
1062
|
let L = {
|
|
950
1063
|
figure: i,
|
|
951
1064
|
plot: m,
|
|
@@ -967,26 +1080,34 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
967
1080
|
annotations: I,
|
|
968
1081
|
checks: []
|
|
969
1082
|
};
|
|
970
|
-
return a.hover && i.getAttribute("data-chart-hover") !== "false" &&
|
|
971
|
-
},
|
|
1083
|
+
return a.hover && i.getAttribute("data-chart-hover") !== "false" && rt(L), tt(L, a), L;
|
|
1084
|
+
}, Qe = (e, t, n, r) => {
|
|
972
1085
|
let i = getComputedStyle(e), a = (i.getPropertyValue(n).trim() || r).match(/^(\d+(?:\.\d+)?)(px|%|em|rem)$/);
|
|
973
1086
|
if (!a) return null;
|
|
974
1087
|
let o = Number(a[1]);
|
|
975
1088
|
return a[2] === "%" ? o / 100 * k : o * (a[2] === "em" ? Number.parseFloat(i.fontSize) : a[2] === "rem" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) : 1) * t;
|
|
976
|
-
},
|
|
1089
|
+
}, $e = (e, t) => Qe(e, t, "--tablechart-bar-max", "60px") ?? Infinity, et = (t, n) => {
|
|
977
1090
|
let { plot: r, svg: i, rows: a, type: o, values: s, series: c, seriesValues: l, names: u, annotations: d } = t, f = r.clientWidth;
|
|
978
1091
|
if (!f) return !1;
|
|
979
1092
|
let p = k / f, m = Number.parseFloat(t.figure.dataset.chartAspect ?? ""), h = k * (m > 0 ? m : o.aspect ?? n.aspect);
|
|
980
1093
|
r.classList.add(w);
|
|
981
|
-
|
|
1094
|
+
for (let e of [...l.flat(), ...t.totals]) delete e.dataset.place;
|
|
1095
|
+
r.style.removeProperty("--tablechart-fit"), re([
|
|
1096
|
+
...l.flat(),
|
|
1097
|
+
...t.totals,
|
|
1098
|
+
...u,
|
|
1099
|
+
...t.categories,
|
|
1100
|
+
...d.map((e) => e.badge)
|
|
1101
|
+
]);
|
|
1102
|
+
let g = (s[0] ? J(s[0]).height : 0) * p, _ = d[0]?.badge ? J(d[0].badge).height * p : 0, v = Math.max(h, Qe(t.figure, p, "--tablechart-min-height", "200px") ?? 0, o.minHeight?.({
|
|
982
1103
|
labelHeight: g,
|
|
983
|
-
nameHeight: Math.max(0,
|
|
1104
|
+
nameHeight: Math.max(0, B(t.categories.map((e) => J(e).height))) * p,
|
|
984
1105
|
unit: p,
|
|
985
1106
|
rows: a.length,
|
|
986
1107
|
series: c.length,
|
|
987
1108
|
stacked: t.stacked
|
|
988
1109
|
}) ?? 0), y = t.stacked ? a.map((e) => {
|
|
989
|
-
let t =
|
|
1110
|
+
let t = ce(e, c.length);
|
|
990
1111
|
return {
|
|
991
1112
|
...e,
|
|
992
1113
|
value: t,
|
|
@@ -1011,11 +1132,11 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1011
1132
|
series: c.length,
|
|
1012
1133
|
focused: c.some((e) => e.focus),
|
|
1013
1134
|
stacked: t.stacked
|
|
1014
|
-
}, C = o.headroom?.(S) ?? g, T = 2 * p + (o.footroom?.(S) ?? 0), E = C, D = t.stacked ? Math.max(
|
|
1135
|
+
}, C = o.headroom?.(S) ?? g, T = 2 * p + (o.footroom?.(S) ?? 0), E = C, D = t.stacked ? Math.max(B(y.map((e) => e.value)), 0) : Math.max(B(x.flatMap((e) => [
|
|
1015
1136
|
e.from,
|
|
1016
1137
|
e.to,
|
|
1017
1138
|
e.value
|
|
1018
|
-
]),
|
|
1139
|
+
])), B(a.flatMap((e) => e.cells.slice(0, c.length).map((e) => e.value)))), O = v - E - T, A = D * 1.02, j = d.find((e) => e.spec.getAttribute("data-annotation") === "axis-break")?.spec, M = (e) => {
|
|
1019
1140
|
let t = Number.parseFloat(j?.getAttribute(e) ?? "");
|
|
1020
1141
|
return Number.isFinite(t) ? t : null;
|
|
1021
1142
|
}, P = M("data-from") ?? M("data-at"), F = M("data-to"), I = null;
|
|
@@ -1030,34 +1151,34 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1030
1151
|
share: s
|
|
1031
1152
|
} : console.warn(`[${e}] This kind of chart cannot break its scale.`);
|
|
1032
1153
|
}
|
|
1033
|
-
let L = I ? I.gap : null,
|
|
1154
|
+
let L = I ? I.gap : null, R = v - T, z = (e) => R - e / A * O;
|
|
1034
1155
|
if (I) {
|
|
1035
1156
|
let { lo: e, hi: t, gap: n, share: r } = I, i = O * r, a = (O - i - 13) / (e + (A - t)), o = i / (t - e);
|
|
1036
|
-
|
|
1157
|
+
z = (r) => r <= e ? R - r * a : r <= n ? R - e * a - (r - e) * o : r <= t ? R - e * a - (r - e) * o - 13 : R - e * a - i - 13 - (r - t) * a;
|
|
1037
1158
|
}
|
|
1038
|
-
let V = u.length ?
|
|
1159
|
+
let V = u.length ? B(u.map((e) => J(e).width)) * p + 12 * p : 0, H = t.categories[0]?.parentElement;
|
|
1039
1160
|
H && (H.style.paddingRight = V ? `${V / k * 100}%` : "");
|
|
1040
1161
|
let U = (k - V) / a.length, W = (e) => (e + .5) * U, G = (e) => e >= 0 && e < a.length ? e : null;
|
|
1041
1162
|
t.rowAt = o.centre ? null : o.categories === "beside" ? (e, t) => G(Math.floor(t * p / (v / a.length))) : (e) => G(Math.floor(e * p / U));
|
|
1042
|
-
let
|
|
1163
|
+
let te = U / k * 100, K = 100 / a.length;
|
|
1043
1164
|
t.rowBox = o.categories === "beside" ? (e) => [
|
|
1044
1165
|
0,
|
|
1045
|
-
e *
|
|
1166
|
+
e * K,
|
|
1046
1167
|
100,
|
|
1047
|
-
|
|
1168
|
+
K
|
|
1048
1169
|
] : (e) => [
|
|
1049
|
-
e *
|
|
1170
|
+
e * te,
|
|
1050
1171
|
0,
|
|
1051
|
-
|
|
1172
|
+
te,
|
|
1052
1173
|
100
|
|
1053
1174
|
], i.setAttribute("viewBox", `0 0 ${k} ${v}`), i.textContent = "", t.checks = [];
|
|
1054
|
-
let
|
|
1175
|
+
let ne = {
|
|
1055
1176
|
rows: a,
|
|
1056
1177
|
segments: x,
|
|
1057
1178
|
cx: W,
|
|
1058
|
-
y:
|
|
1059
|
-
barWidth: Math.min(U * n.barfill,
|
|
1060
|
-
barMax:
|
|
1179
|
+
y: z,
|
|
1180
|
+
barWidth: Math.min(U * n.barfill, $e(t.figure, p)),
|
|
1181
|
+
barMax: $e(t.figure, p),
|
|
1061
1182
|
height: v,
|
|
1062
1183
|
unit: p,
|
|
1063
1184
|
labelHeight: g,
|
|
@@ -1067,7 +1188,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1067
1188
|
labels: t.figure.dataset.chartLabels === "inside" || t.figure.dataset.chartLabels !== "outside" && n.labels === "inside" ? "inside" : "outside",
|
|
1068
1189
|
breakAt: L,
|
|
1069
1190
|
stacked: t.stacked,
|
|
1070
|
-
shape: t.figure
|
|
1191
|
+
shape: Ke(t.figure, n),
|
|
1071
1192
|
totals: t.totals,
|
|
1072
1193
|
svg: i,
|
|
1073
1194
|
plot: r,
|
|
@@ -1080,9 +1201,9 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1080
1201
|
config: n,
|
|
1081
1202
|
checks: t.checks
|
|
1082
1203
|
};
|
|
1083
|
-
o.draw(
|
|
1084
|
-
let
|
|
1085
|
-
|
|
1204
|
+
o.draw(ne);
|
|
1205
|
+
let q = t.categories[0]?.parentElement;
|
|
1206
|
+
q && o.categories !== "beside" && !o.centre && he(q, t.categories.filter((e) => e.offsetParent !== null), (e) => ({
|
|
1086
1207
|
size: e.scrollWidth,
|
|
1087
1208
|
room: e.clientWidth
|
|
1088
1209
|
}), "--tablechart-name-fit");
|
|
@@ -1093,7 +1214,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1093
1214
|
...e.cells[r] ?? e.cells[0]
|
|
1094
1215
|
});
|
|
1095
1216
|
n.type.draw(n.spec, n.badge, {
|
|
1096
|
-
...
|
|
1217
|
+
...ne,
|
|
1097
1218
|
...t.stacked && {
|
|
1098
1219
|
rows: y,
|
|
1099
1220
|
...t.totals.length && { values: t.totals }
|
|
@@ -1113,7 +1234,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1113
1234
|
note: e + 1
|
|
1114
1235
|
});
|
|
1115
1236
|
}
|
|
1116
|
-
return
|
|
1237
|
+
return ee(i, d.flatMap(({ badge: e }) => {
|
|
1117
1238
|
if (!(e instanceof HTMLElement) || !e.offsetWidth) return [];
|
|
1118
1239
|
let t = e.offsetWidth * p, n = e.offsetHeight * p, r = Number.parseFloat(e.style.left) / 100 * k, i = Number.parseFloat(e.style.top) / 100 * v, a = getComputedStyle(e).borderTopLeftRadius, o = a.endsWith("%") ? Number.parseFloat(a) / 100 : null, s = (Number.parseFloat(a) || 0) * p;
|
|
1119
1240
|
return [N("rect", {
|
|
@@ -1129,7 +1250,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1129
1250
|
style: ["--after"].map((t) => e.style.getPropertyValue(t) && `${t}:${e.style.getPropertyValue(t)}`).filter(Boolean).join("; ")
|
|
1130
1251
|
})];
|
|
1131
1252
|
}), k, v), !0;
|
|
1132
|
-
},
|
|
1253
|
+
}, tt = (e, t) => {
|
|
1133
1254
|
let n = [
|
|
1134
1255
|
...e.seriesValues.flat(),
|
|
1135
1256
|
...e.totals,
|
|
@@ -1143,11 +1264,11 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1143
1264
|
}
|
|
1144
1265
|
r.textContent = i + H(Number.parseFloat(r.dataset.value || "0"), r.dataset.decimals ? Number(r.dataset.decimals) : e.decimals, t.locale) + a;
|
|
1145
1266
|
}
|
|
1146
|
-
},
|
|
1267
|
+
}, nt = (e) => {
|
|
1147
1268
|
e.plot.remove(), e.categories[0]?.parentElement?.remove(), e.figure.querySelector(`:scope > .${v}`)?.remove();
|
|
1148
|
-
},
|
|
1269
|
+
}, Q = (e, t) => {
|
|
1149
1270
|
e.figure.classList.toggle(D, t), t || e.plot.removeAttribute("data-pointed");
|
|
1150
|
-
},
|
|
1271
|
+
}, rt = (e) => {
|
|
1151
1272
|
let { plot: t } = e, n = () => [...e.seriesValues.flat(), ...e.totals], r = (e, t) => {
|
|
1152
1273
|
let n = Number(e.dataset.row), r = Number(e.dataset.rowEnd ?? n);
|
|
1153
1274
|
return t >= n && t <= r;
|
|
@@ -1182,25 +1303,25 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1182
1303
|
}), document.addEventListener("pointerdown", (e) => {
|
|
1183
1304
|
t.contains(e.target) || a();
|
|
1184
1305
|
});
|
|
1185
|
-
},
|
|
1306
|
+
}, it = (e) => e === "id" || e === "style" || e.startsWith("data-chart"), at = /^\s*(?:Table)?:\s+/, ot = (e) => e?.tagName === "P" && at.test(e.textContent ?? ""), st = (e) => {
|
|
1186
1307
|
let t = document.createElement("figcaption");
|
|
1187
1308
|
for (let { name: n, value: r } of Array.from(e.attributes)) t.setAttribute(n, r);
|
|
1188
1309
|
let n = e.firstChild;
|
|
1189
|
-
n?.nodeType === Node.TEXT_NODE && (n.textContent = (n.textContent ?? "").replace(
|
|
1310
|
+
n?.nodeType === Node.TEXT_NODE && (n.textContent = (n.textContent ?? "").replace(at, ""), n.textContent || n.remove());
|
|
1190
1311
|
let r = Array.from(e.childNodes), i = r.findIndex((e) => e.nodeName === "BR");
|
|
1191
1312
|
if (t.append(...i === -1 ? r : r.slice(0, i + 1)), i !== -1 && i < r.length - 1) {
|
|
1192
1313
|
let e = document.createElement("span");
|
|
1193
1314
|
e.append(...r.slice(i + 1)), t.append(e);
|
|
1194
1315
|
}
|
|
1195
1316
|
return e.remove(), t;
|
|
1196
|
-
},
|
|
1197
|
-
let t =
|
|
1317
|
+
}, ct = /^\s*([a-z][\w-]*)((?:\s+[\w-]+=[^\s:]+)*)\s*(:\s*|$)/, lt = (e) => {
|
|
1318
|
+
let t = gt(e);
|
|
1198
1319
|
return t?.tagName === "P" ? t : e;
|
|
1199
|
-
},
|
|
1200
|
-
let t =
|
|
1320
|
+
}, ut = (e) => {
|
|
1321
|
+
let t = lt(e).firstChild;
|
|
1201
1322
|
if (t?.nodeType !== Node.TEXT_NODE) return null;
|
|
1202
|
-
let n =
|
|
1203
|
-
if (!n || !
|
|
1323
|
+
let n = ct.exec(t.textContent ?? "");
|
|
1324
|
+
if (!n || !Ue.includes(n[1]) || !n[3] && t.nextSibling) return null;
|
|
1204
1325
|
let r = n[2].trim().split(/\s+/).filter(Boolean).map((e) => e.split("="));
|
|
1205
1326
|
return {
|
|
1206
1327
|
name: n[1],
|
|
@@ -1208,11 +1329,11 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1208
1329
|
text: t,
|
|
1209
1330
|
length: n[0].length
|
|
1210
1331
|
};
|
|
1211
|
-
},
|
|
1332
|
+
}, dt = (e) => {
|
|
1212
1333
|
if (e?.tagName !== "UL" && e?.tagName !== "OL") return null;
|
|
1213
|
-
let t = Array.from(e.children), n = t.map((e) => e.hasAttribute("data-annotation") ? null :
|
|
1334
|
+
let t = Array.from(e.children), n = t.map((e) => e.hasAttribute("data-annotation") ? null : ut(e));
|
|
1214
1335
|
return !t.length || t.some((e, t) => !n[t] && !e.hasAttribute("data-annotation")) ? null : (t.forEach((e, t) => {
|
|
1215
|
-
let r = n[t], i =
|
|
1336
|
+
let r = n[t], i = lt(e);
|
|
1216
1337
|
if (i !== e && i.replaceWith(...i.childNodes), r) {
|
|
1217
1338
|
e.setAttribute("data-annotation", r.name);
|
|
1218
1339
|
for (let [t, n] of r.options) e.setAttribute(`data-${t}`, n);
|
|
@@ -1223,18 +1344,18 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1223
1344
|
t === 0 && e instanceof HTMLElement && e.matches("em, i") ? (n.className = d, n.append(...e.childNodes), e.replaceWith(n)) : e.nodeType === Node.TEXT_NODE && (n.textContent = (e.textContent ?? "").trim(), e.replaceWith(n));
|
|
1224
1345
|
});
|
|
1225
1346
|
}), e.classList.add("chart-annotations"), e);
|
|
1226
|
-
},
|
|
1227
|
-
for (let { name: n, value: r } of Array.from(e.attributes)) (n === "class" ||
|
|
1228
|
-
},
|
|
1229
|
-
let t = e.closest("p"), n =
|
|
1347
|
+
}, ft = (e, t) => {
|
|
1348
|
+
for (let { name: n, value: r } of Array.from(e.attributes)) (n === "class" || it(n)) && (t.setAttribute(n, r), e.removeAttribute(n));
|
|
1349
|
+
}, pt = (e) => e.map((e) => {
|
|
1350
|
+
let t = e.closest("p"), n = ot(t) ? t : e;
|
|
1230
1351
|
if (n.tagName !== "TABLE" && n.tagName !== "P") return n;
|
|
1231
1352
|
let r = document.createElement("div");
|
|
1232
|
-
|
|
1233
|
-
let i = n.tagName === "TABLE" ? n : null, a = n.previousElementSibling, o = n.nextElementSibling, s = i ?
|
|
1353
|
+
ft(e, r), e.classList.length || e.removeAttribute("class");
|
|
1354
|
+
let i = n.tagName === "TABLE" ? n : null, a = n.previousElementSibling, o = n.nextElementSibling, s = i ? ot(a) ? a : ot(o) ? o : null : n;
|
|
1234
1355
|
i && s === o && (o = o?.nextElementSibling ?? null);
|
|
1235
|
-
let c = o?.classList.contains("chart-annotations") ? o :
|
|
1236
|
-
return n.replaceWith(r), s && r.append(
|
|
1237
|
-
}),
|
|
1356
|
+
let c = o?.classList.contains("chart-annotations") ? o : dt(o);
|
|
1357
|
+
return n.replaceWith(r), s && r.append(st(s)), i && r.append(i), c && r.append(c), Z?.log?.(`A ${i ? "table" : "caption"} with chart attributes was wrapped in a figure of its own`), r;
|
|
1358
|
+
}), mt = (e, t = []) => {
|
|
1238
1359
|
let n = document.createElement("table");
|
|
1239
1360
|
if (t.length) {
|
|
1240
1361
|
let e = n.createTHead().insertRow();
|
|
@@ -1253,7 +1374,7 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1253
1374
|
for (let n of t.values ?? [t.value ?? null]) e.insertCell().textContent = n === null ? "" : String(n);
|
|
1254
1375
|
}
|
|
1255
1376
|
return n;
|
|
1256
|
-
},
|
|
1377
|
+
}, ht = async (t) => {
|
|
1257
1378
|
await Promise.all(t.filter((e) => e.hasAttribute("data-chart-src")).map(async (t) => {
|
|
1258
1379
|
let n = t.getAttribute("data-chart-src");
|
|
1259
1380
|
for (let e of t.querySelectorAll("table")) e.remove();
|
|
@@ -1262,17 +1383,17 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1262
1383
|
if (!e.ok) throw Error(`${e.status} ${e.statusText}`);
|
|
1263
1384
|
let r = await e.json(), i = Array.isArray(r) ? r : r?.rows;
|
|
1264
1385
|
if (!Array.isArray(i)) throw Error("no array of rows in it");
|
|
1265
|
-
let a = Array.isArray(r?.series) ? r.series.map(String) : [], o = t.querySelector(":scope > figcaption"), s =
|
|
1266
|
-
o ? o.after(s) : t.prepend(s),
|
|
1386
|
+
let a = Array.isArray(r?.series) ? r.series.map(String) : [], o = t.querySelector(":scope > figcaption"), s = mt(i, a);
|
|
1387
|
+
o ? o.after(s) : t.prepend(s), Z?.log?.(`Read ${i.length} rows from "${n}"`);
|
|
1267
1388
|
} catch (t) {
|
|
1268
1389
|
let r = window.location.protocol === "file:";
|
|
1269
1390
|
console.warn(`[${e}] Could not read the chart data in "${n}": ${t.message}.` + (r ? " A page opened from the file system cannot fetch files; open the page from a server instead." : ""));
|
|
1270
1391
|
}
|
|
1271
1392
|
}));
|
|
1272
|
-
},
|
|
1393
|
+
}, gt = (e) => {
|
|
1273
1394
|
let t = Array.from(e.childNodes).filter((e) => e.nodeType === Node.ELEMENT_NODE || e.nodeType === Node.TEXT_NODE && e.textContent?.trim());
|
|
1274
1395
|
return t.length === 1 && t[0] instanceof HTMLElement ? t[0] : null;
|
|
1275
|
-
},
|
|
1396
|
+
}, _t = "strong, b, span.total", vt = (e) => {
|
|
1276
1397
|
for (let t of e) {
|
|
1277
1398
|
for (let e of t.querySelectorAll("tbody tr")) {
|
|
1278
1399
|
let t = e.cells[0];
|
|
@@ -1280,28 +1401,31 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1280
1401
|
let n = document.createElement("th");
|
|
1281
1402
|
for (let { name: e, value: r } of Array.from(t.attributes)) n.setAttribute(e, r);
|
|
1282
1403
|
n.append(...t.childNodes), t.replaceWith(n);
|
|
1283
|
-
for (let t =
|
|
1404
|
+
for (let t = gt(n); t?.matches(_t); t = gt(n)) e.dataset.kind = "total", t.replaceWith(...t.childNodes);
|
|
1284
1405
|
}
|
|
1285
1406
|
let e = Array.from(t.querySelector("thead tr:last-child")?.children ?? []);
|
|
1286
|
-
for (let t of e.slice(1)) for (let e =
|
|
1407
|
+
for (let t of e.slice(1)) for (let e = gt(t); e?.matches(_t); e = gt(t)) t.setAttribute("data-kind", "focus"), e.replaceWith(...e.childNodes);
|
|
1287
1408
|
}
|
|
1288
|
-
},
|
|
1289
|
-
|
|
1409
|
+
}, yt = "data-chart-made", bt = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches, xt = (e) => new Promise((t) => setTimeout(t, e)), St = (e, t) => {
|
|
1410
|
+
let n = Number.parseFloat(e.dataset.chartEntrance ?? ""), r = Number.isFinite(n) ? n : t.entrance;
|
|
1411
|
+
return Math.min(Math.max(r, 0), 1);
|
|
1412
|
+
}, Ct = async (e, t) => {
|
|
1413
|
+
if (bt()) return;
|
|
1290
1414
|
await new Promise(requestAnimationFrame);
|
|
1291
|
-
let
|
|
1292
|
-
for (let
|
|
1293
|
-
let
|
|
1294
|
-
for (let e of
|
|
1295
|
-
let
|
|
1296
|
-
if (!
|
|
1297
|
-
let
|
|
1298
|
-
|
|
1415
|
+
let n = e.getAnimations().filter((e) => e instanceof CSSAnimation);
|
|
1416
|
+
for (let t = e.parentElement; t && t !== document.body; t = t.parentElement) n.push(...t.getAnimations());
|
|
1417
|
+
let r = 0;
|
|
1418
|
+
for (let e of n) {
|
|
1419
|
+
let n = e.effect?.getComputedTiming(), i = Number(n?.activeDuration ?? 0);
|
|
1420
|
+
if (!n || !Number.isFinite(i)) continue;
|
|
1421
|
+
let a = Number(n.delay ?? 0) + i * t;
|
|
1422
|
+
r = Math.max(r, a - Number(e.currentTime ?? 0));
|
|
1299
1423
|
}
|
|
1300
|
-
|
|
1301
|
-
},
|
|
1424
|
+
r > 0 && await xt(r);
|
|
1425
|
+
}, wt = (e) => {
|
|
1302
1426
|
for (let t = e; t && t !== document.body; t = t.parentElement) if (getComputedStyle(t).opacity === "0") return t;
|
|
1303
1427
|
return null;
|
|
1304
|
-
},
|
|
1428
|
+
}, Tt = (e) => new Promise((t) => {
|
|
1305
1429
|
let n = ["animationstart", "transitionrun"], r = () => {
|
|
1306
1430
|
for (let e of n) document.removeEventListener(e, i, !0);
|
|
1307
1431
|
a.disconnect(), t();
|
|
@@ -1315,85 +1439,85 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1315
1439
|
attributes: !0,
|
|
1316
1440
|
attributeFilter: ["class", "style"]
|
|
1317
1441
|
});
|
|
1318
|
-
}),
|
|
1319
|
-
|
|
1320
|
-
for (let e of
|
|
1442
|
+
}), Et = /* @__PURE__ */ new Set(), $ = null, Dt = (e) => {
|
|
1443
|
+
Et.add(e), !$ && ($ = new MutationObserver(() => {
|
|
1444
|
+
for (let e of Et) e.relabel();
|
|
1321
1445
|
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
1322
|
-
for (let e of
|
|
1446
|
+
for (let e of Et) e.refresh();
|
|
1323
1447
|
}));
|
|
1324
1448
|
}), $.observe(document.documentElement, {
|
|
1325
1449
|
attributes: !0,
|
|
1326
1450
|
attributeFilter: ["lang"]
|
|
1327
1451
|
}));
|
|
1328
|
-
},
|
|
1329
|
-
|
|
1330
|
-
},
|
|
1452
|
+
}, Ot = (e) => {
|
|
1453
|
+
Et.delete(e), !(Et.size || !$) && ($.disconnect(), $ = null);
|
|
1454
|
+
}, kt = ["column", "bar"], At = (e) => {
|
|
1331
1455
|
let t = e.getAttribute("data-chart") || "column";
|
|
1332
|
-
if (!
|
|
1456
|
+
if (!kt.includes(t)) return null;
|
|
1333
1457
|
let n = getComputedStyle(e).getPropertyValue("--tablechart-type").trim();
|
|
1334
|
-
return
|
|
1335
|
-
},
|
|
1336
|
-
let n = e, r =
|
|
1337
|
-
if (!t.animate) return
|
|
1458
|
+
return kt.includes(n) ? n : t;
|
|
1459
|
+
}, jt = (e, t) => {
|
|
1460
|
+
let n = e, r = At(n.figure), i = null, a = !1, o = !1, s = async () => {
|
|
1461
|
+
if (!t.animate) return Q(n, !0);
|
|
1338
1462
|
let e = n.figure.classList.contains("is-shown");
|
|
1339
1463
|
if (a && i !== null && !e && !o) {
|
|
1340
1464
|
o = !0;
|
|
1341
|
-
let e =
|
|
1342
|
-
e && await
|
|
1343
|
-
} else !a && t.replay && e &&
|
|
1465
|
+
let e = bt() ? null : wt(n.figure);
|
|
1466
|
+
e && await Tt(e), await Ct(n.figure, St(n.figure, t)), o = !1, (a || !t.replay) && Q(n, !0);
|
|
1467
|
+
} else !a && t.replay && e && Q(n, !1);
|
|
1344
1468
|
}, c = () => {
|
|
1345
|
-
let e =
|
|
1469
|
+
let e = At(n.figure);
|
|
1346
1470
|
if (!e || e === r) return;
|
|
1347
|
-
let a =
|
|
1348
|
-
a && (
|
|
1471
|
+
let a = Z.timed("Building", n.figure, () => Ze(n.figure, t, e));
|
|
1472
|
+
a && (nt(n), n = a, r = e, i = null);
|
|
1349
1473
|
}, l = () => {
|
|
1350
1474
|
c();
|
|
1351
1475
|
let e = n.plot.clientWidth;
|
|
1352
|
-
!e || e === i ||
|
|
1476
|
+
!e || e === i || Z.timed("Layout", n.figure, () => et(n, t)) && (i = e, s());
|
|
1353
1477
|
}, u = !1, d = new ResizeObserver(() => {
|
|
1354
1478
|
u || (u = !0, requestAnimationFrame(() => {
|
|
1355
1479
|
u = !1, l();
|
|
1356
1480
|
}));
|
|
1357
1481
|
}), f = new IntersectionObserver((e) => {
|
|
1358
1482
|
for (let t of e) a = t.isIntersecting, s();
|
|
1359
|
-
}, { threshold: t.threshold }), p = () =>
|
|
1483
|
+
}, { threshold: t.threshold }), p = () => Q(n, !0), m = () => {
|
|
1360
1484
|
i = null, l();
|
|
1361
1485
|
}, h = {
|
|
1362
|
-
relabel: () =>
|
|
1486
|
+
relabel: () => tt(n, t),
|
|
1363
1487
|
refresh: m
|
|
1364
1488
|
};
|
|
1365
|
-
c(), l(), d.observe(n.figure), f.observe(n.figure), window.addEventListener("beforeprint", p),
|
|
1489
|
+
c(), l(), d.observe(n.figure), f.observe(n.figure), window.addEventListener("beforeprint", p), Dt(h);
|
|
1366
1490
|
let g = {
|
|
1367
1491
|
figure: n.figure,
|
|
1368
1492
|
refresh: m,
|
|
1369
1493
|
destroy() {
|
|
1370
|
-
d.disconnect(), f.disconnect(), window.removeEventListener("beforeprint", p),
|
|
1494
|
+
d.disconnect(), f.disconnect(), window.removeEventListener("beforeprint", p), Ot(h), n.figure.tablechart === g && delete n.figure.tablechart;
|
|
1371
1495
|
}
|
|
1372
1496
|
};
|
|
1373
1497
|
return n.figure.tablechart = g, g;
|
|
1374
|
-
},
|
|
1375
|
-
let n =
|
|
1376
|
-
return await
|
|
1377
|
-
},
|
|
1378
|
-
let n =
|
|
1379
|
-
return n ? (e.setAttribute(
|
|
1380
|
-
},
|
|
1498
|
+
}, Mt = async (e, t) => {
|
|
1499
|
+
let n = pt(e.filter((e) => !e.hasAttribute(yt)));
|
|
1500
|
+
return await ht(n), vt(n), Be(n, t.langattribute), n;
|
|
1501
|
+
}, Nt = (e, t) => {
|
|
1502
|
+
let n = Z.timed("Building", e, () => Ze(e, t));
|
|
1503
|
+
return n ? (e.setAttribute(yt, ""), jt(n, t)) : null;
|
|
1504
|
+
}, Pt = async (e, t = {}) => {
|
|
1381
1505
|
if (e.tablechart) return e.tablechart;
|
|
1382
1506
|
let n = {
|
|
1383
1507
|
...A,
|
|
1384
1508
|
...t
|
|
1385
1509
|
};
|
|
1386
|
-
n.debug && (
|
|
1387
|
-
let [r] = await
|
|
1388
|
-
return r ?
|
|
1389
|
-
},
|
|
1510
|
+
n.debug && (Z.enabled = !0);
|
|
1511
|
+
let [r] = await Mt([e], n);
|
|
1512
|
+
return r ? Nt(r, n) : null;
|
|
1513
|
+
}, Ft = async (e = {}, t = document) => {
|
|
1390
1514
|
let n = {
|
|
1391
1515
|
...A,
|
|
1392
1516
|
...e
|
|
1393
1517
|
};
|
|
1394
|
-
n.debug && (
|
|
1395
|
-
let r = (await
|
|
1396
|
-
return
|
|
1518
|
+
n.debug && (Z.enabled = !0);
|
|
1519
|
+
let r = (await Mt(Array.from(t.querySelectorAll(n.selector)), n)).map((e) => Nt(e, n)).filter((e) => e !== null);
|
|
1520
|
+
return Z.log(`Made ${r.length} chart(s).`), {
|
|
1397
1521
|
charts: r,
|
|
1398
1522
|
refresh: () => {
|
|
1399
1523
|
for (let e of r) e.refresh();
|
|
@@ -1404,4 +1528,4 @@ var e = "tablechart", t = "tablechart-plot", n = "tablechart-categories", r = "t
|
|
|
1404
1528
|
};
|
|
1405
1529
|
};
|
|
1406
1530
|
//#endregion
|
|
1407
|
-
export {
|
|
1531
|
+
export { D as _, pt as a, Ze as c, Q as d, nt as f, O as g, t as h, Mt as i, et as l, w as m, St as n, ht as o, Be as p, Ft as r, vt as s, Pt as t, tt as u, A as v };
|