kanto-ds 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/chunks/defaults-DKzFsNbv.js +57 -0
- package/dist/chunks/defaults-DKzFsNbv.js.map +1 -0
- package/dist/chunks/form-control-CxjBTt1c.js.map +1 -1
- package/dist/chunks/kt-element-B_jjQDhg.js +38 -0
- package/dist/chunks/kt-element-B_jjQDhg.js.map +1 -0
- package/dist/chunks/{listbox-CUXYn_3S.js → listbox-Sm3nvsC6.js} +5 -5
- package/dist/chunks/{listbox-CUXYn_3S.js.map → listbox-Sm3nvsC6.js.map} +1 -1
- package/dist/components/core/kt-avatar/kt-avatar.js +9 -6
- package/dist/components/core/kt-avatar/kt-avatar.js.map +1 -1
- package/dist/components/core/kt-badge/kt-badge.js +17 -17
- package/dist/components/core/kt-badge/kt-badge.js.map +1 -1
- package/dist/components/core/kt-button/kt-button.d.ts +7 -0
- package/dist/components/core/kt-button/kt-button.js +68 -60
- package/dist/components/core/kt-button/kt-button.js.map +1 -1
- package/dist/components/core/kt-card/kt-card.js +1 -1
- package/dist/components/core/kt-code/kt-code.js +12 -12
- package/dist/components/core/kt-code/kt-code.js.map +1 -1
- package/dist/components/core/kt-icon/kt-icon.js +2 -2
- package/dist/components/core/kt-kbd/kt-kbd.js +14 -14
- package/dist/components/core/kt-kbd/kt-kbd.js.map +1 -1
- package/dist/components/core/kt-split-button/kt-split-button.d.ts +112 -0
- package/dist/components/core/kt-split-button/kt-split-button.js +262 -0
- package/dist/components/core/kt-split-button/kt-split-button.js.map +1 -0
- package/dist/components/data/kt-chart/cartesian.d.ts +62 -0
- package/dist/components/data/kt-chart/geometry.d.ts +41 -0
- package/dist/components/data/kt-chart/kt-chart.d.ts +79 -35
- package/dist/components/data/kt-chart/kt-chart.js +1200 -213
- package/dist/components/data/kt-chart/kt-chart.js.map +1 -1
- package/dist/components/data/kt-chart/model.d.ts +38 -0
- package/dist/components/data/kt-chart/point.d.ts +56 -0
- package/dist/components/data/kt-chart/radial.d.ts +60 -0
- package/dist/components/data/kt-chart/scale.d.ts +37 -0
- package/dist/components/data/kt-meter/kt-meter.js +1 -1
- package/dist/components/data/kt-pagination/kt-pagination.js +1 -1
- package/dist/components/data/kt-stat/kt-stat.js +5 -5
- package/dist/components/data/kt-stat/kt-stat.js.map +1 -1
- package/dist/components/data/kt-table/kt-table.js +2 -2
- package/dist/components/data/kt-table/kt-table.js.map +1 -1
- package/dist/components/data/kt-timeline/kt-timeline.js +1 -1
- package/dist/components/feedback/kt-alert/kt-alert.js +26 -26
- package/dist/components/feedback/kt-alert/kt-alert.js.map +1 -1
- package/dist/components/feedback/kt-empty-state/kt-empty-state.js +1 -1
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +2 -2
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js.map +1 -1
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js +1 -1
- package/dist/components/feedback/kt-toast/kt-toast.js +22 -22
- package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -1
- package/dist/components/feedback/kt-toast-container/kt-toast-container.js +1 -1
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js +1 -1
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.d.ts +11 -1
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +69 -36
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -1
- package/dist/components/forms/kt-form/kt-form.js +1 -1
- package/dist/components/forms/kt-input/kt-input.js +95 -91
- package/dist/components/forms/kt-input/kt-input.js.map +1 -1
- package/dist/components/forms/kt-input-menu/kt-input-menu.d.ts +10 -1
- package/dist/components/forms/kt-input-menu/kt-input-menu.js +83 -53
- package/dist/components/forms/kt-input-menu/kt-input-menu.js.map +1 -1
- package/dist/components/forms/kt-label-input/kt-label-input.js +2 -2
- package/dist/components/forms/kt-label-input/kt-label-input.js.map +1 -1
- package/dist/components/forms/kt-select/kt-select.js +3 -3
- package/dist/components/forms/kt-select/kt-select.js.map +1 -1
- package/dist/components/forms/kt-textarea/kt-textarea.js +15 -13
- package/dist/components/forms/kt-textarea/kt-textarea.js.map +1 -1
- package/dist/components/forms/kt-toggle/kt-toggle.js +8 -7
- package/dist/components/forms/kt-toggle/kt-toggle.js.map +1 -1
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +1 -1
- package/dist/components/navigation/kt-header/kt-header.js +1 -1
- package/dist/components/navigation/kt-page-header/kt-page-header.js +18 -18
- package/dist/components/navigation/kt-page-header/kt-page-header.js.map +1 -1
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.d.ts +10 -1
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +88 -62
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js.map +1 -1
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +5 -5
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js.map +1 -1
- package/dist/components/navigation/kt-tabs/kt-tabs.js +1 -1
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +3 -3
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js.map +1 -1
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +1 -1
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js +1 -1
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +41 -25
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js.map +1 -1
- package/dist/components/overlays/kt-dropdown/kt-dropdown.d.ts +16 -0
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js +95 -60
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -1
- package/dist/components/overlays/kt-modal/kt-modal.js +12 -10
- package/dist/components/overlays/kt-modal/kt-modal.js.map +1 -1
- package/dist/components/overlays/kt-side-panel/kt-side-panel.js +1 -1
- package/dist/custom-elements.json +11791 -0
- package/dist/icons/index.js +7 -34
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +89 -87
- package/dist/index.js.map +1 -1
- package/dist/internal/form-control.d.ts +7 -2
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.js +176 -162
- package/dist/react/index.js.map +1 -1
- package/dist/tokens/README.md +7 -3
- package/dist/tokens/colors.css +24 -5
- package/dist/tokens/theme-light.css +18 -0
- package/dist/vscode.css-custom-data.json +154 -0
- package/dist/vscode.html-custom-data.json +1136 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +8 -7
- package/dist/vue/index.js.map +1 -1
- package/dist/web-types.json +3186 -0
- package/package.json +25 -6
- package/dist/chunks/kt-element-CcMLO5e8.js +0 -28
- package/dist/chunks/kt-element-CcMLO5e8.js.map +0 -1
- package/dist/chunks/registry-X4LS9J5K.js +0 -30
- package/dist/chunks/registry-X4LS9J5K.js.map +0 -1
|
@@ -1,21 +1,591 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { query as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return
|
|
1
|
+
import { svg as b, nothing as A, css as gt, html as G } from "lit";
|
|
2
|
+
import { query as vt, state as tt, property as B } from "lit/decorators.js";
|
|
3
|
+
import { classMap as kt } from "lit/directives/class-map.js";
|
|
4
|
+
import { K as rt, d as wt } from "../../../chunks/kt-element-B_jjQDhg.js";
|
|
5
|
+
import { u as Mt, e as nt } from "../../../chunks/events-Bjl5Zmmq.js";
|
|
6
|
+
function At(s) {
|
|
7
|
+
const t = Math.floor(Math.log10(s)), e = s / 10 ** t;
|
|
8
|
+
return (e < 1.5 ? 1 : e < 3 ? 2 : e < 7 ? 5 : 10) * 10 ** t;
|
|
9
|
+
}
|
|
10
|
+
function at(s, t, e) {
|
|
11
|
+
if (t === s) {
|
|
12
|
+
const c = Math.abs(s) || 1;
|
|
13
|
+
s -= c, t += c;
|
|
14
|
+
}
|
|
15
|
+
const a = At((t - s) / Math.max(1, e - 1)), o = Math.max(0, -Math.floor(Math.log10(a))), i = (c) => Number(c.toFixed(o)) || 0, n = i(Math.floor(s / a) * a), r = i(Math.ceil(t / a) * a), h = [];
|
|
16
|
+
for (let c = 0; n + c * a <= r + a / 2; c += 1)
|
|
17
|
+
h.push(i(n + c * a));
|
|
18
|
+
return { min: n, max: r, step: a, values: h };
|
|
19
|
+
}
|
|
20
|
+
function St(s, t, { includeZero: e }) {
|
|
21
|
+
const a = t.flat();
|
|
22
|
+
for (const r of s) {
|
|
23
|
+
const h = Math.max(0, ...r.map((c) => c.length));
|
|
24
|
+
for (let c = 0; c < h; c += 1) {
|
|
25
|
+
let l = 0, d = 0;
|
|
26
|
+
for (const u of r) {
|
|
27
|
+
const m = u[c] ?? 0;
|
|
28
|
+
m >= 0 ? l += m : d += m;
|
|
29
|
+
}
|
|
30
|
+
a.push(l, d);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const o = a.filter(Number.isFinite);
|
|
34
|
+
if (o.length === 0) return { lo: 0, hi: 1 };
|
|
35
|
+
let i = Math.min(...o), n = Math.max(...o);
|
|
36
|
+
return e && (i = Math.min(i, 0), n = Math.max(n, 0)), { lo: i, hi: n };
|
|
37
|
+
}
|
|
38
|
+
function Y(s, t, e, a) {
|
|
39
|
+
const o = at(a.min ?? s, a.max ?? t, e), i = a.min ?? o.min, n = a.max ?? o.max;
|
|
40
|
+
return n <= i ? o : {
|
|
41
|
+
min: i,
|
|
42
|
+
max: n,
|
|
43
|
+
step: o.step,
|
|
44
|
+
values: o.values.filter((r) => r >= i && r <= n)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function I(s, t, e, a) {
|
|
48
|
+
return e + (s - t.min) / (t.max - t.min) * (a - e);
|
|
49
|
+
}
|
|
50
|
+
function F(s, t) {
|
|
51
|
+
return Math.min(6, Math.max(3, Math.round(s / t)));
|
|
52
|
+
}
|
|
53
|
+
const U = Math.PI * 2, R = (s) => Math.round(s * 100) / 100 || 0, P = ([s, t]) => `${R(s)},${R(t)}`;
|
|
54
|
+
function H(s, t = !0) {
|
|
55
|
+
return s.map((e, a) => `${a === 0 && t ? "M" : "L"}${P(e)}`).join(" ");
|
|
56
|
+
}
|
|
57
|
+
function Lt(s) {
|
|
58
|
+
const t = s.length;
|
|
59
|
+
if (t < 3) return [];
|
|
60
|
+
const e = s.slice(0, -1).map(([o, i], n) => {
|
|
61
|
+
const [r, h] = s[n + 1];
|
|
62
|
+
return r === o ? 0 : (h - i) / (r - o);
|
|
63
|
+
}), a = s.map((o, i) => {
|
|
64
|
+
if (i === 0) return e[0];
|
|
65
|
+
if (i === t - 1) return e[t - 2];
|
|
66
|
+
const n = e[i - 1], r = e[i];
|
|
67
|
+
return n * r <= 0 ? 0 : (n + r) / 2;
|
|
68
|
+
});
|
|
69
|
+
return e.forEach((o, i) => {
|
|
70
|
+
if (o === 0) {
|
|
71
|
+
a[i] = 0, a[i + 1] = 0;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const n = a[i] / o, r = a[i + 1] / o, h = n * n + r * r;
|
|
75
|
+
if (h > 9) {
|
|
76
|
+
const c = 3 / Math.sqrt(h);
|
|
77
|
+
a[i] = c * n * o, a[i + 1] = c * r * o;
|
|
78
|
+
}
|
|
79
|
+
}), e.map((o, i) => {
|
|
80
|
+
const n = s[i], r = s[i + 1], h = (r[0] - n[0]) / 3;
|
|
81
|
+
return {
|
|
82
|
+
from: n,
|
|
83
|
+
c1: [n[0] + h, n[1] + a[i] * h],
|
|
84
|
+
c2: [r[0] - h, r[1] - a[i + 1] * h],
|
|
85
|
+
to: r
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function Pt(s, t = !0) {
|
|
90
|
+
return s.length < 3 ? H(s, t) : [
|
|
91
|
+
t ? `M${P(s[0])}` : `L${P(s[0])}`,
|
|
92
|
+
...Lt(s).map(({ c1: a, c2: o, to: i }) => `C${P(a)} ${P(o)} ${P(i)}`)
|
|
93
|
+
].join(" ");
|
|
94
|
+
}
|
|
95
|
+
function T(s, t, e, a) {
|
|
96
|
+
return [s + e * Math.sin(a), t - e * Math.cos(a)];
|
|
97
|
+
}
|
|
98
|
+
function Ct(s, t, e, a, o, i) {
|
|
99
|
+
const n = i - o;
|
|
100
|
+
if (n <= 0 || a <= 0) return "";
|
|
101
|
+
if (n >= U - 1e-6) {
|
|
102
|
+
const l = (d, u) => {
|
|
103
|
+
const m = T(s, t, d, 0), y = T(s, t, d, Math.PI), k = `A${R(d)},${R(d)} 0 1 ${u}`;
|
|
104
|
+
return `M${P(m)} ${k} ${P(y)} ${k} ${P(m)} Z`;
|
|
105
|
+
};
|
|
106
|
+
return e > 0 ? `${l(a, 1)} ${l(e, 0)}` : l(a, 1);
|
|
107
|
+
}
|
|
108
|
+
const r = n > Math.PI ? 1 : 0, h = `A${R(a)},${R(a)} 0 ${r} 1 ${P(T(s, t, a, i))}`;
|
|
109
|
+
if (e <= 0)
|
|
110
|
+
return `M${P([s, t])} L${P(T(s, t, a, o))} ${h} Z`;
|
|
111
|
+
const c = `A${R(e)},${R(e)} 0 ${r} 0 ${P(T(s, t, e, o))}`;
|
|
112
|
+
return `M${P(T(s, t, a, o))} ${h} L${P(T(s, t, e, i))} ${c} Z`;
|
|
113
|
+
}
|
|
114
|
+
function lt(s, t, e, a, o, i) {
|
|
115
|
+
const r = Math.max(
|
|
116
|
+
0,
|
|
117
|
+
i === "top" || i === "bottom" ? Math.min(o, e / 2, a) : Math.min(o, a / 2, e)
|
|
118
|
+
), [h, c, l, d] = [s, t, s + e, t + a], u = (y) => `A${R(r)},${R(r)} 0 0 1 ${P(y)}`, m = (y) => `L${P(y)}`;
|
|
119
|
+
if (i === "none" || r === 0)
|
|
120
|
+
return `M${P([h, c])} ${m([l, c])} ${m([l, d])} ${m([h, d])} Z`;
|
|
121
|
+
switch (i) {
|
|
122
|
+
case "top":
|
|
123
|
+
return `M${P([h, d])} ${m([h, c + r])} ${u([h + r, c])} ${m([l - r, c])} ${u([l, c + r])} ${m([l, d])} Z`;
|
|
124
|
+
case "bottom":
|
|
125
|
+
return `M${P([h, c])} ${m([l, c])} ${m([l, d - r])} ${u([l - r, d])} ${m([h + r, d])} ${u([h, d - r])} Z`;
|
|
126
|
+
case "right":
|
|
127
|
+
return `M${P([h, c])} ${m([l - r, c])} ${u([l, c + r])} ${m([l, d - r])} ${u([l - r, d])} ${m([h, d])} Z`;
|
|
128
|
+
case "left":
|
|
129
|
+
return `M${P([l, c])} ${m([l, d])} ${m([h + r, d])} ${u([h, d - r])} ${m([h, c + r])} ${u([h + r, c])} Z`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const D = { top: 12, right: 8, bottom: 24 }, W = 12, ct = { vertical: 48, horizontal: 96 }, N = (s) => s?.values ?? [];
|
|
133
|
+
function Ot(s) {
|
|
134
|
+
const { series: t, hidden: e, labels: a, measure: o, format: i, noAxis: n, width: r, height: h } = s, c = t.map((v) => v.type ?? s.type), l = t.map((v, O) => O).filter((v) => !e.has(v)), d = l.map((v) => c[v]), u = Math.max(a.length, 0, ...t.map((v) => N(v).length)), m = d.length > 0 ? d.includes("bar") : s.type === "bar", y = s.horizontal && m && (d.length === 0 || d.every((v) => v === "bar")), k = (v) => l.filter((O) => c[O] === v).map((O) => N(t[O])), f = s.stacked ? [k("bar"), k("area")].filter((v) => v.length) : [], g = s.stacked ? k("line") : l.map((v) => N(t[v])), $ = d.length > 0 ? d.some((v) => v !== "line") : s.type !== "line", { lo: _, hi: w } = St(f, g, { includeZero: $ }), p = { min: s.min, max: s.max };
|
|
135
|
+
if (!y) {
|
|
136
|
+
const v = Math.max(0, h - D.top - D.bottom), O = Y(_, w, F(v, ct.vertical), p), K = n ? 0 : Math.max(0, ...O.values.map((yt) => o(i(yt)))), it = n ? 4 : Math.ceil(K) + W;
|
|
137
|
+
return {
|
|
138
|
+
box: {
|
|
139
|
+
x: it,
|
|
140
|
+
y: D.top,
|
|
141
|
+
width: Math.max(0, r - it - D.right),
|
|
142
|
+
height: v
|
|
143
|
+
},
|
|
144
|
+
ticks: O,
|
|
145
|
+
count: u,
|
|
146
|
+
horizontal: y,
|
|
147
|
+
banded: m,
|
|
148
|
+
marks: c,
|
|
149
|
+
visible: l
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const x = Math.max(0, ...a.map(o)), M = Math.ceil(Math.min(x, r * 0.4)) + W, L = Math.max(0, r - M - D.right), z = Y(_, w, F(L, ct.horizontal), p), E = n ? D.right : Math.max(D.right, o(i(z.max)) / 2);
|
|
153
|
+
return {
|
|
154
|
+
box: {
|
|
155
|
+
x: M,
|
|
156
|
+
y: D.top,
|
|
157
|
+
width: Math.max(0, r - M - E),
|
|
158
|
+
height: Math.max(0, h - D.top - (n ? 4 : D.bottom))
|
|
159
|
+
},
|
|
160
|
+
ticks: z,
|
|
161
|
+
count: u,
|
|
162
|
+
horizontal: y,
|
|
163
|
+
banded: m,
|
|
164
|
+
marks: c,
|
|
165
|
+
visible: l
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function X(s, t) {
|
|
169
|
+
const { box: e, count: a, horizontal: o, banded: i } = s, n = o ? e.y : e.x, r = o ? e.height : e.width;
|
|
170
|
+
return i ? n + (t + 0.5) * r / Math.max(1, a) : a <= 1 ? n + r / 2 : n + t / (a - 1) * r;
|
|
171
|
+
}
|
|
172
|
+
function V(s, t) {
|
|
173
|
+
const { box: e, ticks: a, horizontal: o } = s;
|
|
174
|
+
return o ? I(t, a, e.x, e.x + e.width) : I(t, a, e.y + e.height, e.y);
|
|
175
|
+
}
|
|
176
|
+
function _t(s, t, e) {
|
|
177
|
+
const { box: a, count: o, horizontal: i, banded: n } = s;
|
|
178
|
+
if (o === 0) return -1;
|
|
179
|
+
const r = i ? e - a.y : t - a.x, h = i ? a.height : a.width;
|
|
180
|
+
if (h <= 0) return -1;
|
|
181
|
+
const c = n ? Math.floor(r / (h / o)) : Math.round(r / h * (o - 1));
|
|
182
|
+
return Math.min(Math.max(c, 0), o - 1);
|
|
183
|
+
}
|
|
184
|
+
const zt = 0.64, et = 2, ht = 4, dt = { grouped: 40, stacked: 48 }, Gt = 12;
|
|
185
|
+
function ut(s, t) {
|
|
186
|
+
for (let e = s.length - 1; e >= 0; e -= 1)
|
|
187
|
+
if (t(s[e])) return e;
|
|
188
|
+
return -1;
|
|
189
|
+
}
|
|
190
|
+
function Bt(s, t, e) {
|
|
191
|
+
if (e(s) <= t) return s;
|
|
192
|
+
let a = s;
|
|
193
|
+
for (; a.length > 1 && e(`${a}…`) > t; ) a = a.slice(0, -1);
|
|
194
|
+
return `${a}…`;
|
|
195
|
+
}
|
|
196
|
+
function Tt(s) {
|
|
197
|
+
const { layout: t, noGrid: e, noAxis: a, format: o } = s, { box: i, ticks: n, horizontal: r } = t, h = e ? A : n.values.map((d) => {
|
|
198
|
+
const u = V(t, d);
|
|
199
|
+
return r ? b`<line class="grid" x1=${u} y1=${i.y} x2=${u} y2=${i.y + i.height} />` : b`<line class="grid" x1=${i.x} y1=${u} x2=${i.x + i.width} y2=${u} />`;
|
|
200
|
+
}), c = n.min < 0 && n.max > 0 ? (() => {
|
|
201
|
+
const d = V(t, 0);
|
|
202
|
+
return r ? b`<line class="baseline" x1=${d} y1=${i.y} x2=${d} y2=${i.y + i.height} />` : b`<line class="baseline" x1=${i.x} y1=${d} x2=${i.x + i.width} y2=${d} />`;
|
|
203
|
+
})() : A, l = a ? A : n.values.map((d) => {
|
|
204
|
+
const u = V(t, d);
|
|
205
|
+
return r ? b`<text class="tick-label" x=${u} y=${i.y + i.height + 16} text-anchor="middle">${o(d)}</text>` : b`<text class="tick-label" x=${i.x - 8} y=${u} text-anchor="end" dominant-baseline="middle">${o(d)}</text>`;
|
|
206
|
+
});
|
|
207
|
+
return b`${h}${c}${l}`;
|
|
208
|
+
}
|
|
209
|
+
function Et(s) {
|
|
210
|
+
const { layout: t, labels: e, measure: a } = s, { box: o, count: i, horizontal: n, banded: r } = t;
|
|
211
|
+
if (n) {
|
|
212
|
+
const l = Math.max(1, Math.ceil(i / Math.max(1, Math.floor(o.height / 18))));
|
|
213
|
+
return b`${e.map(
|
|
214
|
+
(d, u) => u % l === 0 ? b`<text
|
|
215
|
+
class="axis-label"
|
|
216
|
+
x=${o.x - 8}
|
|
217
|
+
y=${X(t, u)}
|
|
218
|
+
text-anchor="end"
|
|
219
|
+
dominant-baseline="middle"
|
|
220
|
+
>${Bt(d, o.x - W, a)}</text>` : A
|
|
221
|
+
)}`;
|
|
222
|
+
}
|
|
223
|
+
const h = Math.max(0, ...e.map(a)) + W, c = Math.max(1, Math.ceil(i / Math.max(1, Math.floor(o.width / h))));
|
|
224
|
+
return b`${e.map((l, d) => {
|
|
225
|
+
if (d % c !== 0) return A;
|
|
226
|
+
const u = r || i <= 1 ? "middle" : d === 0 ? "start" : d === i - 1 ? "end" : "middle";
|
|
227
|
+
return b`<text
|
|
228
|
+
class="axis-label"
|
|
229
|
+
x=${X(t, d)}
|
|
230
|
+
y=${o.y + o.height + 16}
|
|
231
|
+
text-anchor=${u}
|
|
232
|
+
>${l}</text>`;
|
|
233
|
+
})}`;
|
|
234
|
+
}
|
|
235
|
+
function Dt(s, t, e) {
|
|
236
|
+
return t.map((a, o) => [
|
|
237
|
+
X(s.layout, o),
|
|
238
|
+
V(s.layout, a + (e?.[o] ?? 0))
|
|
239
|
+
]);
|
|
240
|
+
}
|
|
241
|
+
function st(s, t, e = !0) {
|
|
242
|
+
return s.smooth ? Pt(t, e) : H(t, e);
|
|
243
|
+
}
|
|
244
|
+
function Rt(s) {
|
|
245
|
+
const { layout: t, series: e, colorOf: a, active: o, idPrefix: i, stacked: n, smooth: r } = s, { box: h, count: c, visible: l, marks: d } = t, u = V(t, Math.min(Math.max(0, t.ticks.min), t.ticks.max)), m = new Array(c).fill(0), y = [], k = [];
|
|
246
|
+
for (const g of l) {
|
|
247
|
+
const $ = d[g];
|
|
248
|
+
if ($ === "bar") continue;
|
|
249
|
+
const _ = N(e[g]);
|
|
250
|
+
if (_.length === 0) continue;
|
|
251
|
+
const w = a(g), x = $ === "area" && n ? [...m] : void 0, M = Dt(s, _, x);
|
|
252
|
+
if ($ === "area") {
|
|
253
|
+
const L = `${i}-fill-${g}`, z = x ? _.map((v, O) => [X(t, O), V(t, x[O])]) : [
|
|
254
|
+
[M.at(-1)[0], u],
|
|
255
|
+
[M[0][0], u]
|
|
256
|
+
], E = x ? st(s, [...z].reverse(), !1) : H(z, !1);
|
|
257
|
+
y.push(b`
|
|
258
|
+
<defs>
|
|
259
|
+
<linearGradient id=${L} x1="0" y1="0" x2="0" y2="1">
|
|
260
|
+
<stop offset="0%" stop-color=${w} stop-opacity="0.28" />
|
|
261
|
+
<stop offset="100%" stop-color=${w} stop-opacity="0.02" />
|
|
262
|
+
</linearGradient>
|
|
263
|
+
</defs>
|
|
264
|
+
<path class="area" d=${`${st(s, M)} ${E} Z`} fill=${`url(#${L})`} />`), x && _.forEach((v, O) => m[O] = x[O] + v);
|
|
265
|
+
}
|
|
266
|
+
if (k.push(
|
|
267
|
+
b`<path class="line" d=${st(s, M)} stroke=${w} pathLength="1" />`
|
|
268
|
+
), c <= Gt && !r && k.push(
|
|
269
|
+
b`${M.map(([L, z]) => b`<circle class="point" cx=${L} cy=${z} r="3" fill=${w} />`)}`
|
|
270
|
+
), o >= 0 && M[o]) {
|
|
271
|
+
const [L, z] = M[o];
|
|
272
|
+
k.push(b`<circle class="marker" cx=${L} cy=${z} r="5" fill=${w} />`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const f = o >= 0 && !t.banded ? b`<line class="crosshair"
|
|
276
|
+
x1=${X(t, o)} y1=${h.y}
|
|
277
|
+
x2=${X(t, o)} y2=${h.y + h.height} />` : A;
|
|
278
|
+
return b`${y}${f}${k}`;
|
|
279
|
+
}
|
|
280
|
+
function mt(s, t) {
|
|
281
|
+
const { layout: e, active: a, colorOf: o } = s, { from: i, to: n, offset: r, thickness: h, outer: c, series: l, index: d } = t, u = n < i;
|
|
282
|
+
let m = V(e, i), y = V(e, n);
|
|
283
|
+
const k = 0.5, f = Math.sign(y - m) || 1;
|
|
284
|
+
i !== 0 && (m += k * f), c || (y -= k * f), Math.abs(y - m) < 1 && (y = m + f);
|
|
285
|
+
const g = Math.min(m, y), $ = Math.abs(y - m), _ = c ? e.horizontal ? u ? "left" : "right" : u ? "bottom" : "top" : "none", w = e.horizontal ? lt(g, r, $, h, ht, _) : lt(r, g, h, $, ht, _);
|
|
286
|
+
return b`<path
|
|
287
|
+
class=${`bar${u ? " negative" : ""}${e.horizontal ? " sideways" : ""}`}
|
|
288
|
+
d=${w}
|
|
289
|
+
fill=${o(l)}
|
|
290
|
+
data-series=${l}
|
|
291
|
+
data-index=${d}
|
|
292
|
+
opacity=${a === -1 || a === d ? 1 : 0.45}
|
|
293
|
+
/>`;
|
|
294
|
+
}
|
|
295
|
+
function Vt(s) {
|
|
296
|
+
const { layout: t, series: e } = s, { box: a, count: o, horizontal: i, visible: n, marks: r } = t, h = n.filter((u) => r[u] === "bar");
|
|
297
|
+
if (h.length === 0 || o === 0) return A;
|
|
298
|
+
const l = (i ? a.height : a.width) / o * zt, d = [];
|
|
299
|
+
for (let u = 0; u < o; u += 1) {
|
|
300
|
+
const m = X(t, u);
|
|
301
|
+
if (s.stacked) {
|
|
302
|
+
const f = Math.max(2, Math.min(dt.stacked, l)), g = h.map((x) => N(e[x])[u] ?? 0), $ = ut(g, (x) => x > 0), _ = ut(g, (x) => x < 0);
|
|
303
|
+
let w = 0, p = 0;
|
|
304
|
+
g.forEach((x, M) => {
|
|
305
|
+
if (x === 0) return;
|
|
306
|
+
const L = x > 0 ? w : p, z = L + x;
|
|
307
|
+
x > 0 ? w = z : p = z, d.push(
|
|
308
|
+
mt(s, {
|
|
309
|
+
from: L,
|
|
310
|
+
to: z,
|
|
311
|
+
offset: m - f / 2,
|
|
312
|
+
thickness: f,
|
|
313
|
+
outer: M === (x > 0 ? $ : _),
|
|
314
|
+
series: h[M],
|
|
315
|
+
index: u
|
|
316
|
+
})
|
|
317
|
+
);
|
|
318
|
+
});
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const y = Math.max(
|
|
322
|
+
2,
|
|
323
|
+
Math.min(dt.grouped, (l - et * (h.length - 1)) / h.length)
|
|
324
|
+
), k = y * h.length + et * (h.length - 1);
|
|
325
|
+
h.forEach((f, g) => {
|
|
326
|
+
const $ = N(e[f])[u];
|
|
327
|
+
$ === void 0 || $ === 0 || d.push(
|
|
328
|
+
mt(s, {
|
|
329
|
+
from: 0,
|
|
330
|
+
to: $,
|
|
331
|
+
offset: m - k / 2 + g * (y + et),
|
|
332
|
+
thickness: y,
|
|
333
|
+
outer: !0,
|
|
334
|
+
series: f,
|
|
335
|
+
index: u
|
|
336
|
+
})
|
|
337
|
+
);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
return b`${d}`;
|
|
341
|
+
}
|
|
342
|
+
function It(s) {
|
|
343
|
+
return b`
|
|
344
|
+
${Tt(s)}
|
|
345
|
+
${Vt(s)}
|
|
346
|
+
${Rt(s)}
|
|
347
|
+
${Et(s)}`;
|
|
348
|
+
}
|
|
349
|
+
function Xt(s) {
|
|
350
|
+
const { layout: t, series: e, active: a, stacked: o } = s, i = (c) => N(e[c])[a] ?? 0;
|
|
351
|
+
let n = t.ticks.min;
|
|
352
|
+
for (const c of ["bar", "area", "line"]) {
|
|
353
|
+
const l = t.visible.filter((u) => t.marks[u] === c).map(i);
|
|
354
|
+
if (l.length === 0) continue;
|
|
355
|
+
const d = o && c !== "line" ? l.filter((u) => u > 0).reduce((u, m) => u + m, 0) : Math.max(...l);
|
|
356
|
+
n = Math.max(n, d);
|
|
357
|
+
}
|
|
358
|
+
const r = X(t, a), h = V(t, Math.min(n, t.ticks.max));
|
|
359
|
+
return t.horizontal ? { x: h, y: r } : { x: r, y: h };
|
|
360
|
+
}
|
|
361
|
+
const Z = { top: 16, right: 16, bottom: 24 }, Nt = 12, Zt = 24, ft = 3, Ut = 4, Ht = 24, j = (s) => s?.points ?? [];
|
|
362
|
+
function jt(s) {
|
|
363
|
+
return s.series.flatMap((t, e) => s.hidden.has(e) ? [] : j(t));
|
|
364
|
+
}
|
|
365
|
+
function pt(s) {
|
|
366
|
+
return s.length === 0 ? [0, 1] : [Math.min(...s), Math.max(...s)];
|
|
367
|
+
}
|
|
368
|
+
function Kt(s) {
|
|
369
|
+
const { width: t, height: e, measure: a, format: o, formatX: i, noAxis: n } = s, r = jt(s), h = Math.max(0, e - Z.top - Z.bottom), [c, l] = pt(r.map(($) => $.y)), d = Y(c, l, F(h, 48), { min: s.min, max: s.max }), u = n ? 0 : Math.max(0, ...d.values.map(($) => a(o($)))), m = n ? 4 : Math.ceil(u) + Nt, [y, k] = pt(r.map(($) => $.x)), f = Y(y, k, F(Math.max(0, t - m - Z.right), 96), {
|
|
370
|
+
min: null,
|
|
371
|
+
max: null
|
|
372
|
+
}), g = n ? Z.right : Math.max(Z.right, a(i(f.max)) / 2);
|
|
373
|
+
return {
|
|
374
|
+
box: {
|
|
375
|
+
x: m,
|
|
376
|
+
y: Z.top,
|
|
377
|
+
width: Math.max(0, t - m - g),
|
|
378
|
+
height: h
|
|
379
|
+
},
|
|
380
|
+
x: f,
|
|
381
|
+
y: d,
|
|
382
|
+
maxR: s.bubble ? Math.max(0, ...r.map(($) => $.r ?? 0)) : 0
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function J(s, t) {
|
|
386
|
+
const { box: e } = s;
|
|
387
|
+
return [
|
|
388
|
+
I(t.x, s.x, e.x, e.x + e.width),
|
|
389
|
+
I(t.y, s.y, e.y + e.height, e.y)
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
function qt(s, t) {
|
|
393
|
+
return s === void 0 || t <= 0 || s <= 0 ? ft : Math.max(ft, Zt * Math.sqrt(s / t));
|
|
394
|
+
}
|
|
395
|
+
function ot(s, t, e) {
|
|
396
|
+
return s.bubble ? qt(e.r, t.maxR) : Ut;
|
|
397
|
+
}
|
|
398
|
+
function Yt(s, t, e, a) {
|
|
399
|
+
let o = null, i = 1 / 0;
|
|
400
|
+
return s.series.forEach((n, r) => {
|
|
401
|
+
s.hidden.has(r) || j(n).forEach((h, c) => {
|
|
402
|
+
const [l, d] = J(t, h), u = Math.hypot(l - e, d - a), m = Math.max(Ht, ot(s, t, h) + 4);
|
|
403
|
+
u <= m && u < i && (o = { series: r, index: c }, i = u);
|
|
404
|
+
});
|
|
405
|
+
}), o;
|
|
406
|
+
}
|
|
407
|
+
function bt(s) {
|
|
408
|
+
const t = j(s);
|
|
409
|
+
return t.map((e, a) => a).sort((e, a) => t[e].x - t[a].x);
|
|
410
|
+
}
|
|
411
|
+
function Ft(s) {
|
|
412
|
+
const { layout: t, noGrid: e, noAxis: a, format: o, formatX: i, bubble: n, colorOf: r, active: h, activeSeries: c } = s, { box: l } = t, d = e ? A : b`
|
|
413
|
+
${t.y.values.map((f) => {
|
|
414
|
+
const g = I(f, t.y, l.y + l.height, l.y);
|
|
415
|
+
return b`<line class="grid" x1=${l.x} y1=${g} x2=${l.x + l.width} y2=${g} />`;
|
|
416
|
+
})}
|
|
417
|
+
${t.x.values.map((f) => {
|
|
418
|
+
const g = I(f, t.x, l.x, l.x + l.width);
|
|
419
|
+
return b`<line class="grid" x1=${g} y1=${l.y} x2=${g} y2=${l.y + l.height} />`;
|
|
420
|
+
})}`, u = a ? A : b`
|
|
421
|
+
${t.y.values.map(
|
|
422
|
+
(f) => b`<text class="tick-label" x=${l.x - 8} y=${I(f, t.y, l.y + l.height, l.y)}
|
|
423
|
+
text-anchor="end" dominant-baseline="middle">${o(f)}</text>`
|
|
424
|
+
)}
|
|
425
|
+
${t.x.values.map(
|
|
426
|
+
(f) => b`<text class="tick-label" x=${I(f, t.x, l.x, l.x + l.width)}
|
|
427
|
+
y=${l.y + l.height + 16} text-anchor="middle">${i(f)}</text>`
|
|
428
|
+
)}`, y = s.series.flatMap(
|
|
429
|
+
(f, g) => s.hidden.has(g) ? [] : j(f).map(($, _) => ({
|
|
430
|
+
point: $,
|
|
431
|
+
index: _,
|
|
432
|
+
seriesIndex: g,
|
|
433
|
+
radius: ot(s, t, $)
|
|
434
|
+
}))
|
|
435
|
+
).sort((f, g) => g.radius - f.radius).map(({ point: f, index: g, seriesIndex: $, radius: _ }) => {
|
|
436
|
+
const [w, p] = J(t, f), x = r($);
|
|
437
|
+
return b`<circle
|
|
438
|
+
class="dot"
|
|
439
|
+
cx=${w}
|
|
440
|
+
cy=${p}
|
|
441
|
+
r=${_}
|
|
442
|
+
fill=${x}
|
|
443
|
+
fill-opacity=${n ? 0.55 : 0.85}
|
|
444
|
+
stroke=${n ? x : "var(--surface-card)"}
|
|
445
|
+
stroke-width=${n ? 1.5 : 2}
|
|
446
|
+
data-series=${$}
|
|
447
|
+
data-index=${g}
|
|
448
|
+
/>`;
|
|
449
|
+
}), k = (() => {
|
|
450
|
+
const f = j(s.series[c])[h];
|
|
451
|
+
if (!f || s.hidden.has(c)) return A;
|
|
452
|
+
const [g, $] = J(t, f);
|
|
453
|
+
return b`<circle class="focus-ring" cx=${g} cy=${$}
|
|
454
|
+
r=${ot(s, t, f) + 4} fill="none" stroke=${r(c)} stroke-width="2" />`;
|
|
455
|
+
})();
|
|
456
|
+
return b`${d}${u}${y}${k}`;
|
|
457
|
+
}
|
|
458
|
+
const Wt = 8, Jt = 0.62, xt = 4, Q = 12;
|
|
459
|
+
function Qt(s) {
|
|
460
|
+
const { width: t, height: e, kind: a, series: o, hidden: i, labels: n, measure: r } = s, h = t / 2, c = e / 2;
|
|
461
|
+
if (a === "radar") {
|
|
462
|
+
const w = o.flatMap(
|
|
463
|
+
(v, O) => i.has(O) ? [] : v.values ?? []
|
|
464
|
+
), p = Math.min(0, ...w), x = Math.max(0, ...w), M = at(p, x === p ? p + 1 : x, xt), L = Math.min(Math.max(0, ...n.map(r)), t * 0.25) + Q, z = Math.max(0, Math.min(h - L, c - Q * 2)), E = Math.max(n.length, ...o.map((v) => v.values?.length ?? 0));
|
|
465
|
+
return {
|
|
466
|
+
cx: h,
|
|
467
|
+
cy: c,
|
|
468
|
+
outer: z,
|
|
469
|
+
inner: 0,
|
|
470
|
+
slices: Array.from({ length: E }, (v, O) => {
|
|
471
|
+
const K = O * U / Math.max(1, E);
|
|
472
|
+
return { index: O, value: 0, start: K, end: K, outer: z };
|
|
473
|
+
}),
|
|
474
|
+
ticks: M,
|
|
475
|
+
total: 0
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
const l = o[0]?.values ?? [], d = Math.max(n.length, l.length), u = (w) => i.has(w) ? 0 : Math.max(0, l[w] ?? 0), m = Array.from({ length: d }, (w, p) => u(p)).reduce(
|
|
479
|
+
(w, p) => w + p,
|
|
480
|
+
0
|
|
481
|
+
), y = Math.max(0, Math.min(t, e) / 2 - Wt), k = Math.max(0, ...Array.from({ length: d }, (w, p) => u(p))), f = at(0, k || 1, xt), g = Array.from({ length: d }, (w, p) => p).filter(
|
|
482
|
+
(w) => !i.has(w)
|
|
483
|
+
).length;
|
|
484
|
+
let $ = 0;
|
|
485
|
+
const _ = Array.from({ length: d }, (w, p) => {
|
|
486
|
+
const x = u(p), M = $;
|
|
487
|
+
return a === "polar-area" ? (i.has(p) || ($ += U / Math.max(1, g)), { index: p, value: x, start: M, end: $, outer: y * Math.sqrt(x / f.max) }) : ($ += m > 0 ? x / m * U : 0, { index: p, value: x, start: M, end: $, outer: y });
|
|
488
|
+
});
|
|
489
|
+
return { cx: h, cy: c, outer: y, inner: a === "doughnut" ? y * Jt : 0, slices: _, ticks: f, total: m };
|
|
490
|
+
}
|
|
491
|
+
function te(s, t, e, a) {
|
|
492
|
+
const o = e - s.cx, i = a - s.cy, n = Math.hypot(o, i);
|
|
493
|
+
let r = Math.atan2(o, -i);
|
|
494
|
+
if (r < 0 && (r += U), t === "radar") {
|
|
495
|
+
const c = s.slices.length;
|
|
496
|
+
return c === 0 || n > s.outer + Q * 2 ? -1 : Math.round(r / (U / c)) % c;
|
|
497
|
+
}
|
|
498
|
+
return n > s.outer || n < s.inner ? -1 : s.slices.find(
|
|
499
|
+
({ start: c, end: l }) => l > c && r >= c && r < l
|
|
500
|
+
)?.index ?? -1;
|
|
501
|
+
}
|
|
502
|
+
function ee(s, t) {
|
|
503
|
+
const e = s.slices[t];
|
|
504
|
+
if (!e) return [s.cx, s.cy];
|
|
505
|
+
const a = (e.start + e.end) / 2, o = s.inner > 0 ? (s.inner + e.outer) / 2 : e.outer * 0.6;
|
|
506
|
+
return T(s.cx, s.cy, o, a);
|
|
507
|
+
}
|
|
508
|
+
function q(s, t) {
|
|
509
|
+
const { ticks: e, outer: a } = s;
|
|
510
|
+
return (t - e.min) / (e.max - e.min) * a;
|
|
511
|
+
}
|
|
512
|
+
function se(s) {
|
|
513
|
+
const { layout: t, active: e, sliceColor: a, kind: o, noGrid: i, format: n, centerLabel: r } = s, { cx: h, cy: c, inner: l, ticks: d } = t, u = o === "polar-area" && !i ? d.values.filter((f) => f > 0).map(
|
|
514
|
+
(f) => b`<circle class="grid" cx=${h} cy=${c} r=${t.outer * Math.sqrt(f / d.max)} fill="none" />`
|
|
515
|
+
) : A, m = t.slices.filter((f) => f.end > f.start && f.outer > 0), y = m.map(
|
|
516
|
+
(f) => b`<path
|
|
517
|
+
class="slice"
|
|
518
|
+
d=${Ct(h, c, l, f.outer, f.start, f.end)}
|
|
519
|
+
fill=${a(f.index)}
|
|
520
|
+
fill-rule="evenodd"
|
|
521
|
+
stroke="var(--surface-card)"
|
|
522
|
+
stroke-width=${m.length > 1 ? 2 : 0}
|
|
523
|
+
stroke-linejoin="round"
|
|
524
|
+
data-index=${f.index}
|
|
525
|
+
opacity=${e === -1 || e === f.index ? 1 : 0.45}
|
|
526
|
+
/>`
|
|
527
|
+
), k = o === "doughnut" ? b`
|
|
528
|
+
<text class="center-value" x=${h} y=${c} text-anchor="middle" dominant-baseline="middle">${n(t.total)}</text>
|
|
529
|
+
${l > 36 ? b`<text class="center-label" x=${h} y=${c + 20} text-anchor="middle" dominant-baseline="middle">${r}</text>` : A}` : A;
|
|
530
|
+
return b`${u}${y}${k}`;
|
|
531
|
+
}
|
|
532
|
+
function ae(s) {
|
|
533
|
+
const { layout: t, series: e, hidden: a, labels: o, colorOf: i, active: n, noGrid: r, noAxis: h, format: c } = s, { cx: l, cy: d, outer: u, ticks: m, slices: y } = t, k = y.map((p) => p.start), f = r ? A : b`
|
|
534
|
+
${m.values.filter((p) => p > m.min).map((p) => {
|
|
535
|
+
const x = q(t, p);
|
|
536
|
+
return b`<path class="grid" fill="none" d=${`${H(k.map((M) => T(l, d, x, M)))} Z`} />`;
|
|
537
|
+
})}
|
|
538
|
+
${k.map((p) => {
|
|
539
|
+
const [x, M] = T(l, d, u, p);
|
|
540
|
+
return b`<line class="grid" x1=${l} y1=${d} x2=${x} y2=${M} />`;
|
|
541
|
+
})}`, g = h ? A : m.values.filter((p) => p > m.min).map(
|
|
542
|
+
(p) => b`<text class="tick-label ring-label" x=${l + 4} y=${d - q(t, p) + 3} dominant-baseline="hanging">${c(p)}</text>`
|
|
543
|
+
), $ = k.map((p, x) => {
|
|
544
|
+
const M = Math.sin(p), L = Math.cos(p), z = M > 0.1 ? "start" : M < -0.1 ? "end" : "middle", [E, v] = T(l, d, u + (Math.abs(L) > 0.5 ? 8 : Q), p), O = L > 0.5 ? "auto" : L < -0.5 ? "hanging" : "middle";
|
|
545
|
+
return b`<text class="axis-label" x=${E} y=${v} text-anchor=${z} dominant-baseline=${O}>${o[x] ?? ""}</text>`;
|
|
546
|
+
}), _ = e.map((p, x) => {
|
|
547
|
+
if (a.has(x)) return A;
|
|
548
|
+
const M = i(x), L = k.map(
|
|
549
|
+
(E, v) => T(l, d, q(t, p.values?.[v] ?? m.min), E)
|
|
550
|
+
), z = n >= 0 && L[n] ? b`<circle class="marker" cx=${L[n][0]} cy=${L[n][1]} r="5" fill=${M} />` : A;
|
|
551
|
+
return b`
|
|
552
|
+
<path class="radar" d=${`${H(L)} Z`} stroke=${M} fill=${M} />
|
|
553
|
+
${z}`;
|
|
554
|
+
}), w = n >= 0 && k[n] !== void 0 ? (() => {
|
|
555
|
+
const [p, x] = T(l, d, u, k[n]);
|
|
556
|
+
return b`<line class="crosshair" x1=${l} y1=${d} x2=${p} y2=${x} />`;
|
|
557
|
+
})() : A;
|
|
558
|
+
return b`${f}${w}${_}${g}${$}`;
|
|
559
|
+
}
|
|
560
|
+
function oe(s) {
|
|
561
|
+
return s.kind === "radar" ? ae(s) : se(s);
|
|
562
|
+
}
|
|
563
|
+
var ie = Object.defineProperty, C = (s, t, e, a) => {
|
|
564
|
+
for (var o = void 0, i = s.length - 1, n; i >= 0; i--)
|
|
565
|
+
(n = s[i]) && (o = n(t, e, o) || o);
|
|
566
|
+
return o && ie(t, e, o), o;
|
|
9
567
|
};
|
|
10
|
-
const
|
|
11
|
-
class
|
|
568
|
+
const $t = 8;
|
|
569
|
+
class S extends rt {
|
|
12
570
|
constructor() {
|
|
13
|
-
super(...arguments), this.tableId =
|
|
571
|
+
super(...arguments), this.tableId = Mt("kt-chart-table"), this.box = { width: 0, height: 0 }, this.active = -1, this.activeSeries = -1, this.hiddenSeries = /* @__PURE__ */ new Set(), this.type = "area", this.series = [], this.labels = [], this.height = 200, this.format = (t) => String(t), this.formatX = (t) => String(t), this.noGrid = !1, this.noAxis = !1, this.showTable = !1, this.smooth = !1, this.stacked = !1, this.horizontal = !1, this.min = null, this.max = null, this.centerLabel = "Total", this.totalLabel = "Total", this.label = "", this.colorOf = (t) => {
|
|
572
|
+
const e = this.series[t];
|
|
573
|
+
return e?.color ? e.color : this.series.length === 1 ? "var(--color-primary-base)" : `var(--chart-series-${t % $t + 1})`;
|
|
574
|
+
}, this.measure = (t) => {
|
|
575
|
+
if (this.measureContext === void 0)
|
|
576
|
+
try {
|
|
577
|
+
const e = document.createElement("canvas").getContext("2d"), a = getComputedStyle(this).getPropertyValue("--font-family-body").trim();
|
|
578
|
+
e && (e.font = `12px ${a || "sans-serif"}`), this.measureContext = e;
|
|
579
|
+
} catch {
|
|
580
|
+
this.measureContext = null;
|
|
581
|
+
}
|
|
582
|
+
return this.measureContext ? this.measureContext.measureText(t).width : t.length * 6.5;
|
|
583
|
+
}, this.sliceColor = (t) => `var(--chart-series-${t % $t + 1})`;
|
|
14
584
|
}
|
|
15
585
|
static {
|
|
16
586
|
this.styles = [
|
|
17
|
-
|
|
18
|
-
|
|
587
|
+
rt.styles,
|
|
588
|
+
gt`
|
|
19
589
|
:host {
|
|
20
590
|
display: block;
|
|
21
591
|
position: relative;
|
|
@@ -30,6 +600,12 @@ class a extends f {
|
|
|
30
600
|
display: block;
|
|
31
601
|
width: 100%;
|
|
32
602
|
overflow: visible;
|
|
603
|
+
border-radius: var(--border-radius);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
svg:focus-visible {
|
|
607
|
+
outline: var(--outline-width) solid var(--color-primary-base);
|
|
608
|
+
outline-offset: 4px;
|
|
33
609
|
}
|
|
34
610
|
|
|
35
611
|
/* Recessive: the data is the loud part. */
|
|
@@ -39,10 +615,27 @@ class a extends f {
|
|
|
39
615
|
opacity: 0.6;
|
|
40
616
|
}
|
|
41
617
|
|
|
42
|
-
.
|
|
618
|
+
.baseline {
|
|
619
|
+
stroke: var(--chart-axis);
|
|
620
|
+
stroke-width: 1;
|
|
621
|
+
opacity: 0.5;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
.axis-label,
|
|
625
|
+
.tick-label {
|
|
43
626
|
fill: var(--chart-axis);
|
|
44
627
|
font: var(--font-normal-small);
|
|
45
628
|
font-family: var(--font-family-body);
|
|
629
|
+
font-variant-numeric: tabular-nums;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/* Ring values sit on top of the marks; a halo of the surface keeps them
|
|
633
|
+
readable without boxing them in. */
|
|
634
|
+
.ring-label {
|
|
635
|
+
paint-order: stroke;
|
|
636
|
+
stroke: var(--surface-card);
|
|
637
|
+
stroke-width: 2px;
|
|
638
|
+
stroke-linejoin: round;
|
|
46
639
|
}
|
|
47
640
|
|
|
48
641
|
.line {
|
|
@@ -52,11 +645,89 @@ class a extends f {
|
|
|
52
645
|
stroke-linejoin: round;
|
|
53
646
|
}
|
|
54
647
|
|
|
648
|
+
.point,
|
|
55
649
|
.marker {
|
|
56
650
|
stroke: var(--surface-card);
|
|
57
651
|
stroke-width: 2;
|
|
58
652
|
}
|
|
59
653
|
|
|
654
|
+
.bar,
|
|
655
|
+
.slice {
|
|
656
|
+
transition: opacity var(--duration-fast) var(--easing-standard);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/* One entrance, when a mark first appears: bars grow from the baseline,
|
|
660
|
+
lines draw along their length, everything else fades in. Nothing
|
|
661
|
+
moves on hover, and the reduced-motion block in the token layer
|
|
662
|
+
zeroes the duration. Backwards fill, so the animation never holds a
|
|
663
|
+
value past its end — the dimming on hover stays in charge. */
|
|
664
|
+
.bar {
|
|
665
|
+
transform-box: fill-box;
|
|
666
|
+
transform-origin: 50% 100%;
|
|
667
|
+
animation: kt-chart-grow-y var(--duration-normal) var(--easing-standard) backwards;
|
|
668
|
+
}
|
|
669
|
+
.bar.negative {
|
|
670
|
+
transform-origin: 50% 0;
|
|
671
|
+
}
|
|
672
|
+
.bar.sideways {
|
|
673
|
+
transform-origin: 0 50%;
|
|
674
|
+
animation-name: kt-chart-grow-x;
|
|
675
|
+
}
|
|
676
|
+
.bar.sideways.negative {
|
|
677
|
+
transform-origin: 100% 50%;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.line {
|
|
681
|
+
stroke-dasharray: 1;
|
|
682
|
+
animation: kt-chart-draw var(--duration-normal) var(--easing-standard) backwards;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.area,
|
|
686
|
+
.point,
|
|
687
|
+
.dot,
|
|
688
|
+
.slice,
|
|
689
|
+
.radar {
|
|
690
|
+
animation: kt-chart-fade var(--duration-normal) var(--easing-standard) backwards;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
@keyframes kt-chart-grow-y {
|
|
694
|
+
from {
|
|
695
|
+
transform: scaleY(0);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
@keyframes kt-chart-grow-x {
|
|
699
|
+
from {
|
|
700
|
+
transform: scaleX(0);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
@keyframes kt-chart-draw {
|
|
704
|
+
from {
|
|
705
|
+
stroke-dashoffset: 1;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
@keyframes kt-chart-fade {
|
|
709
|
+
from {
|
|
710
|
+
opacity: 0;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
.radar {
|
|
715
|
+
stroke-width: 2;
|
|
716
|
+
stroke-linejoin: round;
|
|
717
|
+
fill-opacity: 0.16;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.center-value {
|
|
721
|
+
fill: var(--text-body);
|
|
722
|
+
font: var(--font-title-h6);
|
|
723
|
+
font-variant-numeric: tabular-nums;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.center-label {
|
|
727
|
+
fill: var(--text-muted);
|
|
728
|
+
font: var(--font-normal-small);
|
|
729
|
+
}
|
|
730
|
+
|
|
60
731
|
.crosshair {
|
|
61
732
|
stroke: var(--chart-axis);
|
|
62
733
|
stroke-width: 1;
|
|
@@ -77,8 +748,17 @@ class a extends f {
|
|
|
77
748
|
border-radius: var(--border-radius);
|
|
78
749
|
box-shadow: var(--shadow-toast);
|
|
79
750
|
pointer-events: none;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.tooltip.above {
|
|
80
754
|
transform: translate(-50%, calc(-100% - 12px));
|
|
81
755
|
}
|
|
756
|
+
.tooltip.right {
|
|
757
|
+
transform: translate(12px, -50%);
|
|
758
|
+
}
|
|
759
|
+
.tooltip.left {
|
|
760
|
+
transform: translate(calc(-100% - 12px), -50%);
|
|
761
|
+
}
|
|
82
762
|
|
|
83
763
|
.tooltip-row {
|
|
84
764
|
display: flex;
|
|
@@ -88,24 +768,46 @@ class a extends f {
|
|
|
88
768
|
}
|
|
89
769
|
|
|
90
770
|
.swatch {
|
|
771
|
+
flex: none;
|
|
91
772
|
width: 8px;
|
|
92
773
|
height: 8px;
|
|
774
|
+
background: var(--swatch);
|
|
93
775
|
border-radius: 2px;
|
|
94
776
|
}
|
|
95
777
|
|
|
778
|
+
.swatch.hollow {
|
|
779
|
+
background: none;
|
|
780
|
+
box-shadow: inset 0 0 0 var(--border-width) var(--swatch);
|
|
781
|
+
}
|
|
782
|
+
|
|
96
783
|
.tooltip-name {
|
|
97
784
|
flex: 1;
|
|
98
785
|
opacity: 0.75;
|
|
99
786
|
}
|
|
100
787
|
|
|
788
|
+
.tooltip-subtitle {
|
|
789
|
+
margin-top: -2px;
|
|
790
|
+
opacity: 0.75;
|
|
791
|
+
}
|
|
792
|
+
|
|
101
793
|
.tooltip-value {
|
|
102
794
|
font-variant-numeric: tabular-nums;
|
|
103
795
|
}
|
|
104
796
|
|
|
797
|
+
.tooltip-total {
|
|
798
|
+
display: flex;
|
|
799
|
+
justify-content: space-between;
|
|
800
|
+
gap: 12px;
|
|
801
|
+
margin-top: 2px;
|
|
802
|
+
padding-top: 4px;
|
|
803
|
+
border-top: var(--border-width) solid color-mix(in srgb, currentColor 20%, transparent);
|
|
804
|
+
font-variant-numeric: tabular-nums;
|
|
805
|
+
}
|
|
806
|
+
|
|
105
807
|
.legend {
|
|
106
808
|
display: flex;
|
|
107
809
|
flex-wrap: wrap;
|
|
108
|
-
gap: 14px;
|
|
810
|
+
gap: 4px 14px;
|
|
109
811
|
margin-top: 10px;
|
|
110
812
|
}
|
|
111
813
|
|
|
@@ -113,8 +815,27 @@ class a extends f {
|
|
|
113
815
|
display: inline-flex;
|
|
114
816
|
align-items: center;
|
|
115
817
|
gap: 6px;
|
|
818
|
+
padding: 2px 0;
|
|
116
819
|
color: var(--text-muted);
|
|
117
820
|
font: var(--font-normal-small);
|
|
821
|
+
background: none;
|
|
822
|
+
border: none;
|
|
823
|
+
border-radius: var(--border-radius);
|
|
824
|
+
cursor: pointer;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
.legend-item:hover {
|
|
828
|
+
color: var(--text-body);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
.legend-item[aria-pressed='false'] {
|
|
832
|
+
text-decoration: line-through;
|
|
833
|
+
opacity: 0.6;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
.legend-item:focus-visible {
|
|
837
|
+
outline: var(--outline-width) solid var(--color-primary-base);
|
|
838
|
+
outline-offset: 2px;
|
|
118
839
|
}
|
|
119
840
|
|
|
120
841
|
/* Present for assistive technology and for anyone who needs the
|
|
@@ -161,8 +882,8 @@ class a extends f {
|
|
|
161
882
|
];
|
|
162
883
|
}
|
|
163
884
|
connectedCallback() {
|
|
164
|
-
super.connectedCallback(), this.observer = new ResizeObserver(([
|
|
165
|
-
|
|
885
|
+
super.connectedCallback(), this.observer = new ResizeObserver(([t]) => {
|
|
886
|
+
t && (this.box = { width: t.contentRect.width, height: this.height });
|
|
166
887
|
});
|
|
167
888
|
}
|
|
168
889
|
firstUpdated() {
|
|
@@ -171,236 +892,502 @@ class a extends f {
|
|
|
171
892
|
disconnectedCallback() {
|
|
172
893
|
super.disconnectedCallback(), this.observer?.disconnect();
|
|
173
894
|
}
|
|
174
|
-
|
|
175
|
-
|
|
895
|
+
willUpdate(t) {
|
|
896
|
+
(t.has("series") || t.has("type") || t.has("labels")) && (this.hiddenSeries.size > 0 && (this.hiddenSeries = /* @__PURE__ */ new Set()), this.active >= this.pointCount && (this.active = -1, this.activeSeries = -1));
|
|
897
|
+
}
|
|
898
|
+
/* ------------------------------------------------------------- helpers */
|
|
899
|
+
get family() {
|
|
900
|
+
return this.type === "scatter" || this.type === "bubble" ? "point" : this.type === "pie" || this.type === "doughnut" || this.type === "polar-area" || this.type === "radar" ? "radial" : "cartesian";
|
|
176
901
|
}
|
|
177
902
|
get pointCount() {
|
|
178
|
-
return Math.max(0, ...this.series.map((
|
|
903
|
+
return Math.max(this.labels.length, 0, ...this.series.map((t) => t.values?.length ?? 0));
|
|
179
904
|
}
|
|
180
|
-
get
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
905
|
+
get cartesianView() {
|
|
906
|
+
const t = {
|
|
907
|
+
width: this.box.width,
|
|
908
|
+
height: this.height,
|
|
909
|
+
series: this.series,
|
|
910
|
+
hidden: this.hiddenSeries,
|
|
911
|
+
labels: this.labels,
|
|
912
|
+
type: this.family === "cartesian" ? this.type : "line",
|
|
913
|
+
stacked: this.stacked,
|
|
914
|
+
horizontal: this.horizontal,
|
|
915
|
+
min: this.min,
|
|
916
|
+
max: this.max,
|
|
917
|
+
noAxis: this.noAxis,
|
|
918
|
+
measure: this.measure,
|
|
919
|
+
format: this.format
|
|
920
|
+
};
|
|
921
|
+
return {
|
|
922
|
+
...t,
|
|
923
|
+
layout: Ot(t),
|
|
924
|
+
active: this.active,
|
|
925
|
+
smooth: this.smooth,
|
|
926
|
+
noGrid: this.noGrid,
|
|
927
|
+
colorOf: this.colorOf,
|
|
928
|
+
idPrefix: this.tableId
|
|
929
|
+
};
|
|
185
930
|
}
|
|
186
|
-
get
|
|
931
|
+
get pointView() {
|
|
932
|
+
const t = {
|
|
933
|
+
width: this.box.width,
|
|
934
|
+
height: this.height,
|
|
935
|
+
series: this.series,
|
|
936
|
+
hidden: this.hiddenSeries,
|
|
937
|
+
bubble: this.type === "bubble",
|
|
938
|
+
min: this.min,
|
|
939
|
+
max: this.max,
|
|
940
|
+
noAxis: this.noAxis,
|
|
941
|
+
measure: this.measure,
|
|
942
|
+
format: this.format,
|
|
943
|
+
formatX: this.formatX
|
|
944
|
+
};
|
|
187
945
|
return {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
946
|
+
...t,
|
|
947
|
+
layout: Kt(t),
|
|
948
|
+
active: this.active,
|
|
949
|
+
activeSeries: this.activeSeries,
|
|
950
|
+
noGrid: this.noGrid,
|
|
951
|
+
colorOf: this.colorOf
|
|
192
952
|
};
|
|
193
953
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return
|
|
954
|
+
/** Pie, doughnut and polar area: one series, whose slices are the labels. */
|
|
955
|
+
get sliced() {
|
|
956
|
+
return this.type === "pie" || this.type === "doughnut" || this.type === "polar-area";
|
|
197
957
|
}
|
|
198
|
-
|
|
199
|
-
const t =
|
|
200
|
-
|
|
958
|
+
get radialView() {
|
|
959
|
+
const t = {
|
|
960
|
+
width: this.box.width,
|
|
961
|
+
height: this.height,
|
|
962
|
+
kind: this.type,
|
|
963
|
+
series: this.series,
|
|
964
|
+
hidden: this.hiddenSeries,
|
|
965
|
+
labels: this.labels,
|
|
966
|
+
measure: this.measure
|
|
967
|
+
};
|
|
968
|
+
return {
|
|
969
|
+
...t,
|
|
970
|
+
layout: Qt(t),
|
|
971
|
+
active: this.active,
|
|
972
|
+
noGrid: this.noGrid,
|
|
973
|
+
noAxis: this.noAxis,
|
|
974
|
+
centerLabel: this.centerLabel,
|
|
975
|
+
format: this.format,
|
|
976
|
+
colorOf: this.colorOf,
|
|
977
|
+
sliceColor: this.sliceColor
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
/** Whether there is anything to draw. */
|
|
981
|
+
get hasData() {
|
|
982
|
+
return this.family === "point" ? this.series.some((t) => (t.points?.length ?? 0) > 0) : this.pointCount > 0;
|
|
983
|
+
}
|
|
984
|
+
setActive(t, e = -1) {
|
|
985
|
+
t === this.active && e === this.activeSeries || (this.active = t, this.activeSeries = e, nt(this, "kt-point-hover", { index: t, series: e }));
|
|
986
|
+
}
|
|
987
|
+
/* --------------------------------------------------------- interaction */
|
|
988
|
+
onPointerMove(t) {
|
|
989
|
+
if (this.box.width !== 0) {
|
|
990
|
+
if (this.family === "cartesian") {
|
|
991
|
+
const e = _t(this.cartesianView.layout, t.offsetX, t.offsetY);
|
|
992
|
+
this.setActive(e);
|
|
993
|
+
} else if (this.family === "radial") {
|
|
994
|
+
const e = this.radialView;
|
|
995
|
+
this.setActive(te(e.layout, e.kind, t.offsetX, t.offsetY));
|
|
996
|
+
} else if (this.family === "point") {
|
|
997
|
+
const e = this.pointView, a = Yt(e, e.layout, t.offsetX, t.offsetY);
|
|
998
|
+
this.setActive(a?.index ?? -1, a?.series ?? -1);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
onPointerLeave() {
|
|
1003
|
+
this.setActive(-1);
|
|
1004
|
+
}
|
|
1005
|
+
/** How many positions the keyboard walks through, in order. */
|
|
1006
|
+
get stops() {
|
|
1007
|
+
const t = Array.from({ length: this.pointCount }, (e, a) => a);
|
|
1008
|
+
return this.sliced ? t.filter((e) => !this.hiddenSeries.has(e)) : t;
|
|
201
1009
|
}
|
|
202
1010
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
1011
|
+
* Arrows walk the points, Home and End jump to the ends, Escape lets go.
|
|
1012
|
+
* Every move emits `kt-point-hover` and opens the tooltip, which is a live
|
|
1013
|
+
* region, so a keyboard user hears what a pointer user sees.
|
|
205
1014
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
1015
|
+
onKeyDown(t) {
|
|
1016
|
+
if (this.family === "point") {
|
|
1017
|
+
this.onPointKeyDown(t);
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
const e = this.stops;
|
|
1021
|
+
if (e.length === 0) return;
|
|
1022
|
+
const a = e.indexOf(this.active), o = e.length - 1, i = {
|
|
1023
|
+
ArrowRight: a < 0 ? 0 : Math.min(a + 1, o),
|
|
1024
|
+
ArrowDown: a < 0 ? 0 : Math.min(a + 1, o),
|
|
1025
|
+
ArrowLeft: a < 0 ? 0 : Math.max(a - 1, 0),
|
|
1026
|
+
ArrowUp: a < 0 ? 0 : Math.max(a - 1, 0),
|
|
1027
|
+
Home: 0,
|
|
1028
|
+
End: o
|
|
1029
|
+
};
|
|
1030
|
+
if (t.key === "Escape") {
|
|
1031
|
+
this.setActive(-1);
|
|
1032
|
+
return;
|
|
215
1033
|
}
|
|
216
|
-
|
|
1034
|
+
const n = i[t.key];
|
|
1035
|
+
n !== void 0 && (t.preventDefault(), this.setActive(e[n]));
|
|
217
1036
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
1037
|
+
/**
|
|
1038
|
+
* Scatter and bubble: left and right walk the current series in x order,
|
|
1039
|
+
* up and down move to the neighbouring visible series.
|
|
1040
|
+
*/
|
|
1041
|
+
onPointKeyDown(t) {
|
|
1042
|
+
const e = this.series.map((c, l) => ({ index: l, count: c.points?.length ?? 0 })).filter(({ index: c, count: l }) => l > 0 && !this.hiddenSeries.has(c)).map(({ index: c }) => c);
|
|
1043
|
+
if (e.length === 0) return;
|
|
1044
|
+
if (t.key === "Escape") {
|
|
1045
|
+
this.setActive(-1);
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
const a = e.indexOf(this.activeSeries), o = a < 0 ? e[0] : this.activeSeries, i = bt(this.series[o]), n = a < 0 ? -1 : i.indexOf(this.active), r = i.length - 1, h = (c) => {
|
|
1049
|
+
const l = e[Math.min(Math.max((a < 0 ? 0 : a) + c, 0), e.length - 1)];
|
|
1050
|
+
this.setActive(bt(this.series[l])[0], l);
|
|
1051
|
+
};
|
|
1052
|
+
switch (t.key) {
|
|
1053
|
+
case "ArrowRight":
|
|
1054
|
+
this.setActive(i[n < 0 ? 0 : Math.min(n + 1, r)], o);
|
|
1055
|
+
break;
|
|
1056
|
+
case "ArrowLeft":
|
|
1057
|
+
this.setActive(i[n < 0 ? 0 : Math.max(n - 1, 0)], o);
|
|
1058
|
+
break;
|
|
1059
|
+
case "ArrowDown":
|
|
1060
|
+
h(a < 0 ? 0 : 1);
|
|
1061
|
+
break;
|
|
1062
|
+
case "ArrowUp":
|
|
1063
|
+
h(a < 0 ? 0 : -1);
|
|
1064
|
+
break;
|
|
1065
|
+
case "Home":
|
|
1066
|
+
this.setActive(i[0], o);
|
|
1067
|
+
break;
|
|
1068
|
+
case "End":
|
|
1069
|
+
this.setActive(i[r], o);
|
|
1070
|
+
break;
|
|
1071
|
+
default:
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
t.preventDefault();
|
|
223
1075
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const e = this.plotArea;
|
|
230
|
-
return l`${[0, 0.25, 0.5, 0.75, 1].map((t) => {
|
|
231
|
-
const o = e.y + e.height * t;
|
|
232
|
-
return l`<line class="grid" x1=${e.x} y1=${o} x2=${e.x + e.width} y2=${o} />`;
|
|
233
|
-
})}`;
|
|
234
|
-
}
|
|
235
|
-
renderBars() {
|
|
236
|
-
const e = this.plotArea, t = this.pointCount, o = this.series.length, i = t > 0 ? e.width / t : 0, s = Math.max(2, i / o - 2), r = this.yFor(Math.max(0, this.bounds.min));
|
|
237
|
-
return l`${this.series.map(
|
|
238
|
-
(d, v) => d.values.map((x, m) => {
|
|
239
|
-
const $ = this.yFor(x), w = e.x + m * i + (i - s * o) / 2 + v * s, k = Math.max(1, r - $);
|
|
240
|
-
return l`<rect
|
|
241
|
-
x=${w} y=${$} width=${s} height=${k}
|
|
242
|
-
rx="4" ry="4"
|
|
243
|
-
fill=${this.colorFor(v, d)}
|
|
244
|
-
opacity=${this.active === -1 || this.active === m ? 1 : 0.45}
|
|
245
|
-
/>`;
|
|
246
|
-
})
|
|
247
|
-
)}`;
|
|
1076
|
+
toggle(t) {
|
|
1077
|
+
const e = !this.hiddenSeries.has(t);
|
|
1078
|
+
if (nt(this, "kt-series-toggle", { series: t, hidden: e }).defaultPrevented) return;
|
|
1079
|
+
const a = new Set(this.hiddenSeries);
|
|
1080
|
+
e ? a.add(t) : a.delete(t), this.hiddenSeries = a, this.setActive(-1);
|
|
248
1081
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
1082
|
+
/* ----------------------------------------------------------- rendering */
|
|
1083
|
+
renderMarks() {
|
|
1084
|
+
return this.family === "cartesian" ? It(this.cartesianView) : this.family === "point" ? Ft(this.pointView) : oe(this.radialView);
|
|
1085
|
+
}
|
|
1086
|
+
get tooltip() {
|
|
1087
|
+
if (this.active < 0 || this.box.width === 0) return null;
|
|
1088
|
+
if (this.family === "cartesian") {
|
|
1089
|
+
const t = this.cartesianView, e = t.layout.visible.map((r) => ({
|
|
1090
|
+
color: this.colorOf(r),
|
|
1091
|
+
name: this.series[r].name,
|
|
1092
|
+
value: this.format(this.series[r].values?.[this.active] ?? 0)
|
|
1093
|
+
})), { x: a, y: o } = Xt(t), i = t.layout.visible.filter(
|
|
1094
|
+
(r) => this.stacked && t.layout.marks[r] !== "line"
|
|
1095
|
+
), n = i.length > 1 ? this.format(
|
|
1096
|
+
i.reduce(
|
|
1097
|
+
(r, h) => r + (this.series[h].values?.[this.active] ?? 0),
|
|
1098
|
+
0
|
|
1099
|
+
)
|
|
1100
|
+
) : void 0;
|
|
1101
|
+
return {
|
|
1102
|
+
title: this.labels[this.active] ?? `#${this.active + 1}`,
|
|
1103
|
+
rows: e,
|
|
1104
|
+
...n === void 0 ? {} : { total: n },
|
|
1105
|
+
x: a,
|
|
1106
|
+
y: o,
|
|
1107
|
+
side: t.layout.horizontal ? "right" : "above"
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
if (this.sliced) {
|
|
1111
|
+
const t = this.radialView.layout, e = this.series[0]?.values?.[this.active] ?? 0, a = t.total > 0 ? Math.round(Math.max(0, e) / t.total * 100) : 0, [o, i] = ee(t, this.active);
|
|
1112
|
+
return {
|
|
1113
|
+
title: this.labels[this.active] ?? `#${this.active + 1}`,
|
|
1114
|
+
rows: [
|
|
1115
|
+
{
|
|
1116
|
+
color: this.sliceColor(this.active),
|
|
1117
|
+
name: this.series[0]?.name ?? "",
|
|
1118
|
+
value: `${this.format(e)} (${a}%)`
|
|
1119
|
+
}
|
|
1120
|
+
],
|
|
1121
|
+
x: o,
|
|
1122
|
+
y: i,
|
|
1123
|
+
side: "above"
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
if (this.type === "radar") {
|
|
1127
|
+
const t = this.radialView.layout, e = this.series.map((r, h) => h).filter((r) => !this.hiddenSeries.has(r)), a = Math.max(
|
|
1128
|
+
t.ticks.min,
|
|
1129
|
+
...e.map((r) => this.series[r].values?.[this.active] ?? t.ticks.min)
|
|
1130
|
+
), o = t.slices[this.active]?.start ?? 0, [i, n] = T(t.cx, t.cy, q(t, a), o);
|
|
1131
|
+
return {
|
|
1132
|
+
title: this.labels[this.active] ?? `#${this.active + 1}`,
|
|
1133
|
+
rows: e.map((r) => ({
|
|
1134
|
+
color: this.colorOf(r),
|
|
1135
|
+
name: this.series[r].name,
|
|
1136
|
+
value: this.format(this.series[r].values?.[this.active] ?? 0)
|
|
1137
|
+
})),
|
|
1138
|
+
x: i,
|
|
1139
|
+
y: n,
|
|
1140
|
+
side: "above"
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
if (this.family === "point") {
|
|
1144
|
+
const t = this.series[this.activeSeries], e = t?.points?.[this.active];
|
|
1145
|
+
if (!t || !e) return null;
|
|
1146
|
+
const [a, o] = J(this.pointView.layout, e), i = this.colorOf(this.activeSeries), n = [
|
|
1147
|
+
{ color: i, name: "x", value: this.formatX(e.x) },
|
|
1148
|
+
{ color: i, name: "y", value: this.format(e.y) }
|
|
1149
|
+
];
|
|
1150
|
+
return this.type === "bubble" && e.r !== void 0 && n.push({ color: i, name: "r", value: String(e.r) }), {
|
|
1151
|
+
title: e.label ?? t.name,
|
|
1152
|
+
...e.label ? { subtitle: t.name } : {},
|
|
1153
|
+
rows: n,
|
|
1154
|
+
x: a,
|
|
1155
|
+
y: o,
|
|
1156
|
+
side: "above"
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
return null;
|
|
285
1160
|
}
|
|
286
1161
|
renderTooltip() {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
>
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
1162
|
+
const t = this.tooltip;
|
|
1163
|
+
if (!t) return A;
|
|
1164
|
+
const e = 36 + t.rows.length * 20 + (t.total ? 24 : 0), a = 20;
|
|
1165
|
+
let o = t.side, i = t.x, n = t.y;
|
|
1166
|
+
return o === "above" && t.y - e < 0 && (o = "right", i = t.x + a), o === "right" && i + 180 > this.box.width && (o = "left", i = t.x - (t.side === "above" ? a : 0)), o === "above" ? i = Math.min(Math.max(i, 72), Math.max(72, this.box.width - 72)) : n = Math.min(
|
|
1167
|
+
Math.max(n, e / 2),
|
|
1168
|
+
Math.max(e / 2, this.height - e / 2)
|
|
1169
|
+
), G`<div class=${`tooltip ${o}`} style=${`left:${i}px;top:${n}px`} role="status">
|
|
1170
|
+
<strong>${t.title}</strong>
|
|
1171
|
+
${t.subtitle ? G`<span class="tooltip-subtitle">${t.subtitle}</span>` : A}
|
|
1172
|
+
${t.rows.map(
|
|
1173
|
+
(r) => G`<span class="tooltip-row">
|
|
1174
|
+
<span class="swatch" style=${`--swatch:${r.color}`}></span>
|
|
1175
|
+
<span class="tooltip-name">${r.name}</span>
|
|
1176
|
+
<span class="tooltip-value">${r.value}</span>
|
|
298
1177
|
</span>`
|
|
299
1178
|
)}
|
|
1179
|
+
${t.total ? G`<span class="tooltip-total"
|
|
1180
|
+
><span>${this.totalLabel}</span><span>${t.total}</span></span
|
|
1181
|
+
>` : A}
|
|
1182
|
+
</div>`;
|
|
1183
|
+
}
|
|
1184
|
+
renderLegend() {
|
|
1185
|
+
const t = this.sliced ? Array.from({ length: this.pointCount }, (e, a) => ({
|
|
1186
|
+
name: this.labels[a] ?? `#${a + 1}`,
|
|
1187
|
+
color: this.sliceColor(a)
|
|
1188
|
+
})) : this.series.map((e, a) => ({ name: e.name, color: this.colorOf(a) }));
|
|
1189
|
+
return t.length === 0 || !this.sliced && t.length < 2 ? A : G`<div part="legend" class="legend">
|
|
1190
|
+
${t.map((e, a) => {
|
|
1191
|
+
const o = this.hiddenSeries.has(a);
|
|
1192
|
+
return G`<button
|
|
1193
|
+
type="button"
|
|
1194
|
+
class="legend-item"
|
|
1195
|
+
aria-pressed=${o ? "false" : "true"}
|
|
1196
|
+
@click=${() => this.toggle(a)}
|
|
1197
|
+
>
|
|
1198
|
+
<span
|
|
1199
|
+
class=${kt({ swatch: !0, hollow: o })}
|
|
1200
|
+
style=${`--swatch:${e.color}`}
|
|
1201
|
+
></span>
|
|
1202
|
+
${e.name}
|
|
1203
|
+
</button>`;
|
|
1204
|
+
})}
|
|
1205
|
+
</div>`;
|
|
1206
|
+
}
|
|
1207
|
+
renderPointTable() {
|
|
1208
|
+
const t = this.type === "bubble";
|
|
1209
|
+
return G`<div part="table" class="table" id=${this.tableId}>
|
|
1210
|
+
<table>
|
|
1211
|
+
<caption>
|
|
1212
|
+
${this.label || "Chart data"}
|
|
1213
|
+
</caption>
|
|
1214
|
+
<thead>
|
|
1215
|
+
<tr>
|
|
1216
|
+
<th scope="col">Series</th>
|
|
1217
|
+
<th scope="col">Point</th>
|
|
1218
|
+
<th scope="col">x</th>
|
|
1219
|
+
<th scope="col">y</th>
|
|
1220
|
+
${t ? G`<th scope="col">r</th>` : A}
|
|
1221
|
+
</tr>
|
|
1222
|
+
</thead>
|
|
1223
|
+
<tbody>
|
|
1224
|
+
${this.series.flatMap(
|
|
1225
|
+
(e) => (e.points ?? []).map(
|
|
1226
|
+
(a, o) => G`<tr>
|
|
1227
|
+
<th scope="row">${e.name}</th>
|
|
1228
|
+
<td>${a.label ?? `#${o + 1}`}</td>
|
|
1229
|
+
<td>${this.formatX(a.x)}</td>
|
|
1230
|
+
<td>${this.format(a.y)}</td>
|
|
1231
|
+
${t ? G`<td>${a.r ?? ""}</td>` : A}
|
|
1232
|
+
</tr>`
|
|
1233
|
+
)
|
|
1234
|
+
)}
|
|
1235
|
+
</tbody>
|
|
1236
|
+
</table>
|
|
1237
|
+
</div>`;
|
|
1238
|
+
}
|
|
1239
|
+
renderSliceTable() {
|
|
1240
|
+
const t = this.series[0]?.values ?? [], e = t.reduce((a, o) => a + Math.max(0, o), 0);
|
|
1241
|
+
return G`<div part="table" class="table" id=${this.tableId}>
|
|
1242
|
+
<table>
|
|
1243
|
+
<caption>
|
|
1244
|
+
${this.label || "Chart data"}
|
|
1245
|
+
</caption>
|
|
1246
|
+
<thead>
|
|
1247
|
+
<tr>
|
|
1248
|
+
<th scope="col">Slice</th>
|
|
1249
|
+
<th scope="col">${this.series[0]?.name ?? "Value"}</th>
|
|
1250
|
+
<th scope="col">Share</th>
|
|
1251
|
+
</tr>
|
|
1252
|
+
</thead>
|
|
1253
|
+
<tbody>
|
|
1254
|
+
${Array.from({ length: this.pointCount }, (a, o) => {
|
|
1255
|
+
const i = t[o] ?? 0, n = e > 0 ? Math.round(Math.max(0, i) / e * 100) : 0;
|
|
1256
|
+
return G`<tr>
|
|
1257
|
+
<th scope="row">${this.labels[o] ?? `#${o + 1}`}</th>
|
|
1258
|
+
<td>${this.format(i)}</td>
|
|
1259
|
+
<td>${n}%</td>
|
|
1260
|
+
</tr>`;
|
|
1261
|
+
})}
|
|
1262
|
+
</tbody>
|
|
1263
|
+
</table>
|
|
1264
|
+
</div>`;
|
|
1265
|
+
}
|
|
1266
|
+
renderTable() {
|
|
1267
|
+
if (this.family === "point") return this.renderPointTable();
|
|
1268
|
+
if (this.sliced) return this.renderSliceTable();
|
|
1269
|
+
const t = this.family === "cartesian" && this.stacked && this.series.length > 1, e = (a) => this.series.reduce(
|
|
1270
|
+
(o, i) => o + (i.type === "line" ? 0 : i.values?.[a] ?? 0),
|
|
1271
|
+
0
|
|
1272
|
+
);
|
|
1273
|
+
return G`<div part="table" class="table" id=${this.tableId}>
|
|
1274
|
+
<table>
|
|
1275
|
+
<caption>
|
|
1276
|
+
${this.label || "Chart data"}
|
|
1277
|
+
</caption>
|
|
1278
|
+
<thead>
|
|
1279
|
+
<tr>
|
|
1280
|
+
<th scope="col">Point</th>
|
|
1281
|
+
${this.series.map((a) => G`<th scope="col">${a.name}</th>`)}
|
|
1282
|
+
${t ? G`<th scope="col">${this.totalLabel}</th>` : A}
|
|
1283
|
+
</tr>
|
|
1284
|
+
</thead>
|
|
1285
|
+
<tbody>
|
|
1286
|
+
${Array.from(
|
|
1287
|
+
{ length: this.pointCount },
|
|
1288
|
+
(a, o) => G`<tr>
|
|
1289
|
+
<th scope="row">${this.labels[o] ?? `#${o + 1}`}</th>
|
|
1290
|
+
${this.series.map(
|
|
1291
|
+
(i) => G`<td>${this.format(i.values?.[o] ?? 0)}</td>`
|
|
1292
|
+
)}
|
|
1293
|
+
${t ? G`<td>${this.format(e(o))}</td>` : A}
|
|
1294
|
+
</tr>`
|
|
1295
|
+
)}
|
|
1296
|
+
</tbody>
|
|
1297
|
+
</table>
|
|
300
1298
|
</div>`;
|
|
301
1299
|
}
|
|
302
1300
|
render() {
|
|
303
|
-
const
|
|
304
|
-
return
|
|
1301
|
+
const t = this.box.width > 0 && this.hasData;
|
|
1302
|
+
return G`<div class="plot" style=${`height:${this.height}px`}>
|
|
305
1303
|
<svg
|
|
306
1304
|
part="svg"
|
|
307
1305
|
width=${this.box.width}
|
|
308
1306
|
height=${this.height}
|
|
309
1307
|
role="img"
|
|
310
|
-
aria-label=${this.label ||
|
|
1308
|
+
aria-label=${this.label || A}
|
|
311
1309
|
aria-describedby=${this.tableId}
|
|
1310
|
+
tabindex="0"
|
|
312
1311
|
@pointermove=${this.onPointerMove}
|
|
313
1312
|
@pointerleave=${this.onPointerLeave}
|
|
1313
|
+
@keydown=${this.onKeyDown}
|
|
1314
|
+
@blur=${this.onPointerLeave}
|
|
314
1315
|
>
|
|
315
|
-
${t ? this.
|
|
316
|
-
${t && this.type === "bar" ? this.renderBars() : h}
|
|
317
|
-
${t && this.type !== "bar" ? this.renderLines() : h}
|
|
318
|
-
${t && this.active >= 0 && this.type !== "bar" ? l`<line
|
|
319
|
-
class="crosshair"
|
|
320
|
-
x1=${this.xFor(this.active)} y1=${e.y}
|
|
321
|
-
x2=${this.xFor(this.active)} y2=${e.y + e.height}
|
|
322
|
-
/>` : h}
|
|
323
|
-
${t ? this.renderAxis() : h}
|
|
1316
|
+
${t ? this.renderMarks() : A}
|
|
324
1317
|
</svg>
|
|
325
1318
|
${this.renderTooltip()}
|
|
326
1319
|
</div>
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
],
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
],
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
],
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
],
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
],
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
],
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
],
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
],
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
],
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
],
|
|
396
|
-
|
|
397
|
-
p({ type: Boolean })
|
|
398
|
-
], a.prototype, "smooth");
|
|
399
|
-
n([
|
|
400
|
-
p({ type: String })
|
|
401
|
-
], a.prototype, "label");
|
|
402
|
-
A("kt-chart", a);
|
|
1320
|
+
${this.renderLegend()} ${this.renderTable()}`;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
C([
|
|
1324
|
+
vt(".plot")
|
|
1325
|
+
], S.prototype, "plot");
|
|
1326
|
+
C([
|
|
1327
|
+
tt()
|
|
1328
|
+
], S.prototype, "box");
|
|
1329
|
+
C([
|
|
1330
|
+
tt()
|
|
1331
|
+
], S.prototype, "active");
|
|
1332
|
+
C([
|
|
1333
|
+
tt()
|
|
1334
|
+
], S.prototype, "activeSeries");
|
|
1335
|
+
C([
|
|
1336
|
+
tt()
|
|
1337
|
+
], S.prototype, "hiddenSeries");
|
|
1338
|
+
C([
|
|
1339
|
+
B({ type: String, reflect: !0 })
|
|
1340
|
+
], S.prototype, "type");
|
|
1341
|
+
C([
|
|
1342
|
+
B({ attribute: !1 })
|
|
1343
|
+
], S.prototype, "series");
|
|
1344
|
+
C([
|
|
1345
|
+
B({ attribute: !1 })
|
|
1346
|
+
], S.prototype, "labels");
|
|
1347
|
+
C([
|
|
1348
|
+
B({ type: Number })
|
|
1349
|
+
], S.prototype, "height");
|
|
1350
|
+
C([
|
|
1351
|
+
B({ attribute: !1 })
|
|
1352
|
+
], S.prototype, "format");
|
|
1353
|
+
C([
|
|
1354
|
+
B({ attribute: !1 })
|
|
1355
|
+
], S.prototype, "formatX");
|
|
1356
|
+
C([
|
|
1357
|
+
B({ type: Boolean, attribute: "no-grid" })
|
|
1358
|
+
], S.prototype, "noGrid");
|
|
1359
|
+
C([
|
|
1360
|
+
B({ type: Boolean, attribute: "no-axis" })
|
|
1361
|
+
], S.prototype, "noAxis");
|
|
1362
|
+
C([
|
|
1363
|
+
B({ type: Boolean, reflect: !0, attribute: "show-table" })
|
|
1364
|
+
], S.prototype, "showTable");
|
|
1365
|
+
C([
|
|
1366
|
+
B({ type: Boolean })
|
|
1367
|
+
], S.prototype, "smooth");
|
|
1368
|
+
C([
|
|
1369
|
+
B({ type: Boolean })
|
|
1370
|
+
], S.prototype, "stacked");
|
|
1371
|
+
C([
|
|
1372
|
+
B({ type: Boolean })
|
|
1373
|
+
], S.prototype, "horizontal");
|
|
1374
|
+
C([
|
|
1375
|
+
B({ type: Number })
|
|
1376
|
+
], S.prototype, "min");
|
|
1377
|
+
C([
|
|
1378
|
+
B({ type: Number })
|
|
1379
|
+
], S.prototype, "max");
|
|
1380
|
+
C([
|
|
1381
|
+
B({ type: String, attribute: "center-label" })
|
|
1382
|
+
], S.prototype, "centerLabel");
|
|
1383
|
+
C([
|
|
1384
|
+
B({ type: String, attribute: "total-label" })
|
|
1385
|
+
], S.prototype, "totalLabel");
|
|
1386
|
+
C([
|
|
1387
|
+
B({ type: String })
|
|
1388
|
+
], S.prototype, "label");
|
|
1389
|
+
wt("kt-chart", S);
|
|
403
1390
|
export {
|
|
404
|
-
|
|
1391
|
+
S as KtChart
|
|
405
1392
|
};
|
|
406
1393
|
//# sourceMappingURL=kt-chart.js.map
|