@ahmetilhn/hanui 4.0.0 → 5.3.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 +259 -39
- package/build/charts.cjs +2 -0
- package/build/charts.cjs.map +1 -0
- package/build/charts.css +1 -0
- package/build/charts.js +1843 -0
- package/build/charts.js.map +1 -0
- package/build/chat.cjs +3 -0
- package/build/chat.cjs.map +1 -0
- package/build/chat.css +1 -0
- package/build/chat.js +707 -0
- package/build/chat.js.map +1 -0
- package/build/index.cjs +7 -7
- package/build/index.cjs.map +1 -1
- package/build/index.d.ts +661 -717
- package/build/index.js +3396 -3303
- package/build/index.js.map +1 -1
- package/build/scss/_colors.generated.scss +119 -0
- package/build/scss/_index.scss +6 -0
- package/build/scss/_metrics.generated.scss +49 -0
- package/build/scss/_mixins.scss +675 -0
- package/build/scss/_variables.scss +51 -0
- package/build/styles.css +1 -1
- package/build/types/charts/AreaChart/index.d.ts +14 -0
- package/build/types/charts/BarChart/index.d.ts +16 -0
- package/build/types/charts/BoxPlot/index.d.ts +43 -0
- package/build/types/charts/ComposedChart/index.d.ts +16 -0
- package/build/types/charts/Heatmap/index.d.ts +30 -0
- package/build/types/charts/Histogram/index.d.ts +29 -0
- package/build/types/charts/LineChart/index.d.ts +14 -0
- package/build/types/charts/PieChart/index.d.ts +36 -0
- package/build/types/charts/RadarChart/index.d.ts +40 -0
- package/build/types/charts/ScatterPlot/index.d.ts +41 -0
- package/build/types/charts/core/CartesianChart.d.ts +43 -0
- package/build/types/charts/core/ChartFrame.d.ts +55 -0
- package/build/types/charts/core/axes.d.ts +34 -0
- package/build/types/charts/core/cartesian.d.ts +79 -0
- package/build/types/charts/core/format.d.ts +9 -0
- package/build/types/charts/core/margins.d.ts +9 -0
- package/build/types/charts/core/palette.d.ts +13 -0
- package/build/types/charts/core/path.d.ts +24 -0
- package/build/types/charts/core/scale.d.ts +40 -0
- package/build/types/charts/core/series.d.ts +11 -0
- package/build/types/charts/core/spatial.d.ts +12 -0
- package/build/types/charts/core/stats.d.ts +34 -0
- package/build/types/charts/core/types.d.ts +31 -0
- package/build/types/charts/core/useChartWidth.d.ts +7 -0
- package/build/types/charts/index.d.ts +21 -0
- package/build/types/chat/ActionList/index.d.ts +46 -0
- package/build/types/chat/AppBar/index.d.ts +21 -0
- package/build/types/chat/ChatMessage/index.d.ts +24 -0
- package/build/types/chat/ChatThread/index.d.ts +24 -0
- package/build/types/chat/Citation/index.d.ts +15 -0
- package/build/types/chat/CodeBlock/index.d.ts +27 -0
- package/build/types/chat/DescriptionList/index.d.ts +16 -0
- package/build/types/chat/Legend/index.d.ts +20 -0
- package/build/types/chat/MessageActions/index.d.ts +21 -0
- package/build/types/chat/PromptInput/index.d.ts +47 -0
- package/build/types/chat/PromptSuggestions/index.d.ts +25 -0
- package/build/types/chat/Prose/index.d.ts +15 -0
- package/build/types/chat/ReasoningBlock/index.d.ts +24 -0
- package/build/types/chat/ReasoningText/index.d.ts +14 -0
- package/build/types/chat/SegmentBar/index.d.ts +46 -0
- package/build/types/chat/SourceList/index.d.ts +25 -0
- package/build/types/chat/TerminalOutput/index.d.ts +25 -0
- package/build/types/chat/ToolCall/index.d.ts +41 -0
- package/build/types/chat/index.d.ts +26 -0
- package/build/types/helpers/class-name.helper.d.ts +3 -0
- package/build/types/helpers/component.helper.d.ts +13 -0
- package/build/types/helpers/label.helper.d.ts +12 -0
- package/build/types/theme/palette.d.ts +203 -0
- package/build/types/theme/tokens.d.ts +208 -0
- package/build/types/types/common-element-props.type.d.ts +8 -0
- package/build/types/types/link.type.d.ts +14 -0
- package/build/types/types/theme.type.d.ts +223 -0
- package/package.json +19 -2
package/build/charts.js
ADDED
|
@@ -0,0 +1,1843 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as m, jsxs as V, Fragment as Ct } from "react/jsx-runtime";
|
|
3
|
+
import { useId as pn, useState as At, useRef as Pt, useEffect as Kt, useCallback as nt, useLayoutEffect as fn, memo as ot, useMemo as L } from "react";
|
|
4
|
+
import { useAnnounce as Mn, useHanui as xt } from "@ahmetilhn/hanui";
|
|
5
|
+
const lt = (t, o) => Object.assign(t, { displayName: o }), wn = "hanui-axis-AqLAe", $n = "hanui-axis__label-dHxpo", kn = "hanui-axis__grid-RVxXW", Nn = "hanui-axis__baseline-jhG2z", ct = {
|
|
6
|
+
axis: wn,
|
|
7
|
+
axis__label: $n,
|
|
8
|
+
axis__grid: kn,
|
|
9
|
+
axis__baseline: Nn
|
|
10
|
+
}, yn = 6.4, ut = (t) => t.length * yn, xn = (t, o = 8) => {
|
|
11
|
+
if (t.length < 2) return [...t];
|
|
12
|
+
const n = Math.max(...t.map((h) => ut(h.label))), e = Math.abs(t[1].position - t[0].position), r = e <= 0 ? 1 : Math.max(1, Math.ceil((n + o) / e));
|
|
13
|
+
return t.filter((h, d) => d % r === 0);
|
|
14
|
+
}, Et = (t, o) => {
|
|
15
|
+
const n = Math.max(1, Math.floor(o / yn));
|
|
16
|
+
return t.length <= n ? t : `${t.slice(0, Math.max(1, n - 1))}…`;
|
|
17
|
+
}, pt = ({ area: t, ticks: o, side: n, hasGrid: e = !1 }) => /* @__PURE__ */ m("g", { className: ct.axis, "aria-hidden": !0, children: o.map(
|
|
18
|
+
(r) => n === "bottom" ? /* @__PURE__ */ V("g", { children: [
|
|
19
|
+
e && /* @__PURE__ */ m(
|
|
20
|
+
"line",
|
|
21
|
+
{
|
|
22
|
+
className: ct.axis__grid,
|
|
23
|
+
x1: r.position,
|
|
24
|
+
x2: r.position,
|
|
25
|
+
y1: t.top,
|
|
26
|
+
y2: t.bottom
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ m(
|
|
30
|
+
"text",
|
|
31
|
+
{
|
|
32
|
+
className: ct.axis__label,
|
|
33
|
+
x: r.position,
|
|
34
|
+
y: t.bottom + 16,
|
|
35
|
+
textAnchor: "middle",
|
|
36
|
+
children: r.label
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
] }, `${r.position}-${r.label}`) : /* @__PURE__ */ V("g", { children: [
|
|
40
|
+
e && /* @__PURE__ */ m(
|
|
41
|
+
"line",
|
|
42
|
+
{
|
|
43
|
+
className: ct.axis__grid,
|
|
44
|
+
x1: t.left,
|
|
45
|
+
x2: t.right,
|
|
46
|
+
y1: r.position,
|
|
47
|
+
y2: r.position
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ m(
|
|
51
|
+
"text",
|
|
52
|
+
{
|
|
53
|
+
className: ct.axis__label,
|
|
54
|
+
x: n === "left" ? t.left - 8 : t.right + 8,
|
|
55
|
+
y: r.position,
|
|
56
|
+
dy: "0.32em",
|
|
57
|
+
textAnchor: n === "left" ? "end" : "start",
|
|
58
|
+
children: r.label
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] }, `${r.position}-${r.label}`)
|
|
62
|
+
) }), Xt = ({ area: t, ticks: o, side: n }) => /* @__PURE__ */ m("g", { className: ct.axis, "aria-hidden": !0, children: n === "bottom" ? /* @__PURE__ */ V(Ct, { children: [
|
|
63
|
+
/* @__PURE__ */ m(
|
|
64
|
+
"line",
|
|
65
|
+
{
|
|
66
|
+
className: ct.axis__baseline,
|
|
67
|
+
x1: t.left,
|
|
68
|
+
x2: t.right,
|
|
69
|
+
y1: t.bottom,
|
|
70
|
+
y2: t.bottom
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
xn(o).map((e) => /* @__PURE__ */ m(
|
|
74
|
+
"text",
|
|
75
|
+
{
|
|
76
|
+
className: ct.axis__label,
|
|
77
|
+
x: e.position,
|
|
78
|
+
y: t.bottom + 16,
|
|
79
|
+
textAnchor: "middle",
|
|
80
|
+
children: e.label
|
|
81
|
+
},
|
|
82
|
+
`${e.position}-${e.label}`
|
|
83
|
+
))
|
|
84
|
+
] }) : /* @__PURE__ */ V(Ct, { children: [
|
|
85
|
+
/* @__PURE__ */ m(
|
|
86
|
+
"line",
|
|
87
|
+
{
|
|
88
|
+
className: ct.axis__baseline,
|
|
89
|
+
x1: t.left,
|
|
90
|
+
x2: t.left,
|
|
91
|
+
y1: t.top,
|
|
92
|
+
y2: t.bottom
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
o.map((e) => /* @__PURE__ */ m(
|
|
96
|
+
"text",
|
|
97
|
+
{
|
|
98
|
+
className: ct.axis__label,
|
|
99
|
+
x: t.left - 8,
|
|
100
|
+
y: e.position,
|
|
101
|
+
dy: "0.32em",
|
|
102
|
+
textAnchor: "end",
|
|
103
|
+
children: Et(e.label, t.left - 12)
|
|
104
|
+
},
|
|
105
|
+
`${e.position}-${e.label}`
|
|
106
|
+
))
|
|
107
|
+
] }) }), j = (t) => Math.round(t * 100) / 100, vn = (t) => {
|
|
108
|
+
const o = [];
|
|
109
|
+
let n = [];
|
|
110
|
+
for (const e of t)
|
|
111
|
+
e === null || !Number.isFinite(e.x) || !Number.isFinite(e.y) ? (n.length > 0 && o.push(n), n = []) : n.push(e);
|
|
112
|
+
return n.length > 0 && o.push(n), o;
|
|
113
|
+
}, Gt = (t) => t.map((o, n) => `${n === 0 ? "M" : "L"}${j(o.x)},${j(o.y)}`).join(""), gn = (t) => {
|
|
114
|
+
const o = t.length;
|
|
115
|
+
if (o < 3) return Gt(t);
|
|
116
|
+
const n = [], e = [];
|
|
117
|
+
for (let h = 0; h < o - 1; h += 1) {
|
|
118
|
+
const d = t[h + 1].x - t[h].x;
|
|
119
|
+
e.push(d === 0 ? 0 : (t[h + 1].y - t[h].y) / d);
|
|
120
|
+
}
|
|
121
|
+
n.push(e[0]);
|
|
122
|
+
for (let h = 1; h < o - 1; h += 1)
|
|
123
|
+
n.push(
|
|
124
|
+
e[h - 1] * e[h] <= 0 ? 0 : (e[h - 1] + e[h]) / 2
|
|
125
|
+
);
|
|
126
|
+
n.push(e[o - 2]);
|
|
127
|
+
for (let h = 0; h < o - 1; h += 1) {
|
|
128
|
+
if (e[h] === 0) {
|
|
129
|
+
n[h] = 0, n[h + 1] = 0;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const d = n[h] / e[h], u = n[h + 1] / e[h], k = d * d + u * u;
|
|
133
|
+
if (k > 9) {
|
|
134
|
+
const I = 3 / Math.sqrt(k);
|
|
135
|
+
n[h] = I * d * e[h], n[h + 1] = I * u * e[h];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let r = `M${j(t[0].x)},${j(t[0].y)}`;
|
|
139
|
+
for (let h = 0; h < o - 1; h += 1) {
|
|
140
|
+
const d = t[h], u = t[h + 1], k = (u.x - d.x) / 3;
|
|
141
|
+
r += `C${j(d.x + k)},${j(d.y + n[h] * k)} ${j(u.x - k)},${j(u.y - n[h + 1] * k)} ${j(u.x)},${j(u.y)}`;
|
|
142
|
+
}
|
|
143
|
+
return r;
|
|
144
|
+
}, An = (t, o = "linear") => vn(t).map((n) => o === "monotone" ? gn(n) : Gt(n)).join(""), Tn = (t, o, n = "linear") => {
|
|
145
|
+
const e = [];
|
|
146
|
+
let r = [], h = [];
|
|
147
|
+
const d = () => {
|
|
148
|
+
if (r.length > 0) {
|
|
149
|
+
const u = n === "monotone" ? gn : Gt, k = u([...h].reverse()).replace(/^M/, "L");
|
|
150
|
+
e.push(`${u(r)}${k}Z`);
|
|
151
|
+
}
|
|
152
|
+
r = [], h = [];
|
|
153
|
+
};
|
|
154
|
+
return t.forEach((u, k) => {
|
|
155
|
+
const I = o[k];
|
|
156
|
+
u === null || I === null || I === void 0 ? d() : (r.push(u), h.push(I));
|
|
157
|
+
}), d(), e.join("");
|
|
158
|
+
}, et = (t, o, n, e) => ({
|
|
159
|
+
x: t + n * Math.sin(e),
|
|
160
|
+
y: o - n * Math.cos(e)
|
|
161
|
+
}), tn = (t, o, n, e, r, h) => {
|
|
162
|
+
const d = h - r;
|
|
163
|
+
if (d <= 0 || n <= 0) return "";
|
|
164
|
+
if (d >= Math.PI * 2 - 1e-6) {
|
|
165
|
+
const b = (S, P) => `M${j(t)},${j(o - S)}A${S},${S} 0 1 ${P} ${j(t)},${j(o + S)}A${S},${S} 0 1 ${P} ${j(t)},${j(o - S)}Z`;
|
|
166
|
+
return b(n, 1) + (e > 0 ? b(e, 0) : "");
|
|
167
|
+
}
|
|
168
|
+
const u = d > Math.PI ? 1 : 0, k = et(t, o, n, r), I = et(t, o, n, h);
|
|
169
|
+
if (e <= 0)
|
|
170
|
+
return `M${j(t)},${j(o)}L${j(k.x)},${j(k.y)}A${n},${n} 0 ${u} 1 ${j(I.x)},${j(I.y)}Z`;
|
|
171
|
+
const A = et(t, o, e, h), C = et(t, o, e, r);
|
|
172
|
+
return `M${j(k.x)},${j(k.y)}A${n},${n} 0 ${u} 1 ${j(I.x)},${j(I.y)}L${j(A.x)},${j(A.y)}A${e},${e} 0 ${u} 0 ${j(C.x)},${j(C.y)}Z`;
|
|
173
|
+
}, nn = (t) => t.length === 0 ? "" : `${Gt(t)}Z`, ft = (t, o) => {
|
|
174
|
+
const [n, e] = t, [r, h] = o, d = e - n, u = (k) => d === 0 ? (r + h) / 2 : r + (k - n) / d * (h - r);
|
|
175
|
+
return u.domain = t, u.range = o, u.invert = (k) => h === r ? n : n + (k - r) / (h - r) * d, u;
|
|
176
|
+
}, Dt = (t, o, { paddingInner: n = 0.2, paddingOuter: e = 0.1 } = {}) => {
|
|
177
|
+
const [r, h] = o, d = t.length, u = d === 0 ? 0 : (h - r) / Math.max(1, d - n + e * 2), k = u * (1 - n), I = r + u * e, A = new Map(t.map((b, S) => [b, S])), C = (b) => {
|
|
178
|
+
const S = A.get(b);
|
|
179
|
+
return S === void 0 ? Number.NaN : I + S * u;
|
|
180
|
+
};
|
|
181
|
+
return C.domain = t, C.range = o, C.bandwidth = k, C.step = u, C.indexAt = (b) => d === 0 ? -1 : Math.min(
|
|
182
|
+
d - 1,
|
|
183
|
+
Math.max(
|
|
184
|
+
0,
|
|
185
|
+
Math.floor((b - r - u * e + (u - k) / 2) / u)
|
|
186
|
+
)
|
|
187
|
+
), C;
|
|
188
|
+
}, Zt = (t, o, n) => {
|
|
189
|
+
const e = Math.abs(o - t);
|
|
190
|
+
if (e === 0 || !Number.isFinite(e) || n <= 0) return 1;
|
|
191
|
+
const r = e / n, h = 10 ** Math.floor(Math.log10(r)), d = r / h;
|
|
192
|
+
return (d >= 7.5 ? 10 : d >= 3.5 ? 5 : d >= 1.5 ? 2 : 1) * h;
|
|
193
|
+
}, Yt = (t, o) => {
|
|
194
|
+
const n = Math.max(0, -Math.floor(Math.log10(o)) + 1);
|
|
195
|
+
return Number(t.toFixed(Math.min(n, 12)));
|
|
196
|
+
}, vt = (t, o, n = 5) => {
|
|
197
|
+
if (!Number.isFinite(t) || !Number.isFinite(o)) return [0, 1];
|
|
198
|
+
let e = Math.min(t, o), r = Math.max(t, o);
|
|
199
|
+
if (e === r) {
|
|
200
|
+
if (e === 0) return [0, 1];
|
|
201
|
+
const d = Math.abs(e) * 0.5;
|
|
202
|
+
e = e > 0 ? 0 : e - d, r = r < 0 ? 0 : r + d;
|
|
203
|
+
}
|
|
204
|
+
const h = Zt(e, r, n);
|
|
205
|
+
return [Yt(Math.floor(e / h) * h, h), Yt(Math.ceil(r / h) * h, h)];
|
|
206
|
+
}, rt = (t, o, n = 5) => {
|
|
207
|
+
if (!Number.isFinite(t) || !Number.isFinite(o)) return [];
|
|
208
|
+
if (t === o) return [t];
|
|
209
|
+
const e = Zt(t, o, n), r = Math.ceil(t / e - 1e-9), h = Math.floor(o / e + 1e-9), d = [];
|
|
210
|
+
for (let u = r; u <= h && d.length < 1e3; u += 1)
|
|
211
|
+
d.push(Yt(u * e, e));
|
|
212
|
+
return d;
|
|
213
|
+
}, In = (t, o) => {
|
|
214
|
+
if (t.length === 0) return -1;
|
|
215
|
+
let n = 0, e = t.length - 1;
|
|
216
|
+
for (; n < e; ) {
|
|
217
|
+
const r = n + e >> 1;
|
|
218
|
+
t[r] < o ? n = r + 1 : e = r;
|
|
219
|
+
}
|
|
220
|
+
return n > 0 && Math.abs(t[n - 1] - o) <= Math.abs(t[n] - o) ? n - 1 : n;
|
|
221
|
+
}, qt = (t) => t.filter((o) => typeof o == "number" && Number.isFinite(o)), yt = (t) => {
|
|
222
|
+
if (t.length === 0) return [0, 0];
|
|
223
|
+
let o = t[0], n = t[0];
|
|
224
|
+
for (const e of t)
|
|
225
|
+
e < o && (o = e), e > n && (n = e);
|
|
226
|
+
return [o, n];
|
|
227
|
+
}, Bt = (t, o) => {
|
|
228
|
+
if (t.length === 0) return Number.NaN;
|
|
229
|
+
if (t.length === 1) return t[0];
|
|
230
|
+
const n = (t.length - 1) * Math.min(1, Math.max(0, o)), e = Math.floor(n), r = n - e;
|
|
231
|
+
return e + 1 < t.length ? t[e] + (t[e + 1] - t[e]) * r : t[e];
|
|
232
|
+
}, Cn = (t) => {
|
|
233
|
+
const o = qt(t).sort((d, u) => d - u);
|
|
234
|
+
if (o.length === 0) return null;
|
|
235
|
+
const n = Bt(o, 0.25), e = Bt(o, 0.75), r = (e - n) * 1.5, h = o.filter((d) => d >= n - r && d <= e + r);
|
|
236
|
+
return {
|
|
237
|
+
count: o.length,
|
|
238
|
+
min: o[0],
|
|
239
|
+
q1: n,
|
|
240
|
+
median: Bt(o, 0.5),
|
|
241
|
+
q3: e,
|
|
242
|
+
max: o[o.length - 1],
|
|
243
|
+
whiskerLow: h[0] ?? n,
|
|
244
|
+
whiskerHigh: h[h.length - 1] ?? e,
|
|
245
|
+
outliers: o.filter((d) => d < n - r || d > e + r)
|
|
246
|
+
};
|
|
247
|
+
}, Rn = (t, o) => {
|
|
248
|
+
const n = qt(t);
|
|
249
|
+
if (n.length === 0) return [];
|
|
250
|
+
const [e, r] = yt(n);
|
|
251
|
+
if (e === r) return [{ from: e, to: e + 1, count: n.length }];
|
|
252
|
+
const h = o ?? Math.ceil(Math.log2(n.length)) + 1, d = Zt(e, r, Math.max(1, h)), u = Math.floor(e / d) * d, k = Math.max(1, Math.ceil((r - u) / d - 1e-9)), I = Array.from({ length: k }, (A, C) => ({
|
|
253
|
+
from: u + C * d,
|
|
254
|
+
to: u + (C + 1) * d,
|
|
255
|
+
count: 0
|
|
256
|
+
}));
|
|
257
|
+
for (const A of n) {
|
|
258
|
+
const C = Math.min(I.length - 1, Math.floor((A - u) / d));
|
|
259
|
+
I[C].count += 1;
|
|
260
|
+
}
|
|
261
|
+
return I;
|
|
262
|
+
}, Nt = (t) => typeof t == "number" && Number.isFinite(t) ? t : null, it = { top: 12, right: 16, bottom: 28, minLeft: 32 }, Fn = (t, o) => {
|
|
263
|
+
const n = t.map(() => 0), e = t.map(() => 0), r = {};
|
|
264
|
+
for (const h of o)
|
|
265
|
+
r[h] = t.map((d, u) => {
|
|
266
|
+
const k = Nt(d[h]) ?? 0;
|
|
267
|
+
if (k >= 0) {
|
|
268
|
+
const A = n[u];
|
|
269
|
+
return n[u] += k, { base: A, top: n[u] };
|
|
270
|
+
}
|
|
271
|
+
const I = e[u];
|
|
272
|
+
return e[u] += k, { base: I, top: e[u] };
|
|
273
|
+
});
|
|
274
|
+
return r;
|
|
275
|
+
}, Sn = (t) => {
|
|
276
|
+
const { rows: o, xKey: n, series: e, width: r, height: h, isStacked: d, curve: u, formatX: k } = t, I = e.some((v) => v.type === "bar"), C = (I && e.every((v) => v.type === "bar") ? t.orientation : "vertical") === "horizontal", b = o.map((v) => v[n]), S = !I && !C && b.length > 1 && b.every((v) => Nt(v) !== null), P = {};
|
|
277
|
+
if (d)
|
|
278
|
+
for (const v of ["left", "right"])
|
|
279
|
+
for (const B of ["bar", "area"]) {
|
|
280
|
+
const W = e.filter((Z) => (Z.axis ?? "left") === v && Z.type === B).map((Z) => Z.key);
|
|
281
|
+
Object.assign(P, Fn(o, W));
|
|
282
|
+
}
|
|
283
|
+
const H = (v, B) => {
|
|
284
|
+
if (P[v]) return P[v][B];
|
|
285
|
+
const W = Nt(o[B][v]);
|
|
286
|
+
return W === null ? null : { base: 0, top: W };
|
|
287
|
+
}, q = (v) => {
|
|
288
|
+
const B = e.filter((dt) => (dt.axis ?? "left") === v);
|
|
289
|
+
if (B.length === 0) return null;
|
|
290
|
+
let W = Number.POSITIVE_INFINITY, Z = Number.NEGATIVE_INFINITY;
|
|
291
|
+
for (const dt of B)
|
|
292
|
+
for (let Mt = 0; Mt < o.length; Mt += 1) {
|
|
293
|
+
const mt = H(dt.key, Mt);
|
|
294
|
+
mt && (W = Math.min(W, mt.top, mt.base), Z = Math.max(Z, mt.top, mt.base));
|
|
295
|
+
}
|
|
296
|
+
if (B.some((dt) => dt.type !== "line") && (W = Math.min(W, 0), Z = Math.max(Z, 0)), !Number.isFinite(W) || !Number.isFinite(Z)) return [0, 1];
|
|
297
|
+
const [at, K] = v === "left" ? t.domain ?? [void 0, void 0] : [void 0, void 0], tt = vt(at ?? W, K ?? Z);
|
|
298
|
+
return [at ?? tt[0], K ?? tt[1]];
|
|
299
|
+
}, E = q("left") ?? [0, 1], N = q("right"), R = N !== null && !C, D = rt(E[0], E[1], 5).map(t.formatLeft), M = N ? rt(N[0], N[1], 5).map(t.formatRight) : [], $ = o.map((v) => k(v[n])), i = C ? Math.min(r * 0.4, Math.max(it.minLeft, ...$.map(ut)) + 12) : Math.max(it.minLeft, ...D.map(ut)) + 10, y = R ? Math.max(it.minLeft, ...M.map(ut)) + 10 : it.right, s = {
|
|
300
|
+
left: i,
|
|
301
|
+
top: it.top,
|
|
302
|
+
right: Math.max(i + 1, r - y),
|
|
303
|
+
bottom: Math.max(it.top + 1, h - it.bottom),
|
|
304
|
+
width: Math.max(1, r - y - i),
|
|
305
|
+
height: Math.max(1, h - it.bottom - it.top)
|
|
306
|
+
}, l = C ? [s.top, s.bottom] : [s.left, s.right], c = C ? [s.left, s.right] : [s.bottom, s.top], a = ft(E, c), p = N ? ft(N, c) : a, _ = (v) => (v.axis ?? "left") === "right" && N ? p : a;
|
|
307
|
+
let w, x = 0, f = null;
|
|
308
|
+
if (S) {
|
|
309
|
+
const v = b.map((B) => Nt(B));
|
|
310
|
+
f = ft(yt(v), l), w = v.map(f);
|
|
311
|
+
} else {
|
|
312
|
+
const v = Dt(
|
|
313
|
+
o.map((B, W) => String(W)),
|
|
314
|
+
l,
|
|
315
|
+
I ? { paddingInner: 0.24, paddingOuter: 0.12 } : { paddingInner: 0, paddingOuter: 0 }
|
|
316
|
+
);
|
|
317
|
+
x = v.bandwidth, w = o.map((B, W) => v(String(W)) + v.bandwidth / 2);
|
|
318
|
+
}
|
|
319
|
+
const T = (v, B) => C ? { x: B, y: v } : { x: v, y: B }, O = [], X = e.filter((v) => v.type === "bar"), U = d ? 1 : Math.max(1, X.length), G = U > 1 ? Math.min(2, x * 0.04) : 0, g = Math.max(1, (x - G * (U - 1)) / U);
|
|
320
|
+
X.forEach((v, B) => {
|
|
321
|
+
const W = _(v), Z = d ? 0 : B;
|
|
322
|
+
o.forEach((at, K) => {
|
|
323
|
+
const tt = H(v.key, K);
|
|
324
|
+
if (!tt || tt.top === tt.base) return;
|
|
325
|
+
const dt = w[K] - x / 2 + Z * (g + G), Mt = W(tt.base), mt = W(tt.top), Qt = Math.min(Mt, mt), Jt = Math.max(1, Math.abs(mt - Mt));
|
|
326
|
+
O.push(
|
|
327
|
+
C ? {
|
|
328
|
+
key: v.key,
|
|
329
|
+
index: K,
|
|
330
|
+
tone: v.tone,
|
|
331
|
+
x: Qt,
|
|
332
|
+
y: dt,
|
|
333
|
+
width: Jt,
|
|
334
|
+
height: g
|
|
335
|
+
} : {
|
|
336
|
+
key: v.key,
|
|
337
|
+
index: K,
|
|
338
|
+
tone: v.tone,
|
|
339
|
+
x: dt,
|
|
340
|
+
y: Qt,
|
|
341
|
+
width: g,
|
|
342
|
+
height: Jt
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
const F = {}, z = [], Y = [];
|
|
348
|
+
for (const v of e) {
|
|
349
|
+
if (v.type === "bar") continue;
|
|
350
|
+
const B = _(v), W = o.map((Z, at) => {
|
|
351
|
+
const K = H(v.key, at);
|
|
352
|
+
return K ? T(w[at], B(K.top)) : null;
|
|
353
|
+
});
|
|
354
|
+
if (F[v.key] = W, v.type === "area") {
|
|
355
|
+
const Z = o.map((at, K) => {
|
|
356
|
+
const tt = H(v.key, K);
|
|
357
|
+
return tt ? T(w[K], B(tt.base)) : null;
|
|
358
|
+
});
|
|
359
|
+
Y.push({ key: v.key, tone: v.tone, d: Tn(W, Z, u) });
|
|
360
|
+
}
|
|
361
|
+
z.push({ key: v.key, tone: v.tone, d: An(W, u) });
|
|
362
|
+
}
|
|
363
|
+
const ht = o.map((v, B) => {
|
|
364
|
+
let W = null;
|
|
365
|
+
for (const at of e) {
|
|
366
|
+
const K = H(at.key, B);
|
|
367
|
+
if (!K) continue;
|
|
368
|
+
const tt = _(at)(K.top);
|
|
369
|
+
W = W === null ? tt : C ? Math.max(W, tt) : Math.min(W, tt);
|
|
370
|
+
}
|
|
371
|
+
const Z = C ? s.left : s.bottom;
|
|
372
|
+
return T(w[B], W ?? Z);
|
|
373
|
+
}), Tt = (v, B, W) => rt(
|
|
374
|
+
B[0],
|
|
375
|
+
B[1],
|
|
376
|
+
C ? Math.max(2, Math.floor(s.width / 90)) : Math.max(2, Math.floor(s.height / 48))
|
|
377
|
+
).map((Z) => ({
|
|
378
|
+
position: v(Z),
|
|
379
|
+
label: W(Z)
|
|
380
|
+
})), _n = f ? rt(f.domain[0], f.domain[1], Math.max(2, Math.floor(s.width / 90))).map(
|
|
381
|
+
(v) => ({
|
|
382
|
+
position: f(v),
|
|
383
|
+
label: k(v)
|
|
384
|
+
})
|
|
385
|
+
) : o.map((v, B) => ({
|
|
386
|
+
position: w[B],
|
|
387
|
+
label: C ? Et($[B], i - 12) : $[B]
|
|
388
|
+
}));
|
|
389
|
+
return {
|
|
390
|
+
zero: E[0] < 0 && E[1] > 0 ? a(0) : null,
|
|
391
|
+
area: s,
|
|
392
|
+
centers: w,
|
|
393
|
+
bandwidth: x,
|
|
394
|
+
isContinuous: S,
|
|
395
|
+
categoryTicks: _n,
|
|
396
|
+
leftTicks: Tt(a, E, t.formatLeft),
|
|
397
|
+
rightTicks: R && N ? Tt(p, N, t.formatRight) : [],
|
|
398
|
+
hasRightAxis: R,
|
|
399
|
+
lines: z,
|
|
400
|
+
areas: Y,
|
|
401
|
+
bars: O,
|
|
402
|
+
points: F,
|
|
403
|
+
anchors: ht
|
|
404
|
+
};
|
|
405
|
+
}, en = (...t) => {
|
|
406
|
+
let o = "";
|
|
407
|
+
for (const n of t)
|
|
408
|
+
n && (o = o === "" ? n : `${o} ${n}`);
|
|
409
|
+
return o;
|
|
410
|
+
}, on = [
|
|
411
|
+
"cat-1",
|
|
412
|
+
"cat-2",
|
|
413
|
+
"cat-3",
|
|
414
|
+
"cat-4",
|
|
415
|
+
"cat-5",
|
|
416
|
+
"series-2"
|
|
417
|
+
], Ft = (t, o) => o ?? on[t % on.length], Q = (t) => t === "muted" ? "var(--hanui-text-3)" : `var(--hanui-${t})`, Hn = "hanui-chart-iR-5u", Ln = "hanui-chart__canvas-4wf8o", zn = "hanui-chart__svg-yC5iw", Pn = "hanui-chart__overlay-kbXEv", Dn = "hanui-chart__tooltip-wbhLY", En = "hanui-chart__tooltipTitle-j-1Nw", Gn = "hanui-chart__tooltipRow-phors", qn = "hanui-chart__tooltipLabel-72x80", On = "hanui-chart__tooltipValue-caeby", Bn = "hanui-chart__swatch--mk77", Wn = "hanui-chart__legend-EhXcQ", jn = "hanui-chart__legendItem--AaGe", Vn = "hanui-chart__srOnly-Oyem2", J = {
|
|
418
|
+
chart: Hn,
|
|
419
|
+
chart__canvas: Ln,
|
|
420
|
+
chart__svg: zn,
|
|
421
|
+
chart__overlay: Pn,
|
|
422
|
+
chart__tooltip: Dn,
|
|
423
|
+
chart__tooltipTitle: En,
|
|
424
|
+
chart__tooltipRow: Gn,
|
|
425
|
+
chart__tooltipLabel: qn,
|
|
426
|
+
chart__tooltipValue: On,
|
|
427
|
+
chart__swatch: Bn,
|
|
428
|
+
chart__legend: Wn,
|
|
429
|
+
chart__legendItem: jn,
|
|
430
|
+
"chart__legendItem--hidden": "hanui-chart__legendItem--hidden-D3li8",
|
|
431
|
+
chart__srOnly: Vn
|
|
432
|
+
}, an = 12, gt = ({
|
|
433
|
+
label: t,
|
|
434
|
+
description: o,
|
|
435
|
+
containerRef: n,
|
|
436
|
+
width: e,
|
|
437
|
+
height: r,
|
|
438
|
+
plot: h,
|
|
439
|
+
overlay: d,
|
|
440
|
+
underlay: u,
|
|
441
|
+
itemCount: k,
|
|
442
|
+
columns: I,
|
|
443
|
+
pick: A,
|
|
444
|
+
tooltip: C,
|
|
445
|
+
anchor: b,
|
|
446
|
+
tooltipSide: S = "inward",
|
|
447
|
+
announce: P,
|
|
448
|
+
table: H,
|
|
449
|
+
legend: q,
|
|
450
|
+
className: E,
|
|
451
|
+
testId: N
|
|
452
|
+
}) => {
|
|
453
|
+
const R = pn(), D = Mn(), [M, $] = At(null), i = Pt(null), y = Pt(null), s = Pt(null);
|
|
454
|
+
Kt(() => {
|
|
455
|
+
M !== null && M >= k && $(k > 0 ? k - 1 : null);
|
|
456
|
+
}, [M, k]), Kt(
|
|
457
|
+
() => () => {
|
|
458
|
+
i.current !== null && cancelAnimationFrame(i.current);
|
|
459
|
+
},
|
|
460
|
+
[]
|
|
461
|
+
);
|
|
462
|
+
const l = nt(
|
|
463
|
+
(x) => {
|
|
464
|
+
const f = x.currentTarget.getBoundingClientRect();
|
|
465
|
+
s.current = { x: x.clientX - f.left, y: x.clientY - f.top }, i.current === null && (i.current = requestAnimationFrame(() => {
|
|
466
|
+
i.current = null;
|
|
467
|
+
const T = s.current;
|
|
468
|
+
T && $(A(T.x, T.y));
|
|
469
|
+
}));
|
|
470
|
+
},
|
|
471
|
+
[A]
|
|
472
|
+
), c = (x) => {
|
|
473
|
+
const f = Math.min(k - 1, Math.max(0, x));
|
|
474
|
+
$(f), D(P(f));
|
|
475
|
+
}, a = (x) => {
|
|
476
|
+
if (k === 0) return;
|
|
477
|
+
const f = M ?? -1, T = I ?? 1, O = x.key === "ArrowRight" ? f + 1 : x.key === "ArrowLeft" ? Math.max(0, f - 1) : x.key === "ArrowDown" ? f < 0 ? 0 : f + T : x.key === "ArrowUp" ? Math.max(0, f - T) : x.key === "Home" ? 0 : x.key === "End" ? k - 1 : null;
|
|
478
|
+
if (x.key === "Escape" && M !== null) {
|
|
479
|
+
x.preventDefault(), $(null);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
O !== null && (x.preventDefault(), c(O));
|
|
483
|
+
}, p = M === null ? null : C(M), _ = M === null ? null : b(M), w = _ == null ? void 0 : _.x;
|
|
484
|
+
return fn(() => {
|
|
485
|
+
const x = y.current;
|
|
486
|
+
if (!x || w === void 0) return;
|
|
487
|
+
const f = x.offsetWidth, T = w > e / 2, O = S === "outward" ? !T : T, X = w - an - f, U = w + an, G = X >= 0, g = U + f <= e, F = S === "outward" ? O ? X : U : O ? G || !g ? X : U : g || !G ? U : X;
|
|
488
|
+
x.style.left = `${Math.min(Math.max(0, F), Math.max(0, e - f))}px`;
|
|
489
|
+
}, [M, w, e, S]), /* @__PURE__ */ V("figure", { className: en(J.chart, E), "data-testid": N, children: [
|
|
490
|
+
/* @__PURE__ */ V("div", { ref: n, className: J.chart__canvas, style: { blockSize: r }, children: [
|
|
491
|
+
/* @__PURE__ */ V(
|
|
492
|
+
"svg",
|
|
493
|
+
{
|
|
494
|
+
className: J.chart__svg,
|
|
495
|
+
width: e,
|
|
496
|
+
height: r,
|
|
497
|
+
viewBox: `0 0 ${e} ${r}`,
|
|
498
|
+
role: "img",
|
|
499
|
+
"aria-label": t,
|
|
500
|
+
"aria-describedby": o ? R : void 0,
|
|
501
|
+
tabIndex: k > 0 ? 0 : void 0,
|
|
502
|
+
onPointerMove: l,
|
|
503
|
+
onPointerDown: l,
|
|
504
|
+
onPointerLeave: () => $(null),
|
|
505
|
+
onKeyDown: a,
|
|
506
|
+
onBlur: () => $(null),
|
|
507
|
+
children: [
|
|
508
|
+
M !== null && u && /* @__PURE__ */ m("g", { className: J.chart__overlay, children: u(M) }),
|
|
509
|
+
h,
|
|
510
|
+
M !== null && /* @__PURE__ */ m("g", { className: J.chart__overlay, children: d(M) })
|
|
511
|
+
]
|
|
512
|
+
}
|
|
513
|
+
),
|
|
514
|
+
p && _ && /* Okunan karşılığı duyuru ve tablo; ipucu yalnızca görsel. */
|
|
515
|
+
/* @__PURE__ */ V(
|
|
516
|
+
"div",
|
|
517
|
+
{
|
|
518
|
+
ref: y,
|
|
519
|
+
"aria-hidden": !0,
|
|
520
|
+
className: J.chart__tooltip,
|
|
521
|
+
style: { insetBlockStart: Math.max(24, Math.min(_.y, r - 24)) },
|
|
522
|
+
children: [
|
|
523
|
+
p.title && /* @__PURE__ */ m("span", { className: J.chart__tooltipTitle, children: p.title }),
|
|
524
|
+
p.rows.map((x) => /* @__PURE__ */ V("span", { className: J.chart__tooltipRow, children: [
|
|
525
|
+
x.tone && /* @__PURE__ */ m(
|
|
526
|
+
"span",
|
|
527
|
+
{
|
|
528
|
+
className: J.chart__swatch,
|
|
529
|
+
style: { backgroundColor: Q(x.tone) }
|
|
530
|
+
}
|
|
531
|
+
),
|
|
532
|
+
/* @__PURE__ */ m("span", { className: J.chart__tooltipLabel, children: x.label }),
|
|
533
|
+
/* @__PURE__ */ m("span", { className: J.chart__tooltipValue, children: x.value })
|
|
534
|
+
] }, x.id))
|
|
535
|
+
]
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
] }),
|
|
539
|
+
q && q.entries.length > 1 && /* @__PURE__ */ m("ul", { className: J.chart__legend, children: q.entries.map((x) => {
|
|
540
|
+
const f = q.hidden.has(x.id);
|
|
541
|
+
return /* @__PURE__ */ m("li", { children: /* @__PURE__ */ V(
|
|
542
|
+
"button",
|
|
543
|
+
{
|
|
544
|
+
type: "button",
|
|
545
|
+
className: en(
|
|
546
|
+
J.chart__legendItem,
|
|
547
|
+
f && J["chart__legendItem--hidden"]
|
|
548
|
+
),
|
|
549
|
+
"aria-pressed": !f,
|
|
550
|
+
onClick: () => q.onToggle(x.id),
|
|
551
|
+
children: [
|
|
552
|
+
/* @__PURE__ */ m(Xn, { tone: x.tone, isHidden: f }),
|
|
553
|
+
x.label
|
|
554
|
+
]
|
|
555
|
+
}
|
|
556
|
+
) }, x.id);
|
|
557
|
+
}) }),
|
|
558
|
+
o && /* @__PURE__ */ m("p", { id: R, className: J.chart__srOnly, children: o }),
|
|
559
|
+
/* @__PURE__ */ m("div", { className: J.chart__srOnly, children: /* @__PURE__ */ V("table", { children: [
|
|
560
|
+
/* @__PURE__ */ m("caption", { children: t }),
|
|
561
|
+
/* @__PURE__ */ m("thead", { children: /* @__PURE__ */ m("tr", { children: H.columns.map((x, f) => /* @__PURE__ */ m("th", { scope: "col", children: x }, f)) }) }),
|
|
562
|
+
/* @__PURE__ */ m("tbody", { children: H.rows.map((x, f) => /* @__PURE__ */ m("tr", { children: x.map(
|
|
563
|
+
(T, O) => O === 0 ? /* @__PURE__ */ m("th", { scope: "row", children: T }, O) : /* @__PURE__ */ m("td", { children: T }, O)
|
|
564
|
+
) }, f)) })
|
|
565
|
+
] }) })
|
|
566
|
+
] });
|
|
567
|
+
}, Xn = ({ tone: t, isHidden: o }) => /* @__PURE__ */ m(
|
|
568
|
+
"span",
|
|
569
|
+
{
|
|
570
|
+
"aria-hidden": !0,
|
|
571
|
+
className: J.chart__swatch,
|
|
572
|
+
style: o ? { backgroundColor: "transparent", boxShadow: `inset 0 0 0 2px ${Q(t)}` } : { backgroundColor: Q(t) }
|
|
573
|
+
}
|
|
574
|
+
), sn = /* @__PURE__ */ new Map(), bn = (t, o) => {
|
|
575
|
+
const n = `${t ?? ""}|${JSON.stringify(o)}`;
|
|
576
|
+
let e = sn.get(n);
|
|
577
|
+
return e || (e = new Intl.NumberFormat(t, o), sn.set(n, e)), e;
|
|
578
|
+
}, St = (t) => (o) => bn(t, { notation: "compact", maximumFractionDigits: 1 }).format(o), bt = (t) => (o) => bn(t, { maximumFractionDigits: 2 }).format(o), Yn = 640, Zn = typeof window > "u" ? () => {
|
|
579
|
+
} : fn, _t = (t) => {
|
|
580
|
+
const o = Pt(null), [n, e] = At(t ?? Yn);
|
|
581
|
+
return Zn(() => {
|
|
582
|
+
if (t !== void 0) {
|
|
583
|
+
e(t);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
const r = o.current;
|
|
587
|
+
if (!r) return;
|
|
588
|
+
const h = (u) => {
|
|
589
|
+
const k = Math.floor(u);
|
|
590
|
+
k > 0 && e((I) => I === k ? I : k);
|
|
591
|
+
};
|
|
592
|
+
if (h(r.clientWidth), typeof ResizeObserver > "u") return;
|
|
593
|
+
const d = new ResizeObserver(([u]) => h(u.contentRect.width));
|
|
594
|
+
return d.observe(r), () => d.disconnect();
|
|
595
|
+
}, [t]), [o, n];
|
|
596
|
+
}, Un = "hanui-line-CLpqU", Qn = "hanui-area-LkWXB", Jn = "hanui-bar-260Bd", Kn = "hanui-point-Vc-kX", te = "hanui-marker-G-xZb", ne = "hanui-crosshair-nV-xX", ee = "hanui-band-jnG7s", oe = "hanui-zero-GpHvw", st = {
|
|
597
|
+
line: Un,
|
|
598
|
+
area: Qn,
|
|
599
|
+
bar: Jn,
|
|
600
|
+
point: Kn,
|
|
601
|
+
marker: te,
|
|
602
|
+
crosshair: ne,
|
|
603
|
+
band: ee,
|
|
604
|
+
zero: oe
|
|
605
|
+
}, ae = 280, cn = "—", se = ({
|
|
606
|
+
label: t,
|
|
607
|
+
description: o,
|
|
608
|
+
data: n,
|
|
609
|
+
xKey: e,
|
|
610
|
+
xLabel: r,
|
|
611
|
+
series: h,
|
|
612
|
+
height: d = ae,
|
|
613
|
+
width: u,
|
|
614
|
+
isStacked: k = !1,
|
|
615
|
+
orientation: I = "vertical",
|
|
616
|
+
curve: A = "monotone",
|
|
617
|
+
hasPoints: C = !1,
|
|
618
|
+
formatX: b = String,
|
|
619
|
+
formatValue: S,
|
|
620
|
+
domain: P,
|
|
621
|
+
className: H,
|
|
622
|
+
testId: q
|
|
623
|
+
}) => {
|
|
624
|
+
const { labels: E } = xt(), N = E == null ? void 0 : E.locale, [R, D] = _t(u), [M, $] = At(() => /* @__PURE__ */ new Set()), i = L(() => S ?? bt(N), [S, N]), y = L(() => St(N), [N]), s = nt(
|
|
625
|
+
(g) => g == null ? "" : b(g),
|
|
626
|
+
[b]
|
|
627
|
+
), l = L(
|
|
628
|
+
() => h.map((g, F) => ({ ...g, tone: Ft(F, g.tone) })),
|
|
629
|
+
[h]
|
|
630
|
+
), c = L(() => l.filter((g) => !M.has(g.key)), [l, M]), a = L(
|
|
631
|
+
() => Sn({
|
|
632
|
+
rows: n,
|
|
633
|
+
xKey: e,
|
|
634
|
+
series: c,
|
|
635
|
+
width: D,
|
|
636
|
+
height: d,
|
|
637
|
+
isStacked: k,
|
|
638
|
+
orientation: I,
|
|
639
|
+
curve: A,
|
|
640
|
+
formatX: s,
|
|
641
|
+
formatLeft: y,
|
|
642
|
+
formatRight: y,
|
|
643
|
+
domain: P
|
|
644
|
+
}),
|
|
645
|
+
[
|
|
646
|
+
n,
|
|
647
|
+
e,
|
|
648
|
+
c,
|
|
649
|
+
D,
|
|
650
|
+
d,
|
|
651
|
+
k,
|
|
652
|
+
I,
|
|
653
|
+
A,
|
|
654
|
+
s,
|
|
655
|
+
y,
|
|
656
|
+
P
|
|
657
|
+
]
|
|
658
|
+
), p = I === "horizontal" && c.length > 0 && c.every((g) => g.type === "bar"), _ = c.some((g) => g.type === "bar"), w = L(() => {
|
|
659
|
+
const g = a.centers.map((F, z) => ({ center: F, index: z })).sort((F, z) => F.center - z.center);
|
|
660
|
+
return { centers: g.map((F) => F.center), indices: g.map((F) => F.index) };
|
|
661
|
+
}, [a.centers]), x = nt(
|
|
662
|
+
(g, F) => {
|
|
663
|
+
const { area: z } = a;
|
|
664
|
+
if (g < z.left - 4 || g > z.right + 4 || F < z.top - 4 || F > z.bottom + 4)
|
|
665
|
+
return null;
|
|
666
|
+
const Y = In(w.centers, p ? F : g);
|
|
667
|
+
return Y < 0 ? null : w.indices[Y];
|
|
668
|
+
},
|
|
669
|
+
[a, w, p]
|
|
670
|
+
), f = nt(
|
|
671
|
+
(g) => {
|
|
672
|
+
var F;
|
|
673
|
+
return {
|
|
674
|
+
title: s((F = n[g]) == null ? void 0 : F[e]),
|
|
675
|
+
rows: c.map((z) => {
|
|
676
|
+
var ht;
|
|
677
|
+
const Y = Nt((ht = n[g]) == null ? void 0 : ht[z.key]);
|
|
678
|
+
return {
|
|
679
|
+
id: z.key,
|
|
680
|
+
label: z.label,
|
|
681
|
+
tone: z.tone,
|
|
682
|
+
value: Y === null ? cn : (z.format ?? i)(Y)
|
|
683
|
+
};
|
|
684
|
+
})
|
|
685
|
+
};
|
|
686
|
+
},
|
|
687
|
+
[n, e, c, i, s]
|
|
688
|
+
), T = nt(
|
|
689
|
+
(g) => {
|
|
690
|
+
const F = f(g);
|
|
691
|
+
return `${F.title}: ${F.rows.map((z) => `${z.label} ${z.value}`).join(", ")}`;
|
|
692
|
+
},
|
|
693
|
+
[f]
|
|
694
|
+
), O = L(
|
|
695
|
+
() => ({
|
|
696
|
+
columns: [r ?? e, ...l.map((g) => g.label)],
|
|
697
|
+
rows: n.map((g) => [
|
|
698
|
+
s(g[e]),
|
|
699
|
+
...l.map((F) => {
|
|
700
|
+
const z = Nt(g[F.key]);
|
|
701
|
+
return z === null ? cn : (F.format ?? i)(z);
|
|
702
|
+
})
|
|
703
|
+
])
|
|
704
|
+
}),
|
|
705
|
+
[n, e, r, l, i, s]
|
|
706
|
+
), X = L(
|
|
707
|
+
() => /* @__PURE__ */ V("g", { children: [
|
|
708
|
+
p ? /* @__PURE__ */ V(Ct, { children: [
|
|
709
|
+
/* @__PURE__ */ m(pt, { area: a.area, ticks: a.leftTicks, side: "bottom", hasGrid: !0 }),
|
|
710
|
+
/* @__PURE__ */ m(Xt, { area: a.area, ticks: a.categoryTicks, side: "left" })
|
|
711
|
+
] }) : /* @__PURE__ */ V(Ct, { children: [
|
|
712
|
+
/* @__PURE__ */ m(pt, { area: a.area, ticks: a.leftTicks, side: "left", hasGrid: !0 }),
|
|
713
|
+
a.hasRightAxis && /* @__PURE__ */ m(pt, { area: a.area, ticks: a.rightTicks, side: "right" }),
|
|
714
|
+
/* @__PURE__ */ m(Xt, { area: a.area, ticks: a.categoryTicks, side: "bottom" })
|
|
715
|
+
] }),
|
|
716
|
+
a.zero !== null && (p ? /* @__PURE__ */ m(
|
|
717
|
+
"line",
|
|
718
|
+
{
|
|
719
|
+
className: st.zero,
|
|
720
|
+
x1: a.zero,
|
|
721
|
+
x2: a.zero,
|
|
722
|
+
y1: a.area.top,
|
|
723
|
+
y2: a.area.bottom
|
|
724
|
+
}
|
|
725
|
+
) : /* @__PURE__ */ m(
|
|
726
|
+
"line",
|
|
727
|
+
{
|
|
728
|
+
className: st.zero,
|
|
729
|
+
x1: a.area.left,
|
|
730
|
+
x2: a.area.right,
|
|
731
|
+
y1: a.zero,
|
|
732
|
+
y2: a.zero
|
|
733
|
+
}
|
|
734
|
+
)),
|
|
735
|
+
a.areas.map((g) => /* @__PURE__ */ m(
|
|
736
|
+
"path",
|
|
737
|
+
{
|
|
738
|
+
d: g.d,
|
|
739
|
+
className: st.area,
|
|
740
|
+
style: { fill: `color-mix(in srgb, ${Q(g.tone)} 18%, transparent)` }
|
|
741
|
+
},
|
|
742
|
+
`area-${g.key}`
|
|
743
|
+
)),
|
|
744
|
+
a.bars.map((g) => /* @__PURE__ */ m(
|
|
745
|
+
"rect",
|
|
746
|
+
{
|
|
747
|
+
className: st.bar,
|
|
748
|
+
x: g.x,
|
|
749
|
+
y: g.y,
|
|
750
|
+
width: g.width,
|
|
751
|
+
height: g.height,
|
|
752
|
+
rx: Math.min(3, g.width / 4, g.height / 4),
|
|
753
|
+
style: { fill: Q(g.tone) }
|
|
754
|
+
},
|
|
755
|
+
`bar-${g.key}-${g.index}`
|
|
756
|
+
)),
|
|
757
|
+
a.lines.map((g) => /* @__PURE__ */ m(
|
|
758
|
+
"path",
|
|
759
|
+
{
|
|
760
|
+
d: g.d,
|
|
761
|
+
className: st.line,
|
|
762
|
+
style: { stroke: Q(g.tone) }
|
|
763
|
+
},
|
|
764
|
+
`line-${g.key}`
|
|
765
|
+
)),
|
|
766
|
+
c.filter((g) => g.type !== "bar").flatMap(
|
|
767
|
+
(g) => (a.points[g.key] ?? []).map(
|
|
768
|
+
(F, z, Y) => F && (C || !Y[z - 1] && !Y[z + 1]) ? /* @__PURE__ */ m(
|
|
769
|
+
"circle",
|
|
770
|
+
{
|
|
771
|
+
className: st.point,
|
|
772
|
+
cx: F.x,
|
|
773
|
+
cy: F.y,
|
|
774
|
+
r: 3,
|
|
775
|
+
style: { fill: Q(g.tone) }
|
|
776
|
+
},
|
|
777
|
+
`point-${g.key}-${z}`
|
|
778
|
+
) : null
|
|
779
|
+
)
|
|
780
|
+
)
|
|
781
|
+
] }),
|
|
782
|
+
[a, C, p, c]
|
|
783
|
+
), U = nt(
|
|
784
|
+
(g) => {
|
|
785
|
+
if (!_ || a.bandwidth <= 0) return null;
|
|
786
|
+
const { area: F } = a, z = a.centers[g], Y = a.bandwidth * 0.12;
|
|
787
|
+
return p ? /* @__PURE__ */ m(
|
|
788
|
+
"rect",
|
|
789
|
+
{
|
|
790
|
+
className: st.band,
|
|
791
|
+
x: F.left,
|
|
792
|
+
width: F.width,
|
|
793
|
+
y: z - a.bandwidth / 2 - Y,
|
|
794
|
+
height: a.bandwidth + Y * 2
|
|
795
|
+
}
|
|
796
|
+
) : /* @__PURE__ */ m(
|
|
797
|
+
"rect",
|
|
798
|
+
{
|
|
799
|
+
className: st.band,
|
|
800
|
+
y: F.top,
|
|
801
|
+
height: F.height,
|
|
802
|
+
x: z - a.bandwidth / 2 - Y,
|
|
803
|
+
width: a.bandwidth + Y * 2
|
|
804
|
+
}
|
|
805
|
+
);
|
|
806
|
+
},
|
|
807
|
+
[a, p, _]
|
|
808
|
+
), G = nt(
|
|
809
|
+
(g) => {
|
|
810
|
+
const { area: F } = a, z = a.centers[g];
|
|
811
|
+
return /* @__PURE__ */ V(Ct, { children: [
|
|
812
|
+
!_ && /* @__PURE__ */ m(
|
|
813
|
+
"line",
|
|
814
|
+
{
|
|
815
|
+
className: st.crosshair,
|
|
816
|
+
x1: z,
|
|
817
|
+
x2: z,
|
|
818
|
+
y1: F.top,
|
|
819
|
+
y2: F.bottom
|
|
820
|
+
}
|
|
821
|
+
),
|
|
822
|
+
c.filter((Y) => Y.type !== "bar").map((Y) => {
|
|
823
|
+
var Tt;
|
|
824
|
+
const ht = (Tt = a.points[Y.key]) == null ? void 0 : Tt[g];
|
|
825
|
+
return ht ? /* @__PURE__ */ m(
|
|
826
|
+
"circle",
|
|
827
|
+
{
|
|
828
|
+
className: st.marker,
|
|
829
|
+
cx: ht.x,
|
|
830
|
+
cy: ht.y,
|
|
831
|
+
r: 4.5,
|
|
832
|
+
style: { fill: Q(Y.tone) }
|
|
833
|
+
},
|
|
834
|
+
Y.key
|
|
835
|
+
) : null;
|
|
836
|
+
})
|
|
837
|
+
] });
|
|
838
|
+
},
|
|
839
|
+
[a, c, _]
|
|
840
|
+
);
|
|
841
|
+
return /* @__PURE__ */ m(
|
|
842
|
+
gt,
|
|
843
|
+
{
|
|
844
|
+
label: t,
|
|
845
|
+
description: o,
|
|
846
|
+
containerRef: R,
|
|
847
|
+
width: D,
|
|
848
|
+
height: d,
|
|
849
|
+
plot: X,
|
|
850
|
+
overlay: G,
|
|
851
|
+
underlay: U,
|
|
852
|
+
itemCount: n.length,
|
|
853
|
+
pick: x,
|
|
854
|
+
tooltip: f,
|
|
855
|
+
anchor: (g) => a.anchors[g] ?? { x: 0, y: 0 },
|
|
856
|
+
announce: T,
|
|
857
|
+
table: O,
|
|
858
|
+
legend: {
|
|
859
|
+
entries: l.map((g) => ({ id: g.key, label: g.label, tone: g.tone })),
|
|
860
|
+
hidden: M,
|
|
861
|
+
onToggle: (g) => $((F) => {
|
|
862
|
+
const z = new Set(F);
|
|
863
|
+
return z.has(g) ? z.delete(g) : l.length - F.size > 1 && z.add(g), z;
|
|
864
|
+
})
|
|
865
|
+
},
|
|
866
|
+
className: H,
|
|
867
|
+
testId: q
|
|
868
|
+
}
|
|
869
|
+
);
|
|
870
|
+
}, Ot = ot(se), ce = ({ series: t, ...o }) => {
|
|
871
|
+
const n = L(() => t.map((e) => ({ ...e, type: "line" })), [t]);
|
|
872
|
+
return /* @__PURE__ */ m(Ot, { ...o, series: n });
|
|
873
|
+
}, We = /* @__PURE__ */ ot(/* @__PURE__ */ lt(ce, "LineChart")), re = ({ series: t, ...o }) => {
|
|
874
|
+
const n = L(() => t.map((e) => ({ ...e, type: "area" })), [t]);
|
|
875
|
+
return /* @__PURE__ */ m(Ot, { ...o, series: n });
|
|
876
|
+
}, je = /* @__PURE__ */ ot(/* @__PURE__ */ lt(re, "AreaChart")), le = ({ series: t, ...o }) => {
|
|
877
|
+
const n = L(() => t.map((e) => ({ ...e, type: "bar" })), [t]);
|
|
878
|
+
return /* @__PURE__ */ m(Ot, { ...o, series: n });
|
|
879
|
+
}, Ve = /* @__PURE__ */ ot(/* @__PURE__ */ lt(le, "BarChart")), ie = (t) => /* @__PURE__ */ m(Ot, { ...t }), Xe = /* @__PURE__ */ ot(
|
|
880
|
+
/* @__PURE__ */ lt(ie, "ComposedChart")
|
|
881
|
+
), he = "hanui-slice-dFWuh", de = "hanui-center__value-GnqKe", me = "hanui-center__label-DsgTV", It = {
|
|
882
|
+
slice: he,
|
|
883
|
+
center__value: de,
|
|
884
|
+
center__label: me
|
|
885
|
+
}, Ht = 6, rn = 1.5, ue = ({
|
|
886
|
+
label: t,
|
|
887
|
+
description: o,
|
|
888
|
+
data: n,
|
|
889
|
+
variant: e = "donut",
|
|
890
|
+
centerValue: r,
|
|
891
|
+
centerLabel: h,
|
|
892
|
+
valueLabel: d,
|
|
893
|
+
height: u = 260,
|
|
894
|
+
width: k,
|
|
895
|
+
formatValue: I,
|
|
896
|
+
className: A,
|
|
897
|
+
testId: C
|
|
898
|
+
}) => {
|
|
899
|
+
const { labels: b } = xt(), [S, P] = _t(k), [H, q] = At(() => /* @__PURE__ */ new Set()), E = L(() => bt(b == null ? void 0 : b.locale), [b == null ? void 0 : b.locale]), N = I ?? E, R = L(
|
|
900
|
+
() => n.map((s, l) => ({ ...s, tone: Ft(l, s.tone) })),
|
|
901
|
+
[n]
|
|
902
|
+
), D = L(() => {
|
|
903
|
+
const s = R.filter(
|
|
904
|
+
(f) => !H.has(f.id) && Number.isFinite(f.value) && f.value > 0
|
|
905
|
+
), l = s.reduce((f, T) => f + T.value, 0), c = P / 2, a = u / 2, p = Math.max(8, Math.min(P, u) / 2 - Ht - 4), _ = e === "donut" ? p * 0.62 : 0;
|
|
906
|
+
let w = 0;
|
|
907
|
+
const x = s.map((f) => {
|
|
908
|
+
const T = l > 0 ? f.value / l * Math.PI * 2 : 0, O = w;
|
|
909
|
+
return w += T, { ...f, start: O, end: w, share: l > 0 ? f.value / l : 0 };
|
|
910
|
+
});
|
|
911
|
+
return { cx: c, cy: a, outer: p, inner: _, total: l, slices: x };
|
|
912
|
+
}, [R, H, P, u, e]), M = L(() => {
|
|
913
|
+
const s = new Intl.NumberFormat(b == null ? void 0 : b.locale, {
|
|
914
|
+
style: "percent",
|
|
915
|
+
maximumFractionDigits: 1
|
|
916
|
+
});
|
|
917
|
+
return (l) => s.format(l);
|
|
918
|
+
}, [b == null ? void 0 : b.locale]), $ = L(() => {
|
|
919
|
+
const { cx: s, cy: l, outer: c, inner: a, slices: p, total: _ } = D;
|
|
920
|
+
return /* @__PURE__ */ V("g", { children: [
|
|
921
|
+
p.map((w) => /* @__PURE__ */ m(
|
|
922
|
+
"path",
|
|
923
|
+
{
|
|
924
|
+
className: It.slice,
|
|
925
|
+
d: tn(s, l, c, a, w.start, w.end),
|
|
926
|
+
style: { fill: Q(w.tone), strokeWidth: p.length > 1 ? rn : 0 }
|
|
927
|
+
},
|
|
928
|
+
w.id
|
|
929
|
+
)),
|
|
930
|
+
e === "donut" && /* @__PURE__ */ V("g", { "aria-hidden": !0, className: It.center, children: [
|
|
931
|
+
/* @__PURE__ */ m(
|
|
932
|
+
"text",
|
|
933
|
+
{
|
|
934
|
+
className: It.center__value,
|
|
935
|
+
x: s,
|
|
936
|
+
y: h ? l - 4 : l,
|
|
937
|
+
dy: "0.32em",
|
|
938
|
+
textAnchor: "middle",
|
|
939
|
+
children: r ?? N(_)
|
|
940
|
+
}
|
|
941
|
+
),
|
|
942
|
+
h && /* @__PURE__ */ m(
|
|
943
|
+
"text",
|
|
944
|
+
{
|
|
945
|
+
className: It.center__label,
|
|
946
|
+
x: s,
|
|
947
|
+
y: l + 16,
|
|
948
|
+
dy: "0.32em",
|
|
949
|
+
textAnchor: "middle",
|
|
950
|
+
children: h
|
|
951
|
+
}
|
|
952
|
+
)
|
|
953
|
+
] })
|
|
954
|
+
] });
|
|
955
|
+
}, [D, e, r, h, N]), i = nt(
|
|
956
|
+
(s, l) => {
|
|
957
|
+
const { cx: c, cy: a, outer: p, inner: _, slices: w } = D, x = Math.hypot(s - c, l - a);
|
|
958
|
+
if (x > p + Ht || x < _) return null;
|
|
959
|
+
let f = Math.atan2(s - c, -(l - a));
|
|
960
|
+
f < 0 && (f += Math.PI * 2);
|
|
961
|
+
const T = w.findIndex((O) => f >= O.start && f < O.end);
|
|
962
|
+
return T < 0 ? null : T;
|
|
963
|
+
},
|
|
964
|
+
[D]
|
|
965
|
+
), y = (s) => {
|
|
966
|
+
const l = D.slices[s];
|
|
967
|
+
return `${N(l.value)} (${M(l.share)})`;
|
|
968
|
+
};
|
|
969
|
+
return /* @__PURE__ */ m(
|
|
970
|
+
gt,
|
|
971
|
+
{
|
|
972
|
+
label: t,
|
|
973
|
+
description: o,
|
|
974
|
+
containerRef: S,
|
|
975
|
+
width: P,
|
|
976
|
+
height: u,
|
|
977
|
+
plot: $,
|
|
978
|
+
overlay: (s) => {
|
|
979
|
+
const { cx: l, cy: c, outer: a, inner: p, slices: _ } = D, w = _[s], x = (w.start + w.end) / 2, f = et(0, 0, Ht, x);
|
|
980
|
+
return /* @__PURE__ */ m(
|
|
981
|
+
"path",
|
|
982
|
+
{
|
|
983
|
+
className: It.slice,
|
|
984
|
+
d: tn(l + f.x, c + f.y, a, p, w.start, w.end),
|
|
985
|
+
style: { fill: Q(w.tone), strokeWidth: rn }
|
|
986
|
+
}
|
|
987
|
+
);
|
|
988
|
+
},
|
|
989
|
+
itemCount: D.slices.length,
|
|
990
|
+
pick: i,
|
|
991
|
+
tooltip: (s) => {
|
|
992
|
+
const l = D.slices[s];
|
|
993
|
+
return {
|
|
994
|
+
rows: [{ id: l.id, label: l.label, value: y(s), tone: l.tone }]
|
|
995
|
+
};
|
|
996
|
+
},
|
|
997
|
+
anchor: (s) => {
|
|
998
|
+
const { cx: l, cy: c, outer: a, slices: p } = D, _ = p[s];
|
|
999
|
+
return et(l, c, a + Ht, (_.start + _.end) / 2);
|
|
1000
|
+
},
|
|
1001
|
+
tooltipSide: "outward",
|
|
1002
|
+
announce: (s) => `${D.slices[s].label}: ${y(s)}`,
|
|
1003
|
+
table: {
|
|
1004
|
+
columns: [t, d],
|
|
1005
|
+
rows: R.map((s) => [
|
|
1006
|
+
s.label,
|
|
1007
|
+
Number.isFinite(s.value) ? N(s.value) : "—"
|
|
1008
|
+
])
|
|
1009
|
+
},
|
|
1010
|
+
legend: {
|
|
1011
|
+
entries: R.map((s) => ({ id: s.id, label: s.label, tone: s.tone })),
|
|
1012
|
+
hidden: H,
|
|
1013
|
+
onToggle: (s) => q((l) => {
|
|
1014
|
+
const c = new Set(l);
|
|
1015
|
+
return c.has(s) ? c.delete(s) : R.length - l.size > 1 && c.add(s), c;
|
|
1016
|
+
})
|
|
1017
|
+
},
|
|
1018
|
+
className: A,
|
|
1019
|
+
testId: C
|
|
1020
|
+
}
|
|
1021
|
+
);
|
|
1022
|
+
}, Ye = /* @__PURE__ */ ot(/* @__PURE__ */ lt(ue, "PieChart")), Ut = (t, o, n, { top: e = 12, right: r = 16, bottom: h = 28 } = {}) => {
|
|
1023
|
+
const d = Math.max(32, ...n.map(ut)) + 10;
|
|
1024
|
+
return {
|
|
1025
|
+
left: d,
|
|
1026
|
+
top: e,
|
|
1027
|
+
right: Math.max(d + 1, t - r),
|
|
1028
|
+
bottom: Math.max(e + 1, o - h),
|
|
1029
|
+
width: Math.max(1, t - r - d),
|
|
1030
|
+
height: Math.max(1, o - e - h)
|
|
1031
|
+
};
|
|
1032
|
+
}, Rt = (t, o) => Math.max(2, Math.floor(t / (o ? 90 : 48))), pe = (t, o = 24) => {
|
|
1033
|
+
const n = /* @__PURE__ */ new Map(), e = (r, h) => `${r}:${h}`;
|
|
1034
|
+
return t.forEach((r, h) => {
|
|
1035
|
+
if (!Number.isFinite(r.x) || !Number.isFinite(r.y)) return;
|
|
1036
|
+
const d = e(Math.floor(r.x / o), Math.floor(r.y / o)), u = n.get(d);
|
|
1037
|
+
u ? u.push(h) : n.set(d, [h]);
|
|
1038
|
+
}), {
|
|
1039
|
+
nearest: (r, h, d) => {
|
|
1040
|
+
const u = Math.ceil(d / o), k = Math.floor(r / o), I = Math.floor(h / o);
|
|
1041
|
+
let A = null, C = d * d;
|
|
1042
|
+
for (let b = -u; b <= u; b += 1)
|
|
1043
|
+
for (let S = -u; S <= u; S += 1)
|
|
1044
|
+
for (const P of n.get(e(k + b, I + S)) ?? []) {
|
|
1045
|
+
const H = (t[P].x - r) ** 2 + (t[P].y - h) ** 2;
|
|
1046
|
+
H <= C && (C = H, A = P);
|
|
1047
|
+
}
|
|
1048
|
+
return A;
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
}, fe = "hanui-point-YKyMm", ye = "hanui-marker-ToO1T", ln = {
|
|
1052
|
+
point: fe,
|
|
1053
|
+
marker: ye
|
|
1054
|
+
}, wt = { plain: 4, min: 3, max: 16 }, xe = 22, ge = ({
|
|
1055
|
+
label: t,
|
|
1056
|
+
description: o,
|
|
1057
|
+
series: n,
|
|
1058
|
+
xLabel: e,
|
|
1059
|
+
yLabel: r,
|
|
1060
|
+
sizeLabel: h,
|
|
1061
|
+
height: d = 300,
|
|
1062
|
+
width: u,
|
|
1063
|
+
formatX: k,
|
|
1064
|
+
formatY: I,
|
|
1065
|
+
className: A,
|
|
1066
|
+
testId: C
|
|
1067
|
+
}) => {
|
|
1068
|
+
const { labels: b } = xt(), [S, P] = _t(u), [H, q] = At(() => /* @__PURE__ */ new Set()), E = L(() => bt(b == null ? void 0 : b.locale), [b == null ? void 0 : b.locale]), N = L(() => St(b == null ? void 0 : b.locale), [b == null ? void 0 : b.locale]), R = k ?? E, D = I ?? E, M = L(
|
|
1069
|
+
() => n.map((c, a) => ({ ...c, tone: Ft(a, c.tone) })),
|
|
1070
|
+
[n]
|
|
1071
|
+
), $ = L(
|
|
1072
|
+
() => M.filter((c) => !H.has(c.id)).flatMap(
|
|
1073
|
+
(c) => c.data.filter((a) => Number.isFinite(a.x) && Number.isFinite(a.y)).map((a) => ({ ...a, series: c }))
|
|
1074
|
+
).sort((c, a) => c.x - a.x || c.y - a.y),
|
|
1075
|
+
[M, H]
|
|
1076
|
+
), i = L(() => {
|
|
1077
|
+
const c = vt(...yt($.map((G) => G.x))), a = vt(...yt($.map((G) => G.y))), p = rt(a[0], a[1], Rt(d, !1)), _ = Ut(P, d, p.map(N), { right: 20 }), w = ft(c, [_.left, _.right]), x = ft(a, [_.bottom, _.top]), f = qt($.map((G) => G.size)), [T, O] = yt(f), X = (G) => G === void 0 || !Number.isFinite(G) || f.length === 0 ? wt.plain : O === T ? (wt.min + wt.max) / 2 : Math.sqrt(
|
|
1078
|
+
wt.min ** 2 + (G - T) / (O - T) * (wt.max ** 2 - wt.min ** 2)
|
|
1079
|
+
), U = $.map((G) => ({
|
|
1080
|
+
...G,
|
|
1081
|
+
cx: w(G.x),
|
|
1082
|
+
cy: x(G.y),
|
|
1083
|
+
r: X(G.size)
|
|
1084
|
+
}));
|
|
1085
|
+
return {
|
|
1086
|
+
area: _,
|
|
1087
|
+
placed: U,
|
|
1088
|
+
index: pe(U.map((G) => ({ x: G.cx, y: G.cy }))),
|
|
1089
|
+
xTicks: rt(c[0], c[1], Rt(_.width, !0)).map((G) => ({
|
|
1090
|
+
position: w(G),
|
|
1091
|
+
label: N(G)
|
|
1092
|
+
})),
|
|
1093
|
+
yTicks: p.map((G) => ({ position: x(G), label: N(G) }))
|
|
1094
|
+
};
|
|
1095
|
+
}, [$, P, d, N]), y = L(
|
|
1096
|
+
() => /* @__PURE__ */ V("g", { children: [
|
|
1097
|
+
/* @__PURE__ */ m(pt, { area: i.area, ticks: i.yTicks, side: "left", hasGrid: !0 }),
|
|
1098
|
+
/* @__PURE__ */ m(pt, { area: i.area, ticks: i.xTicks, side: "bottom", hasGrid: !0 }),
|
|
1099
|
+
i.placed.map((c, a) => /* @__PURE__ */ m(
|
|
1100
|
+
"circle",
|
|
1101
|
+
{
|
|
1102
|
+
className: ln.point,
|
|
1103
|
+
cx: c.cx,
|
|
1104
|
+
cy: c.cy,
|
|
1105
|
+
r: c.r,
|
|
1106
|
+
style: {
|
|
1107
|
+
fill: `color-mix(in srgb, ${Q(c.series.tone)} 72%, transparent)`,
|
|
1108
|
+
stroke: Q(c.series.tone)
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
a
|
|
1112
|
+
))
|
|
1113
|
+
] }),
|
|
1114
|
+
[i]
|
|
1115
|
+
), s = nt(
|
|
1116
|
+
(c, a) => i.index.nearest(c, a, xe),
|
|
1117
|
+
[i]
|
|
1118
|
+
), l = (c) => {
|
|
1119
|
+
const a = i.placed[c];
|
|
1120
|
+
return {
|
|
1121
|
+
title: a.label ?? a.series.label,
|
|
1122
|
+
rows: [
|
|
1123
|
+
{ id: "series", label: a.series.label, value: "", tone: a.series.tone },
|
|
1124
|
+
{ id: "x", label: e, value: R(a.x) },
|
|
1125
|
+
{ id: "y", label: r, value: D(a.y) },
|
|
1126
|
+
...a.size !== void 0 && h ? [{ id: "size", label: h, value: E(a.size) }] : []
|
|
1127
|
+
]
|
|
1128
|
+
};
|
|
1129
|
+
};
|
|
1130
|
+
return /* @__PURE__ */ m(
|
|
1131
|
+
gt,
|
|
1132
|
+
{
|
|
1133
|
+
label: t,
|
|
1134
|
+
description: o,
|
|
1135
|
+
containerRef: S,
|
|
1136
|
+
width: P,
|
|
1137
|
+
height: d,
|
|
1138
|
+
plot: y,
|
|
1139
|
+
overlay: (c) => {
|
|
1140
|
+
const a = i.placed[c];
|
|
1141
|
+
return /* @__PURE__ */ m(
|
|
1142
|
+
"circle",
|
|
1143
|
+
{
|
|
1144
|
+
className: ln.marker,
|
|
1145
|
+
cx: a.cx,
|
|
1146
|
+
cy: a.cy,
|
|
1147
|
+
r: a.r + 3,
|
|
1148
|
+
style: { stroke: Q(a.series.tone) }
|
|
1149
|
+
}
|
|
1150
|
+
);
|
|
1151
|
+
},
|
|
1152
|
+
itemCount: i.placed.length,
|
|
1153
|
+
pick: s,
|
|
1154
|
+
tooltip: l,
|
|
1155
|
+
anchor: (c) => ({ x: i.placed[c].cx, y: i.placed[c].cy }),
|
|
1156
|
+
announce: (c) => {
|
|
1157
|
+
const a = i.placed[c];
|
|
1158
|
+
return `${a.label ? `${a.label}, ` : ""}${a.series.label}: ${e} ${R(a.x)}, ${r} ${D(a.y)}`;
|
|
1159
|
+
},
|
|
1160
|
+
table: {
|
|
1161
|
+
columns: [t, e, r],
|
|
1162
|
+
rows: $.map((c) => [c.label ?? c.series.label, R(c.x), D(c.y)])
|
|
1163
|
+
},
|
|
1164
|
+
legend: {
|
|
1165
|
+
entries: M.map((c) => ({ id: c.id, label: c.label, tone: c.tone })),
|
|
1166
|
+
hidden: H,
|
|
1167
|
+
onToggle: (c) => q((a) => {
|
|
1168
|
+
const p = new Set(a);
|
|
1169
|
+
return p.has(c) ? p.delete(c) : M.length - a.size > 1 && p.add(c), p;
|
|
1170
|
+
})
|
|
1171
|
+
},
|
|
1172
|
+
className: A,
|
|
1173
|
+
testId: C
|
|
1174
|
+
}
|
|
1175
|
+
);
|
|
1176
|
+
}, Ze = /* @__PURE__ */ ot(
|
|
1177
|
+
/* @__PURE__ */ lt(ge, "ScatterPlot")
|
|
1178
|
+
), be = "hanui-labels-MJWYF", _e = "hanui-empty-AW7c9", Me = "hanui-focus-hLQdB", Lt = {
|
|
1179
|
+
labels: be,
|
|
1180
|
+
empty: _e,
|
|
1181
|
+
focus: Me
|
|
1182
|
+
}, Wt = 8, we = 28, jt = 140, hn = (t, o, n) => {
|
|
1183
|
+
var r;
|
|
1184
|
+
const e = (r = t[o]) == null ? void 0 : r[n];
|
|
1185
|
+
return typeof e == "number" && Number.isFinite(e) ? e : null;
|
|
1186
|
+
}, dn = (t) => t.map((o, n) => String(n)), $e = ({
|
|
1187
|
+
label: t,
|
|
1188
|
+
description: o,
|
|
1189
|
+
columns: n,
|
|
1190
|
+
rows: e,
|
|
1191
|
+
values: r,
|
|
1192
|
+
valueLabel: h,
|
|
1193
|
+
tone: d = "cat-1",
|
|
1194
|
+
height: u = 280,
|
|
1195
|
+
width: k,
|
|
1196
|
+
formatValue: I,
|
|
1197
|
+
className: A,
|
|
1198
|
+
testId: C
|
|
1199
|
+
}) => {
|
|
1200
|
+
const { labels: b } = xt(), [S, P] = _t(k), H = L(() => bt(b == null ? void 0 : b.locale), [b == null ? void 0 : b.locale]), q = I ?? H, E = `hanui-heat-${pn().replace(/:/g, "")}`, N = L(() => {
|
|
1201
|
+
const y = { left: Math.min(P * 0.3, Math.max(32, ...e.map(ut)) + 12), top: 8, right: P - 8, bottom: u - 28 - we }, s = Dt(dn(n), [y.left, y.right], {
|
|
1202
|
+
paddingInner: 0.06,
|
|
1203
|
+
paddingOuter: 0
|
|
1204
|
+
}), l = Dt(dn(e), [y.top, y.bottom], {
|
|
1205
|
+
paddingInner: 0.06,
|
|
1206
|
+
paddingOuter: 0
|
|
1207
|
+
}), [c, a] = yt(qt(r.flat())), p = (w) => w === null ? null : a === c ? 60 : Wt + (w - c) / (a - c) * (100 - Wt), _ = e.flatMap(
|
|
1208
|
+
(w, x) => n.map((f, T) => {
|
|
1209
|
+
const O = hn(r, x, T);
|
|
1210
|
+
return {
|
|
1211
|
+
row: w,
|
|
1212
|
+
column: f,
|
|
1213
|
+
key: `${x}:${T}`,
|
|
1214
|
+
value: O,
|
|
1215
|
+
x: s(String(T)),
|
|
1216
|
+
y: l(String(x)),
|
|
1217
|
+
width: s.bandwidth,
|
|
1218
|
+
height: l.bandwidth,
|
|
1219
|
+
mix: p(O)
|
|
1220
|
+
};
|
|
1221
|
+
})
|
|
1222
|
+
);
|
|
1223
|
+
return { area: y, x: s, y: l, cells: _, min: c, max: a };
|
|
1224
|
+
}, [n, e, r, P, u]), R = Q(d), D = L(() => {
|
|
1225
|
+
const { area: i, x: y, y: s, cells: l } = N, c = q(N.max), a = i.right - ut(c) - 8, p = xn(
|
|
1226
|
+
n.map((_, w) => ({
|
|
1227
|
+
position: y(String(w)) + y.bandwidth / 2,
|
|
1228
|
+
label: _
|
|
1229
|
+
}))
|
|
1230
|
+
);
|
|
1231
|
+
return /* @__PURE__ */ V("g", { children: [
|
|
1232
|
+
l.map((_) => /* @__PURE__ */ m(
|
|
1233
|
+
"rect",
|
|
1234
|
+
{
|
|
1235
|
+
className: _.mix === null ? Lt.empty : void 0,
|
|
1236
|
+
x: _.x,
|
|
1237
|
+
y: _.y,
|
|
1238
|
+
width: _.width,
|
|
1239
|
+
height: _.height,
|
|
1240
|
+
rx: 2,
|
|
1241
|
+
style: _.mix === null ? void 0 : { fill: `color-mix(in srgb, ${R} ${_.mix}%, var(--hanui-surface))` }
|
|
1242
|
+
},
|
|
1243
|
+
_.key
|
|
1244
|
+
)),
|
|
1245
|
+
/* @__PURE__ */ V("g", { "aria-hidden": !0, className: Lt.labels, children: [
|
|
1246
|
+
e.map((_, w) => /* @__PURE__ */ m(
|
|
1247
|
+
"text",
|
|
1248
|
+
{
|
|
1249
|
+
x: i.left - 8,
|
|
1250
|
+
y: s(String(w)) + s.bandwidth / 2,
|
|
1251
|
+
dy: "0.32em",
|
|
1252
|
+
textAnchor: "end",
|
|
1253
|
+
children: Et(_, i.left - 12)
|
|
1254
|
+
},
|
|
1255
|
+
w
|
|
1256
|
+
)),
|
|
1257
|
+
p.map((_) => /* @__PURE__ */ m("text", { x: _.position, y: i.bottom + 16, textAnchor: "middle", children: _.label }, _.position))
|
|
1258
|
+
] }),
|
|
1259
|
+
/* @__PURE__ */ m("defs", { children: /* @__PURE__ */ V("linearGradient", { id: E, children: [
|
|
1260
|
+
/* @__PURE__ */ m(
|
|
1261
|
+
"stop",
|
|
1262
|
+
{
|
|
1263
|
+
offset: "0%",
|
|
1264
|
+
style: {
|
|
1265
|
+
stopColor: `color-mix(in srgb, ${R} ${Wt}%, var(--hanui-surface))`
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
),
|
|
1269
|
+
/* @__PURE__ */ m("stop", { offset: "100%", style: { stopColor: R } })
|
|
1270
|
+
] }) }),
|
|
1271
|
+
/* @__PURE__ */ V("g", { "aria-hidden": !0, className: Lt.labels, children: [
|
|
1272
|
+
/* @__PURE__ */ m(
|
|
1273
|
+
"rect",
|
|
1274
|
+
{
|
|
1275
|
+
x: a - jt,
|
|
1276
|
+
y: u - 18,
|
|
1277
|
+
width: jt,
|
|
1278
|
+
height: 8,
|
|
1279
|
+
rx: 4,
|
|
1280
|
+
style: { fill: `url(#${E})` }
|
|
1281
|
+
}
|
|
1282
|
+
),
|
|
1283
|
+
/* @__PURE__ */ m("text", { x: a - jt - 8, y: u - 14, dy: "0.32em", textAnchor: "end", children: q(N.min) }),
|
|
1284
|
+
/* @__PURE__ */ m("text", { x: i.right, y: u - 14, dy: "0.32em", textAnchor: "end", children: c })
|
|
1285
|
+
] })
|
|
1286
|
+
] });
|
|
1287
|
+
}, [N, n, e, R, E, u, q]), M = nt(
|
|
1288
|
+
(i, y) => {
|
|
1289
|
+
const { area: s, x: l, y: c } = N;
|
|
1290
|
+
if (i < s.left || i > s.right || y < s.top || y > s.bottom) return null;
|
|
1291
|
+
const a = l.indexAt(i), p = c.indexAt(y);
|
|
1292
|
+
return a < 0 || p < 0 ? null : p * n.length + a;
|
|
1293
|
+
},
|
|
1294
|
+
[N, n.length]
|
|
1295
|
+
), $ = (i) => {
|
|
1296
|
+
const y = N.cells[i];
|
|
1297
|
+
return { cell: y, value: y.value === null ? "—" : q(y.value) };
|
|
1298
|
+
};
|
|
1299
|
+
return /* @__PURE__ */ m(
|
|
1300
|
+
gt,
|
|
1301
|
+
{
|
|
1302
|
+
label: t,
|
|
1303
|
+
description: o,
|
|
1304
|
+
containerRef: S,
|
|
1305
|
+
width: P,
|
|
1306
|
+
height: u,
|
|
1307
|
+
plot: D,
|
|
1308
|
+
overlay: (i) => {
|
|
1309
|
+
const y = N.cells[i];
|
|
1310
|
+
return /* @__PURE__ */ m(
|
|
1311
|
+
"rect",
|
|
1312
|
+
{
|
|
1313
|
+
className: Lt.focus,
|
|
1314
|
+
x: y.x - 1,
|
|
1315
|
+
y: y.y - 1,
|
|
1316
|
+
width: y.width + 2,
|
|
1317
|
+
height: y.height + 2,
|
|
1318
|
+
rx: 3
|
|
1319
|
+
}
|
|
1320
|
+
);
|
|
1321
|
+
},
|
|
1322
|
+
itemCount: N.cells.length,
|
|
1323
|
+
columns: n.length,
|
|
1324
|
+
pick: M,
|
|
1325
|
+
tooltip: (i) => {
|
|
1326
|
+
const { cell: y, value: s } = $(i);
|
|
1327
|
+
return {
|
|
1328
|
+
title: `${y.row} · ${y.column}`,
|
|
1329
|
+
rows: [{ id: "value", label: h, value: s, tone: d }]
|
|
1330
|
+
};
|
|
1331
|
+
},
|
|
1332
|
+
anchor: (i) => {
|
|
1333
|
+
const y = N.cells[i];
|
|
1334
|
+
return { x: y.x + y.width / 2, y: y.y + y.height / 2 };
|
|
1335
|
+
},
|
|
1336
|
+
announce: (i) => {
|
|
1337
|
+
const { cell: y, value: s } = $(i);
|
|
1338
|
+
return `${y.row}, ${y.column}: ${h} ${s}`;
|
|
1339
|
+
},
|
|
1340
|
+
table: {
|
|
1341
|
+
columns: [t, ...n],
|
|
1342
|
+
rows: e.map((i, y) => [
|
|
1343
|
+
i,
|
|
1344
|
+
...n.map((s, l) => {
|
|
1345
|
+
const c = hn(r, y, l);
|
|
1346
|
+
return c === null ? "—" : q(c);
|
|
1347
|
+
})
|
|
1348
|
+
])
|
|
1349
|
+
},
|
|
1350
|
+
className: A,
|
|
1351
|
+
testId: C
|
|
1352
|
+
}
|
|
1353
|
+
);
|
|
1354
|
+
}, Ue = /* @__PURE__ */ ot(/* @__PURE__ */ lt($e, "Heatmap")), ke = "hanui-box-7zEQ-", Ne = "hanui-median-J5g6o", ve = "hanui-outlier-M0VN-", Ae = "hanui-band-kK09D", zt = {
|
|
1355
|
+
box: ke,
|
|
1356
|
+
median: Ne,
|
|
1357
|
+
outlier: ve,
|
|
1358
|
+
band: Ae
|
|
1359
|
+
}, Te = ({
|
|
1360
|
+
label: t,
|
|
1361
|
+
description: o,
|
|
1362
|
+
groups: n,
|
|
1363
|
+
groupLabel: e,
|
|
1364
|
+
labels: r,
|
|
1365
|
+
height: h = 280,
|
|
1366
|
+
width: d,
|
|
1367
|
+
formatValue: u,
|
|
1368
|
+
className: k,
|
|
1369
|
+
testId: I
|
|
1370
|
+
}) => {
|
|
1371
|
+
const { labels: A } = xt(), [C, b] = _t(d), S = L(() => bt(A == null ? void 0 : A.locale), [A == null ? void 0 : A.locale]), P = L(() => St(A == null ? void 0 : A.locale), [A == null ? void 0 : A.locale]), H = u ?? S, q = L(
|
|
1372
|
+
() => n.map((M, $) => ({
|
|
1373
|
+
group: M,
|
|
1374
|
+
tone: Ft($, M.tone),
|
|
1375
|
+
stats: Cn(M.values)
|
|
1376
|
+
})),
|
|
1377
|
+
[n]
|
|
1378
|
+
), E = L(() => {
|
|
1379
|
+
const M = q.flatMap((p) => p.stats ? [p.stats.min, p.stats.max] : []), [$, i] = M.length ? yt(M) : [0, 1], y = vt($, i), s = rt(y[0], y[1], Rt(h, !1)), l = Ut(b, h, s.map(P)), c = Dt(
|
|
1380
|
+
n.map((p) => p.id),
|
|
1381
|
+
[l.left, l.right],
|
|
1382
|
+
{ paddingInner: 0.4, paddingOuter: 0.2 }
|
|
1383
|
+
), a = ft(y, [l.bottom, l.top]);
|
|
1384
|
+
return {
|
|
1385
|
+
area: l,
|
|
1386
|
+
band: c,
|
|
1387
|
+
y: a,
|
|
1388
|
+
yTicks: s.map((p) => ({ position: a(p), label: P(p) })),
|
|
1389
|
+
groupTicks: n.map((p) => ({
|
|
1390
|
+
position: c(p.id) + c.bandwidth / 2,
|
|
1391
|
+
label: p.label
|
|
1392
|
+
}))
|
|
1393
|
+
};
|
|
1394
|
+
}, [q, n, b, h, P]), N = (M) => [
|
|
1395
|
+
{ id: "max", label: r.max, value: H(M.whiskerHigh) },
|
|
1396
|
+
{ id: "q3", label: r.q3, value: H(M.q3) },
|
|
1397
|
+
{ id: "median", label: r.median, value: H(M.median) },
|
|
1398
|
+
{ id: "q1", label: r.q1, value: H(M.q1) },
|
|
1399
|
+
{ id: "min", label: r.min, value: H(M.whiskerLow) },
|
|
1400
|
+
...M.outliers.length > 0 ? [{ id: "outliers", label: r.outliers, value: S(M.outliers.length) }] : [],
|
|
1401
|
+
{ id: "count", label: r.count, value: S(M.count) }
|
|
1402
|
+
], R = L(() => {
|
|
1403
|
+
const { area: M, band: $, y: i } = E;
|
|
1404
|
+
return /* @__PURE__ */ V("g", { children: [
|
|
1405
|
+
/* @__PURE__ */ m(pt, { area: M, ticks: E.yTicks, side: "left", hasGrid: !0 }),
|
|
1406
|
+
/* @__PURE__ */ m(Xt, { area: M, ticks: E.groupTicks, side: "bottom" }),
|
|
1407
|
+
q.map(({ group: y, tone: s, stats: l }) => {
|
|
1408
|
+
if (!l) return null;
|
|
1409
|
+
const c = $(y.id), a = c + $.bandwidth / 2, p = $.bandwidth * 0.3, _ = Q(s);
|
|
1410
|
+
return /* @__PURE__ */ V("g", { style: { stroke: _ }, className: zt.box, children: [
|
|
1411
|
+
/* @__PURE__ */ m("line", { x1: a, x2: a, y1: i(l.whiskerHigh), y2: i(l.q3) }),
|
|
1412
|
+
/* @__PURE__ */ m("line", { x1: a, x2: a, y1: i(l.q1), y2: i(l.whiskerLow) }),
|
|
1413
|
+
/* @__PURE__ */ m(
|
|
1414
|
+
"line",
|
|
1415
|
+
{
|
|
1416
|
+
x1: a - p,
|
|
1417
|
+
x2: a + p,
|
|
1418
|
+
y1: i(l.whiskerHigh),
|
|
1419
|
+
y2: i(l.whiskerHigh)
|
|
1420
|
+
}
|
|
1421
|
+
),
|
|
1422
|
+
/* @__PURE__ */ m(
|
|
1423
|
+
"line",
|
|
1424
|
+
{
|
|
1425
|
+
x1: a - p,
|
|
1426
|
+
x2: a + p,
|
|
1427
|
+
y1: i(l.whiskerLow),
|
|
1428
|
+
y2: i(l.whiskerLow)
|
|
1429
|
+
}
|
|
1430
|
+
),
|
|
1431
|
+
/* @__PURE__ */ m(
|
|
1432
|
+
"rect",
|
|
1433
|
+
{
|
|
1434
|
+
x: c,
|
|
1435
|
+
width: $.bandwidth,
|
|
1436
|
+
y: i(l.q3),
|
|
1437
|
+
height: Math.max(1, i(l.q1) - i(l.q3)),
|
|
1438
|
+
rx: 2,
|
|
1439
|
+
style: { fill: `color-mix(in srgb, ${_} 22%, transparent)` }
|
|
1440
|
+
}
|
|
1441
|
+
),
|
|
1442
|
+
/* @__PURE__ */ m(
|
|
1443
|
+
"line",
|
|
1444
|
+
{
|
|
1445
|
+
className: zt.median,
|
|
1446
|
+
x1: c,
|
|
1447
|
+
x2: c + $.bandwidth,
|
|
1448
|
+
y1: i(l.median),
|
|
1449
|
+
y2: i(l.median)
|
|
1450
|
+
}
|
|
1451
|
+
),
|
|
1452
|
+
l.outliers.map((w, x) => /* @__PURE__ */ m("circle", { className: zt.outlier, cx: a, cy: i(w), r: 3 }, x))
|
|
1453
|
+
] }, y.id);
|
|
1454
|
+
})
|
|
1455
|
+
] });
|
|
1456
|
+
}, [E, q]), D = nt(
|
|
1457
|
+
(M, $) => {
|
|
1458
|
+
const { area: i, band: y } = E;
|
|
1459
|
+
if (M < i.left || M > i.right || $ < i.top - 4 || $ > i.bottom + 4)
|
|
1460
|
+
return null;
|
|
1461
|
+
const s = y.indexAt(M);
|
|
1462
|
+
return s < 0 ? null : s;
|
|
1463
|
+
},
|
|
1464
|
+
[E]
|
|
1465
|
+
);
|
|
1466
|
+
return /* @__PURE__ */ m(
|
|
1467
|
+
gt,
|
|
1468
|
+
{
|
|
1469
|
+
label: t,
|
|
1470
|
+
description: o,
|
|
1471
|
+
containerRef: C,
|
|
1472
|
+
width: b,
|
|
1473
|
+
height: h,
|
|
1474
|
+
plot: R,
|
|
1475
|
+
underlay: (M) => {
|
|
1476
|
+
const { area: $, band: i } = E, y = i.step * 0.2;
|
|
1477
|
+
return /* @__PURE__ */ m(
|
|
1478
|
+
"rect",
|
|
1479
|
+
{
|
|
1480
|
+
className: zt.band,
|
|
1481
|
+
x: i(n[M].id) - y,
|
|
1482
|
+
width: i.bandwidth + y * 2,
|
|
1483
|
+
y: $.top,
|
|
1484
|
+
height: $.height
|
|
1485
|
+
}
|
|
1486
|
+
);
|
|
1487
|
+
},
|
|
1488
|
+
overlay: () => null,
|
|
1489
|
+
itemCount: n.length,
|
|
1490
|
+
pick: D,
|
|
1491
|
+
tooltip: (M) => {
|
|
1492
|
+
const $ = q[M];
|
|
1493
|
+
return {
|
|
1494
|
+
title: $.group.label,
|
|
1495
|
+
rows: $.stats ? N($.stats).map((i) => ({
|
|
1496
|
+
...i,
|
|
1497
|
+
tone: i.id === "median" ? $.tone : void 0
|
|
1498
|
+
})) : []
|
|
1499
|
+
};
|
|
1500
|
+
},
|
|
1501
|
+
anchor: (M) => {
|
|
1502
|
+
const $ = q[M], { band: i, y } = E;
|
|
1503
|
+
return {
|
|
1504
|
+
x: i($.group.id) + i.bandwidth / 2,
|
|
1505
|
+
y: $.stats ? y($.stats.q3) : E.area.bottom
|
|
1506
|
+
};
|
|
1507
|
+
},
|
|
1508
|
+
announce: (M) => {
|
|
1509
|
+
const $ = q[M];
|
|
1510
|
+
return $.stats ? `${$.group.label}: ${N($.stats).map((i) => `${i.label} ${i.value}`).join(", ")}` : $.group.label;
|
|
1511
|
+
},
|
|
1512
|
+
table: {
|
|
1513
|
+
columns: [
|
|
1514
|
+
e,
|
|
1515
|
+
r.min,
|
|
1516
|
+
r.q1,
|
|
1517
|
+
r.median,
|
|
1518
|
+
r.q3,
|
|
1519
|
+
r.max,
|
|
1520
|
+
r.count
|
|
1521
|
+
],
|
|
1522
|
+
rows: q.map(
|
|
1523
|
+
({ group: M, stats: $ }) => $ ? [
|
|
1524
|
+
M.label,
|
|
1525
|
+
H($.whiskerLow),
|
|
1526
|
+
H($.q1),
|
|
1527
|
+
H($.median),
|
|
1528
|
+
H($.q3),
|
|
1529
|
+
H($.whiskerHigh),
|
|
1530
|
+
S($.count)
|
|
1531
|
+
] : [M.label, "—", "—", "—", "—", "—", "0"]
|
|
1532
|
+
)
|
|
1533
|
+
},
|
|
1534
|
+
className: k,
|
|
1535
|
+
testId: I
|
|
1536
|
+
}
|
|
1537
|
+
);
|
|
1538
|
+
}, Qe = /* @__PURE__ */ ot(/* @__PURE__ */ lt(Te, "BoxPlot")), Ie = "hanui-baseline-wWs7h", Ce = "hanui-band-xvYtL", mn = {
|
|
1539
|
+
baseline: Ie,
|
|
1540
|
+
band: Ce
|
|
1541
|
+
}, $t = 1, Re = ({
|
|
1542
|
+
label: t,
|
|
1543
|
+
description: o,
|
|
1544
|
+
values: n,
|
|
1545
|
+
bins: e,
|
|
1546
|
+
valueLabel: r,
|
|
1547
|
+
countLabel: h,
|
|
1548
|
+
tone: d = "cat-1",
|
|
1549
|
+
height: u = 260,
|
|
1550
|
+
width: k,
|
|
1551
|
+
formatValue: I,
|
|
1552
|
+
className: A,
|
|
1553
|
+
testId: C
|
|
1554
|
+
}) => {
|
|
1555
|
+
const { labels: b } = xt(), [S, P] = _t(k), H = L(() => bt(b == null ? void 0 : b.locale), [b == null ? void 0 : b.locale]), q = L(() => St(b == null ? void 0 : b.locale), [b == null ? void 0 : b.locale]), E = I ?? H, N = L(() => Rn(n, e), [n, e]), R = L(() => {
|
|
1556
|
+
var w, x;
|
|
1557
|
+
const i = Math.max(1, ...N.map((f) => f.count)), y = vt(0, i), s = rt(0, y[1], Rt(u, !1)).filter(Number.isInteger), l = Ut(P, u, s.map(q)), c = ((w = N[0]) == null ? void 0 : w.from) ?? 0, a = ((x = N[N.length - 1]) == null ? void 0 : x.to) ?? 1, p = ft([c, a], [l.left, l.right]), _ = ft(y, [l.bottom, l.top]);
|
|
1558
|
+
return {
|
|
1559
|
+
area: l,
|
|
1560
|
+
columns: N.map((f) => ({
|
|
1561
|
+
x: p(f.from) + $t / 2,
|
|
1562
|
+
width: Math.max(1, p(f.to) - p(f.from) - $t),
|
|
1563
|
+
y: _(f.count),
|
|
1564
|
+
height: Math.max(0, l.bottom - _(f.count)),
|
|
1565
|
+
center: (p(f.from) + p(f.to)) / 2
|
|
1566
|
+
})),
|
|
1567
|
+
xTicks: rt(c, a, Rt(l.width, !0)).map((f) => ({
|
|
1568
|
+
position: p(f),
|
|
1569
|
+
label: q(f)
|
|
1570
|
+
})),
|
|
1571
|
+
yTicks: s.map((f) => ({ position: _(f), label: q(f) }))
|
|
1572
|
+
};
|
|
1573
|
+
}, [N, P, u, q]), D = (i) => `${E(N[i].from)} – ${E(N[i].to)}`, M = L(
|
|
1574
|
+
() => /* @__PURE__ */ V("g", { children: [
|
|
1575
|
+
/* @__PURE__ */ m(pt, { area: R.area, ticks: R.yTicks, side: "left", hasGrid: !0 }),
|
|
1576
|
+
/* @__PURE__ */ m(pt, { area: R.area, ticks: R.xTicks, side: "bottom" }),
|
|
1577
|
+
/* @__PURE__ */ m(
|
|
1578
|
+
"line",
|
|
1579
|
+
{
|
|
1580
|
+
className: mn.baseline,
|
|
1581
|
+
x1: R.area.left,
|
|
1582
|
+
x2: R.area.right,
|
|
1583
|
+
y1: R.area.bottom,
|
|
1584
|
+
y2: R.area.bottom
|
|
1585
|
+
}
|
|
1586
|
+
),
|
|
1587
|
+
R.columns.map(
|
|
1588
|
+
(i, y) => i.height > 0 ? /* @__PURE__ */ m(
|
|
1589
|
+
"rect",
|
|
1590
|
+
{
|
|
1591
|
+
x: i.x,
|
|
1592
|
+
y: i.y,
|
|
1593
|
+
width: i.width,
|
|
1594
|
+
height: i.height,
|
|
1595
|
+
style: { fill: Q(d) }
|
|
1596
|
+
},
|
|
1597
|
+
y
|
|
1598
|
+
) : null
|
|
1599
|
+
)
|
|
1600
|
+
] }),
|
|
1601
|
+
[R, d]
|
|
1602
|
+
), $ = nt(
|
|
1603
|
+
(i, y) => {
|
|
1604
|
+
const { area: s, columns: l } = R;
|
|
1605
|
+
if (i < s.left || i > s.right || y < s.top - 4 || y > s.bottom + 4)
|
|
1606
|
+
return null;
|
|
1607
|
+
const c = l.findIndex(
|
|
1608
|
+
(a) => i >= a.x - $t && i <= a.x + a.width + $t
|
|
1609
|
+
);
|
|
1610
|
+
return c < 0 ? null : c;
|
|
1611
|
+
},
|
|
1612
|
+
[R]
|
|
1613
|
+
);
|
|
1614
|
+
return /* @__PURE__ */ m(
|
|
1615
|
+
gt,
|
|
1616
|
+
{
|
|
1617
|
+
label: t,
|
|
1618
|
+
description: o,
|
|
1619
|
+
containerRef: S,
|
|
1620
|
+
width: P,
|
|
1621
|
+
height: u,
|
|
1622
|
+
plot: M,
|
|
1623
|
+
underlay: (i) => {
|
|
1624
|
+
const y = R.columns[i];
|
|
1625
|
+
return /* @__PURE__ */ m(
|
|
1626
|
+
"rect",
|
|
1627
|
+
{
|
|
1628
|
+
className: mn.band,
|
|
1629
|
+
x: y.x - $t / 2,
|
|
1630
|
+
width: y.width + $t,
|
|
1631
|
+
y: R.area.top,
|
|
1632
|
+
height: R.area.height
|
|
1633
|
+
}
|
|
1634
|
+
);
|
|
1635
|
+
},
|
|
1636
|
+
overlay: () => null,
|
|
1637
|
+
itemCount: N.length,
|
|
1638
|
+
pick: $,
|
|
1639
|
+
tooltip: (i) => ({
|
|
1640
|
+
title: D(i),
|
|
1641
|
+
rows: [{ id: "count", label: h, value: H(N[i].count), tone: d }]
|
|
1642
|
+
}),
|
|
1643
|
+
anchor: (i) => ({ x: R.columns[i].center, y: R.columns[i].y }),
|
|
1644
|
+
announce: (i) => `${r} ${D(i)}: ${h} ${H(N[i].count)}`,
|
|
1645
|
+
table: {
|
|
1646
|
+
columns: [r, h],
|
|
1647
|
+
rows: N.map((i, y) => [D(y), H(i.count)])
|
|
1648
|
+
},
|
|
1649
|
+
className: A,
|
|
1650
|
+
testId: C
|
|
1651
|
+
}
|
|
1652
|
+
);
|
|
1653
|
+
}, Je = /* @__PURE__ */ ot(/* @__PURE__ */ lt(Re, "Histogram")), Fe = "hanui-grid-fHioN", Se = "hanui-shape-Vbb9D", He = "hanui-labels-nRfEk", Le = "hanui-axisLabel-UOZQ7", ze = "hanui-spoke-P-6cp", Pe = "hanui-marker-xzn9h", kt = {
|
|
1654
|
+
grid: Fe,
|
|
1655
|
+
shape: Se,
|
|
1656
|
+
labels: He,
|
|
1657
|
+
axisLabel: Le,
|
|
1658
|
+
spoke: ze,
|
|
1659
|
+
marker: Pe
|
|
1660
|
+
}, un = 10, De = 16, Ee = 28, Vt = (t, o) => {
|
|
1661
|
+
const n = t.values[o];
|
|
1662
|
+
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
1663
|
+
}, Ge = ({
|
|
1664
|
+
label: t,
|
|
1665
|
+
description: o,
|
|
1666
|
+
axes: n,
|
|
1667
|
+
series: e,
|
|
1668
|
+
max: r,
|
|
1669
|
+
height: h = 320,
|
|
1670
|
+
width: d,
|
|
1671
|
+
formatValue: u,
|
|
1672
|
+
className: k,
|
|
1673
|
+
testId: I
|
|
1674
|
+
}) => {
|
|
1675
|
+
const { labels: A } = xt(), [C, b] = _t(d), [S, P] = At(() => /* @__PURE__ */ new Set()), H = L(() => St(A == null ? void 0 : A.locale), [A == null ? void 0 : A.locale]), q = L(() => bt(A == null ? void 0 : A.locale), [A == null ? void 0 : A.locale]), E = u ?? q, N = L(
|
|
1676
|
+
() => e.map((s, l) => ({ ...s, tone: Ft(l, s.tone) })),
|
|
1677
|
+
[e]
|
|
1678
|
+
), R = L(() => N.filter((s) => !S.has(s.id)), [N, S]), D = L(() => {
|
|
1679
|
+
const s = n.length, l = s > 0 ? Math.PI * 2 / s : 0, c = n.map((X, U) => U * l), a = Math.min(b * 0.22, Math.max(0, ...n.map((X) => ut(X.label)))), p = Math.max(24, Math.min(h / 2 - 24, b / 2 - a - un - 4)), _ = b / 2, w = h / 2;
|
|
1680
|
+
let x = 0;
|
|
1681
|
+
for (const X of e)
|
|
1682
|
+
for (const U of n) {
|
|
1683
|
+
const G = Vt(X, U.key);
|
|
1684
|
+
G !== null && G > x && (x = G);
|
|
1685
|
+
}
|
|
1686
|
+
const f = r !== void 0 && r > 0 ? r : vt(0, x, 4)[1], T = rt(0, f, 4).filter((X) => X > 0);
|
|
1687
|
+
return { cx: _, cy: w, radius: p, angles: c, step: l, top: f, rings: T, scale: (X) => Math.min(Math.max(X, 0), f) / f * p, labelRoom: a };
|
|
1688
|
+
}, [n, e, r, b, h]), M = L(() => {
|
|
1689
|
+
const { cx: s, cy: l, angles: c, scale: a } = D;
|
|
1690
|
+
return R.map((p) => ({
|
|
1691
|
+
...p,
|
|
1692
|
+
points: n.map((_, w) => {
|
|
1693
|
+
const x = Vt(p, _.key);
|
|
1694
|
+
return { ...et(s, l, a(x ?? 0), c[w]), value: x };
|
|
1695
|
+
})
|
|
1696
|
+
}));
|
|
1697
|
+
}, [D, R, n]), $ = L(() => {
|
|
1698
|
+
const { cx: s, cy: l, radius: c, angles: a, rings: p, scale: _, labelRoom: w } = D, x = p.length > 0 ? _(p[0]) : c, f = Math.max(1, Math.ceil(De / Math.max(1, x)));
|
|
1699
|
+
return /* @__PURE__ */ V("g", { children: [
|
|
1700
|
+
/* @__PURE__ */ V("g", { "aria-hidden": !0, className: kt.grid, children: [
|
|
1701
|
+
p.map((T) => /* @__PURE__ */ m(
|
|
1702
|
+
"path",
|
|
1703
|
+
{
|
|
1704
|
+
d: nn(a.map((O) => et(s, l, _(T), O)))
|
|
1705
|
+
},
|
|
1706
|
+
T
|
|
1707
|
+
)),
|
|
1708
|
+
a.map((T, O) => {
|
|
1709
|
+
const X = et(s, l, c, T);
|
|
1710
|
+
return /* @__PURE__ */ m("line", { x1: s, y1: l, x2: X.x, y2: X.y }, n[O].key);
|
|
1711
|
+
})
|
|
1712
|
+
] }),
|
|
1713
|
+
M.map((T) => /* @__PURE__ */ m(
|
|
1714
|
+
"path",
|
|
1715
|
+
{
|
|
1716
|
+
className: kt.shape,
|
|
1717
|
+
d: nn(T.points),
|
|
1718
|
+
style: {
|
|
1719
|
+
fill: `color-mix(in srgb, ${Q(T.tone)} 14%, transparent)`,
|
|
1720
|
+
stroke: Q(T.tone)
|
|
1721
|
+
}
|
|
1722
|
+
},
|
|
1723
|
+
T.id
|
|
1724
|
+
)),
|
|
1725
|
+
/* @__PURE__ */ V("g", { "aria-hidden": !0, className: kt.labels, children: [
|
|
1726
|
+
p.map(
|
|
1727
|
+
(T, O) => (p.length - 1 - O) % f === 0 ? /* @__PURE__ */ m("text", { x: s + 4, y: l - _(T), dy: "1.1em", children: H(T) }, T) : null
|
|
1728
|
+
),
|
|
1729
|
+
n.map((T, O) => {
|
|
1730
|
+
const X = a[O], U = et(s, l, c + un, X), G = Math.sin(X), g = Math.cos(X), F = G > 0.3 ? "start" : G < -0.3 ? "end" : "middle", z = g > 0.3 ? "-0.2em" : g < -0.3 ? "0.9em" : "0.32em";
|
|
1731
|
+
return /* @__PURE__ */ m(
|
|
1732
|
+
"text",
|
|
1733
|
+
{
|
|
1734
|
+
className: kt.axisLabel,
|
|
1735
|
+
x: U.x,
|
|
1736
|
+
y: U.y,
|
|
1737
|
+
dy: z,
|
|
1738
|
+
textAnchor: F,
|
|
1739
|
+
children: Et(T.label, F === "middle" ? c * 1.4 : w)
|
|
1740
|
+
},
|
|
1741
|
+
T.key
|
|
1742
|
+
);
|
|
1743
|
+
})
|
|
1744
|
+
] })
|
|
1745
|
+
] });
|
|
1746
|
+
}, [D, M, n, H]), i = nt(
|
|
1747
|
+
(s, l) => {
|
|
1748
|
+
const { cx: c, cy: a, radius: p, step: _ } = D;
|
|
1749
|
+
if (n.length === 0 || Math.hypot(s - c, l - a) > p + Ee) return null;
|
|
1750
|
+
let w = Math.atan2(s - c, -(l - a));
|
|
1751
|
+
return w < 0 && (w += Math.PI * 2), Math.round(w / _) % n.length;
|
|
1752
|
+
},
|
|
1753
|
+
[D, n.length]
|
|
1754
|
+
), y = (s) => M.map((l) => {
|
|
1755
|
+
const c = l.points[s].value;
|
|
1756
|
+
return {
|
|
1757
|
+
id: l.id,
|
|
1758
|
+
label: l.label,
|
|
1759
|
+
value: c === null ? "—" : E(c),
|
|
1760
|
+
tone: l.tone
|
|
1761
|
+
};
|
|
1762
|
+
});
|
|
1763
|
+
return /* @__PURE__ */ m(
|
|
1764
|
+
gt,
|
|
1765
|
+
{
|
|
1766
|
+
label: t,
|
|
1767
|
+
description: o,
|
|
1768
|
+
containerRef: C,
|
|
1769
|
+
width: b,
|
|
1770
|
+
height: h,
|
|
1771
|
+
plot: $,
|
|
1772
|
+
overlay: (s) => {
|
|
1773
|
+
const { cx: l, cy: c, radius: a, angles: p } = D, _ = et(l, c, a, p[s]);
|
|
1774
|
+
return /* @__PURE__ */ V("g", { children: [
|
|
1775
|
+
/* @__PURE__ */ m("line", { className: kt.spoke, x1: l, y1: c, x2: _.x, y2: _.y }),
|
|
1776
|
+
M.map((w) => {
|
|
1777
|
+
const x = w.points[s];
|
|
1778
|
+
return x.value === null ? null : /* @__PURE__ */ m(
|
|
1779
|
+
"circle",
|
|
1780
|
+
{
|
|
1781
|
+
className: kt.marker,
|
|
1782
|
+
cx: x.x,
|
|
1783
|
+
cy: x.y,
|
|
1784
|
+
r: 4.5,
|
|
1785
|
+
style: { fill: Q(w.tone) }
|
|
1786
|
+
},
|
|
1787
|
+
w.id
|
|
1788
|
+
);
|
|
1789
|
+
})
|
|
1790
|
+
] });
|
|
1791
|
+
},
|
|
1792
|
+
itemCount: n.length,
|
|
1793
|
+
pick: i,
|
|
1794
|
+
tooltip: (s) => ({ title: n[s].label, rows: y(s) }),
|
|
1795
|
+
anchor: (s) => {
|
|
1796
|
+
const { cx: l, cy: c, radius: a, angles: p } = D;
|
|
1797
|
+
let _ = 0;
|
|
1798
|
+
for (const w of M) {
|
|
1799
|
+
const x = w.points[s];
|
|
1800
|
+
_ = Math.max(_, Math.hypot(x.x - l, x.y - c));
|
|
1801
|
+
}
|
|
1802
|
+
return et(l, c, Math.min(a, _), p[s]);
|
|
1803
|
+
},
|
|
1804
|
+
tooltipSide: "outward",
|
|
1805
|
+
announce: (s) => `${n[s].label}: ${y(s).map((l) => `${l.label} ${l.value}`).join(", ")}`,
|
|
1806
|
+
table: {
|
|
1807
|
+
columns: [t, ...N.map((s) => s.label)],
|
|
1808
|
+
rows: n.map((s) => [
|
|
1809
|
+
s.label,
|
|
1810
|
+
...N.map((l) => {
|
|
1811
|
+
const c = Vt(l, s.key);
|
|
1812
|
+
return c === null ? "—" : E(c);
|
|
1813
|
+
})
|
|
1814
|
+
])
|
|
1815
|
+
},
|
|
1816
|
+
legend: N.length > 1 ? {
|
|
1817
|
+
entries: N.map((s) => ({ id: s.id, label: s.label, tone: s.tone })),
|
|
1818
|
+
hidden: S,
|
|
1819
|
+
onToggle: (s) => P((l) => {
|
|
1820
|
+
const c = new Set(l);
|
|
1821
|
+
return c.has(s) ? c.delete(s) : N.length - l.size > 1 && c.add(s), c;
|
|
1822
|
+
})
|
|
1823
|
+
} : void 0,
|
|
1824
|
+
className: k,
|
|
1825
|
+
testId: I
|
|
1826
|
+
}
|
|
1827
|
+
);
|
|
1828
|
+
}, Ke = /* @__PURE__ */ ot(
|
|
1829
|
+
/* @__PURE__ */ lt(Ge, "RadarChart")
|
|
1830
|
+
);
|
|
1831
|
+
export {
|
|
1832
|
+
je as AreaChart,
|
|
1833
|
+
Ve as BarChart,
|
|
1834
|
+
Qe as BoxPlot,
|
|
1835
|
+
Xe as ComposedChart,
|
|
1836
|
+
Ue as Heatmap,
|
|
1837
|
+
Je as Histogram,
|
|
1838
|
+
We as LineChart,
|
|
1839
|
+
Ye as PieChart,
|
|
1840
|
+
Ke as RadarChart,
|
|
1841
|
+
Ze as ScatterPlot
|
|
1842
|
+
};
|
|
1843
|
+
//# sourceMappingURL=charts.js.map
|