@mechane-ai/elements 0.20.0 → 0.21.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 +11 -5
- package/dist/{categorical-values-Cf-zlA1u.js → categorical-values-DG0kzYxN.js} +2 -2
- package/dist/{chart-frame-Cf6LBA8M.js → chart-frame-DxAZ0h_q.js} +49 -50
- package/dist/{chart-input-BTDzeBQU.js → chart-input-Dru0GScv.js} +1 -1
- package/dist/charts/cartesian.js +276 -226
- package/dist/charts/distribution.js +2 -2
- package/dist/charts/graph.js +82 -80
- package/dist/charts/hierarchy.js +3 -3
- package/dist/charts/matrix.js +136 -134
- package/dist/charts/timeline.js +1 -1
- package/dist/charts.js +1 -1
- package/dist/code-block-DlUwVaPP.js +182 -0
- package/dist/collections.js +227 -117
- package/dist/content/code.js +1 -1
- package/dist/content/diff.js +2 -2
- package/dist/content/markdown.js +108 -102
- package/dist/content/tree.js +41 -39
- package/dist/content.js +138 -136
- package/dist/elements.css +42 -0
- package/dist/layout.js +212 -203
- package/dist/navigation.js +0 -1
- package/dist/packages/charts/src/chart-cursor.d.ts +7 -0
- package/dist/packages/charts/src/chart-theme.d.ts +1 -7
- package/dist/packages/collections/src/index.d.ts +1 -0
- package/dist/packages/collections/src/metrics.d.ts +64 -5
- package/dist/packages/foundations/src/use-scroll-tab-index.d.ts +6 -0
- package/dist/packages/layout/src/index.d.ts +2 -0
- package/dist/packages/layout/src/report-section.d.ts +6 -0
- package/dist/pierre-diff-CHQsoQSZ.js +72 -0
- package/dist/use-scroll-tab-index-Dxpdh4W7.js +45 -0
- package/package.json +1 -1
- package/dist/code-block-D1_kzPrs.js +0 -180
- package/dist/pierre-diff-hAwARDse.js +0 -71
package/dist/charts/cartesian.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { u as e } from "../src-0mocxTaR.js";
|
|
2
|
-
import { i as t, n, r, t as i } from "../categorical-values-
|
|
3
|
-
import { a, i as o, n as s, o as c, r as l, s as u, t as d } from "../chart-frame-
|
|
4
|
-
import { n as f, r as p, t as m } from "../chart-input-
|
|
2
|
+
import { i as t, n, r, t as i } from "../categorical-values-DG0kzYxN.js";
|
|
3
|
+
import { a, i as o, n as s, o as c, r as l, s as u, t as d } from "../chart-frame-DxAZ0h_q.js";
|
|
4
|
+
import { n as f, r as p, t as m } from "../chart-input-Dru0GScv.js";
|
|
5
5
|
import { t as h } from "../plot-width--OgdohB5.js";
|
|
6
6
|
import { E as g } from "../src-qU5Z5LRH.js";
|
|
7
7
|
import { g as _ } from "../src-D4zPPr32.js";
|
|
@@ -11,6 +11,26 @@ import { useEffect as b, useId as x, useMemo as S, useRef as C, useState as w }
|
|
|
11
11
|
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
12
12
|
import { scaleBand as O, scaleLinear as k } from "@visx/scale";
|
|
13
13
|
import { AreaClosed as ee, Bar as te, LinePath as A } from "@visx/shape";
|
|
14
|
+
// packages/charts/src/chart-cursor.tsx
|
|
15
|
+
function ne({ x: e, top: t, bottom: n, width: r }) {
|
|
16
|
+
return /* @__PURE__ */ D("g", {
|
|
17
|
+
"aria-hidden": !0,
|
|
18
|
+
className: "xlshs6z xgs60n x17y187c xbabvq0 x47corl",
|
|
19
|
+
children: [/* @__PURE__ */ E("line", {
|
|
20
|
+
x1: e,
|
|
21
|
+
x2: e,
|
|
22
|
+
y1: t,
|
|
23
|
+
y2: n,
|
|
24
|
+
className: "xnpr05h x1ntoi03 x13efnbd"
|
|
25
|
+
}), /* @__PURE__ */ E("line", {
|
|
26
|
+
x1: e - r / 2,
|
|
27
|
+
x2: e + r / 2,
|
|
28
|
+
y1: n + 4,
|
|
29
|
+
y2: n + 4,
|
|
30
|
+
className: "xzly4p3 x13efnbd"
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
14
34
|
// packages/charts/src/cartesian/bar-data.ts
|
|
15
35
|
function j({ composition: e, series: t, categoryIds: n, domain: r }) {
|
|
16
36
|
if (e === void 0) return;
|
|
@@ -37,7 +57,7 @@ var M = { mark: {
|
|
|
37
57
|
kAMwcw: "x1faw7qm",
|
|
38
58
|
$$css: !0
|
|
39
59
|
} };
|
|
40
|
-
function
|
|
60
|
+
function re({ bucket: e, series: t, focusedSeries: n, index: i, x: a, width: o, y: s, isHighlighted: l }) {
|
|
41
61
|
let d = n !== void 0, f = n !== void 0 && !t.some((e) => e.id === n.id) ? [...t, n] : t;
|
|
42
62
|
function p(e, t) {
|
|
43
63
|
let n = s(t), r = s(t + e);
|
|
@@ -75,11 +95,11 @@ function ne({ bucket: e, series: t, focusedSeries: n, index: i, x: a, width: o,
|
|
|
75
95
|
})] });
|
|
76
96
|
}
|
|
77
97
|
// packages/charts/src/cartesian/bar-chart.tsx
|
|
78
|
-
var
|
|
98
|
+
var ie = { plot: {
|
|
79
99
|
kqGvvJ: "x1we84gm",
|
|
80
100
|
$$css: !0
|
|
81
|
-
} },
|
|
82
|
-
function
|
|
101
|
+
} }, ae = /* @__PURE__ */ new Set(["Enter", " "]), oe = 200, se = "Point, tap, or use the arrow keys to inspect values.";
|
|
102
|
+
function ce({ title: e, description: t, series: n, children: i }) {
|
|
83
103
|
let a = n.map((e, t) => ({
|
|
84
104
|
id: e.id,
|
|
85
105
|
label: e.label,
|
|
@@ -97,18 +117,18 @@ function F({ title: e, description: t, series: n, children: i }) {
|
|
|
97
117
|
}), i]
|
|
98
118
|
});
|
|
99
119
|
}
|
|
100
|
-
function
|
|
101
|
-
let a =
|
|
120
|
+
function le({ title: t = "Loading chart", description: n, series: r = [], height: i = oe }) {
|
|
121
|
+
let a = N(i);
|
|
102
122
|
return a === void 0 ? /* @__PURE__ */ E("div", {
|
|
103
123
|
"aria-hidden": !0,
|
|
104
124
|
inert: !0,
|
|
105
|
-
children: /* @__PURE__ */ D(
|
|
125
|
+
children: /* @__PURE__ */ D(ce, {
|
|
106
126
|
title: t,
|
|
107
127
|
description: n,
|
|
108
128
|
series: r,
|
|
109
129
|
children: [
|
|
110
130
|
/* @__PURE__ */ E("div", {
|
|
111
|
-
...y.props(c.plot,
|
|
131
|
+
...y.props(c.plot, ie.plot),
|
|
112
132
|
children: /* @__PURE__ */ E(e, { height: i })
|
|
113
133
|
}),
|
|
114
134
|
/* @__PURE__ */ E("div", {
|
|
@@ -117,7 +137,7 @@ function I({ title: t = "Loading chart", description: n, series: r = [], height:
|
|
|
117
137
|
className: "x1n2onr6 xeuugli",
|
|
118
138
|
children: [/* @__PURE__ */ E("span", {
|
|
119
139
|
className: "xlshs6z",
|
|
120
|
-
children:
|
|
140
|
+
children: se
|
|
121
141
|
}), /* @__PURE__ */ E("span", {
|
|
122
142
|
className: "x10l6tqk x10a8y8t",
|
|
123
143
|
children: /* @__PURE__ */ E(e, { height: "100%" })
|
|
@@ -136,10 +156,10 @@ function I({ title: t = "Loading chart", description: n, series: r = [], height:
|
|
|
136
156
|
message: a
|
|
137
157
|
});
|
|
138
158
|
}
|
|
139
|
-
function
|
|
159
|
+
function N(e) {
|
|
140
160
|
if (!Number.isFinite(e) || e < 48) return "Chart height must be at least 48 pixels.";
|
|
141
161
|
}
|
|
142
|
-
function
|
|
162
|
+
function ue({ categories: e, series: t, domain: r, mode: i }) {
|
|
143
163
|
if (e.length > n.items || t.length > n.series) return `Choose a window with at most ${n.items} categories and ${n.series} series.`;
|
|
144
164
|
if (!p(r) || r[0] > 0 || r[1] < 0) return "The bar domain must be finite, increasing, and include zero.";
|
|
145
165
|
if (!f(e) || !f(t)) return "Bar categories and series require unique identifiers.";
|
|
@@ -152,13 +172,17 @@ function ae({ categories: e, series: t, domain: r, mode: i }) {
|
|
|
152
172
|
}
|
|
153
173
|
if (i === "stacked" && e.some((e, n) => t.reduce((e, t) => e + (t.values[n] ?? 0), 0) > r[1])) return "Stacked bar totals must fit the supplied domain.";
|
|
154
174
|
}
|
|
155
|
-
|
|
156
|
-
|
|
175
|
+
var P = {
|
|
176
|
+
"x-default-marker": "x-default-marker",
|
|
177
|
+
$$css: !0
|
|
178
|
+
};
|
|
179
|
+
function F({ title: e, description: t, categories: n, series: a, domain: o, mode: s = "grouped", formatValue: l, selection: f, height: p = oe, composition: g }) {
|
|
180
|
+
let _ = g?.focusedSeries, v = x(), b = _ === void 0 ? void 0 : ue({
|
|
157
181
|
categories: n,
|
|
158
182
|
series: [_],
|
|
159
183
|
domain: o,
|
|
160
184
|
mode: "grouped"
|
|
161
|
-
}), S =
|
|
185
|
+
}), S = ue({
|
|
162
186
|
categories: n,
|
|
163
187
|
series: a,
|
|
164
188
|
domain: o,
|
|
@@ -168,109 +192,118 @@ function oe({ title: e, description: t, categories: n, series: a, domain: o, mod
|
|
|
168
192
|
series: a,
|
|
169
193
|
categoryIds: n.map((e) => e.id),
|
|
170
194
|
domain: o
|
|
171
|
-
}) ??
|
|
195
|
+
}) ?? N(p), ee = S ?? C, A = g === void 0 ? void 0 : {
|
|
172
196
|
id: v,
|
|
173
197
|
label: g.contextLabel,
|
|
174
198
|
tone: "neutral",
|
|
175
199
|
values: g.buckets.map((e) => e.kind === "gap" ? null : e.total)
|
|
176
|
-
}, M = A === void 0 ? a : [A, ..._ === void 0 ? [] : [_]],
|
|
200
|
+
}, M = A === void 0 ? a : [A, ..._ === void 0 ? [] : [_]], le = A === void 0 ? a : [
|
|
177
201
|
A,
|
|
178
202
|
...a,
|
|
179
203
|
..._ === void 0 || a.some((e) => e.id === _.id) ? [] : [_]
|
|
180
|
-
],
|
|
204
|
+
], F = a.length > 0 ? a : M, { ref: fe, width: I } = h(), L = x(), [R, z] = w(), [B, V] = w(), H = n.findIndex((e) => e.id === R?.id), U = n[H], W = n.findIndex((e) => e.id === f?.selectedId), G = n[W], K = n.find((e) => e.id === B) ?? G ?? n[0], q = n.findIndex((e) => e.id === K?.id), J = U ?? G, Y = U === void 0 ? W : H;
|
|
181
205
|
if (ee !== void 0) return /* @__PURE__ */ E(m, {
|
|
182
206
|
title: e,
|
|
183
207
|
description: t,
|
|
184
208
|
message: ee
|
|
185
209
|
});
|
|
186
|
-
let
|
|
210
|
+
let X = p - 28, Z = k({
|
|
187
211
|
domain: [...o],
|
|
188
|
-
range: [
|
|
189
|
-
}),
|
|
212
|
+
range: [X, 12]
|
|
213
|
+
}), Q = Math.max(52, ...Z.ticks(3).map((e) => l(e).length * 7 + 12)), pe = Math.max(Q + 1, I - 16), $ = O({
|
|
190
214
|
domain: n.map((e) => e.id),
|
|
191
|
-
range: [
|
|
215
|
+
range: [Q, pe],
|
|
192
216
|
padding: .3
|
|
193
|
-
}),
|
|
217
|
+
}), me = O({
|
|
194
218
|
domain: a.map((e) => e.id),
|
|
195
219
|
range: [0, $.bandwidth()],
|
|
196
220
|
padding: .08
|
|
197
|
-
}),
|
|
198
|
-
function
|
|
199
|
-
let t = e.currentTarget.getBoundingClientRect(), r = (e.clientX - t.left) / t.width *
|
|
200
|
-
a !== void 0 &&
|
|
221
|
+
}), he = Math.min(120, Math.max(40, ...n.map((e) => (e.axisLabel ?? e.label).length * 7))), ge = Math.max(1, Math.ceil((he + 16) / $.step())), _e = n.length > 0 && (a.length > 0 || g !== void 0), ve = Math.max(1, Math.floor(($.step() * ge - 16) / 7));
|
|
222
|
+
function ye(e) {
|
|
223
|
+
let t = e.currentTarget.getBoundingClientRect(), r = (e.clientX - t.left) / t.width * I, i = Math.floor((r - Q) / $.step()), a = n[Math.max(0, Math.min(n.length - 1, i))];
|
|
224
|
+
a !== void 0 && (e.type === "pointerdown" && V(a.id), z({
|
|
201
225
|
id: a.id,
|
|
202
226
|
source: "pointer"
|
|
203
|
-
});
|
|
227
|
+
}));
|
|
204
228
|
}
|
|
205
|
-
function
|
|
229
|
+
function be(e) {
|
|
206
230
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
207
231
|
if (e.key === "Escape") {
|
|
208
|
-
e.preventDefault(), e.stopPropagation(),
|
|
232
|
+
e.preventDefault(), e.stopPropagation(), z(void 0);
|
|
209
233
|
return;
|
|
210
234
|
}
|
|
211
|
-
if (
|
|
212
|
-
|
|
235
|
+
if (ae.has(e.key)) {
|
|
236
|
+
K !== void 0 && f !== void 0 && (e.preventDefault(), f.onSelect(K.id));
|
|
213
237
|
return;
|
|
214
238
|
}
|
|
215
239
|
let t = {
|
|
216
|
-
ArrowRight: Math.min(n.length - 1,
|
|
217
|
-
ArrowLeft: Math.max(0,
|
|
240
|
+
ArrowRight: Math.min(n.length - 1, q + 1),
|
|
241
|
+
ArrowLeft: Math.max(0, q - 1),
|
|
218
242
|
Home: 0,
|
|
219
243
|
End: n.length - 1
|
|
220
244
|
}[e.key], r = t === void 0 ? void 0 : n[t];
|
|
221
|
-
r !== void 0 && (e.preventDefault(),
|
|
245
|
+
r !== void 0 && (e.preventDefault(), V(r.id), z({
|
|
222
246
|
id: r.id,
|
|
223
247
|
source: "keyboard"
|
|
224
248
|
}));
|
|
225
249
|
}
|
|
226
|
-
return /* @__PURE__ */ D(
|
|
250
|
+
return /* @__PURE__ */ D(ce, {
|
|
227
251
|
title: e,
|
|
228
252
|
description: t,
|
|
229
|
-
series:
|
|
253
|
+
series: F,
|
|
230
254
|
children: [
|
|
231
255
|
/* @__PURE__ */ E("div", {
|
|
232
|
-
ref:
|
|
233
|
-
...y.props(c.plot,
|
|
256
|
+
ref: fe,
|
|
257
|
+
...y.props(c.plot, ie.plot),
|
|
234
258
|
children: n.length === 0 || a.length === 0 && g === void 0 ? /* @__PURE__ */ E("p", {
|
|
235
259
|
className: "x153jb6y x1ghz6dp xy8obcc",
|
|
236
260
|
children: "No categories"
|
|
237
261
|
}) : /* @__PURE__ */ D("svg", {
|
|
238
262
|
role: "img",
|
|
239
263
|
"aria-label": `${e}. Use arrow keys to inspect categories.${f === void 0 ? "" : " Press Enter to select."}`,
|
|
240
|
-
"aria-describedby":
|
|
264
|
+
"aria-describedby": L,
|
|
241
265
|
tabIndex: 0,
|
|
242
|
-
viewBox: `0 0 ${
|
|
266
|
+
viewBox: `0 0 ${I} ${p}`,
|
|
243
267
|
height: p,
|
|
244
|
-
onKeyDown:
|
|
268
|
+
onKeyDown: be,
|
|
269
|
+
onFocus: (e) => {
|
|
270
|
+
if (e.currentTarget.matches(":focus-visible")) {
|
|
271
|
+
let e = G ?? n[0];
|
|
272
|
+
V(e?.id), z(e === void 0 ? void 0 : {
|
|
273
|
+
id: e.id,
|
|
274
|
+
source: "keyboard"
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
},
|
|
245
278
|
onPointerMove: (e) => {
|
|
246
|
-
e.pointerType === "mouse" &&
|
|
279
|
+
e.pointerType === "mouse" && ye(e);
|
|
247
280
|
},
|
|
248
|
-
onPointerDown:
|
|
281
|
+
onPointerDown: ye,
|
|
249
282
|
onPointerLeave: (e) => {
|
|
250
|
-
e.pointerType === "mouse" &&
|
|
283
|
+
e.pointerType === "mouse" && R?.source === "pointer" && z(void 0);
|
|
251
284
|
},
|
|
252
|
-
onBlur: () =>
|
|
285
|
+
onBlur: () => z(void 0),
|
|
253
286
|
onClick: () => {
|
|
254
|
-
|
|
287
|
+
U !== void 0 && f?.onSelect(U.id);
|
|
255
288
|
},
|
|
256
|
-
...y.props(c.svg, c.
|
|
289
|
+
...y.props(c.svg, c.inspectable, P),
|
|
257
290
|
children: [
|
|
258
|
-
|
|
259
|
-
x: ($(
|
|
291
|
+
U !== void 0 && /* @__PURE__ */ E("rect", {
|
|
292
|
+
x: ($(U.id) ?? Q) - ($.step() - $.bandwidth()) / 2,
|
|
260
293
|
y: 12,
|
|
261
294
|
width: $.step(),
|
|
262
|
-
height:
|
|
295
|
+
height: X - 12,
|
|
263
296
|
className: "x2wnxhi"
|
|
264
297
|
}),
|
|
265
|
-
|
|
266
|
-
x1:
|
|
267
|
-
x2:
|
|
268
|
-
y1:
|
|
269
|
-
y2:
|
|
298
|
+
Z.ticks(3).map((e) => /* @__PURE__ */ D("g", { children: [/* @__PURE__ */ E("line", {
|
|
299
|
+
x1: Q,
|
|
300
|
+
x2: pe,
|
|
301
|
+
y1: Z(e),
|
|
302
|
+
y2: Z(e),
|
|
270
303
|
...y.props(c.grid)
|
|
271
304
|
}), /* @__PURE__ */ E("text", {
|
|
272
|
-
x:
|
|
273
|
-
y:
|
|
305
|
+
x: Q - 8,
|
|
306
|
+
y: Z(e),
|
|
274
307
|
textAnchor: "end",
|
|
275
308
|
dominantBaseline: "middle",
|
|
276
309
|
...y.props(c.label),
|
|
@@ -278,7 +311,7 @@ function oe({ title: e, description: t, categories: n, series: a, domain: o, mod
|
|
|
278
311
|
})] }, e)),
|
|
279
312
|
g?.annotation !== void 0 && n.some((e) => e.id === g.annotation?.categoryId) && /* @__PURE__ */ E("text", {
|
|
280
313
|
x: $(g.annotation.categoryId),
|
|
281
|
-
y: Math.max(12,
|
|
314
|
+
y: Math.max(12, Z(g.annotation.value) - 8),
|
|
282
315
|
...y.props(c.label),
|
|
283
316
|
children: g.annotation.label
|
|
284
317
|
}),
|
|
@@ -287,54 +320,60 @@ function oe({ title: e, description: t, categories: n, series: a, domain: o, mod
|
|
|
287
320
|
return /* @__PURE__ */ D("g", { children: [i === void 0 ? a.map((n, i) => {
|
|
288
321
|
let o = n.values[t];
|
|
289
322
|
if (o == null) return null;
|
|
290
|
-
let l = s === "stacked" ? a.slice(0, i).reduce((e, n) => e + (n.values[t] ?? 0), 0) : 0, d =
|
|
323
|
+
let l = s === "stacked" ? a.slice(0, i).reduce((e, n) => e + (n.values[t] ?? 0), 0) : 0, d = Z(l), p = Z(l + o), m = f?.selectedId === e.id || U?.id === e.id;
|
|
291
324
|
return /* @__PURE__ */ E(te, {
|
|
292
|
-
x: ($(e.id) ??
|
|
325
|
+
x: ($(e.id) ?? Q) + (s === "stacked" ? 0 : me(n.id) ?? 0),
|
|
293
326
|
y: Math.min(d, p),
|
|
294
|
-
width: s === "stacked" ? $.bandwidth() :
|
|
327
|
+
width: s === "stacked" ? $.bandwidth() : me.bandwidth(),
|
|
295
328
|
height: Math.max(+(o === 0), Math.abs(p - d)),
|
|
296
329
|
fill: u[r(n.tone, i)],
|
|
297
330
|
...y.props(m && c.selected)
|
|
298
331
|
}, n.id);
|
|
299
|
-
}) : /* @__PURE__ */ E(
|
|
332
|
+
}) : /* @__PURE__ */ E(re, {
|
|
300
333
|
bucket: i,
|
|
301
334
|
series: a,
|
|
302
335
|
focusedSeries: _,
|
|
303
336
|
index: t,
|
|
304
|
-
x: $(e.id) ??
|
|
337
|
+
x: $(e.id) ?? Q,
|
|
305
338
|
width: $.bandwidth(),
|
|
306
|
-
y:
|
|
307
|
-
isHighlighted: f?.selectedId === e.id ||
|
|
308
|
-
}), t %
|
|
309
|
-
x: ($(e.id) ??
|
|
339
|
+
y: Z,
|
|
340
|
+
isHighlighted: f?.selectedId === e.id || U?.id === e.id
|
|
341
|
+
}), t % ge === 0 && /* @__PURE__ */ E("text", {
|
|
342
|
+
x: ($(e.id) ?? Q) + $.bandwidth() / 2,
|
|
310
343
|
y: p - 4,
|
|
311
344
|
textAnchor: "middle",
|
|
312
345
|
...y.props(c.label),
|
|
313
|
-
children: n.length >
|
|
346
|
+
children: n.length > ve ? `${n.slice(0, ve - 1)}…` : n
|
|
314
347
|
})] }, e.id);
|
|
348
|
+
}),
|
|
349
|
+
K !== void 0 && /* @__PURE__ */ E(ne, {
|
|
350
|
+
x: ($(K.id) ?? Q) + $.bandwidth() / 2,
|
|
351
|
+
top: 12,
|
|
352
|
+
bottom: X,
|
|
353
|
+
width: Math.max(8, $.bandwidth())
|
|
315
354
|
})
|
|
316
355
|
]
|
|
317
356
|
})
|
|
318
357
|
}),
|
|
319
|
-
|
|
320
|
-
id:
|
|
321
|
-
"aria-live":
|
|
358
|
+
_e && /* @__PURE__ */ E("div", {
|
|
359
|
+
id: L,
|
|
360
|
+
"aria-live": R?.source === "pointer" ? "off" : "polite",
|
|
322
361
|
className: "x78zum5 x1a02dak x8zbtdt x1gkm1c7 x1rtsecp xy8obcc xas2l8k xss6m8b xj0a0fe",
|
|
323
|
-
children:
|
|
362
|
+
children: J === void 0 ? /* @__PURE__ */ E("span", {
|
|
324
363
|
className: "x153jb6y x1ghz6dp xy8obcc",
|
|
325
|
-
children:
|
|
326
|
-
}) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E("span", { children:
|
|
364
|
+
children: se
|
|
365
|
+
}) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E("span", { children: J.label }), M.map((e) => /* @__PURE__ */ D("span", { children: [
|
|
327
366
|
e.label,
|
|
328
367
|
":",
|
|
329
368
|
" ",
|
|
330
|
-
e.values[
|
|
369
|
+
e.values[Y] === null || e.values[Y] === void 0 ? "Unavailable" : l(e.values[Y])
|
|
331
370
|
] }, e.id))] })
|
|
332
371
|
}),
|
|
333
372
|
/* @__PURE__ */ E(d, { children: /* @__PURE__ */ E(i, {
|
|
334
373
|
items: n.map((e, t) => ({
|
|
335
374
|
id: e.id,
|
|
336
375
|
label: e.label,
|
|
337
|
-
valueLabel:
|
|
376
|
+
valueLabel: de(le, t, l),
|
|
338
377
|
tone: "neutral"
|
|
339
378
|
})),
|
|
340
379
|
selection: f
|
|
@@ -342,19 +381,19 @@ function oe({ title: e, description: t, categories: n, series: a, domain: o, mod
|
|
|
342
381
|
]
|
|
343
382
|
});
|
|
344
383
|
}
|
|
345
|
-
function
|
|
384
|
+
function de(e, t, n) {
|
|
346
385
|
return e.map((e) => {
|
|
347
386
|
let r = e.values[t];
|
|
348
387
|
return `${e.label}: ${r == null ? "Unavailable" : n(r)}`;
|
|
349
388
|
}).join(" · ");
|
|
350
389
|
}
|
|
351
390
|
// packages/charts/src/cartesian/breakdown-bar.tsx
|
|
352
|
-
var
|
|
391
|
+
var fe = {
|
|
353
392
|
kzqmXN: "x5lhr3w",
|
|
354
393
|
kZKoxP: "x5yr21d",
|
|
355
394
|
$$css: !0
|
|
356
|
-
},
|
|
357
|
-
|
|
395
|
+
}, I = { segment: (e, t) => [
|
|
396
|
+
fe,
|
|
358
397
|
{
|
|
359
398
|
kWkggS: t == null ? t : "xl8spv7",
|
|
360
399
|
$$css: !0
|
|
@@ -364,7 +403,7 @@ var se = {
|
|
|
364
403
|
"--x-backgroundColor": t ?? void 0
|
|
365
404
|
}
|
|
366
405
|
] };
|
|
367
|
-
function
|
|
406
|
+
function L({ title: e, description: n, items: a, total: o, formatValue: s, selection: c }) {
|
|
368
407
|
let d = t(a), f = a.reduce((e, t) => e + (t.value ?? 0), 0), p = 2 ** -52 * Math.max(f, o, 1) * a.length;
|
|
369
408
|
return d === void 0 ? !Number.isFinite(o) || o < 0 || f - o > p ? /* @__PURE__ */ E(m, {
|
|
370
409
|
title: e,
|
|
@@ -380,7 +419,7 @@ function B({ title: e, description: n, items: a, total: o, formatValue: s, selec
|
|
|
380
419
|
/* @__PURE__ */ E("div", {
|
|
381
420
|
"aria-hidden": !0,
|
|
382
421
|
className: "x78zum5 x170jfvy xb3r6kr x1r7kqkb xmkeg23 x1y0btm7 x1ey3b81 x1jfksii",
|
|
383
|
-
children: a.map((e, t) => e.value === null ? null : /* @__PURE__ */ E("span", { ...y.props(
|
|
422
|
+
children: a.map((e, t) => e.value === null ? null : /* @__PURE__ */ E("span", { ...y.props(I.segment(o === 0 ? 0 : e.value / o * 100, u[r(e.tone, t)])) }, e.id))
|
|
384
423
|
}),
|
|
385
424
|
/* @__PURE__ */ E(i, {
|
|
386
425
|
items: a.map((e, t) => ({
|
|
@@ -408,12 +447,12 @@ function B({ title: e, description: n, items: a, total: o, formatValue: s, selec
|
|
|
408
447
|
});
|
|
409
448
|
}
|
|
410
449
|
// packages/charts/src/cartesian/scatter-plot.tsx
|
|
411
|
-
var
|
|
450
|
+
var R = 260, z = 56, B = 20, V = 12, H = 1e3, U = {
|
|
412
451
|
kzqmXN: "x1xc55vz",
|
|
413
452
|
kZKoxP: "xdk7pt",
|
|
414
453
|
kaIpWk: "x16rqkct",
|
|
415
454
|
$$css: !0
|
|
416
|
-
},
|
|
455
|
+
}, W = {
|
|
417
456
|
brush: {
|
|
418
457
|
kFalU9: "xx69xxh",
|
|
419
458
|
kkrTdU: "xsid9ct",
|
|
@@ -451,7 +490,7 @@ var V = 260, H = 56, U = 20, W = 12, G = 1e3, K = {
|
|
|
451
490
|
"--x-top": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
|
|
452
491
|
}],
|
|
453
492
|
dot: (e) => [
|
|
454
|
-
|
|
493
|
+
U,
|
|
455
494
|
{
|
|
456
495
|
kWkggS: e == null ? e : "xl8spv7",
|
|
457
496
|
$$css: !0
|
|
@@ -466,8 +505,8 @@ var V = 260, H = 56, U = 20, W = 12, G = 1e3, K = {
|
|
|
466
505
|
$$css: !0
|
|
467
506
|
}
|
|
468
507
|
};
|
|
469
|
-
function
|
|
470
|
-
let { title: t, description: n, points: r, xDomain: i, yDomain: o, xLabel: c, yLabel: f, formatX: p, formatY: g, selection: _, rangeSelection: v, emptyLabel: b } = e, { ref: x, width: S } = h(), C =
|
|
508
|
+
function G(e) {
|
|
509
|
+
let { title: t, description: n, points: r, xDomain: i, yDomain: o, xLabel: c, yLabel: f, formatX: p, formatY: g, selection: _, rangeSelection: v, emptyLabel: b } = e, { ref: x, width: S } = h(), C = J(e);
|
|
471
510
|
if (C !== null) return /* @__PURE__ */ E(m, {
|
|
472
511
|
title: t,
|
|
473
512
|
description: n,
|
|
@@ -475,10 +514,10 @@ function J(e) {
|
|
|
475
514
|
});
|
|
476
515
|
let w = k({
|
|
477
516
|
domain: [...i],
|
|
478
|
-
range: [
|
|
517
|
+
range: [z, Math.max(z, S - B)]
|
|
479
518
|
}), T = k({
|
|
480
519
|
domain: [...o],
|
|
481
|
-
range: [216,
|
|
520
|
+
range: [216, V]
|
|
482
521
|
}), O = r.find((e) => e.id === _?.selectedId);
|
|
483
522
|
return /* @__PURE__ */ D(l, {
|
|
484
523
|
title: t,
|
|
@@ -491,7 +530,7 @@ function J(e) {
|
|
|
491
530
|
}) : /* @__PURE__ */ D("div", {
|
|
492
531
|
ref: x,
|
|
493
532
|
className: "x1n2onr6 xeuugli",
|
|
494
|
-
children: [/* @__PURE__ */ E(
|
|
533
|
+
children: [/* @__PURE__ */ E(K, {
|
|
495
534
|
width: S,
|
|
496
535
|
scaleX: w,
|
|
497
536
|
scaleY: T,
|
|
@@ -504,15 +543,15 @@ function J(e) {
|
|
|
504
543
|
"aria-label": `${e.label}, ${c}: ${p(e.x)}, ${f}: ${g(e.y)}`,
|
|
505
544
|
"aria-pressed": _.selectedId === e.id,
|
|
506
545
|
onClick: () => _.onSelect(e.id),
|
|
507
|
-
...y.props(
|
|
546
|
+
...y.props(W.target, W.location(w(e.x), T(e.y))),
|
|
508
547
|
children: /* @__PURE__ */ E("span", {
|
|
509
548
|
"aria-hidden": !0,
|
|
510
|
-
...y.props(
|
|
549
|
+
...y.props(W.dot(u[e.tone]), _.selectedId === e.id && W.selected)
|
|
511
550
|
})
|
|
512
551
|
}, e.id))
|
|
513
552
|
})]
|
|
514
553
|
}),
|
|
515
|
-
v !== void 0 && /* @__PURE__ */ E(
|
|
554
|
+
v !== void 0 && /* @__PURE__ */ E(q, {
|
|
516
555
|
...e,
|
|
517
556
|
rangeSelection: v
|
|
518
557
|
}),
|
|
@@ -532,7 +571,7 @@ function J(e) {
|
|
|
532
571
|
]
|
|
533
572
|
});
|
|
534
573
|
}
|
|
535
|
-
function
|
|
574
|
+
function K({ width: e, scaleX: t, scaleY: n, points: r, xLabel: i, yLabel: a, formatX: o, formatY: s, selection: l, rangeSelection: d }) {
|
|
536
575
|
let f = x(), [p, m] = w(null), h = p === null ? d?.value : {
|
|
537
576
|
x: [Math.min(p.start.x, p.end.x), Math.max(p.start.x, p.end.x)],
|
|
538
577
|
y: [Math.min(p.start.y, p.end.y), Math.max(p.start.y, p.end.y)]
|
|
@@ -541,13 +580,13 @@ function Y({ width: e, scaleX: t, scaleY: n, points: r, xLabel: i, yLabel: a, fo
|
|
|
541
580
|
let i = r.currentTarget.getBoundingClientRect();
|
|
542
581
|
return {
|
|
543
582
|
x: t.copy().clamp(!0).invert((r.clientX - i.left) / i.width * e),
|
|
544
|
-
y: n.copy().clamp(!0).invert((r.clientY - i.top) / i.height *
|
|
583
|
+
y: n.copy().clamp(!0).invert((r.clientY - i.top) / i.height * R)
|
|
545
584
|
};
|
|
546
585
|
}
|
|
547
586
|
function _(t) {
|
|
548
587
|
if (d === void 0 || t.button !== 0 || t.pointerType === "touch") return;
|
|
549
|
-
let n = t.currentTarget.getBoundingClientRect(), r = (t.clientX - n.left) / n.width * e, i = (t.clientY - n.top) / n.height *
|
|
550
|
-
if (r <
|
|
588
|
+
let n = t.currentTarget.getBoundingClientRect(), r = (t.clientX - n.left) / n.width * e, i = (t.clientY - n.top) / n.height * R;
|
|
589
|
+
if (r < z || r > e - B || i < V || i > 216) return;
|
|
551
590
|
let a = g(t);
|
|
552
591
|
t.currentTarget.setPointerCapture(t.pointerId), m({
|
|
553
592
|
start: a,
|
|
@@ -571,29 +610,29 @@ function Y({ width: e, scaleX: t, scaleY: n, points: r, xLabel: i, yLabel: a, fo
|
|
|
571
610
|
}
|
|
572
611
|
return /* @__PURE__ */ D("svg", {
|
|
573
612
|
width: e,
|
|
574
|
-
height:
|
|
575
|
-
viewBox: `0 0 ${e} ${
|
|
613
|
+
height: R,
|
|
614
|
+
viewBox: `0 0 ${e} ${R}`,
|
|
576
615
|
"aria-hidden": !0,
|
|
577
616
|
onPointerDown: _,
|
|
578
617
|
onPointerMove: v,
|
|
579
618
|
onPointerUp: b,
|
|
580
619
|
onPointerCancel: () => m(null),
|
|
581
620
|
onLostPointerCapture: () => m(null),
|
|
582
|
-
...y.props(c.svg, d !== void 0 &&
|
|
621
|
+
...y.props(c.svg, d !== void 0 && W.brush),
|
|
583
622
|
children: [
|
|
584
623
|
/* @__PURE__ */ E("defs", { children: /* @__PURE__ */ E("clipPath", {
|
|
585
624
|
id: f,
|
|
586
625
|
children: /* @__PURE__ */ E("rect", {
|
|
587
|
-
x:
|
|
588
|
-
y:
|
|
589
|
-
width: Math.max(0, e -
|
|
626
|
+
x: z,
|
|
627
|
+
y: V,
|
|
628
|
+
width: Math.max(0, e - z - B),
|
|
590
629
|
height: 204
|
|
591
630
|
})
|
|
592
631
|
}) }),
|
|
593
632
|
t.ticks(5).map((e) => /* @__PURE__ */ D("g", { children: [/* @__PURE__ */ E("line", {
|
|
594
633
|
x1: t(e),
|
|
595
634
|
x2: t(e),
|
|
596
|
-
y1:
|
|
635
|
+
y1: V,
|
|
597
636
|
y2: 216,
|
|
598
637
|
...y.props(c.grid)
|
|
599
638
|
}), /* @__PURE__ */ E("text", {
|
|
@@ -604,8 +643,8 @@ function Y({ width: e, scaleX: t, scaleY: n, points: r, xLabel: i, yLabel: a, fo
|
|
|
604
643
|
children: o(e)
|
|
605
644
|
})] }, e)),
|
|
606
645
|
n.ticks(4).map((t) => /* @__PURE__ */ D("g", { children: [/* @__PURE__ */ E("line", {
|
|
607
|
-
x1:
|
|
608
|
-
x2: e -
|
|
646
|
+
x1: z,
|
|
647
|
+
x2: e - B,
|
|
609
648
|
y1: n(t),
|
|
610
649
|
y2: n(t),
|
|
611
650
|
...y.props(c.grid)
|
|
@@ -617,7 +656,7 @@ function Y({ width: e, scaleX: t, scaleY: n, points: r, xLabel: i, yLabel: a, fo
|
|
|
617
656
|
children: s(t)
|
|
618
657
|
})] }, t)),
|
|
619
658
|
/* @__PURE__ */ E("text", {
|
|
620
|
-
x: (
|
|
659
|
+
x: (z + e - B) / 2,
|
|
621
660
|
y: 256,
|
|
622
661
|
textAnchor: "middle",
|
|
623
662
|
...y.props(c.label),
|
|
@@ -649,7 +688,7 @@ function Y({ width: e, scaleX: t, scaleY: n, points: r, xLabel: i, yLabel: a, fo
|
|
|
649
688
|
]
|
|
650
689
|
});
|
|
651
690
|
}
|
|
652
|
-
function
|
|
691
|
+
function q({ rangeSelection: e, xDomain: t, yDomain: n, xLabel: r, yLabel: i, formatX: a, formatY: o }) {
|
|
653
692
|
let s = e.value ?? {
|
|
654
693
|
x: t,
|
|
655
694
|
y: n
|
|
@@ -734,9 +773,9 @@ function X({ rangeSelection: e, xDomain: t, yDomain: n, xLabel: r, yLabel: i, fo
|
|
|
734
773
|
]
|
|
735
774
|
});
|
|
736
775
|
}
|
|
737
|
-
function
|
|
776
|
+
function J({ points: e, xDomain: t, yDomain: n, rangeSelection: r }) {
|
|
738
777
|
if (!p(t) || !p(n)) return "Scatter domains must contain finite, increasing endpoints.";
|
|
739
|
-
if (e.length > 1e3) return `This plot exceeds the ${
|
|
778
|
+
if (e.length > 1e3) return `This plot exceeds the ${H}-point render limit. Supply a smaller, labelled sample.`;
|
|
740
779
|
if (!f(e)) return "Scatter points must have unique identifiers.";
|
|
741
780
|
if (e.some((e) => !Number.isFinite(e.x) || !Number.isFinite(e.y))) return "Scatter coordinates must be finite.";
|
|
742
781
|
if (e.some((e) => {
|
|
@@ -747,18 +786,18 @@ function Z({ points: e, xDomain: t, yDomain: n, rangeSelection: r }) {
|
|
|
747
786
|
let i = Number.isFinite(r.xStep) && r.xStep > 0 && r.xStep <= t[1] - t[0], a = Number.isFinite(r.yStep) && r.yStep > 0 && r.yStep <= n[1] - n[0];
|
|
748
787
|
if (!i || !a) return "Range selection steps must be finite, positive, and no larger than their domain span.";
|
|
749
788
|
let o = r.value;
|
|
750
|
-
return o === null ? null : !
|
|
789
|
+
return o === null ? null : !Y(o.x, t) || !Y(o.y, n) ? "The selected range must have finite, ordered bounds inside the declared domain." : null;
|
|
751
790
|
}
|
|
752
|
-
function
|
|
791
|
+
function Y(e, t) {
|
|
753
792
|
return !e.every(Number.isFinite) || e[0] > e[1] ? !1 : e[0] >= t[0] && e[1] <= t[1];
|
|
754
793
|
}
|
|
755
794
|
// packages/charts/src/cartesian/time-series-data.ts
|
|
756
|
-
var
|
|
795
|
+
var X = {
|
|
757
796
|
series: 12,
|
|
758
797
|
pointsPerSeries: 2e3,
|
|
759
798
|
markers: 200,
|
|
760
799
|
panels: 12
|
|
761
|
-
},
|
|
800
|
+
}, Z = .01, Q = [
|
|
762
801
|
"series1",
|
|
763
802
|
"series2",
|
|
764
803
|
"series3",
|
|
@@ -766,13 +805,13 @@ var $ = {
|
|
|
766
805
|
"series5",
|
|
767
806
|
"series6"
|
|
768
807
|
];
|
|
769
|
-
function
|
|
808
|
+
function pe({ series: e, isStacked: t, markers: n }) {
|
|
770
809
|
let r = e[0]?.points.map((e) => e.timestamp) ?? [];
|
|
771
|
-
if (e.length >
|
|
810
|
+
if (e.length > X.series || r.length > X.pointsPerSeries || n.length > X.markers) return `Choose a window with at most ${X.series} series, ${X.pointsPerSeries} observations per series, and ${X.markers} markers.`;
|
|
772
811
|
if (!f(e) || !f(n)) return "Series and markers require unique identifiers.";
|
|
773
812
|
for (let n of e) {
|
|
774
813
|
if (n.points.length !== r.length) return "Every series must supply the same observation timestamps.";
|
|
775
|
-
let e =
|
|
814
|
+
let e = ge({
|
|
776
815
|
points: n.points,
|
|
777
816
|
timestamps: r,
|
|
778
817
|
isStacked: t
|
|
@@ -790,7 +829,7 @@ function ue({ series: e, isStacked: t, markers: n }) {
|
|
|
790
829
|
if (!Number.isFinite(a) || !Number.isFinite(o)) return "The elapsed-time and value ranges must be finite.";
|
|
791
830
|
if (t && r.some((t, n) => !Number.isFinite(e.reduce((e, t) => e + (t.points[n]?.value ?? 0), 0)))) return "Stacked observation totals must be finite.";
|
|
792
831
|
}
|
|
793
|
-
function
|
|
832
|
+
function $({ series: e, markers: t, timestampUnit: n, isStacked: r }) {
|
|
794
833
|
return JSON.stringify([
|
|
795
834
|
n,
|
|
796
835
|
r,
|
|
@@ -810,15 +849,15 @@ function de({ series: e, markers: t, timestampUnit: n, isStacked: r }) {
|
|
|
810
849
|
])
|
|
811
850
|
]);
|
|
812
851
|
}
|
|
813
|
-
function
|
|
852
|
+
function me(e, t, n = !1) {
|
|
814
853
|
if (e !== t) return [e, t];
|
|
815
|
-
let r = Math.max(1, Math.abs(e) *
|
|
854
|
+
let r = Math.max(1, Math.abs(e) * Z), i = n ? 0 : e - r, a = t + r;
|
|
816
855
|
return [Number.isFinite(i) ? i : e, Number.isFinite(a) ? a : t];
|
|
817
856
|
}
|
|
818
|
-
function
|
|
857
|
+
function he(e, t) {
|
|
819
858
|
let n = e.filter((e) => e.tone === void 0);
|
|
820
859
|
return e.map((r, i) => {
|
|
821
|
-
let a = n.findIndex((e) => e.id === r.id), o = r.tone ??
|
|
860
|
+
let a = n.findIndex((e) => e.id === r.id), o = r.tone ?? Q[a % Q.length] ?? "series1", s = r.points.map((n, r) => {
|
|
822
861
|
let a = t ? e.slice(0, i).reduce((e, t) => e + (t.points[r]?.value ?? 0), 0) : 0;
|
|
823
862
|
return {
|
|
824
863
|
...n,
|
|
@@ -833,7 +872,7 @@ function pe(e, t) {
|
|
|
833
872
|
};
|
|
834
873
|
});
|
|
835
874
|
}
|
|
836
|
-
function
|
|
875
|
+
function ge({ points: e, timestamps: t, isStacked: n }) {
|
|
837
876
|
for (let [r, i] of e.entries()) {
|
|
838
877
|
let a = e[r - 1], o = a !== void 0 && i.timestamp <= a.timestamp;
|
|
839
878
|
if (!Number.isFinite(i.timestamp) || i.timestamp !== t[r] || o) return "Observation timestamps must be finite, aligned, and strictly increasing.";
|
|
@@ -842,7 +881,7 @@ function me({ points: e, timestamps: t, isStacked: n }) {
|
|
|
842
881
|
}
|
|
843
882
|
}
|
|
844
883
|
// packages/charts/src/cartesian/time-series-line.tsx
|
|
845
|
-
function
|
|
884
|
+
function _e({ series: e, x: t, y: n, inspectedTimestamp: r, pointRadius: i = 3 }) {
|
|
846
885
|
return /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(A, {
|
|
847
886
|
data: [...e.points],
|
|
848
887
|
defined: (e) => e.value !== null,
|
|
@@ -862,8 +901,8 @@ function he({ series: e, x: t, y: n, inspectedTimestamp: r, pointRadius: i = 3 }
|
|
|
862
901
|
}, r.timestamp))] });
|
|
863
902
|
}
|
|
864
903
|
// packages/charts/src/cartesian/sparkline.tsx
|
|
865
|
-
function
|
|
866
|
-
let o = x(), s = x(), c =
|
|
904
|
+
function ve({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueDomain: a }) {
|
|
905
|
+
let o = x(), s = x(), c = ye({
|
|
867
906
|
title: e,
|
|
868
907
|
summary: t,
|
|
869
908
|
unit: n,
|
|
@@ -878,12 +917,12 @@ function ge({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueD
|
|
|
878
917
|
children: c === void 0 ? "No data" : "Invalid trend"
|
|
879
918
|
});
|
|
880
919
|
let u = i.points[0]?.timestamp ?? 0, d = i.points.at(-1)?.timestamp ?? u, f = k({
|
|
881
|
-
domain: [...
|
|
920
|
+
domain: [...me(u, d)],
|
|
882
921
|
range: [3, 125]
|
|
883
922
|
}), p = k({
|
|
884
923
|
domain: [...a],
|
|
885
924
|
range: [29, 3]
|
|
886
|
-
}), m =
|
|
925
|
+
}), m = he([i], !1)[0];
|
|
887
926
|
return /* @__PURE__ */ D("svg", {
|
|
888
927
|
role: "img",
|
|
889
928
|
"aria-labelledby": o,
|
|
@@ -916,7 +955,7 @@ function ge({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueD
|
|
|
916
955
|
"."
|
|
917
956
|
]
|
|
918
957
|
}),
|
|
919
|
-
m !== void 0 && /* @__PURE__ */ E(
|
|
958
|
+
m !== void 0 && /* @__PURE__ */ E(_e, {
|
|
920
959
|
series: m,
|
|
921
960
|
x: f,
|
|
922
961
|
y: p,
|
|
@@ -925,10 +964,10 @@ function ge({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueD
|
|
|
925
964
|
]
|
|
926
965
|
});
|
|
927
966
|
}
|
|
928
|
-
function
|
|
967
|
+
function ye({ title: e, summary: t, unit: n, series: r, valueDomain: i }) {
|
|
929
968
|
if (e.trim() === "" || t.trim() === "" || n.trim() === "") return "A trend requires a title, a readable summary, and a value unit.";
|
|
930
969
|
if (!p(i)) return "The displayed value domain must have finite, increasing bounds.";
|
|
931
|
-
let a =
|
|
970
|
+
let a = pe({
|
|
932
971
|
series: [r],
|
|
933
972
|
isStacked: !1,
|
|
934
973
|
markers: []
|
|
@@ -937,16 +976,7 @@ function _e({ title: e, summary: t, unit: n, series: r, valueDomain: i }) {
|
|
|
937
976
|
if (r.points.some((e) => e.value !== null && (e.value < i[0] || e.value > i[1]))) return "Every recorded value must be inside the declared value domain.";
|
|
938
977
|
}
|
|
939
978
|
// packages/charts/src/cartesian/time-series.tsx
|
|
940
|
-
var
|
|
941
|
-
plot: {
|
|
942
|
-
k7Eaqz: "xeuugli",
|
|
943
|
-
k3XXqK: "x1t137rt",
|
|
944
|
-
kInvED: "x2ssjo2",
|
|
945
|
-
kZs9gx: "x19rmrnh",
|
|
946
|
-
k7shQP: "x9v5kkp",
|
|
947
|
-
kPJHz1: "x13qnu6",
|
|
948
|
-
$$css: !0
|
|
949
|
-
},
|
|
979
|
+
var be = {
|
|
950
980
|
timeAxis: {
|
|
951
981
|
k1xSpc: "x78zum5",
|
|
952
982
|
kjj79g: "x1qughib",
|
|
@@ -967,25 +997,25 @@ var ve = {
|
|
|
967
997
|
"--x-paddingInlineEnd": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
|
|
968
998
|
}]
|
|
969
999
|
};
|
|
970
|
-
function
|
|
971
|
-
return /* @__PURE__ */ E(
|
|
1000
|
+
function xe(e) {
|
|
1001
|
+
return /* @__PURE__ */ E(Te, {
|
|
972
1002
|
...e,
|
|
973
1003
|
kind: "line",
|
|
974
1004
|
isStacked: !1
|
|
975
1005
|
});
|
|
976
1006
|
}
|
|
977
|
-
function
|
|
978
|
-
return /* @__PURE__ */ E(
|
|
1007
|
+
function Se({ isStacked: e = !1, ...t }) {
|
|
1008
|
+
return /* @__PURE__ */ E(Te, {
|
|
979
1009
|
...t,
|
|
980
1010
|
kind: "area",
|
|
981
1011
|
isStacked: e
|
|
982
1012
|
});
|
|
983
1013
|
}
|
|
984
|
-
function
|
|
1014
|
+
function Ce({ charts: e, ...t }) {
|
|
985
1015
|
let n = C(null), [r, i] = w(), a = JSON.stringify(e.map((e) => [
|
|
986
1016
|
e.id,
|
|
987
1017
|
e.title,
|
|
988
|
-
|
|
1018
|
+
$({
|
|
989
1019
|
series: e.series,
|
|
990
1020
|
markers: e.markers ?? [],
|
|
991
1021
|
timestampUnit: t.timestampUnit,
|
|
@@ -1001,9 +1031,9 @@ function xe({ charts: e, ...t }) {
|
|
|
1001
1031
|
title: "Small multiples",
|
|
1002
1032
|
message: "Charts need unique identifiers and aligned observation timestamps."
|
|
1003
1033
|
});
|
|
1004
|
-
if (e.length >
|
|
1034
|
+
if (e.length > X.panels) return /* @__PURE__ */ E(m, {
|
|
1005
1035
|
title: "Small multiples",
|
|
1006
|
-
message: `Choose at most ${
|
|
1036
|
+
message: `Choose at most ${X.panels} panels.`
|
|
1007
1037
|
});
|
|
1008
1038
|
if (e.length === 0) return /* @__PURE__ */ E(l, {
|
|
1009
1039
|
title: "Small multiples",
|
|
@@ -1022,7 +1052,7 @@ function xe({ charts: e, ...t }) {
|
|
|
1022
1052
|
return /* @__PURE__ */ E("div", {
|
|
1023
1053
|
ref: n,
|
|
1024
1054
|
className: "xrvj5dj x1j825kq",
|
|
1025
|
-
children: e.map((e) => /* @__PURE__ */ E(
|
|
1055
|
+
children: e.map((e) => /* @__PURE__ */ E(Te, {
|
|
1026
1056
|
...t,
|
|
1027
1057
|
title: e.title,
|
|
1028
1058
|
description: e.description,
|
|
@@ -1036,30 +1066,34 @@ function xe({ charts: e, ...t }) {
|
|
|
1036
1066
|
}, e.id))
|
|
1037
1067
|
});
|
|
1038
1068
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1069
|
+
var we = {
|
|
1070
|
+
"x-default-marker": "x-default-marker",
|
|
1071
|
+
$$css: !0
|
|
1072
|
+
};
|
|
1073
|
+
function Te({ title: e, description: t, series: n, timestampUnit: r, formatTimestamp: i, formatValue: a, markers: s = [], height: f = 180, actions: p, kind: g, isStacked: _, sharedInspection: O, axisWidth: te }) {
|
|
1074
|
+
let A = !Number.isFinite(f) || f < 48 ? "Chart height must be at least 48 pixels." : pe({
|
|
1041
1075
|
series: n,
|
|
1042
1076
|
isStacked: _,
|
|
1043
1077
|
markers: s
|
|
1044
|
-
}), j = S(() => A === void 0 ?
|
|
1078
|
+
}), j = S(() => A === void 0 ? he(n, _) : [], [
|
|
1045
1079
|
n,
|
|
1046
1080
|
_,
|
|
1047
1081
|
A
|
|
1048
|
-
]), M = j[0]?.points ?? [], { ref:
|
|
1082
|
+
]), M = j[0]?.points ?? [], { ref: re, width: ie, element: ae } = h(), oe = C(null), [se, ce] = w(), le = M.find((e) => e.timestamp === se) ?? M[0], [N, ue] = w(), P = $({
|
|
1049
1083
|
series: n,
|
|
1050
1084
|
markers: s,
|
|
1051
1085
|
timestampUnit: r,
|
|
1052
1086
|
isStacked: _
|
|
1053
|
-
}),
|
|
1054
|
-
|
|
1055
|
-
let
|
|
1087
|
+
}), F = O === void 0 ? N?.signature === P ? N : void 0 : O.value, de = x();
|
|
1088
|
+
N !== void 0 && (N.signature !== P || A !== void 0) && ue(void 0);
|
|
1089
|
+
let fe = O !== void 0;
|
|
1056
1090
|
if (b(() => {
|
|
1057
|
-
if (
|
|
1091
|
+
if (fe) return;
|
|
1058
1092
|
function e(e) {
|
|
1059
|
-
e.target instanceof Node &&
|
|
1093
|
+
e.target instanceof Node && oe.current?.contains(e.target) !== !0 && ue(void 0);
|
|
1060
1094
|
}
|
|
1061
1095
|
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
1062
|
-
}, [
|
|
1096
|
+
}, [fe]), A !== void 0) return /* @__PURE__ */ E(m, {
|
|
1063
1097
|
title: e,
|
|
1064
1098
|
description: t,
|
|
1065
1099
|
message: A
|
|
@@ -1073,32 +1107,32 @@ function Se({ title: e, description: t, series: n, timestampUnit: r, formatTimes
|
|
|
1073
1107
|
children: "No observations"
|
|
1074
1108
|
})
|
|
1075
1109
|
});
|
|
1076
|
-
let
|
|
1077
|
-
domain: [...
|
|
1078
|
-
range: [
|
|
1079
|
-
}),
|
|
1080
|
-
domain: [...
|
|
1081
|
-
range: [
|
|
1110
|
+
let I = f - 28, L = I + 12, R = M[0]?.timestamp ?? 0, z = M.at(-1)?.timestamp ?? R, B = j.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value + e.base])), V = g === "area" ? Math.min(0, ...B) : Math.min(...B), H = g === "area" ? Math.max(0, ...B) : Math.max(...B), U = B.length === 0 ? 0 : V, W = B.length === 0 ? 1 : H, G = k({
|
|
1111
|
+
domain: [...me(U, W, g === "area")],
|
|
1112
|
+
range: [I, 12]
|
|
1113
|
+
}), K = G.ticks(3), q = te ?? Math.max(52, ...K.map((e) => a(e).length * 7 + 12)), J = Math.max(q + 1, ie - 16), Y = k({
|
|
1114
|
+
domain: [...me(R, z)],
|
|
1115
|
+
range: [q, J]
|
|
1082
1116
|
});
|
|
1083
|
-
function
|
|
1084
|
-
let t =
|
|
1117
|
+
function X(e) {
|
|
1118
|
+
let t = ae?.getBoundingClientRect();
|
|
1085
1119
|
if (t === void 0) return;
|
|
1086
|
-
let n =
|
|
1120
|
+
let n = Y.invert(e - t.left), r = M.find((e, t) => {
|
|
1087
1121
|
let r = M[t + 1];
|
|
1088
1122
|
return r === void 0 || n <= e.timestamp + (r.timestamp - e.timestamp) / 2;
|
|
1089
1123
|
});
|
|
1090
|
-
r !== void 0 &&
|
|
1091
|
-
signature:
|
|
1124
|
+
r !== void 0 && Z({
|
|
1125
|
+
signature: P,
|
|
1092
1126
|
timestamp: r.timestamp,
|
|
1093
1127
|
source: "pointer"
|
|
1094
1128
|
});
|
|
1095
1129
|
}
|
|
1096
|
-
function
|
|
1097
|
-
O === void 0 ?
|
|
1130
|
+
function Z(e) {
|
|
1131
|
+
O === void 0 ? ue(e) : O.onChange(e);
|
|
1098
1132
|
}
|
|
1099
|
-
function
|
|
1133
|
+
function Q(e) {
|
|
1100
1134
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
1101
|
-
let t = M.findIndex((e) => e.timestamp ===
|
|
1135
|
+
let t = M.findIndex((e) => e.timestamp === le?.timestamp), n = {
|
|
1102
1136
|
ArrowRight: Math.min(M.length - 1, t + 1),
|
|
1103
1137
|
ArrowLeft: Math.max(0, t - 1),
|
|
1104
1138
|
Home: 0,
|
|
@@ -1106,7 +1140,7 @@ function Se({ title: e, description: t, series: n, timestampUnit: r, formatTimes
|
|
|
1106
1140
|
};
|
|
1107
1141
|
switch (e.key) {
|
|
1108
1142
|
case "Escape":
|
|
1109
|
-
e.preventDefault(), e.stopPropagation(),
|
|
1143
|
+
e.preventDefault(), e.stopPropagation(), Z(void 0);
|
|
1110
1144
|
break;
|
|
1111
1145
|
case "ArrowRight":
|
|
1112
1146
|
case "ArrowLeft":
|
|
@@ -1114,17 +1148,17 @@ function Se({ title: e, description: t, series: n, timestampUnit: r, formatTimes
|
|
|
1114
1148
|
case "End": {
|
|
1115
1149
|
e.preventDefault();
|
|
1116
1150
|
let t = M[n[e.key]];
|
|
1117
|
-
t !== void 0 &&
|
|
1118
|
-
signature:
|
|
1151
|
+
t !== void 0 && (ce(t.timestamp), Z({
|
|
1152
|
+
signature: P,
|
|
1119
1153
|
timestamp: t.timestamp,
|
|
1120
1154
|
source: "keyboard"
|
|
1121
|
-
});
|
|
1155
|
+
}));
|
|
1122
1156
|
break;
|
|
1123
1157
|
}
|
|
1124
1158
|
}
|
|
1125
1159
|
}
|
|
1126
1160
|
return /* @__PURE__ */ E("div", {
|
|
1127
|
-
ref:
|
|
1161
|
+
ref: oe,
|
|
1128
1162
|
className: "xeuugli",
|
|
1129
1163
|
children: /* @__PURE__ */ D(l, {
|
|
1130
1164
|
title: e,
|
|
@@ -1139,31 +1173,41 @@ function Se({ title: e, description: t, series: n, timestampUnit: r, formatTimes
|
|
|
1139
1173
|
tone: n
|
|
1140
1174
|
})) }),
|
|
1141
1175
|
/* @__PURE__ */ D("div", {
|
|
1142
|
-
ref:
|
|
1176
|
+
ref: re,
|
|
1143
1177
|
...y.props(c.plot),
|
|
1144
1178
|
children: [/* @__PURE__ */ D("svg", {
|
|
1145
1179
|
role: "img",
|
|
1146
1180
|
"aria-label": `${e}. Use arrow keys to inspect observations.`,
|
|
1147
|
-
"aria-describedby":
|
|
1181
|
+
"aria-describedby": de,
|
|
1148
1182
|
tabIndex: 0,
|
|
1149
|
-
viewBox: `0 0 ${
|
|
1150
|
-
height:
|
|
1151
|
-
onKeyDown:
|
|
1183
|
+
viewBox: `0 0 ${ie} ${L}`,
|
|
1184
|
+
height: L,
|
|
1185
|
+
onKeyDown: Q,
|
|
1186
|
+
onFocus: (e) => {
|
|
1187
|
+
if (e.currentTarget.matches(":focus-visible")) {
|
|
1188
|
+
let e = F?.timestamp ?? R;
|
|
1189
|
+
ce(e), Z({
|
|
1190
|
+
signature: P,
|
|
1191
|
+
timestamp: e,
|
|
1192
|
+
source: "keyboard"
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
},
|
|
1152
1196
|
onPointerMove: (e) => {
|
|
1153
|
-
e.pointerType === "mouse" &&
|
|
1197
|
+
e.pointerType === "mouse" && X(e.clientX);
|
|
1154
1198
|
},
|
|
1155
|
-
onPointerDown: (e) =>
|
|
1156
|
-
...y.props(c.svg,
|
|
1199
|
+
onPointerDown: (e) => X(e.clientX),
|
|
1200
|
+
...y.props(c.svg, c.inspectable, we),
|
|
1157
1201
|
children: [
|
|
1158
|
-
|
|
1159
|
-
x1:
|
|
1160
|
-
x2:
|
|
1161
|
-
y1:
|
|
1162
|
-
y2:
|
|
1202
|
+
K.map((e) => /* @__PURE__ */ D("g", { children: [/* @__PURE__ */ E("line", {
|
|
1203
|
+
x1: q,
|
|
1204
|
+
x2: J,
|
|
1205
|
+
y1: G(e),
|
|
1206
|
+
y2: G(e),
|
|
1163
1207
|
...y.props(c.grid)
|
|
1164
1208
|
}), /* @__PURE__ */ E("text", {
|
|
1165
|
-
x:
|
|
1166
|
-
y:
|
|
1209
|
+
x: q - 8,
|
|
1210
|
+
y: G(e),
|
|
1167
1211
|
textAnchor: "end",
|
|
1168
1212
|
dominantBaseline: "middle",
|
|
1169
1213
|
...y.props(c.label),
|
|
@@ -1172,64 +1216,70 @@ function Se({ title: e, description: t, series: n, timestampUnit: r, formatTimes
|
|
|
1172
1216
|
j.map((e) => /* @__PURE__ */ D("g", { children: [g === "area" && /* @__PURE__ */ E(ee, {
|
|
1173
1217
|
data: [...e.points],
|
|
1174
1218
|
defined: (e) => e.value !== null,
|
|
1175
|
-
x: (e) =>
|
|
1176
|
-
y0: (e) =>
|
|
1177
|
-
y1: (e) =>
|
|
1178
|
-
yScale:
|
|
1219
|
+
x: (e) => Y(e.timestamp),
|
|
1220
|
+
y0: (e) => G(e.base),
|
|
1221
|
+
y1: (e) => G((e.value ?? 0) + e.base),
|
|
1222
|
+
yScale: G,
|
|
1179
1223
|
fill: u[e.tone],
|
|
1180
1224
|
fillOpacity: _ ? .65 : .15
|
|
1181
|
-
}), /* @__PURE__ */ E(
|
|
1225
|
+
}), /* @__PURE__ */ E(_e, {
|
|
1182
1226
|
series: e,
|
|
1183
|
-
x:
|
|
1184
|
-
y:
|
|
1185
|
-
inspectedTimestamp:
|
|
1227
|
+
x: Y,
|
|
1228
|
+
y: G,
|
|
1229
|
+
inspectedTimestamp: F?.timestamp
|
|
1186
1230
|
})] }, e.id)),
|
|
1187
1231
|
s.map((e) => /* @__PURE__ */ D("g", { children: [e.kind === "time" ? /* @__PURE__ */ E("line", {
|
|
1188
|
-
x1:
|
|
1189
|
-
x2:
|
|
1232
|
+
x1: Y(e.timestamp),
|
|
1233
|
+
x2: Y(e.timestamp),
|
|
1190
1234
|
y1: 12,
|
|
1191
|
-
y2:
|
|
1235
|
+
y2: I,
|
|
1192
1236
|
className: "xhq4mlf x1ntoi03 x13efnbd"
|
|
1193
1237
|
}) : /* @__PURE__ */ E("circle", {
|
|
1194
|
-
cx:
|
|
1195
|
-
cy:
|
|
1238
|
+
cx: Y(e.timestamp),
|
|
1239
|
+
cy: G(e.value + (j.find((t) => t.id === e.seriesId)?.points.find((t) => t.timestamp === e.timestamp)?.base ?? 0)),
|
|
1196
1240
|
r: 4,
|
|
1197
1241
|
fill: v.surface,
|
|
1198
1242
|
...y.props(c.selected)
|
|
1199
1243
|
}), /* @__PURE__ */ E("title", { children: e.kind === "point" ? `${e.label}: ${a(e.value)}` : e.label })] }, e.id)),
|
|
1200
|
-
|
|
1201
|
-
x1:
|
|
1202
|
-
x2:
|
|
1244
|
+
F !== void 0 && /* @__PURE__ */ E("line", {
|
|
1245
|
+
x1: Y(F.timestamp),
|
|
1246
|
+
x2: Y(F.timestamp),
|
|
1203
1247
|
y1: 12,
|
|
1204
|
-
y2:
|
|
1248
|
+
y2: I,
|
|
1205
1249
|
className: "xhq4mlf x1ntoi03 x13efnbd"
|
|
1250
|
+
}),
|
|
1251
|
+
le !== void 0 && /* @__PURE__ */ E(ne, {
|
|
1252
|
+
x: Y(le.timestamp),
|
|
1253
|
+
top: 12,
|
|
1254
|
+
bottom: I,
|
|
1255
|
+
width: Math.min(16, (J - q) / 2)
|
|
1206
1256
|
})
|
|
1207
1257
|
]
|
|
1208
1258
|
}), /* @__PURE__ */ D("div", {
|
|
1209
1259
|
"aria-hidden": !0,
|
|
1210
|
-
...y.props(
|
|
1260
|
+
...y.props(be.timeAxis, be.timeAxisInset(q, Math.max(0, ie - J))),
|
|
1211
1261
|
children: [/* @__PURE__ */ E("span", {
|
|
1212
1262
|
className: "x1cqoux5 xeuugli xj0a0fe",
|
|
1213
|
-
children: i(
|
|
1214
|
-
}),
|
|
1263
|
+
children: i(R)
|
|
1264
|
+
}), z !== R && /* @__PURE__ */ E("span", {
|
|
1215
1265
|
className: "x1cqoux5 xeuugli xj0a0fe xp4054r",
|
|
1216
|
-
children: i(
|
|
1266
|
+
children: i(z)
|
|
1217
1267
|
})]
|
|
1218
1268
|
})]
|
|
1219
1269
|
}),
|
|
1220
1270
|
/* @__PURE__ */ E("div", {
|
|
1221
|
-
id:
|
|
1222
|
-
"aria-live":
|
|
1271
|
+
id: de,
|
|
1272
|
+
"aria-live": F?.source === "keyboard" ? "polite" : "off",
|
|
1223
1273
|
className: "x78zum5 x1a02dak x1pha0wt x8zbtdt x1gkm1c7 xy8obcc xas2l8k x1mqbd49 xj0a0fe",
|
|
1224
|
-
children:
|
|
1274
|
+
children: F === void 0 ? /* @__PURE__ */ E("span", {
|
|
1225
1275
|
className: "x153jb6y",
|
|
1226
1276
|
children: "Point, tap, or use the arrow keys to inspect values."
|
|
1227
1277
|
}) : /* @__PURE__ */ D(T, { children: [
|
|
1228
|
-
/* @__PURE__ */ E("span", { children: i(
|
|
1278
|
+
/* @__PURE__ */ E("span", { children: i(F.timestamp) }),
|
|
1229
1279
|
/* @__PURE__ */ E("dl", {
|
|
1230
1280
|
className: "x78zum5 x1a02dak x8zbtdt x1gkm1c7 x1ghz6dp xeuugli",
|
|
1231
1281
|
children: j.map((e) => {
|
|
1232
|
-
let t = e.points.find((e) => e.timestamp ===
|
|
1282
|
+
let t = e.points.find((e) => e.timestamp === F.timestamp);
|
|
1233
1283
|
return /* @__PURE__ */ D("div", {
|
|
1234
1284
|
className: "x78zum5 x1a02dak xunmzkg x1ghz6dp xeuugli xss6m8b",
|
|
1235
1285
|
children: [/* @__PURE__ */ E("dt", { children: e.label }), /* @__PURE__ */ E("dd", {
|
|
@@ -1239,7 +1289,7 @@ function Se({ title: e, description: t, series: n, timestampUnit: r, formatTimes
|
|
|
1239
1289
|
}, e.id);
|
|
1240
1290
|
})
|
|
1241
1291
|
}),
|
|
1242
|
-
s.filter((e) => e.timestamp ===
|
|
1292
|
+
s.filter((e) => e.timestamp === F.timestamp).map((e) => /* @__PURE__ */ E("span", { children: e.label }, e.id))
|
|
1243
1293
|
] })
|
|
1244
1294
|
}),
|
|
1245
1295
|
s.length > 0 && /* @__PURE__ */ E("ul", {
|
|
@@ -1282,4 +1332,4 @@ function Se({ title: e, description: t, series: n, timestampUnit: r, formatTimes
|
|
|
1282
1332
|
})
|
|
1283
1333
|
});
|
|
1284
1334
|
}
|
|
1285
|
-
export {
|
|
1335
|
+
export { Se as AreaChart, F as BarChart, le as BarChartPlaceholder, L as BreakdownBar, xe as LineChart, H as MAX_SCATTER_POINTS, G as ScatterPlot, Ce as SmallMultiples, ve as Sparkline, X as timeSeriesLimits };
|