@cascivo/charts 0.2.0 → 0.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/LICENSE +21 -0
- package/dist/index.d.ts +152 -68
- package/dist/index.js +694 -561
- package/package.json +22 -20
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useSignal as e, useSignalEffect as t, useSignals as n } from "@cascivo/core";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { builtin as r, t as i } from "@cascivo/i18n";
|
|
4
|
+
import { useId as a, useRef as o } from "react";
|
|
5
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
6
|
//#region src/engine/scale.ts
|
|
7
7
|
function u(e, t) {
|
|
8
8
|
let [n, r] = e, [i, a] = t, o = r - n;
|
|
@@ -202,8 +202,30 @@ function C(e) {
|
|
|
202
202
|
}));
|
|
203
203
|
}
|
|
204
204
|
//#endregion
|
|
205
|
+
//#region src/engine/stacked.ts
|
|
206
|
+
function w(e) {
|
|
207
|
+
let t = [], n = /* @__PURE__ */ new Map();
|
|
208
|
+
for (let r of e) for (let e of r.segments) n.has(e.key) ? n.get(e.key) == null && e.color != null && n.set(e.key, e.color) : (t.push(e.key), n.set(e.key, e.color));
|
|
209
|
+
return {
|
|
210
|
+
series: t.map((t) => {
|
|
211
|
+
let r = n.get(t);
|
|
212
|
+
return {
|
|
213
|
+
id: t,
|
|
214
|
+
label: t,
|
|
215
|
+
...r != null && { color: r },
|
|
216
|
+
data: e.map((e) => ({
|
|
217
|
+
x: e.label,
|
|
218
|
+
y: e.segments.find((e) => e.key === t)?.value ?? 0
|
|
219
|
+
}))
|
|
220
|
+
};
|
|
221
|
+
}),
|
|
222
|
+
x: (e) => e.x,
|
|
223
|
+
y: (e) => e.y
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
205
227
|
//#region src/engine/nearest.ts
|
|
206
|
-
function
|
|
228
|
+
function T(e, t) {
|
|
207
229
|
if (e.length === 0) return -1;
|
|
208
230
|
if (e.length === 1) return 0;
|
|
209
231
|
let n = 0, r = e.length - 1;
|
|
@@ -215,11 +237,11 @@ function w(e, t) {
|
|
|
215
237
|
}
|
|
216
238
|
//#endregion
|
|
217
239
|
//#region src/engine/stats.ts
|
|
218
|
-
function
|
|
240
|
+
function E(e) {
|
|
219
241
|
let t = e.length, n = e[Math.floor(t * .25)] ?? 0;
|
|
220
242
|
return (e[Math.floor(t * .75)] ?? 0) - n;
|
|
221
243
|
}
|
|
222
|
-
function
|
|
244
|
+
function D(e, t) {
|
|
223
245
|
if (e.length === 0) return [];
|
|
224
246
|
let n = [...e].sort((e, t) => e - t), r = n.length, i = n[0] ?? 0, a = n[r - 1] ?? 0;
|
|
225
247
|
if (i === a) return [{
|
|
@@ -230,7 +252,7 @@ function E(e, t) {
|
|
|
230
252
|
let o;
|
|
231
253
|
if (t !== void 0 && t > 0) o = t;
|
|
232
254
|
else {
|
|
233
|
-
let e = 2 *
|
|
255
|
+
let e = 2 * E(n) * r ** (-1 / 3);
|
|
234
256
|
o = Math.ceil(e > 0 ? (a - i) / e : Math.sqrt(r)), o = Math.max(1, Math.min(o, 200));
|
|
235
257
|
}
|
|
236
258
|
let s = (a - i) / o, c = Array.from({ length: o }, (e, t) => ({
|
|
@@ -244,7 +266,7 @@ function E(e, t) {
|
|
|
244
266
|
}
|
|
245
267
|
return c;
|
|
246
268
|
}
|
|
247
|
-
function
|
|
269
|
+
function O(e) {
|
|
248
270
|
if (e.length === 0) return {
|
|
249
271
|
min: 0,
|
|
250
272
|
q1: 0,
|
|
@@ -266,7 +288,7 @@ function D(e) {
|
|
|
266
288
|
outliers: d
|
|
267
289
|
};
|
|
268
290
|
}
|
|
269
|
-
function
|
|
291
|
+
function k(e) {
|
|
270
292
|
if (e.length === 0) return [0, 1];
|
|
271
293
|
let t = e[0] ?? 0, n = e[0] ?? 0;
|
|
272
294
|
for (let r of e) r < t && (t = r), r > n && (n = r);
|
|
@@ -274,11 +296,11 @@ function O(e) {
|
|
|
274
296
|
}
|
|
275
297
|
//#endregion
|
|
276
298
|
//#region src/engine/treemap.ts
|
|
277
|
-
function
|
|
299
|
+
function A(e, t, n) {
|
|
278
300
|
let r = Math.max(...e), i = Math.min(...e);
|
|
279
301
|
return Math.max(t * t * r / (n * n), n * n / (t * t * i));
|
|
280
302
|
}
|
|
281
|
-
function
|
|
303
|
+
function j(e, t, n, r, i, a, o) {
|
|
282
304
|
let s = e.reduce((e, t) => e + t, 0), c = t, l = n;
|
|
283
305
|
for (let t = 0; t < e.length; t++) {
|
|
284
306
|
let n = e[t] ?? 0, u = a[t] ?? "";
|
|
@@ -303,85 +325,85 @@ function A(e, t, n, r, i, a, o) {
|
|
|
303
325
|
}
|
|
304
326
|
}
|
|
305
327
|
}
|
|
306
|
-
function
|
|
328
|
+
function M(e, t, n, r, i, a) {
|
|
307
329
|
if (e.length === 0 || r <= 0 || i <= 0) return;
|
|
308
330
|
let o = e.reduce((e, t) => e + t.value, 0);
|
|
309
331
|
if (o === 0) return;
|
|
310
332
|
let s = r * i, c = e.map((e) => e.value / o * s), l = e.map((e) => e.id), u = [], d = [], f = Math.min(r, i), p = 0, m = 0;
|
|
311
333
|
for (; m < c.length;) {
|
|
312
334
|
let o = c[m] ?? 0, h = l[m] ?? "", g = [...u, o], _ = p + o;
|
|
313
|
-
if (u.length === 0 ||
|
|
335
|
+
if (u.length === 0 || A(g, f, _) <= A(u, f, p)) u = g, d = [...d, h], p = _, m++;
|
|
314
336
|
else {
|
|
315
337
|
let o = p / s;
|
|
316
338
|
if (r >= i) {
|
|
317
339
|
let s = o * r;
|
|
318
|
-
|
|
340
|
+
j(u, t, n, s, i, d, a), M(e.slice(m), t + s, n, r - s, i, a);
|
|
319
341
|
} else {
|
|
320
342
|
let s = o * i;
|
|
321
|
-
|
|
343
|
+
j(u, t, n, r, s, d, a), M(e.slice(m), t, n + s, r, i - s, a);
|
|
322
344
|
}
|
|
323
345
|
return;
|
|
324
346
|
}
|
|
325
347
|
}
|
|
326
348
|
if (u.length > 0) {
|
|
327
349
|
let e = p / s;
|
|
328
|
-
r >= i ?
|
|
350
|
+
r >= i ? j(u, t, n, e * r, i, d, a) : j(u, t, n, r, e * i, d, a);
|
|
329
351
|
}
|
|
330
352
|
}
|
|
331
|
-
function
|
|
353
|
+
function N(e, t, n) {
|
|
332
354
|
if (e.length === 0 || t <= 0 || n <= 0) return [];
|
|
333
355
|
let r = [...e].sort((e, t) => t.value - e.value), i = [];
|
|
334
|
-
return
|
|
356
|
+
return M(r, 0, 0, t, n, i), i;
|
|
335
357
|
}
|
|
336
358
|
//#endregion
|
|
337
359
|
//#region src/core/use-chart.ts
|
|
338
|
-
function
|
|
339
|
-
let
|
|
360
|
+
function P(n = 400, r = 300) {
|
|
361
|
+
let i = o(null), a = e(n), s = e(r);
|
|
340
362
|
return t(() => {
|
|
341
|
-
let e =
|
|
363
|
+
let e = i.current;
|
|
342
364
|
if (!e) return;
|
|
343
365
|
if (typeof ResizeObserver > "u") {
|
|
344
366
|
let t = e.getBoundingClientRect();
|
|
345
|
-
t.width > 0 && (
|
|
367
|
+
t.width > 0 && (a.value = t.width), t.height > 0 && (s.value = t.height);
|
|
346
368
|
return;
|
|
347
369
|
}
|
|
348
370
|
let t = new ResizeObserver((e) => {
|
|
349
371
|
for (let t of e) {
|
|
350
372
|
let { contentRect: e } = t;
|
|
351
|
-
e.width > 0 && (
|
|
373
|
+
e.width > 0 && (a.value = e.width), e.height > 0 && (s.value = e.height);
|
|
352
374
|
}
|
|
353
375
|
});
|
|
354
376
|
return t.observe(e), () => t.disconnect();
|
|
355
377
|
}), {
|
|
356
|
-
ref:
|
|
357
|
-
width:
|
|
378
|
+
ref: i,
|
|
379
|
+
width: a,
|
|
358
380
|
height: s
|
|
359
381
|
};
|
|
360
382
|
}
|
|
361
|
-
var
|
|
383
|
+
var F = {
|
|
362
384
|
top: 8,
|
|
363
385
|
right: 8,
|
|
364
386
|
bottom: 24,
|
|
365
387
|
left: 36
|
|
366
|
-
},
|
|
388
|
+
}, I = {
|
|
367
389
|
top: 2,
|
|
368
390
|
right: 2,
|
|
369
391
|
bottom: 2,
|
|
370
392
|
left: 2
|
|
371
|
-
},
|
|
393
|
+
}, L = {
|
|
372
394
|
frame: "_frame_1aivh_2",
|
|
373
395
|
fallback: "_fallback_1aivh_7"
|
|
374
396
|
};
|
|
375
397
|
//#endregion
|
|
376
398
|
//#region src/core/data-point.ts
|
|
377
|
-
function
|
|
399
|
+
function R(e) {
|
|
378
400
|
return `${e.label}: ${e.value}`;
|
|
379
401
|
}
|
|
380
402
|
//#endregion
|
|
381
403
|
//#region src/core/chart-tooltip.tsx
|
|
382
404
|
function ee({ point: e, model: t }) {
|
|
383
|
-
let n = t.format ? t.format(e) :
|
|
384
|
-
return /* @__PURE__ */
|
|
405
|
+
let n = t.format ? t.format(e) : R(e), r = e.segments?.filter((e) => e.value !== 0);
|
|
406
|
+
return /* @__PURE__ */ c("div", {
|
|
385
407
|
role: "tooltip",
|
|
386
408
|
style: {
|
|
387
409
|
position: "absolute",
|
|
@@ -398,7 +420,32 @@ function ee({ point: e, model: t }) {
|
|
|
398
420
|
boxShadow: "var(--cascivo-shadow-sm, 0 1px 4px rgba(0,0,0,0.1))",
|
|
399
421
|
zIndex: 10
|
|
400
422
|
},
|
|
401
|
-
children:
|
|
423
|
+
children: r && r.length > 0 ? /* @__PURE__ */ l("span", {
|
|
424
|
+
style: {
|
|
425
|
+
display: "flex",
|
|
426
|
+
flexDirection: "column",
|
|
427
|
+
gap: "2px"
|
|
428
|
+
},
|
|
429
|
+
children: [/* @__PURE__ */ l("span", {
|
|
430
|
+
style: { fontWeight: 600 },
|
|
431
|
+
"data-tooltip-header": "",
|
|
432
|
+
children: [
|
|
433
|
+
e.label,
|
|
434
|
+
" · ",
|
|
435
|
+
e.value
|
|
436
|
+
]
|
|
437
|
+
}), r.map((e) => /* @__PURE__ */ l("span", {
|
|
438
|
+
style: e.color ? { color: e.color } : void 0,
|
|
439
|
+
children: [
|
|
440
|
+
e.label,
|
|
441
|
+
": ",
|
|
442
|
+
e.value
|
|
443
|
+
]
|
|
444
|
+
}, e.label))]
|
|
445
|
+
}) : /* @__PURE__ */ c("span", {
|
|
446
|
+
style: e.color ? { color: e.color } : void 0,
|
|
447
|
+
children: n
|
|
448
|
+
})
|
|
402
449
|
});
|
|
403
450
|
}
|
|
404
451
|
//#endregion
|
|
@@ -414,54 +461,67 @@ function te(e, t, n, r = "xy") {
|
|
|
414
461
|
}
|
|
415
462
|
//#endregion
|
|
416
463
|
//#region src/core/chart-frame.tsx
|
|
417
|
-
function
|
|
464
|
+
function z({ title: u, description: d, width: f, height: p = 300, fallback: m, children: h, className: g, "data-state": _, emptyLabel: v, plain: y, tooltip: b }) {
|
|
418
465
|
n();
|
|
419
|
-
let
|
|
420
|
-
width:
|
|
421
|
-
height:
|
|
422
|
-
}) :
|
|
466
|
+
let x = a(), S = `${x}-desc`, C = `${x}-live`, { ref: w, width: T, height: E } = P(f ?? 400, p), D = e(null), O = o(null), k = f ?? T.value, A = p ?? E.value, j = typeof b == "function" ? b({
|
|
467
|
+
width: k,
|
|
468
|
+
height: A
|
|
469
|
+
}) : b;
|
|
423
470
|
t(() => {
|
|
424
|
-
let e =
|
|
425
|
-
if (!
|
|
426
|
-
let t = e === null ? void 0 :
|
|
427
|
-
|
|
471
|
+
let e = D.value;
|
|
472
|
+
if (!j || !O.current) return;
|
|
473
|
+
let t = e === null ? void 0 : j.points[e];
|
|
474
|
+
O.current.textContent = t ? (j.format ?? R)(t) : "";
|
|
428
475
|
});
|
|
429
|
-
let
|
|
476
|
+
let M = {
|
|
430
477
|
position: "absolute",
|
|
431
478
|
inset: 0,
|
|
432
479
|
cursor: "crosshair",
|
|
433
480
|
background: "transparent"
|
|
434
|
-
},
|
|
435
|
-
return /* @__PURE__ */
|
|
436
|
-
ref:
|
|
437
|
-
className: [
|
|
438
|
-
style:
|
|
439
|
-
...
|
|
440
|
-
...
|
|
481
|
+
}, N = j === void 0 ? void 0 : { position: "relative" };
|
|
482
|
+
return /* @__PURE__ */ l("div", {
|
|
483
|
+
ref: w,
|
|
484
|
+
className: [L.frame, g].filter(Boolean).join(" "),
|
|
485
|
+
style: N,
|
|
486
|
+
..._ !== void 0 && { "data-state": _ },
|
|
487
|
+
...y === !0 && { "data-plain": "" },
|
|
441
488
|
children: [
|
|
442
|
-
/* @__PURE__ */
|
|
489
|
+
/* @__PURE__ */ l("svg", {
|
|
443
490
|
role: "img",
|
|
444
|
-
"aria-label":
|
|
445
|
-
"aria-describedby":
|
|
446
|
-
width:
|
|
447
|
-
height:
|
|
448
|
-
viewBox: `0 0 ${
|
|
449
|
-
children: [
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
491
|
+
"aria-label": u,
|
|
492
|
+
"aria-describedby": d ? S : void 0,
|
|
493
|
+
width: k,
|
|
494
|
+
height: A,
|
|
495
|
+
viewBox: `0 0 ${k} ${A}`,
|
|
496
|
+
children: [
|
|
497
|
+
d && /* @__PURE__ */ c("desc", {
|
|
498
|
+
id: S,
|
|
499
|
+
children: d
|
|
500
|
+
}),
|
|
501
|
+
h({
|
|
502
|
+
width: k,
|
|
503
|
+
height: A
|
|
504
|
+
}),
|
|
505
|
+
_ === "empty" && /* @__PURE__ */ c("text", {
|
|
506
|
+
x: k / 2,
|
|
507
|
+
y: A / 2,
|
|
508
|
+
textAnchor: "middle",
|
|
509
|
+
dominantBaseline: "central",
|
|
510
|
+
fill: "var(--cascivo-color-foreground-muted)",
|
|
511
|
+
fontSize: "0.875rem",
|
|
512
|
+
"data-empty": "",
|
|
513
|
+
children: v ?? i(r.charts.noData)
|
|
514
|
+
})
|
|
515
|
+
]
|
|
456
516
|
}),
|
|
457
|
-
|
|
458
|
-
className:
|
|
459
|
-
children:
|
|
517
|
+
m && /* @__PURE__ */ c("div", {
|
|
518
|
+
className: L.fallback,
|
|
519
|
+
children: m
|
|
460
520
|
}),
|
|
461
|
-
|
|
462
|
-
/* @__PURE__ */
|
|
463
|
-
id:
|
|
464
|
-
ref:
|
|
521
|
+
j !== void 0 && /* @__PURE__ */ l(s, { children: [
|
|
522
|
+
/* @__PURE__ */ c("span", {
|
|
523
|
+
id: C,
|
|
524
|
+
ref: O,
|
|
465
525
|
"aria-live": "polite",
|
|
466
526
|
style: {
|
|
467
527
|
position: "absolute",
|
|
@@ -475,9 +535,9 @@ function R({ title: c, description: l, width: u, height: d = 300, fallback: f, c
|
|
|
475
535
|
border: 0
|
|
476
536
|
}
|
|
477
537
|
}),
|
|
478
|
-
|
|
479
|
-
let e =
|
|
480
|
-
return /* @__PURE__ */
|
|
538
|
+
D.value !== null && j.points[D.value] !== void 0 && (() => {
|
|
539
|
+
let e = j.points[D.value];
|
|
540
|
+
return /* @__PURE__ */ c("div", {
|
|
481
541
|
"aria-hidden": "true",
|
|
482
542
|
style: {
|
|
483
543
|
position: "absolute",
|
|
@@ -493,33 +553,33 @@ function R({ title: c, description: l, width: u, height: d = 300, fallback: f, c
|
|
|
493
553
|
}
|
|
494
554
|
});
|
|
495
555
|
})(),
|
|
496
|
-
|
|
497
|
-
point:
|
|
498
|
-
model:
|
|
556
|
+
D.value !== null && j.points[D.value] !== void 0 && /* @__PURE__ */ c(ee, {
|
|
557
|
+
point: j.points[D.value],
|
|
558
|
+
model: j
|
|
499
559
|
}),
|
|
500
|
-
/* @__PURE__ */
|
|
560
|
+
/* @__PURE__ */ c("div", {
|
|
501
561
|
role: "application",
|
|
502
562
|
"aria-label": "Chart data — use arrow keys to navigate points",
|
|
503
563
|
tabIndex: 0,
|
|
504
|
-
style:
|
|
564
|
+
style: M,
|
|
505
565
|
onPointerMove: (e) => {
|
|
506
|
-
if (!
|
|
566
|
+
if (!j.points.length) return;
|
|
507
567
|
let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
|
|
508
|
-
|
|
568
|
+
D.value = te(j.points, n, r, "xy");
|
|
509
569
|
},
|
|
510
570
|
onPointerLeave: () => {
|
|
511
|
-
|
|
571
|
+
D.value = null;
|
|
512
572
|
},
|
|
513
573
|
onKeyDown: (e) => {
|
|
514
|
-
if (!
|
|
515
|
-
let t =
|
|
516
|
-
e.key === "ArrowRight" || e.key === "ArrowDown" ? (e.preventDefault(),
|
|
574
|
+
if (!j.points.length) return;
|
|
575
|
+
let t = D.value;
|
|
576
|
+
e.key === "ArrowRight" || e.key === "ArrowDown" ? (e.preventDefault(), D.value = t === null ? 0 : Math.min(t + 1, j.points.length - 1)) : e.key === "ArrowLeft" || e.key === "ArrowUp" ? (e.preventDefault(), D.value = t === null ? j.points.length - 1 : Math.max(t - 1, 0)) : e.key === "Home" ? (e.preventDefault(), D.value = 0) : e.key === "End" ? (e.preventDefault(), D.value = j.points.length - 1) : e.key === "Escape" && (D.value = null);
|
|
517
577
|
},
|
|
518
578
|
onFocus: () => {
|
|
519
|
-
|
|
579
|
+
j.points.length > 0 && D.value === null && (D.value = 0);
|
|
520
580
|
},
|
|
521
581
|
onBlur: () => {
|
|
522
|
-
|
|
582
|
+
D.value = null;
|
|
523
583
|
}
|
|
524
584
|
})
|
|
525
585
|
] })
|
|
@@ -537,47 +597,50 @@ function re(e) {
|
|
|
537
597
|
function ie(e) {
|
|
538
598
|
return e instanceof Date ? e.toLocaleDateString() : typeof e == "number" ? e.toLocaleString() : String(e);
|
|
539
599
|
}
|
|
540
|
-
function
|
|
541
|
-
let
|
|
542
|
-
if (ne(e))
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
600
|
+
function B({ scale: e, orientation: t, length: n, format: r = ie, tickCount: i = 5, labelEvery: a, transform: o }) {
|
|
601
|
+
let s;
|
|
602
|
+
if (ne(e)) {
|
|
603
|
+
let t = e.domain.length - 1;
|
|
604
|
+
s = e.domain.map((t, n) => ({
|
|
605
|
+
position: (e.map(t) ?? 0) + e.bandwidth / 2,
|
|
606
|
+
label: r(t),
|
|
607
|
+
i: n
|
|
608
|
+
})).filter(({ i: e }) => a != null && a > 1 ? e % a === 0 || e === t : !0);
|
|
609
|
+
} else if (re(e)) s = e.ticks(i).map((t) => ({
|
|
547
610
|
position: e.map(t),
|
|
548
611
|
label: r(t)
|
|
549
612
|
}));
|
|
550
613
|
else {
|
|
551
614
|
let t = e;
|
|
552
|
-
|
|
615
|
+
s = t.ticks(i).map((e) => ({
|
|
553
616
|
position: t.map(e),
|
|
554
617
|
label: r(e)
|
|
555
618
|
}));
|
|
556
619
|
}
|
|
557
|
-
let
|
|
558
|
-
return /* @__PURE__ */
|
|
559
|
-
transform:
|
|
620
|
+
let u = t === "x";
|
|
621
|
+
return /* @__PURE__ */ l("g", {
|
|
622
|
+
transform: o,
|
|
560
623
|
"aria-hidden": "true",
|
|
561
|
-
children: [/* @__PURE__ */
|
|
624
|
+
children: [/* @__PURE__ */ c("line", {
|
|
562
625
|
x1: 0,
|
|
563
626
|
y1: 0,
|
|
564
|
-
x2:
|
|
565
|
-
y2:
|
|
627
|
+
x2: u ? n : 0,
|
|
628
|
+
y2: u ? 0 : n,
|
|
566
629
|
stroke: "var(--cascivo-chart-axis)",
|
|
567
630
|
strokeWidth: 1
|
|
568
|
-
}),
|
|
569
|
-
transform:
|
|
570
|
-
children: [/* @__PURE__ */
|
|
631
|
+
}), s.map(({ position: e, label: t }, n) => /* @__PURE__ */ l("g", {
|
|
632
|
+
transform: u ? `translate(${e},0)` : `translate(0,${e})`,
|
|
633
|
+
children: [/* @__PURE__ */ c("line", {
|
|
571
634
|
x1: 0,
|
|
572
635
|
y1: 0,
|
|
573
|
-
x2:
|
|
574
|
-
y2:
|
|
636
|
+
x2: u ? 0 : -4,
|
|
637
|
+
y2: u ? 4 : 0,
|
|
575
638
|
stroke: "var(--cascivo-chart-axis)",
|
|
576
639
|
strokeWidth: 1
|
|
577
|
-
}), /* @__PURE__ */
|
|
578
|
-
x:
|
|
579
|
-
y:
|
|
580
|
-
textAnchor:
|
|
640
|
+
}), /* @__PURE__ */ c("text", {
|
|
641
|
+
x: u ? 0 : -8,
|
|
642
|
+
y: u ? 16 : 4,
|
|
643
|
+
textAnchor: u ? "middle" : "end",
|
|
581
644
|
fill: "var(--cascivo-chart-axis)",
|
|
582
645
|
fontSize: 11,
|
|
583
646
|
children: t
|
|
@@ -587,18 +650,18 @@ function z({ scale: e, orientation: t, length: n, format: r = ie, tickCount: i =
|
|
|
587
650
|
}
|
|
588
651
|
//#endregion
|
|
589
652
|
//#region src/chrome/grid-lines.tsx
|
|
590
|
-
function
|
|
591
|
-
let a = e.ticks(r),
|
|
592
|
-
return /* @__PURE__ */
|
|
653
|
+
function V({ scale: e, orientation: t, length: n, tickCount: r = 5, transform: i }) {
|
|
654
|
+
let a = e.ticks(r), o = t === "x";
|
|
655
|
+
return /* @__PURE__ */ c("g", {
|
|
593
656
|
transform: i,
|
|
594
657
|
"aria-hidden": "true",
|
|
595
658
|
children: a.map((t) => {
|
|
596
659
|
let r = e.map(t);
|
|
597
|
-
return /* @__PURE__ */
|
|
598
|
-
x1:
|
|
599
|
-
y1:
|
|
600
|
-
x2:
|
|
601
|
-
y2:
|
|
660
|
+
return /* @__PURE__ */ c("line", {
|
|
661
|
+
x1: o ? r : 0,
|
|
662
|
+
y1: o ? 0 : r,
|
|
663
|
+
x2: o ? r : n,
|
|
664
|
+
y2: o ? n : r,
|
|
602
665
|
stroke: "var(--cascivo-chart-grid)",
|
|
603
666
|
strokeWidth: 1,
|
|
604
667
|
strokeDasharray: "2 4"
|
|
@@ -606,31 +669,31 @@ function B({ scale: e, orientation: t, length: n, tickCount: r = 5, transform: i
|
|
|
606
669
|
})
|
|
607
670
|
});
|
|
608
671
|
}
|
|
609
|
-
var
|
|
672
|
+
var H = {
|
|
610
673
|
legend: "_legend_zczeh_2",
|
|
611
674
|
item: "_item_zczeh_9",
|
|
612
675
|
swatch: "_swatch_zczeh_27"
|
|
613
676
|
};
|
|
614
677
|
//#endregion
|
|
615
678
|
//#region src/chrome/legend.tsx
|
|
616
|
-
function
|
|
617
|
-
return n(), /* @__PURE__ */
|
|
618
|
-
className:
|
|
679
|
+
function U({ series: e, hidden: t }) {
|
|
680
|
+
return n(), /* @__PURE__ */ c("div", {
|
|
681
|
+
className: H.legend,
|
|
619
682
|
"aria-label": "Chart legend",
|
|
620
683
|
children: e.map((e, n) => {
|
|
621
|
-
let
|
|
622
|
-
return /* @__PURE__ */
|
|
684
|
+
let a = t.value.has(e.id);
|
|
685
|
+
return /* @__PURE__ */ l("button", {
|
|
623
686
|
type: "button",
|
|
624
|
-
className:
|
|
625
|
-
"data-state":
|
|
626
|
-
"aria-pressed": !
|
|
627
|
-
"aria-label":
|
|
687
|
+
className: H.item,
|
|
688
|
+
"data-state": a ? "off" : "on",
|
|
689
|
+
"aria-pressed": !a,
|
|
690
|
+
"aria-label": i(r.charts.legendToggle, { name: e.label }),
|
|
628
691
|
onClick: () => {
|
|
629
692
|
let n = new Set(t.value);
|
|
630
|
-
|
|
693
|
+
a ? n.delete(e.id) : n.add(e.id), t.value = n;
|
|
631
694
|
},
|
|
632
|
-
children: [/* @__PURE__ */
|
|
633
|
-
className:
|
|
695
|
+
children: [/* @__PURE__ */ c("span", {
|
|
696
|
+
className: H.swatch,
|
|
634
697
|
style: { background: e.color || `var(--cascivo-chart-${n + 1})` },
|
|
635
698
|
"aria-hidden": "true"
|
|
636
699
|
}), e.label]
|
|
@@ -640,25 +703,25 @@ function H({ series: e, hidden: t }) {
|
|
|
640
703
|
}
|
|
641
704
|
//#endregion
|
|
642
705
|
//#region src/charts/line-chart/line-chart.tsx
|
|
643
|
-
var
|
|
644
|
-
function ae({ series: t, x: r, y: i, title:
|
|
706
|
+
var W = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
707
|
+
function ae({ series: t, x: r, y: i, title: a, description: o, curve: d = "monotone", width: f, height: p, xTicks: m = 5, yTicks: h = 5, legend: g, tooltip: _, formatTooltip: b, className: x, plain: S }) {
|
|
645
708
|
n();
|
|
646
|
-
let C = e(/* @__PURE__ */ new Set()), w = S ?
|
|
647
|
-
return /* @__PURE__ */
|
|
709
|
+
let C = e(/* @__PURE__ */ new Set()), w = S ? I : F, T = p ?? (S ? 48 : 300), E = S ? !1 : g ?? t.length > 1, D = t.flatMap((e) => e.data.map((e) => r(e))), O = t.flatMap((e) => e.data.map((e) => i(e))), k = D.length > 0, A = k && D[0] instanceof Date;
|
|
710
|
+
return /* @__PURE__ */ l("div", {
|
|
648
711
|
style: {
|
|
649
712
|
display: "flex",
|
|
650
713
|
flexDirection: "column",
|
|
651
714
|
gap: "0.5rem"
|
|
652
715
|
},
|
|
653
|
-
children: [/* @__PURE__ */
|
|
654
|
-
title:
|
|
655
|
-
description:
|
|
716
|
+
children: [/* @__PURE__ */ c(z, {
|
|
717
|
+
title: a,
|
|
718
|
+
description: o,
|
|
656
719
|
width: f,
|
|
657
720
|
height: T,
|
|
658
|
-
fallback: /* @__PURE__ */
|
|
659
|
-
/* @__PURE__ */
|
|
660
|
-
/* @__PURE__ */
|
|
661
|
-
/* @__PURE__ */
|
|
721
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
722
|
+
/* @__PURE__ */ c("caption", { children: a }),
|
|
723
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("th", { children: "X" }), t.map((e) => /* @__PURE__ */ c("th", { children: e.label }, e.id))] }) }),
|
|
724
|
+
/* @__PURE__ */ c("tbody", { children: (t[0]?.data ?? []).map((e, n) => /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: String(t[0] ? r(t[0].data[n]) : "") }), t.map((e) => /* @__PURE__ */ c("td", { children: e.data[n] == null ? "" : i(e.data[n]) }, e.id))] }, n)) })
|
|
662
725
|
] }),
|
|
663
726
|
className: x,
|
|
664
727
|
"data-state": k ? void 0 : "empty",
|
|
@@ -685,14 +748,14 @@ function ae({ series: t, x: r, y: i, title: c, description: l, curve: d = "monot
|
|
|
685
748
|
} : { points: m };
|
|
686
749
|
} : void 0,
|
|
687
750
|
children: ({ width: e, height: n }) => {
|
|
688
|
-
let
|
|
689
|
-
return /* @__PURE__ */
|
|
751
|
+
let a = e - w.left - w.right, o = n - w.top - w.bottom, f = Math.min(...A ? D.map((e) => e.getTime()) : D), p = Math.max(...A ? D.map((e) => e.getTime()) : D), g = Math.min(0, ...O), _ = Math.max(...O), b = A ? v([new Date(f), new Date(p)], [0, a]) : u([f, p], [0, a]), x = u([g, _], [o, 0]);
|
|
752
|
+
return /* @__PURE__ */ c("g", { children: /* @__PURE__ */ l("g", {
|
|
690
753
|
transform: `translate(${w.left},${w.top})`,
|
|
691
754
|
children: [
|
|
692
|
-
!S && /* @__PURE__ */
|
|
755
|
+
!S && /* @__PURE__ */ c(V, {
|
|
693
756
|
scale: x,
|
|
694
757
|
orientation: "y",
|
|
695
|
-
length:
|
|
758
|
+
length: a,
|
|
696
759
|
tickCount: h
|
|
697
760
|
}),
|
|
698
761
|
t.map((e, t) => {
|
|
@@ -700,8 +763,8 @@ function ae({ series: t, x: r, y: i, title: c, description: l, curve: d = "monot
|
|
|
700
763
|
let n = e.data.map((e) => {
|
|
701
764
|
let t = r(e);
|
|
702
765
|
return [b.map(t), x.map(i(e))];
|
|
703
|
-
}), a = e.color ??
|
|
704
|
-
return /* @__PURE__ */
|
|
766
|
+
}), a = e.color ?? W[t % W.length];
|
|
767
|
+
return /* @__PURE__ */ c("path", {
|
|
705
768
|
d: y(n, d),
|
|
706
769
|
fill: "none",
|
|
707
770
|
stroke: a,
|
|
@@ -711,26 +774,26 @@ function ae({ series: t, x: r, y: i, title: c, description: l, curve: d = "monot
|
|
|
711
774
|
"data-series": e.id
|
|
712
775
|
}, e.id);
|
|
713
776
|
}),
|
|
714
|
-
!S && /* @__PURE__ */ s
|
|
777
|
+
!S && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
715
778
|
scale: b,
|
|
716
779
|
orientation: "x",
|
|
717
|
-
length:
|
|
780
|
+
length: a,
|
|
718
781
|
tickCount: m,
|
|
719
|
-
transform: `translate(0,${
|
|
720
|
-
}), /* @__PURE__ */
|
|
782
|
+
transform: `translate(0,${o})`
|
|
783
|
+
}), /* @__PURE__ */ c(B, {
|
|
721
784
|
scale: x,
|
|
722
785
|
orientation: "y",
|
|
723
|
-
length:
|
|
786
|
+
length: o,
|
|
724
787
|
tickCount: h
|
|
725
788
|
})] })
|
|
726
789
|
]
|
|
727
790
|
}) });
|
|
728
791
|
}
|
|
729
|
-
}), E && /* @__PURE__ */
|
|
792
|
+
}), E && /* @__PURE__ */ c(U, {
|
|
730
793
|
series: t.map((e, t) => ({
|
|
731
794
|
id: e.id,
|
|
732
795
|
label: e.label,
|
|
733
|
-
color: e.color ??
|
|
796
|
+
color: e.color ?? W[t % W.length]
|
|
734
797
|
})),
|
|
735
798
|
hidden: C
|
|
736
799
|
})]
|
|
@@ -738,32 +801,32 @@ function ae({ series: t, x: r, y: i, title: c, description: l, curve: d = "monot
|
|
|
738
801
|
}
|
|
739
802
|
//#endregion
|
|
740
803
|
//#region src/charts/area-chart/area-chart.tsx
|
|
741
|
-
var
|
|
742
|
-
function oe({ series: t, x: r, y: i, title:
|
|
804
|
+
var G = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
805
|
+
function oe({ series: t, x: r, y: i, title: a, description: o, stacked: d = !1, curve: f = "monotone", width: p, height: m, xTicks: h = 5, yTicks: g = 5, legend: _, tooltip: v, className: b, plain: S }) {
|
|
743
806
|
n();
|
|
744
|
-
let w = e(/* @__PURE__ */ new Set()), T = S ?
|
|
745
|
-
return /* @__PURE__ */
|
|
807
|
+
let w = e(/* @__PURE__ */ new Set()), T = S ? I : F, E = m ?? (S ? 48 : 300), D = S ? !1 : _ ?? t.length > 1, O = (t[0]?.data ?? []).map((e) => r(e)), k = t.flatMap((e) => e.data.map((e) => i(e))), A = O.length > 0, j = A ? Math.min(...O) : 0, M = A ? Math.max(...O) : 1, N = d ? 0 : Math.min(0, ...k), P = Math.max(...d ? (t[0]?.data ?? []).map((e, n) => t.reduce((e, t) => e + i(t.data[n]), 0)) : k);
|
|
808
|
+
return /* @__PURE__ */ l("div", {
|
|
746
809
|
style: {
|
|
747
810
|
display: "flex",
|
|
748
811
|
flexDirection: "column",
|
|
749
812
|
gap: "0.5rem"
|
|
750
813
|
},
|
|
751
|
-
children: [/* @__PURE__ */
|
|
752
|
-
title:
|
|
753
|
-
description:
|
|
814
|
+
children: [/* @__PURE__ */ c(z, {
|
|
815
|
+
title: a,
|
|
816
|
+
description: o,
|
|
754
817
|
width: p,
|
|
755
818
|
height: E,
|
|
756
|
-
fallback: /* @__PURE__ */
|
|
757
|
-
/* @__PURE__ */
|
|
758
|
-
/* @__PURE__ */
|
|
759
|
-
/* @__PURE__ */
|
|
819
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
820
|
+
/* @__PURE__ */ c("caption", { children: a }),
|
|
821
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("th", { children: "X" }), t.map((e) => /* @__PURE__ */ c("th", { children: e.label }, e.id))] }) }),
|
|
822
|
+
/* @__PURE__ */ c("tbody", { children: (t[0]?.data ?? []).map((e, n) => /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: t[0] ? String(r(t[0].data[n])) : "" }), t.map((e) => /* @__PURE__ */ c("td", { children: e.data[n] == null ? "" : i(e.data[n]) }, e.id))] }, n)) })
|
|
760
823
|
] }),
|
|
761
824
|
className: b,
|
|
762
825
|
"data-state": A ? void 0 : "empty",
|
|
763
826
|
plain: S,
|
|
764
827
|
tooltip: v !== !1 && A ? ({ width: e, height: n }) => {
|
|
765
828
|
if (v === !1 || !A) return;
|
|
766
|
-
let a = e - T.left - T.right, o = n - T.top - T.bottom, s = u([j, M], [0, a]), c = u([N,
|
|
829
|
+
let a = e - T.left - T.right, o = n - T.top - T.bottom, s = u([j, M], [0, a]), c = u([N, P], [o, 0]);
|
|
767
830
|
return { points: t.flatMap((e) => w.value.has(e.id) ? [] : e.data.map((t, n) => ({
|
|
768
831
|
id: `${e.id}-${n}`,
|
|
769
832
|
cx: T.left + s.map(r(t)),
|
|
@@ -774,47 +837,47 @@ function oe({ series: t, x: r, y: i, title: c, description: l, stacked: d = !1,
|
|
|
774
837
|
}))) };
|
|
775
838
|
} : void 0,
|
|
776
839
|
children: ({ width: e, height: n }) => {
|
|
777
|
-
let
|
|
778
|
-
return d && (_ = C(t.map((e) => e.data.map((e) => i(e))))), /* @__PURE__ */
|
|
840
|
+
let a = e - T.left - T.right, o = n - T.top - T.bottom, p = u([j, M], [0, a]), m = u([N, P], [o, 0]), _ = [];
|
|
841
|
+
return d && (_ = C(t.map((e) => e.data.map((e) => i(e))))), /* @__PURE__ */ c("g", { children: /* @__PURE__ */ l("g", {
|
|
779
842
|
transform: `translate(${T.left},${T.top})`,
|
|
780
843
|
children: [
|
|
781
|
-
!S && /* @__PURE__ */
|
|
844
|
+
!S && /* @__PURE__ */ c(V, {
|
|
782
845
|
scale: m,
|
|
783
846
|
orientation: "y",
|
|
784
|
-
length:
|
|
847
|
+
length: a,
|
|
785
848
|
tickCount: g
|
|
786
849
|
}),
|
|
787
850
|
t.map((e, t) => {
|
|
788
851
|
if (w.value.has(e.id)) return null;
|
|
789
|
-
let n = e.color ??
|
|
852
|
+
let n = e.color ?? G[t % G.length], a, o;
|
|
790
853
|
if (d && _[t]) {
|
|
791
854
|
let i = _[t];
|
|
792
855
|
a = e.data.map((e, t) => [p.map(r(e)), m.map(i[t][1])]);
|
|
793
|
-
let
|
|
794
|
-
|
|
795
|
-
let u = y(a, f), d =
|
|
796
|
-
return /* @__PURE__ */
|
|
856
|
+
let s = e.data.map((e, t) => [p.map(r(e)), m.map(i[t][0])]);
|
|
857
|
+
o = m.map(0);
|
|
858
|
+
let u = y(a, f), d = s[s.length - 1], h = s[0], g = [...s].reverse().map(([e, t]) => `L${e},${t}`).join(""), v = `${u}L${d[0]},${d[1]}${g}L${h[0]},${h[1]}Z`;
|
|
859
|
+
return /* @__PURE__ */ l("g", {
|
|
797
860
|
"data-series": e.id,
|
|
798
|
-
children: [/* @__PURE__ */
|
|
861
|
+
children: [/* @__PURE__ */ c("path", {
|
|
799
862
|
d: v,
|
|
800
863
|
fill: n,
|
|
801
864
|
fillOpacity: .25,
|
|
802
865
|
stroke: "none"
|
|
803
|
-
}), /* @__PURE__ */
|
|
866
|
+
}), /* @__PURE__ */ c("path", {
|
|
804
867
|
d: y(a, f),
|
|
805
868
|
fill: "none",
|
|
806
869
|
stroke: n,
|
|
807
870
|
strokeWidth: 2
|
|
808
871
|
})]
|
|
809
872
|
}, e.id);
|
|
810
|
-
} else return a = e.data.map((e) => [p.map(r(e)), m.map(i(e))]),
|
|
873
|
+
} else return a = e.data.map((e) => [p.map(r(e)), m.map(i(e))]), o = m.map(0), /* @__PURE__ */ l("g", {
|
|
811
874
|
"data-series": e.id,
|
|
812
|
-
children: [/* @__PURE__ */
|
|
813
|
-
d: x(a,
|
|
875
|
+
children: [/* @__PURE__ */ c("path", {
|
|
876
|
+
d: x(a, o, f),
|
|
814
877
|
fill: n,
|
|
815
878
|
fillOpacity: .25,
|
|
816
879
|
stroke: "none"
|
|
817
|
-
}), /* @__PURE__ */
|
|
880
|
+
}), /* @__PURE__ */ c("path", {
|
|
818
881
|
d: y(a, f),
|
|
819
882
|
fill: "none",
|
|
820
883
|
stroke: n,
|
|
@@ -822,26 +885,26 @@ function oe({ series: t, x: r, y: i, title: c, description: l, stacked: d = !1,
|
|
|
822
885
|
})]
|
|
823
886
|
}, e.id);
|
|
824
887
|
}),
|
|
825
|
-
!S && /* @__PURE__ */ s
|
|
888
|
+
!S && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
826
889
|
scale: p,
|
|
827
890
|
orientation: "x",
|
|
828
|
-
length:
|
|
891
|
+
length: a,
|
|
829
892
|
tickCount: h,
|
|
830
|
-
transform: `translate(0,${
|
|
831
|
-
}), /* @__PURE__ */
|
|
893
|
+
transform: `translate(0,${o})`
|
|
894
|
+
}), /* @__PURE__ */ c(B, {
|
|
832
895
|
scale: m,
|
|
833
896
|
orientation: "y",
|
|
834
|
-
length:
|
|
897
|
+
length: o,
|
|
835
898
|
tickCount: g
|
|
836
899
|
})] })
|
|
837
900
|
]
|
|
838
901
|
}) });
|
|
839
902
|
}
|
|
840
|
-
}), D && /* @__PURE__ */
|
|
903
|
+
}), D && /* @__PURE__ */ c(U, {
|
|
841
904
|
series: t.map((e, t) => ({
|
|
842
905
|
id: e.id,
|
|
843
906
|
label: e.label,
|
|
844
|
-
color: e.color ??
|
|
907
|
+
color: e.color ?? G[t % G.length]
|
|
845
908
|
})),
|
|
846
909
|
hidden: w
|
|
847
910
|
})]
|
|
@@ -849,237 +912,307 @@ function oe({ series: t, x: r, y: i, title: c, description: l, stacked: d = !1,
|
|
|
849
912
|
}
|
|
850
913
|
//#endregion
|
|
851
914
|
//#region src/charts/bar-chart/bar-chart.tsx
|
|
852
|
-
var
|
|
853
|
-
function se(
|
|
915
|
+
var K = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
916
|
+
function se(e) {
|
|
917
|
+
let t = e.segments?.filter((e) => e.value !== 0) ?? [], n = `${e.label} · ${e.value}`;
|
|
918
|
+
return t.length > 0 ? `${n} — ${t.map((e) => `${e.label}: ${e.value}`).join(", ")}` : n;
|
|
919
|
+
}
|
|
920
|
+
function ce({ series: t, x: r, y: i, title: a, description: o, orientation: d = "vertical", mode: p = "grouped", width: m, height: h, xTicks: g = 5, yTicks: _ = 5, xLabelEvery: v, legend: y, tooltip: b, tooltipFormat: x, className: S, plain: w }) {
|
|
854
921
|
n();
|
|
855
|
-
let
|
|
856
|
-
return /* @__PURE__ */
|
|
922
|
+
let T = e(/* @__PURE__ */ new Set()), E = w ? I : F, D = h ?? (w ? 48 : 300), O = w ? !1 : y ?? t.length > 1, k = (t[0]?.data ?? []).map((e) => r(e)), A = t.flatMap((e) => e.data.map((e) => i(e))), j = k.length > 0, M = p === "stacked" ? 0 : Math.min(0, ...A), N = j ? Math.max(...k.map((e, n) => t.reduce((e, t) => e + i(t.data[n]), 0))) : 1, P = p === "stacked" ? N : Math.max(1, ...A);
|
|
923
|
+
return /* @__PURE__ */ l("div", {
|
|
857
924
|
style: {
|
|
858
925
|
display: "flex",
|
|
859
926
|
flexDirection: "column",
|
|
860
927
|
gap: "0.5rem"
|
|
861
928
|
},
|
|
862
|
-
children: [/* @__PURE__ */
|
|
863
|
-
title:
|
|
864
|
-
description:
|
|
929
|
+
children: [/* @__PURE__ */ c(z, {
|
|
930
|
+
title: a,
|
|
931
|
+
description: o,
|
|
865
932
|
width: m,
|
|
866
|
-
height:
|
|
867
|
-
fallback: /* @__PURE__ */
|
|
868
|
-
/* @__PURE__ */
|
|
869
|
-
/* @__PURE__ */
|
|
870
|
-
/* @__PURE__ */
|
|
933
|
+
height: D,
|
|
934
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
935
|
+
/* @__PURE__ */ c("caption", { children: a }),
|
|
936
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("th", { children: "Category" }), t.map((e) => /* @__PURE__ */ c("th", { children: e.label }, e.id))] }) }),
|
|
937
|
+
/* @__PURE__ */ c("tbody", { children: k.map((e, n) => /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: e }), t.map((e) => /* @__PURE__ */ c("td", { children: e.data[n] == null ? "" : i(e.data[n]) }, e.id))] }, e)) })
|
|
871
938
|
] }),
|
|
872
|
-
className:
|
|
873
|
-
"data-state":
|
|
874
|
-
plain:
|
|
875
|
-
tooltip:
|
|
876
|
-
if (!
|
|
877
|
-
let a = e -
|
|
878
|
-
|
|
939
|
+
className: S,
|
|
940
|
+
"data-state": j ? void 0 : "empty",
|
|
941
|
+
plain: w,
|
|
942
|
+
tooltip: b && j ? ({ width: e, height: n }) => {
|
|
943
|
+
if (!b || !j) return;
|
|
944
|
+
let a = e - E.left - E.right, o = n - E.top - E.bottom, s = d === "vertical", c = f(k, s ? [0, a] : [0, o], .2), l = u([M, P], s ? [o, 0] : [0, a]), m = t.filter((e) => !T.value.has(e.id)), h = [];
|
|
945
|
+
p === "stacked" && (h = C(t.map((e) => e.data.map((e) => i(e)))));
|
|
946
|
+
let g = p === "stacked" && !x, _ = k.map((e, n) => {
|
|
947
|
+
let r = m.map((e) => ({
|
|
948
|
+
label: e.label,
|
|
949
|
+
value: i(e.data[n]),
|
|
950
|
+
color: e.color ?? K[t.indexOf(e) % K.length]
|
|
951
|
+
}));
|
|
952
|
+
return {
|
|
953
|
+
segs: r,
|
|
954
|
+
total: r.reduce((e, t) => e + t.value, 0)
|
|
955
|
+
};
|
|
956
|
+
}), v = m.flatMap((e) => {
|
|
879
957
|
let n = t.indexOf(e), a = p === "grouped" ? c.bandwidth / m.length : c.bandwidth;
|
|
880
958
|
return e.data.map((t, o) => {
|
|
881
959
|
let u = c.map(r(t)) ?? 0, d, f;
|
|
882
960
|
if (p === "stacked" && h[n]) {
|
|
883
961
|
let e = h[n][o];
|
|
884
962
|
d = e[1], f = e[0];
|
|
885
|
-
} else d = i(t), f =
|
|
886
|
-
let
|
|
963
|
+
} else d = i(t), f = M;
|
|
964
|
+
let v = m.indexOf(e), y = u + (p === "grouped" ? v * a : 0) + a / 2, b = (Math.min(l.map(d), l.map(f)) + Math.max(l.map(d), l.map(f))) / 2;
|
|
887
965
|
return {
|
|
888
966
|
id: `${e.id}-${o}`,
|
|
889
|
-
cx:
|
|
890
|
-
cy:
|
|
967
|
+
cx: E.left + (s ? y : b),
|
|
968
|
+
cy: E.top + (s ? b : y),
|
|
891
969
|
label: r(t),
|
|
892
|
-
value: i(t),
|
|
893
|
-
seriesId: e.id
|
|
970
|
+
value: g ? _[o].total : i(t),
|
|
971
|
+
seriesId: e.id,
|
|
972
|
+
...g && { segments: _[o].segs }
|
|
894
973
|
};
|
|
895
974
|
});
|
|
896
|
-
})
|
|
975
|
+
}), y = x ?? (g ? se : void 0);
|
|
976
|
+
return y ? {
|
|
977
|
+
points: v,
|
|
978
|
+
format: y
|
|
979
|
+
} : { points: v };
|
|
897
980
|
} : void 0,
|
|
898
981
|
children: ({ width: e, height: n }) => {
|
|
899
|
-
let
|
|
900
|
-
return p === "stacked" && (
|
|
901
|
-
transform: `translate(${
|
|
982
|
+
let a = e - E.left - E.right, o = n - E.top - E.bottom, m = d === "vertical", h = f(k, m ? [0, a] : [0, o], .2), y = u([M, P], m ? [o, 0] : [0, a]), b = t.filter((e) => !T.value.has(e.id)), x = [];
|
|
983
|
+
return p === "stacked" && (x = C(t.map((e) => e.data.map((e) => i(e))))), /* @__PURE__ */ c("g", { children: /* @__PURE__ */ l("g", {
|
|
984
|
+
transform: `translate(${E.left},${E.top})`,
|
|
902
985
|
children: [
|
|
903
|
-
!
|
|
904
|
-
scale:
|
|
986
|
+
!w && m && /* @__PURE__ */ c(V, {
|
|
987
|
+
scale: y,
|
|
905
988
|
orientation: "y",
|
|
906
|
-
length:
|
|
989
|
+
length: a,
|
|
907
990
|
tickCount: _
|
|
908
991
|
}),
|
|
909
|
-
!
|
|
910
|
-
scale:
|
|
992
|
+
!w && !m && /* @__PURE__ */ c(V, {
|
|
993
|
+
scale: y,
|
|
911
994
|
orientation: "x",
|
|
912
|
-
length:
|
|
995
|
+
length: o,
|
|
913
996
|
tickCount: g
|
|
914
997
|
}),
|
|
915
|
-
|
|
916
|
-
let a = e.color ??
|
|
998
|
+
b.map((e, n) => {
|
|
999
|
+
let a = e.color ?? K[t.indexOf(e) % K.length], o = t.indexOf(e), s = p === "grouped" ? h.bandwidth / b.length : h.bandwidth;
|
|
917
1000
|
return e.data.map((t, l) => {
|
|
918
1001
|
let u = h.map(r(t)) ?? 0, d, f;
|
|
919
|
-
if (p === "stacked" &&
|
|
920
|
-
let e =
|
|
1002
|
+
if (p === "stacked" && x[o]) {
|
|
1003
|
+
let e = x[o][l];
|
|
921
1004
|
d = e[1], f = e[0];
|
|
922
|
-
} else d = i(t), f =
|
|
923
|
-
let g = u + (p === "grouped" ? n *
|
|
924
|
-
return m ? /* @__PURE__ */
|
|
1005
|
+
} else d = i(t), f = M;
|
|
1006
|
+
let g = u + (p === "grouped" ? n * s : 0), _ = Math.min(y.map(d), y.map(f)), v = Math.abs(y.map(d) - y.map(f));
|
|
1007
|
+
return m ? /* @__PURE__ */ c("rect", {
|
|
925
1008
|
x: g,
|
|
926
1009
|
y: _,
|
|
927
|
-
width:
|
|
928
|
-
height:
|
|
1010
|
+
width: s,
|
|
1011
|
+
height: v,
|
|
929
1012
|
fill: a,
|
|
930
1013
|
rx: 2,
|
|
931
1014
|
"data-series": e.id
|
|
932
|
-
}, `${e.id}-${l}`) : /* @__PURE__ */
|
|
1015
|
+
}, `${e.id}-${l}`) : /* @__PURE__ */ c("rect", {
|
|
933
1016
|
x: _,
|
|
934
1017
|
y: g,
|
|
935
|
-
width:
|
|
936
|
-
height:
|
|
1018
|
+
width: v,
|
|
1019
|
+
height: s,
|
|
937
1020
|
fill: a,
|
|
938
1021
|
rx: 2,
|
|
939
1022
|
"data-series": e.id
|
|
940
1023
|
}, `${e.id}-${l}`);
|
|
941
1024
|
});
|
|
942
1025
|
}),
|
|
943
|
-
!
|
|
1026
|
+
!w && m && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
944
1027
|
scale: h,
|
|
945
1028
|
orientation: "x",
|
|
946
|
-
length:
|
|
1029
|
+
length: a,
|
|
947
1030
|
tickCount: g,
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1031
|
+
labelEvery: v,
|
|
1032
|
+
transform: `translate(0,${o})`
|
|
1033
|
+
}), /* @__PURE__ */ c(B, {
|
|
1034
|
+
scale: y,
|
|
951
1035
|
orientation: "y",
|
|
952
|
-
length:
|
|
1036
|
+
length: o,
|
|
953
1037
|
tickCount: _
|
|
954
1038
|
})] }),
|
|
955
|
-
!
|
|
956
|
-
scale:
|
|
1039
|
+
!w && !m && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
1040
|
+
scale: y,
|
|
957
1041
|
orientation: "x",
|
|
958
|
-
length:
|
|
1042
|
+
length: a,
|
|
959
1043
|
tickCount: g,
|
|
960
|
-
transform: `translate(0,${
|
|
961
|
-
}), /* @__PURE__ */
|
|
1044
|
+
transform: `translate(0,${o})`
|
|
1045
|
+
}), /* @__PURE__ */ c(B, {
|
|
962
1046
|
scale: h,
|
|
963
1047
|
orientation: "y",
|
|
964
|
-
length:
|
|
965
|
-
tickCount: _
|
|
1048
|
+
length: o,
|
|
1049
|
+
tickCount: _,
|
|
1050
|
+
labelEvery: v
|
|
966
1051
|
})] })
|
|
967
1052
|
]
|
|
968
1053
|
}) });
|
|
969
1054
|
}
|
|
970
|
-
}),
|
|
1055
|
+
}), O && /* @__PURE__ */ c(U, {
|
|
971
1056
|
series: t.map((e, t) => ({
|
|
972
1057
|
id: e.id,
|
|
973
1058
|
label: e.label,
|
|
974
|
-
color: e.color ??
|
|
1059
|
+
color: e.color ?? K[t % K.length]
|
|
975
1060
|
})),
|
|
976
|
-
hidden:
|
|
1061
|
+
hidden: T
|
|
977
1062
|
})]
|
|
978
1063
|
});
|
|
979
1064
|
}
|
|
980
1065
|
//#endregion
|
|
981
1066
|
//#region src/charts/pie-chart/pie-chart.tsx
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1067
|
+
function le(e) {
|
|
1068
|
+
let t = e.percent == null ? 0 : Math.round(e.percent);
|
|
1069
|
+
return `${e.value} (${t}%)`;
|
|
1070
|
+
}
|
|
1071
|
+
var q = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
1072
|
+
function ue({ data: t, title: r, description: i, donut: a = !1, width: o, height: s, size: u, thickness: d, innerRadius: f, centerValue: p, centerLabel: m, centerSlot: h, emptyLabel: g, tooltipFormat: _, legend: v, className: y, plain: b }) {
|
|
1073
|
+
let x = o ?? u, C = s ?? u ?? (b ? 48 : 300), w = b ? !1 : v ?? !0;
|
|
985
1074
|
n();
|
|
986
|
-
let
|
|
987
|
-
return /* @__PURE__ */
|
|
1075
|
+
let T = e(/* @__PURE__ */ new Set()), E = t.length > 0;
|
|
1076
|
+
return /* @__PURE__ */ l("div", {
|
|
988
1077
|
style: {
|
|
989
1078
|
display: "flex",
|
|
990
1079
|
flexDirection: "column",
|
|
991
1080
|
gap: "0.5rem"
|
|
992
1081
|
},
|
|
993
|
-
children: [/* @__PURE__ */
|
|
1082
|
+
children: [/* @__PURE__ */ c(z, {
|
|
994
1083
|
title: r,
|
|
995
1084
|
description: i,
|
|
996
|
-
width:
|
|
997
|
-
height:
|
|
998
|
-
fallback: /* @__PURE__ */
|
|
999
|
-
/* @__PURE__ */
|
|
1000
|
-
/* @__PURE__ */
|
|
1001
|
-
/* @__PURE__ */
|
|
1002
|
-
/* @__PURE__ */
|
|
1003
|
-
/* @__PURE__ */
|
|
1085
|
+
width: x,
|
|
1086
|
+
height: C,
|
|
1087
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
1088
|
+
/* @__PURE__ */ c("caption", { children: r }),
|
|
1089
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [
|
|
1090
|
+
/* @__PURE__ */ c("th", { children: "Label" }),
|
|
1091
|
+
/* @__PURE__ */ c("th", { children: "Value" }),
|
|
1092
|
+
/* @__PURE__ */ c("th", { children: "Percent" })
|
|
1004
1093
|
] }) }),
|
|
1005
|
-
/* @__PURE__ */
|
|
1094
|
+
/* @__PURE__ */ c("tbody", { children: t.map((e) => {
|
|
1006
1095
|
let n = t.reduce((e, t) => e + t.value, 0), r = n > 0 ? (e.value / n * 100).toFixed(1) : "0";
|
|
1007
|
-
return /* @__PURE__ */
|
|
1008
|
-
/* @__PURE__ */
|
|
1009
|
-
/* @__PURE__ */
|
|
1010
|
-
/* @__PURE__ */
|
|
1096
|
+
return /* @__PURE__ */ l("tr", { children: [
|
|
1097
|
+
/* @__PURE__ */ c("td", { children: e.label }),
|
|
1098
|
+
/* @__PURE__ */ c("td", { children: e.value }),
|
|
1099
|
+
/* @__PURE__ */ l("td", { children: [r, "%"] })
|
|
1011
1100
|
] }, e.id);
|
|
1012
1101
|
}) })
|
|
1013
1102
|
] }),
|
|
1014
|
-
className:
|
|
1015
|
-
"data-state":
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1103
|
+
className: y,
|
|
1104
|
+
"data-state": E ? void 0 : "empty",
|
|
1105
|
+
emptyLabel: g,
|
|
1106
|
+
plain: b,
|
|
1107
|
+
tooltip: E ? ({ width: e, height: n }) => {
|
|
1108
|
+
if (!E) return;
|
|
1109
|
+
let r = e / 2, i = n / 2, a = Math.min(r, i) - 8, o = t.filter((e) => !T.value.has(e.id)), s = o.reduce((e, t) => e + t.value, 0), c = 0;
|
|
1110
|
+
return {
|
|
1111
|
+
points: o.map((e, t) => {
|
|
1112
|
+
let n = s > 0 ? e.value / s * 2 * Math.PI : 0, o = c + n, l = (c + o) / 2;
|
|
1113
|
+
return c = o, {
|
|
1114
|
+
id: e.id,
|
|
1115
|
+
cx: r + Math.sin(l) * a * .65,
|
|
1116
|
+
cy: i - Math.cos(l) * a * .65,
|
|
1117
|
+
label: e.label,
|
|
1118
|
+
value: e.value,
|
|
1119
|
+
seriesId: String(t),
|
|
1120
|
+
percent: s > 0 ? e.value / s * 100 : 0,
|
|
1121
|
+
color: e.color ?? q[t % q.length]
|
|
1122
|
+
};
|
|
1123
|
+
}),
|
|
1124
|
+
format: _ ?? le
|
|
1125
|
+
};
|
|
1031
1126
|
} : void 0,
|
|
1032
1127
|
children: ({ width: e, height: n }) => {
|
|
1033
|
-
let r = e / 2, i = n / 2,
|
|
1034
|
-
return /* @__PURE__ */
|
|
1035
|
-
let n =
|
|
1036
|
-
return
|
|
1037
|
-
d:
|
|
1038
|
-
fill:
|
|
1128
|
+
let r = e / 2, i = n / 2, o = Math.min(r, i) - 8, s = f ?? (d == null ? o * .6 : o - d), u = a ? Math.max(0, Math.min(s, o)) : 0, g = t.filter((e) => !T.value.has(e.id)), _ = g.reduce((e, t) => e + t.value, 0), v = 0, y = a && (p != null || m != null || h != null);
|
|
1129
|
+
return /* @__PURE__ */ l("g", { children: [g.map((e, t) => {
|
|
1130
|
+
let n = _ > 0 ? e.value / _ * 2 * Math.PI : 0, a = v + n, s = e.color ?? q[t % q.length], l = S(r, i, o, u, v, a);
|
|
1131
|
+
return v = a, /* @__PURE__ */ c("path", {
|
|
1132
|
+
d: l,
|
|
1133
|
+
fill: s,
|
|
1039
1134
|
stroke: "var(--cascivo-color-surface)",
|
|
1040
1135
|
strokeWidth: 1,
|
|
1041
1136
|
"data-series": e.id
|
|
1042
1137
|
}, e.id);
|
|
1043
|
-
})
|
|
1138
|
+
}), y && (h == null ? /* @__PURE__ */ l("g", {
|
|
1139
|
+
"data-center": "",
|
|
1140
|
+
children: [p != null && /* @__PURE__ */ c("text", {
|
|
1141
|
+
x: r,
|
|
1142
|
+
y: m == null ? i : i - 8,
|
|
1143
|
+
textAnchor: "middle",
|
|
1144
|
+
dominantBaseline: "central",
|
|
1145
|
+
fontSize: "1.5rem",
|
|
1146
|
+
fontWeight: 700,
|
|
1147
|
+
fill: "var(--cascivo-color-foreground)",
|
|
1148
|
+
children: p
|
|
1149
|
+
}), m != null && /* @__PURE__ */ c("text", {
|
|
1150
|
+
x: r,
|
|
1151
|
+
y: p == null ? i : i + 14,
|
|
1152
|
+
textAnchor: "middle",
|
|
1153
|
+
dominantBaseline: "central",
|
|
1154
|
+
fontSize: "0.8125rem",
|
|
1155
|
+
fill: "var(--cascivo-color-foreground-muted)",
|
|
1156
|
+
children: m
|
|
1157
|
+
})]
|
|
1158
|
+
}) : /* @__PURE__ */ c("foreignObject", {
|
|
1159
|
+
x: r - u,
|
|
1160
|
+
y: i - u,
|
|
1161
|
+
width: u * 2,
|
|
1162
|
+
height: u * 2,
|
|
1163
|
+
"data-center-slot": "",
|
|
1164
|
+
children: /* @__PURE__ */ c("div", {
|
|
1165
|
+
style: {
|
|
1166
|
+
width: "100%",
|
|
1167
|
+
height: "100%",
|
|
1168
|
+
display: "flex",
|
|
1169
|
+
flexDirection: "column",
|
|
1170
|
+
alignItems: "center",
|
|
1171
|
+
justifyContent: "center",
|
|
1172
|
+
textAlign: "center"
|
|
1173
|
+
},
|
|
1174
|
+
children: h
|
|
1175
|
+
})
|
|
1176
|
+
}))] });
|
|
1044
1177
|
}
|
|
1045
|
-
}),
|
|
1178
|
+
}), w && /* @__PURE__ */ c(U, {
|
|
1046
1179
|
series: t.map((e, t) => ({
|
|
1047
1180
|
id: e.id,
|
|
1048
1181
|
label: e.label,
|
|
1049
|
-
color: e.color ??
|
|
1182
|
+
color: e.color ?? q[t % q.length]
|
|
1050
1183
|
})),
|
|
1051
|
-
hidden:
|
|
1184
|
+
hidden: T
|
|
1052
1185
|
})]
|
|
1053
1186
|
});
|
|
1054
1187
|
}
|
|
1055
1188
|
//#endregion
|
|
1056
1189
|
//#region src/charts/scatter-chart/scatter-chart.tsx
|
|
1057
|
-
var
|
|
1058
|
-
function
|
|
1190
|
+
var J = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
1191
|
+
function de({ series: t, title: r, description: i, r: a = 4, width: o, height: d, xTicks: f = 5, yTicks: p = 5, legend: m, tooltip: h, className: g, plain: _ }) {
|
|
1059
1192
|
n();
|
|
1060
|
-
let v = e(/* @__PURE__ */ new Set()), y = _ ?
|
|
1061
|
-
return /* @__PURE__ */
|
|
1193
|
+
let v = e(/* @__PURE__ */ new Set()), y = _ ? I : F, b = d ?? (_ ? 48 : 300), x = _ ? !1 : m ?? t.length > 1, S = t.flatMap((e) => e.data.map((e) => e.x)), C = t.flatMap((e) => e.data.map((e) => e.y)), w = S.length > 0, T = w ? Math.min(...S) : 0, E = w ? Math.max(...S) : 1, D = w ? Math.min(0, ...C) : 0, O = w ? Math.max(...C) : 1;
|
|
1194
|
+
return /* @__PURE__ */ l("div", {
|
|
1062
1195
|
style: {
|
|
1063
1196
|
display: "flex",
|
|
1064
1197
|
flexDirection: "column",
|
|
1065
1198
|
gap: "0.5rem"
|
|
1066
1199
|
},
|
|
1067
|
-
children: [/* @__PURE__ */
|
|
1200
|
+
children: [/* @__PURE__ */ c(z, {
|
|
1068
1201
|
title: r,
|
|
1069
1202
|
description: i,
|
|
1070
|
-
width:
|
|
1203
|
+
width: o,
|
|
1071
1204
|
height: b,
|
|
1072
|
-
fallback: /* @__PURE__ */
|
|
1073
|
-
/* @__PURE__ */
|
|
1074
|
-
/* @__PURE__ */
|
|
1075
|
-
/* @__PURE__ */
|
|
1076
|
-
/* @__PURE__ */
|
|
1077
|
-
/* @__PURE__ */
|
|
1205
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
1206
|
+
/* @__PURE__ */ c("caption", { children: r }),
|
|
1207
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [
|
|
1208
|
+
/* @__PURE__ */ c("th", { children: "Series" }),
|
|
1209
|
+
/* @__PURE__ */ c("th", { children: "X" }),
|
|
1210
|
+
/* @__PURE__ */ c("th", { children: "Y" })
|
|
1078
1211
|
] }) }),
|
|
1079
|
-
/* @__PURE__ */
|
|
1080
|
-
/* @__PURE__ */
|
|
1081
|
-
/* @__PURE__ */
|
|
1082
|
-
/* @__PURE__ */
|
|
1212
|
+
/* @__PURE__ */ c("tbody", { children: t.flatMap((e) => e.data.map((t, n) => /* @__PURE__ */ l("tr", { children: [
|
|
1213
|
+
/* @__PURE__ */ c("td", { children: e.label }),
|
|
1214
|
+
/* @__PURE__ */ c("td", { children: t.x }),
|
|
1215
|
+
/* @__PURE__ */ c("td", { children: t.y })
|
|
1083
1216
|
] }, `${e.id}-${n}`))) })
|
|
1084
1217
|
] }),
|
|
1085
1218
|
className: g,
|
|
@@ -1098,11 +1231,11 @@ function le({ series: t, title: r, description: i, r: c = 4, width: l, height: d
|
|
|
1098
1231
|
}))) };
|
|
1099
1232
|
} : void 0,
|
|
1100
1233
|
children: ({ width: e, height: n }) => {
|
|
1101
|
-
let r = e - y.left - y.right, i = n - y.top - y.bottom,
|
|
1102
|
-
return /* @__PURE__ */
|
|
1234
|
+
let r = e - y.left - y.right, i = n - y.top - y.bottom, o = u([T, E], [0, r]), d = u([D, O], [i, 0]);
|
|
1235
|
+
return /* @__PURE__ */ c("g", { children: /* @__PURE__ */ l("g", {
|
|
1103
1236
|
transform: `translate(${y.left},${y.top})`,
|
|
1104
1237
|
children: [
|
|
1105
|
-
!_ && /* @__PURE__ */
|
|
1238
|
+
!_ && /* @__PURE__ */ c(V, {
|
|
1106
1239
|
scale: d,
|
|
1107
1240
|
orientation: "y",
|
|
1108
1241
|
length: r,
|
|
@@ -1110,13 +1243,13 @@ function le({ series: t, title: r, description: i, r: c = 4, width: l, height: d
|
|
|
1110
1243
|
}),
|
|
1111
1244
|
t.map((e, t) => {
|
|
1112
1245
|
if (v.value.has(e.id)) return null;
|
|
1113
|
-
let n = e.color ??
|
|
1114
|
-
return /* @__PURE__ */
|
|
1246
|
+
let n = e.color ?? J[t % J.length];
|
|
1247
|
+
return /* @__PURE__ */ c("g", {
|
|
1115
1248
|
"data-series": e.id,
|
|
1116
1249
|
children: e.data.map((e, t) => {
|
|
1117
|
-
let r = typeof
|
|
1118
|
-
return /* @__PURE__ */
|
|
1119
|
-
cx:
|
|
1250
|
+
let r = typeof a == "function" ? a(e) : e.r ?? a;
|
|
1251
|
+
return /* @__PURE__ */ c("circle", {
|
|
1252
|
+
cx: o.map(e.x),
|
|
1120
1253
|
cy: d.map(e.y),
|
|
1121
1254
|
r,
|
|
1122
1255
|
fill: n,
|
|
@@ -1127,13 +1260,13 @@ function le({ series: t, title: r, description: i, r: c = 4, width: l, height: d
|
|
|
1127
1260
|
})
|
|
1128
1261
|
}, e.id);
|
|
1129
1262
|
}),
|
|
1130
|
-
!_ && /* @__PURE__ */ s
|
|
1131
|
-
scale:
|
|
1263
|
+
!_ && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
1264
|
+
scale: o,
|
|
1132
1265
|
orientation: "x",
|
|
1133
1266
|
length: r,
|
|
1134
1267
|
tickCount: f,
|
|
1135
1268
|
transform: `translate(0,${i})`
|
|
1136
|
-
}), /* @__PURE__ */
|
|
1269
|
+
}), /* @__PURE__ */ c(B, {
|
|
1137
1270
|
scale: d,
|
|
1138
1271
|
orientation: "y",
|
|
1139
1272
|
length: i,
|
|
@@ -1142,11 +1275,11 @@ function le({ series: t, title: r, description: i, r: c = 4, width: l, height: d
|
|
|
1142
1275
|
]
|
|
1143
1276
|
}) });
|
|
1144
1277
|
}
|
|
1145
|
-
}), x && /* @__PURE__ */
|
|
1278
|
+
}), x && /* @__PURE__ */ c(U, {
|
|
1146
1279
|
series: t.map((e, t) => ({
|
|
1147
1280
|
id: e.id,
|
|
1148
1281
|
label: e.label,
|
|
1149
|
-
color: e.color ??
|
|
1282
|
+
color: e.color ?? J[t % J.length]
|
|
1150
1283
|
})),
|
|
1151
1284
|
hidden: v
|
|
1152
1285
|
})]
|
|
@@ -1154,8 +1287,8 @@ function le({ series: t, title: r, description: i, r: c = 4, width: l, height: d
|
|
|
1154
1287
|
}
|
|
1155
1288
|
//#endregion
|
|
1156
1289
|
//#region src/charts/sparkline/sparkline.tsx
|
|
1157
|
-
function
|
|
1158
|
-
return /* @__PURE__ */
|
|
1290
|
+
function Y({ data: e, width: t = 120, height: n = 32, label: r, color: i = "var(--cascivo-chart-1)", endDot: a = !0 }) {
|
|
1291
|
+
return /* @__PURE__ */ c(z, {
|
|
1159
1292
|
title: r,
|
|
1160
1293
|
width: t,
|
|
1161
1294
|
height: n,
|
|
@@ -1173,15 +1306,15 @@ function J({ data: e, width: t = 120, height: n = 32, label: r, color: i = "var(
|
|
|
1173
1306
|
})() : void 0,
|
|
1174
1307
|
children: () => {
|
|
1175
1308
|
if (e.length === 0) return null;
|
|
1176
|
-
let r = u([0, e.length - 1], [2, t - 2]),
|
|
1177
|
-
return /* @__PURE__ */ s
|
|
1309
|
+
let r = u([0, e.length - 1], [2, t - 2]), o = Math.min(...e), d = Math.max(...e), f = u([o === d ? o - 1 : o, d], [n - 2, 2]), p = e.map((e, t) => [r.map(t), f.map(e)]), m = y(p, "monotone"), h = p[p.length - 1];
|
|
1310
|
+
return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("path", {
|
|
1178
1311
|
d: m,
|
|
1179
1312
|
fill: "none",
|
|
1180
1313
|
stroke: i,
|
|
1181
1314
|
strokeWidth: 1.5,
|
|
1182
1315
|
strokeLinecap: "round",
|
|
1183
1316
|
strokeLinejoin: "round"
|
|
1184
|
-
}),
|
|
1317
|
+
}), a && /* @__PURE__ */ c("circle", {
|
|
1185
1318
|
cx: h[0],
|
|
1186
1319
|
cy: h[1],
|
|
1187
1320
|
r: 2.5,
|
|
@@ -1192,33 +1325,33 @@ function J({ data: e, width: t = 120, height: n = 32, label: r, color: i = "var(
|
|
|
1192
1325
|
}
|
|
1193
1326
|
//#endregion
|
|
1194
1327
|
//#region src/charts/meter/meter.tsx
|
|
1195
|
-
function
|
|
1328
|
+
function fe(e, t, n, r) {
|
|
1196
1329
|
if (!r) return "var(--cascivo-chart-1)";
|
|
1197
1330
|
let { warning: i, critical: a } = r;
|
|
1198
1331
|
return a != null && e >= a ? "var(--cascivo-color-destructive)" : i != null && e >= i ? "var(--cascivo-color-warning)" : "var(--cascivo-color-success)";
|
|
1199
1332
|
}
|
|
1200
|
-
function
|
|
1201
|
-
let u = n > t ? (Math.min(n, Math.max(t, e)) - t) / (n - t) : 0, d =
|
|
1333
|
+
function pe({ value: e, min: t = 0, max: n = 100, label: r, variant: i = "bar", thresholds: a, width: o = 200, height: s }) {
|
|
1334
|
+
let u = n > t ? (Math.min(n, Math.max(t, e)) - t) / (n - t) : 0, d = fe(e, t, n, a);
|
|
1202
1335
|
if (i === "gauge") {
|
|
1203
|
-
let i =
|
|
1204
|
-
return /* @__PURE__ */
|
|
1336
|
+
let i = s ?? 100, a = o, f = a / 2, p = i * .9, m = Math.min(f, p) - 4, h = m * .65, g = Math.PI, _ = S(f, p, m, h, g, 2 * Math.PI), v = g + u * Math.PI, y = u > 0 ? S(f, p, m, h, g, v) : "";
|
|
1337
|
+
return /* @__PURE__ */ l("div", {
|
|
1205
1338
|
"aria-label": r,
|
|
1206
1339
|
role: "meter",
|
|
1207
1340
|
"aria-valuenow": e,
|
|
1208
1341
|
"aria-valuemin": t,
|
|
1209
1342
|
"aria-valuemax": n,
|
|
1210
|
-
children: [/* @__PURE__ */
|
|
1343
|
+
children: [/* @__PURE__ */ l("svg", {
|
|
1211
1344
|
width: a,
|
|
1212
1345
|
height: i,
|
|
1213
1346
|
"aria-hidden": "true",
|
|
1214
|
-
children: [/* @__PURE__ */
|
|
1347
|
+
children: [/* @__PURE__ */ c("path", {
|
|
1215
1348
|
d: _,
|
|
1216
1349
|
fill: "var(--cascivo-color-border)"
|
|
1217
|
-
}), y && /* @__PURE__ */
|
|
1350
|
+
}), y && /* @__PURE__ */ c("path", {
|
|
1218
1351
|
d: y,
|
|
1219
1352
|
fill: d
|
|
1220
1353
|
})]
|
|
1221
|
-
}), /* @__PURE__ */
|
|
1354
|
+
}), /* @__PURE__ */ l("div", {
|
|
1222
1355
|
style: {
|
|
1223
1356
|
textAlign: "center",
|
|
1224
1357
|
fontSize: "var(--cascivo-text-sm)",
|
|
@@ -1232,26 +1365,26 @@ function de({ value: e, min: t = 0, max: n = 100, label: r, variant: i = "bar",
|
|
|
1232
1365
|
})]
|
|
1233
1366
|
});
|
|
1234
1367
|
}
|
|
1235
|
-
let f =
|
|
1236
|
-
return /* @__PURE__ */
|
|
1368
|
+
let f = s ?? 12, p = o;
|
|
1369
|
+
return /* @__PURE__ */ l("div", {
|
|
1237
1370
|
"aria-label": r,
|
|
1238
1371
|
role: "meter",
|
|
1239
1372
|
"aria-valuenow": e,
|
|
1240
1373
|
"aria-valuemin": t,
|
|
1241
1374
|
"aria-valuemax": n,
|
|
1242
|
-
children: [/* @__PURE__ */
|
|
1375
|
+
children: [/* @__PURE__ */ l("svg", {
|
|
1243
1376
|
width: p,
|
|
1244
1377
|
height: f,
|
|
1245
1378
|
"aria-hidden": "true",
|
|
1246
1379
|
style: { display: "block" },
|
|
1247
|
-
children: [/* @__PURE__ */
|
|
1380
|
+
children: [/* @__PURE__ */ c("rect", {
|
|
1248
1381
|
x: 0,
|
|
1249
1382
|
y: 0,
|
|
1250
1383
|
width: p,
|
|
1251
1384
|
height: f,
|
|
1252
1385
|
rx: f / 2,
|
|
1253
1386
|
fill: "var(--cascivo-color-border)"
|
|
1254
|
-
}), /* @__PURE__ */
|
|
1387
|
+
}), /* @__PURE__ */ c("rect", {
|
|
1255
1388
|
x: 0,
|
|
1256
1389
|
y: 0,
|
|
1257
1390
|
width: p,
|
|
@@ -1264,7 +1397,7 @@ function de({ value: e, min: t = 0, max: n = 100, label: r, variant: i = "bar",
|
|
|
1264
1397
|
transition: "transform 400ms ease"
|
|
1265
1398
|
}
|
|
1266
1399
|
})]
|
|
1267
|
-
}), /* @__PURE__ */
|
|
1400
|
+
}), /* @__PURE__ */ c("div", {
|
|
1268
1401
|
style: {
|
|
1269
1402
|
marginTop: "var(--cascivo-space-1)",
|
|
1270
1403
|
fontSize: "var(--cascivo-text-xs)",
|
|
@@ -1276,13 +1409,13 @@ function de({ value: e, min: t = 0, max: n = 100, label: r, variant: i = "bar",
|
|
|
1276
1409
|
}
|
|
1277
1410
|
//#endregion
|
|
1278
1411
|
//#region src/charts/kpi/kpi.tsx
|
|
1279
|
-
function
|
|
1412
|
+
function X(e) {
|
|
1280
1413
|
return `${e >= 0 ? "+" : ""}${e.toLocaleString()}`;
|
|
1281
1414
|
}
|
|
1282
|
-
function
|
|
1283
|
-
let
|
|
1284
|
-
return /* @__PURE__ */
|
|
1285
|
-
className:
|
|
1415
|
+
function me({ value: e, label: t, delta: n, deltaLabel: r, icon: i, sparkline: a, className: o }) {
|
|
1416
|
+
let s = n != null && n >= 0, u = n != null && n < 0;
|
|
1417
|
+
return /* @__PURE__ */ l("div", {
|
|
1418
|
+
className: o,
|
|
1286
1419
|
style: {
|
|
1287
1420
|
display: "flex",
|
|
1288
1421
|
flexDirection: "column",
|
|
@@ -1293,30 +1426,30 @@ function fe({ value: e, label: t, delta: n, deltaLabel: r, icon: i, sparkline: a
|
|
|
1293
1426
|
background: "var(--cascivo-color-surface)"
|
|
1294
1427
|
},
|
|
1295
1428
|
children: [
|
|
1296
|
-
/* @__PURE__ */
|
|
1429
|
+
/* @__PURE__ */ l("div", {
|
|
1297
1430
|
style: {
|
|
1298
1431
|
display: "flex",
|
|
1299
1432
|
alignItems: "center",
|
|
1300
1433
|
justifyContent: "space-between"
|
|
1301
1434
|
},
|
|
1302
|
-
children: [/* @__PURE__ */
|
|
1435
|
+
children: [/* @__PURE__ */ c("span", {
|
|
1303
1436
|
style: {
|
|
1304
1437
|
fontSize: "var(--cascivo-text-sm)",
|
|
1305
1438
|
color: "var(--cascivo-color-foreground-muted)"
|
|
1306
1439
|
},
|
|
1307
1440
|
children: t
|
|
1308
|
-
}), i && /* @__PURE__ */
|
|
1441
|
+
}), i && /* @__PURE__ */ c("span", {
|
|
1309
1442
|
"aria-hidden": "true",
|
|
1310
1443
|
children: i
|
|
1311
1444
|
})]
|
|
1312
1445
|
}),
|
|
1313
|
-
/* @__PURE__ */
|
|
1446
|
+
/* @__PURE__ */ l("div", {
|
|
1314
1447
|
style: {
|
|
1315
1448
|
display: "flex",
|
|
1316
1449
|
alignItems: "flex-end",
|
|
1317
1450
|
gap: "var(--cascivo-space-2)"
|
|
1318
1451
|
},
|
|
1319
|
-
children: [/* @__PURE__ */
|
|
1452
|
+
children: [/* @__PURE__ */ c("span", {
|
|
1320
1453
|
style: {
|
|
1321
1454
|
fontSize: "var(--cascivo-text-2xl)",
|
|
1322
1455
|
fontWeight: 700,
|
|
@@ -1324,22 +1457,22 @@ function fe({ value: e, label: t, delta: n, deltaLabel: r, icon: i, sparkline: a
|
|
|
1324
1457
|
color: "var(--cascivo-color-foreground)"
|
|
1325
1458
|
},
|
|
1326
1459
|
children: typeof e == "number" ? e.toLocaleString() : e
|
|
1327
|
-
}), n != null && /* @__PURE__ */
|
|
1460
|
+
}), n != null && /* @__PURE__ */ l("span", {
|
|
1328
1461
|
style: {
|
|
1329
1462
|
fontSize: "var(--cascivo-text-sm)",
|
|
1330
1463
|
fontWeight: 500,
|
|
1331
|
-
color:
|
|
1464
|
+
color: s ? "var(--cascivo-color-success)" : u ? "var(--cascivo-color-destructive)" : "var(--cascivo-color-foreground-muted)"
|
|
1332
1465
|
},
|
|
1333
|
-
"aria-label": `Trend: ${
|
|
1466
|
+
"aria-label": `Trend: ${X(n)}${r ? ` ${r}` : ""}`,
|
|
1334
1467
|
children: [
|
|
1335
|
-
|
|
1468
|
+
s ? "▲" : u ? "▼" : "–",
|
|
1336
1469
|
" ",
|
|
1337
|
-
|
|
1470
|
+
X(n),
|
|
1338
1471
|
r && ` ${r}`
|
|
1339
1472
|
]
|
|
1340
1473
|
})]
|
|
1341
1474
|
}),
|
|
1342
|
-
a && a.length > 0 && /* @__PURE__ */
|
|
1475
|
+
a && a.length > 0 && /* @__PURE__ */ c(Y, {
|
|
1343
1476
|
data: a,
|
|
1344
1477
|
label: `${t} trend`,
|
|
1345
1478
|
width: 120,
|
|
@@ -1350,22 +1483,22 @@ function fe({ value: e, label: t, delta: n, deltaLabel: r, icon: i, sparkline: a
|
|
|
1350
1483
|
}
|
|
1351
1484
|
//#endregion
|
|
1352
1485
|
//#region src/charts/histogram/histogram.tsx
|
|
1353
|
-
function
|
|
1486
|
+
function he({ data: e, bins: t, title: r, label: i, description: a, width: o, height: d, className: f, plain: p }) {
|
|
1354
1487
|
n();
|
|
1355
|
-
let m = p ?
|
|
1356
|
-
return /* @__PURE__ */
|
|
1488
|
+
let m = p ? I : F, h = d ?? (p ? 48 : 300), g = D(e, t), _ = g.reduce((e, t) => Math.max(e, t.count), 0);
|
|
1489
|
+
return /* @__PURE__ */ c(z, {
|
|
1357
1490
|
title: r,
|
|
1358
|
-
description:
|
|
1359
|
-
width:
|
|
1491
|
+
description: a,
|
|
1492
|
+
width: o,
|
|
1360
1493
|
height: h,
|
|
1361
|
-
fallback: /* @__PURE__ */
|
|
1362
|
-
/* @__PURE__ */
|
|
1363
|
-
/* @__PURE__ */
|
|
1364
|
-
/* @__PURE__ */
|
|
1494
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
1495
|
+
/* @__PURE__ */ c("caption", { children: r }),
|
|
1496
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("th", { children: "Range" }), /* @__PURE__ */ c("th", { children: "Count" })] }) }),
|
|
1497
|
+
/* @__PURE__ */ c("tbody", { children: g.map((e, t) => /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ l("td", { children: [
|
|
1365
1498
|
e.x0.toFixed(2),
|
|
1366
1499
|
" – ",
|
|
1367
1500
|
e.x1.toFixed(2)
|
|
1368
|
-
] }), /* @__PURE__ */
|
|
1501
|
+
] }), /* @__PURE__ */ c("td", { children: e.count })] }, t)) })
|
|
1369
1502
|
] }),
|
|
1370
1503
|
className: f,
|
|
1371
1504
|
plain: p,
|
|
@@ -1390,32 +1523,32 @@ function pe({ data: e, bins: t, title: r, label: i, description: c, width: l, he
|
|
|
1390
1523
|
};
|
|
1391
1524
|
if (n.width <= 0 || g.length === 0) return null;
|
|
1392
1525
|
let r = u([g[0]?.x0 ?? 0, g[g.length - 1]?.x1 ?? 1], [0, n.width]), i = u([0, _ || 1], [n.height, 0]);
|
|
1393
|
-
return /* @__PURE__ */
|
|
1526
|
+
return /* @__PURE__ */ l("g", {
|
|
1394
1527
|
transform: `translate(${m.left},${m.top})`,
|
|
1395
1528
|
children: [
|
|
1396
|
-
!p && /* @__PURE__ */
|
|
1529
|
+
!p && /* @__PURE__ */ c(V, {
|
|
1397
1530
|
scale: i,
|
|
1398
1531
|
orientation: "y",
|
|
1399
1532
|
length: n.width
|
|
1400
1533
|
}),
|
|
1401
1534
|
g.map((e, t) => {
|
|
1402
|
-
let a = r.map(e.x0),
|
|
1403
|
-
return /* @__PURE__ */
|
|
1535
|
+
let a = r.map(e.x0), o = Math.max(0, r.map(e.x1) - a - 1), s = i.map(e.count), l = n.height - s;
|
|
1536
|
+
return /* @__PURE__ */ c("rect", {
|
|
1404
1537
|
x: a,
|
|
1405
|
-
y:
|
|
1406
|
-
width:
|
|
1538
|
+
y: s,
|
|
1539
|
+
width: o,
|
|
1407
1540
|
height: Math.max(0, l),
|
|
1408
1541
|
fill: "var(--cascivo-chart-1)",
|
|
1409
1542
|
opacity: .85,
|
|
1410
1543
|
"aria-label": `${e.x0.toFixed(1)}–${e.x1.toFixed(1)}: ${e.count}`
|
|
1411
1544
|
}, t);
|
|
1412
1545
|
}),
|
|
1413
|
-
!p && /* @__PURE__ */ s
|
|
1546
|
+
!p && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
1414
1547
|
scale: r,
|
|
1415
1548
|
orientation: "x",
|
|
1416
1549
|
length: n.width,
|
|
1417
1550
|
transform: `translate(0,${n.height})`
|
|
1418
|
-
}), /* @__PURE__ */
|
|
1551
|
+
}), /* @__PURE__ */ c(B, {
|
|
1419
1552
|
scale: i,
|
|
1420
1553
|
orientation: "y",
|
|
1421
1554
|
length: n.height
|
|
@@ -1427,38 +1560,38 @@ function pe({ data: e, bins: t, title: r, label: i, description: c, width: l, he
|
|
|
1427
1560
|
}
|
|
1428
1561
|
//#endregion
|
|
1429
1562
|
//#region src/charts/boxplot/boxplot.tsx
|
|
1430
|
-
var
|
|
1431
|
-
function
|
|
1563
|
+
var Z = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
1564
|
+
function ge({ series: e, title: t, description: r, width: i, height: a, className: o, plain: d }) {
|
|
1432
1565
|
n();
|
|
1433
|
-
let p = d ?
|
|
1566
|
+
let p = d ? I : F, m = a ?? (d ? 48 : 320), h = e.map((e) => ({
|
|
1434
1567
|
...e,
|
|
1435
|
-
stats:
|
|
1436
|
-
})), g = e.flatMap((e) => e.values), [_, v] = g.length > 0 ?
|
|
1437
|
-
return /* @__PURE__ */
|
|
1568
|
+
stats: O(e.values)
|
|
1569
|
+
})), g = e.flatMap((e) => e.values), [_, v] = g.length > 0 ? k(g) : [0, 1];
|
|
1570
|
+
return /* @__PURE__ */ c(z, {
|
|
1438
1571
|
title: t,
|
|
1439
1572
|
description: r,
|
|
1440
1573
|
width: i,
|
|
1441
1574
|
height: m,
|
|
1442
|
-
fallback: /* @__PURE__ */
|
|
1443
|
-
/* @__PURE__ */
|
|
1444
|
-
/* @__PURE__ */
|
|
1445
|
-
/* @__PURE__ */
|
|
1446
|
-
/* @__PURE__ */
|
|
1447
|
-
/* @__PURE__ */
|
|
1448
|
-
/* @__PURE__ */
|
|
1449
|
-
/* @__PURE__ */
|
|
1450
|
-
/* @__PURE__ */
|
|
1575
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
1576
|
+
/* @__PURE__ */ c("caption", { children: t }),
|
|
1577
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [
|
|
1578
|
+
/* @__PURE__ */ c("th", { children: "Series" }),
|
|
1579
|
+
/* @__PURE__ */ c("th", { children: "Min" }),
|
|
1580
|
+
/* @__PURE__ */ c("th", { children: "Q1" }),
|
|
1581
|
+
/* @__PURE__ */ c("th", { children: "Median" }),
|
|
1582
|
+
/* @__PURE__ */ c("th", { children: "Q3" }),
|
|
1583
|
+
/* @__PURE__ */ c("th", { children: "Max" })
|
|
1451
1584
|
] }) }),
|
|
1452
|
-
/* @__PURE__ */
|
|
1453
|
-
/* @__PURE__ */
|
|
1454
|
-
/* @__PURE__ */
|
|
1455
|
-
/* @__PURE__ */
|
|
1456
|
-
/* @__PURE__ */
|
|
1457
|
-
/* @__PURE__ */
|
|
1458
|
-
/* @__PURE__ */
|
|
1585
|
+
/* @__PURE__ */ c("tbody", { children: h.map((e) => /* @__PURE__ */ l("tr", { children: [
|
|
1586
|
+
/* @__PURE__ */ c("td", { children: e.label }),
|
|
1587
|
+
/* @__PURE__ */ c("td", { children: e.stats.min.toFixed(2) }),
|
|
1588
|
+
/* @__PURE__ */ c("td", { children: e.stats.q1.toFixed(2) }),
|
|
1589
|
+
/* @__PURE__ */ c("td", { children: e.stats.median.toFixed(2) }),
|
|
1590
|
+
/* @__PURE__ */ c("td", { children: e.stats.q3.toFixed(2) }),
|
|
1591
|
+
/* @__PURE__ */ c("td", { children: e.stats.max.toFixed(2) })
|
|
1459
1592
|
] }, e.id)) })
|
|
1460
1593
|
] }),
|
|
1461
|
-
className:
|
|
1594
|
+
className: o,
|
|
1462
1595
|
plain: d,
|
|
1463
1596
|
tooltip: h.length > 0 ? ({ width: e, height: t }) => {
|
|
1464
1597
|
if (h.length === 0) return;
|
|
@@ -1488,15 +1621,15 @@ function me({ series: e, title: t, description: r, width: i, height: c, classNam
|
|
|
1488
1621
|
height: t - p.top - p.bottom
|
|
1489
1622
|
};
|
|
1490
1623
|
if (n.width <= 0 || h.length === 0) return null;
|
|
1491
|
-
let r = f(h.map((e) => e.id), [0, n.width], .3), i = (v - _) * .05 || 1,
|
|
1492
|
-
return /* @__PURE__ */
|
|
1624
|
+
let r = f(h.map((e) => e.id), [0, n.width], .3), i = (v - _) * .05 || 1, a = u([_ - i, v + i], [n.height, 0]);
|
|
1625
|
+
return /* @__PURE__ */ l("g", {
|
|
1493
1626
|
transform: `translate(${p.left},${p.top})`,
|
|
1494
1627
|
children: [h.map((e, t) => {
|
|
1495
|
-
let n =
|
|
1496
|
-
return /* @__PURE__ */
|
|
1628
|
+
let n = Z[t % Z.length] ?? "var(--cascivo-chart-1)", i = (r.map(e.id) ?? 0) + r.bandwidth / 2, o = r.bandwidth * .6, s = i - o / 2, u = a.map(e.stats.q1), d = a.map(e.stats.q3), f = a.map(e.stats.median), p = a.map(e.stats.min), m = a.map(e.stats.max);
|
|
1629
|
+
return /* @__PURE__ */ l("g", {
|
|
1497
1630
|
"aria-label": `${e.label}: median ${e.stats.median.toFixed(2)}`,
|
|
1498
1631
|
children: [
|
|
1499
|
-
/* @__PURE__ */
|
|
1632
|
+
/* @__PURE__ */ c("line", {
|
|
1500
1633
|
x1: i,
|
|
1501
1634
|
y1: d,
|
|
1502
1635
|
x2: i,
|
|
@@ -1504,7 +1637,7 @@ function me({ series: e, title: t, description: r, width: i, height: c, classNam
|
|
|
1504
1637
|
stroke: n,
|
|
1505
1638
|
strokeWidth: 1.5
|
|
1506
1639
|
}),
|
|
1507
|
-
/* @__PURE__ */
|
|
1640
|
+
/* @__PURE__ */ c("line", {
|
|
1508
1641
|
x1: i,
|
|
1509
1642
|
y1: u,
|
|
1510
1643
|
x2: i,
|
|
@@ -1512,43 +1645,43 @@ function me({ series: e, title: t, description: r, width: i, height: c, classNam
|
|
|
1512
1645
|
stroke: n,
|
|
1513
1646
|
strokeWidth: 1.5
|
|
1514
1647
|
}),
|
|
1515
|
-
/* @__PURE__ */
|
|
1516
|
-
x1: i -
|
|
1648
|
+
/* @__PURE__ */ c("line", {
|
|
1649
|
+
x1: i - o / 4,
|
|
1517
1650
|
y1: m,
|
|
1518
|
-
x2: i +
|
|
1651
|
+
x2: i + o / 4,
|
|
1519
1652
|
y2: m,
|
|
1520
1653
|
stroke: n,
|
|
1521
1654
|
strokeWidth: 1.5
|
|
1522
1655
|
}),
|
|
1523
|
-
/* @__PURE__ */
|
|
1524
|
-
x1: i -
|
|
1656
|
+
/* @__PURE__ */ c("line", {
|
|
1657
|
+
x1: i - o / 4,
|
|
1525
1658
|
y1: p,
|
|
1526
|
-
x2: i +
|
|
1659
|
+
x2: i + o / 4,
|
|
1527
1660
|
y2: p,
|
|
1528
1661
|
stroke: n,
|
|
1529
1662
|
strokeWidth: 1.5
|
|
1530
1663
|
}),
|
|
1531
|
-
/* @__PURE__ */
|
|
1532
|
-
x:
|
|
1664
|
+
/* @__PURE__ */ c("rect", {
|
|
1665
|
+
x: s,
|
|
1533
1666
|
y: d,
|
|
1534
|
-
width:
|
|
1667
|
+
width: o,
|
|
1535
1668
|
height: Math.max(0, u - d),
|
|
1536
1669
|
fill: n,
|
|
1537
1670
|
fillOpacity: .25,
|
|
1538
1671
|
stroke: n,
|
|
1539
1672
|
strokeWidth: 1.5
|
|
1540
1673
|
}),
|
|
1541
|
-
/* @__PURE__ */
|
|
1542
|
-
x1:
|
|
1674
|
+
/* @__PURE__ */ c("line", {
|
|
1675
|
+
x1: s,
|
|
1543
1676
|
y1: f,
|
|
1544
|
-
x2:
|
|
1677
|
+
x2: s + o,
|
|
1545
1678
|
y2: f,
|
|
1546
1679
|
stroke: n,
|
|
1547
1680
|
strokeWidth: 2.5
|
|
1548
1681
|
}),
|
|
1549
|
-
e.stats.outliers.map((e, t) => /* @__PURE__ */
|
|
1682
|
+
e.stats.outliers.map((e, t) => /* @__PURE__ */ c("circle", {
|
|
1550
1683
|
cx: i,
|
|
1551
|
-
cy:
|
|
1684
|
+
cy: a.map(e),
|
|
1552
1685
|
r: 3,
|
|
1553
1686
|
fill: "none",
|
|
1554
1687
|
stroke: n,
|
|
@@ -1557,13 +1690,13 @@ function me({ series: e, title: t, description: r, width: i, height: c, classNam
|
|
|
1557
1690
|
}, t))
|
|
1558
1691
|
]
|
|
1559
1692
|
}, e.id);
|
|
1560
|
-
}), !d && /* @__PURE__ */ s
|
|
1693
|
+
}), !d && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
1561
1694
|
scale: r,
|
|
1562
1695
|
orientation: "x",
|
|
1563
1696
|
length: n.width,
|
|
1564
1697
|
transform: `translate(0,${n.height})`
|
|
1565
|
-
}), /* @__PURE__ */
|
|
1566
|
-
scale:
|
|
1698
|
+
}), /* @__PURE__ */ c(B, {
|
|
1699
|
+
scale: a,
|
|
1567
1700
|
orientation: "y",
|
|
1568
1701
|
length: n.height
|
|
1569
1702
|
})] })]
|
|
@@ -1573,28 +1706,28 @@ function me({ series: e, title: t, description: r, width: i, height: c, classNam
|
|
|
1573
1706
|
}
|
|
1574
1707
|
//#endregion
|
|
1575
1708
|
//#region src/charts/bubble-chart/bubble-chart.tsx
|
|
1576
|
-
var
|
|
1577
|
-
function
|
|
1709
|
+
var Q = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`), _e = 3, ve = 24;
|
|
1710
|
+
function ye({ series: t, title: r, description: i, width: a, height: o, tooltip: d, className: f, plain: m }) {
|
|
1578
1711
|
n();
|
|
1579
|
-
let h = e(null), g = m ?
|
|
1580
|
-
return /* @__PURE__ */
|
|
1712
|
+
let h = e(null), g = m ? I : F, _ = o ?? (m ? 48 : 320), v = t.flatMap((e) => e.data), [y, b] = v.length > 0 ? k(v.map((e) => e.x)) : [0, 1], [x, S] = v.length > 0 ? k(v.map((e) => e.y)) : [0, 1], [C, w] = v.length > 0 ? k(v.map((e) => e.size)) : [0, 1], T = p([C, w], [_e, ve]), E = v.length > 0;
|
|
1713
|
+
return /* @__PURE__ */ c(z, {
|
|
1581
1714
|
title: r,
|
|
1582
1715
|
description: i,
|
|
1583
|
-
width:
|
|
1716
|
+
width: a,
|
|
1584
1717
|
height: _,
|
|
1585
|
-
fallback: /* @__PURE__ */
|
|
1586
|
-
/* @__PURE__ */
|
|
1587
|
-
/* @__PURE__ */
|
|
1588
|
-
/* @__PURE__ */
|
|
1589
|
-
/* @__PURE__ */
|
|
1590
|
-
/* @__PURE__ */
|
|
1591
|
-
/* @__PURE__ */
|
|
1718
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
1719
|
+
/* @__PURE__ */ c("caption", { children: r }),
|
|
1720
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [
|
|
1721
|
+
/* @__PURE__ */ c("th", { children: "Series" }),
|
|
1722
|
+
/* @__PURE__ */ c("th", { children: "X" }),
|
|
1723
|
+
/* @__PURE__ */ c("th", { children: "Y" }),
|
|
1724
|
+
/* @__PURE__ */ c("th", { children: "Size" })
|
|
1592
1725
|
] }) }),
|
|
1593
|
-
/* @__PURE__ */
|
|
1594
|
-
/* @__PURE__ */
|
|
1595
|
-
/* @__PURE__ */
|
|
1596
|
-
/* @__PURE__ */
|
|
1597
|
-
/* @__PURE__ */
|
|
1726
|
+
/* @__PURE__ */ c("tbody", { children: t.flatMap((e) => e.data.map((t, n) => /* @__PURE__ */ l("tr", { children: [
|
|
1727
|
+
/* @__PURE__ */ c("td", { children: e.name }),
|
|
1728
|
+
/* @__PURE__ */ c("td", { children: t.x }),
|
|
1729
|
+
/* @__PURE__ */ c("td", { children: t.y }),
|
|
1730
|
+
/* @__PURE__ */ c("td", { children: t.size })
|
|
1598
1731
|
] }, `${e.name}-${n}`))) })
|
|
1599
1732
|
] }),
|
|
1600
1733
|
className: f,
|
|
@@ -1622,18 +1755,18 @@ function _e({ series: t, title: r, description: i, width: c, height: l, tooltip:
|
|
|
1622
1755
|
height: n - g.top - g.bottom
|
|
1623
1756
|
};
|
|
1624
1757
|
if (r.width <= 0 || v.length === 0) return null;
|
|
1625
|
-
let i = (b - y) * .05 || 1,
|
|
1626
|
-
return /* @__PURE__ */
|
|
1758
|
+
let i = (b - y) * .05 || 1, a = (S - x) * .05 || 1, o = u([y - i, b + i], [0, r.width]), d = u([x - a, S + a], [r.height, 0]);
|
|
1759
|
+
return /* @__PURE__ */ l("g", {
|
|
1627
1760
|
transform: `translate(${g.left},${g.top})`,
|
|
1628
1761
|
children: [
|
|
1629
|
-
!m && /* @__PURE__ */
|
|
1762
|
+
!m && /* @__PURE__ */ c(V, {
|
|
1630
1763
|
scale: d,
|
|
1631
1764
|
orientation: "y",
|
|
1632
1765
|
length: r.width
|
|
1633
1766
|
}),
|
|
1634
1767
|
t.map((e, t) => {
|
|
1635
|
-
let n =
|
|
1636
|
-
return /* @__PURE__ */
|
|
1768
|
+
let n = Q[t % Q.length] ?? "var(--cascivo-chart-1)";
|
|
1769
|
+
return /* @__PURE__ */ c("g", {
|
|
1637
1770
|
opacity: h.value !== null && h.value !== e.name ? .2 : 1,
|
|
1638
1771
|
onMouseEnter: () => {
|
|
1639
1772
|
h.value = e.name;
|
|
@@ -1641,8 +1774,8 @@ function _e({ series: t, title: r, description: i, width: c, height: l, tooltip:
|
|
|
1641
1774
|
onMouseLeave: () => {
|
|
1642
1775
|
h.value = null;
|
|
1643
1776
|
},
|
|
1644
|
-
children: e.data.map((t, r) => /* @__PURE__ */
|
|
1645
|
-
cx:
|
|
1777
|
+
children: e.data.map((t, r) => /* @__PURE__ */ c("circle", {
|
|
1778
|
+
cx: o.map(t.x),
|
|
1646
1779
|
cy: d.map(t.y),
|
|
1647
1780
|
r: T(t.size),
|
|
1648
1781
|
fill: n,
|
|
@@ -1653,12 +1786,12 @@ function _e({ series: t, title: r, description: i, width: c, height: l, tooltip:
|
|
|
1653
1786
|
}, r))
|
|
1654
1787
|
}, e.name);
|
|
1655
1788
|
}),
|
|
1656
|
-
!m && /* @__PURE__ */ s
|
|
1657
|
-
scale:
|
|
1789
|
+
!m && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
1790
|
+
scale: o,
|
|
1658
1791
|
orientation: "x",
|
|
1659
1792
|
length: r.width,
|
|
1660
1793
|
transform: `translate(0,${r.height})`
|
|
1661
|
-
}), /* @__PURE__ */
|
|
1794
|
+
}), /* @__PURE__ */ c(B, {
|
|
1662
1795
|
scale: d,
|
|
1663
1796
|
orientation: "y",
|
|
1664
1797
|
length: r.height
|
|
@@ -1670,21 +1803,21 @@ function _e({ series: t, title: r, description: i, width: c, height: l, tooltip:
|
|
|
1670
1803
|
}
|
|
1671
1804
|
//#endregion
|
|
1672
1805
|
//#region src/charts/combo-chart/combo-chart.tsx
|
|
1673
|
-
function
|
|
1806
|
+
function be({ bars: e, line: t, title: r, description: i, secondAxis: a = !1, width: o, height: d, tooltip: p, className: m, plain: h }) {
|
|
1674
1807
|
n();
|
|
1675
|
-
let g = d ?? (h ? 48 : 320), _ = h ?
|
|
1676
|
-
...
|
|
1677
|
-
right:
|
|
1808
|
+
let g = d ?? (h ? 48 : 320), _ = h ? I : {
|
|
1809
|
+
...F,
|
|
1810
|
+
right: a ? 60 : F.right
|
|
1678
1811
|
}, v = e.reduce((e, t) => Math.max(e, t.value), 0) || 1, b = t.length > 0 ? Math.min(...t.map((e) => e.y)) : 0, x = t.length > 0 ? Math.max(...t.map((e) => e.y)) : 1, S = e.length > 0;
|
|
1679
|
-
return /* @__PURE__ */
|
|
1812
|
+
return /* @__PURE__ */ c(z, {
|
|
1680
1813
|
title: r,
|
|
1681
1814
|
description: i,
|
|
1682
|
-
width:
|
|
1815
|
+
width: o,
|
|
1683
1816
|
height: g,
|
|
1684
|
-
fallback: /* @__PURE__ */
|
|
1685
|
-
/* @__PURE__ */
|
|
1686
|
-
/* @__PURE__ */
|
|
1687
|
-
/* @__PURE__ */
|
|
1817
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
1818
|
+
/* @__PURE__ */ c("caption", { children: r }),
|
|
1819
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("th", { children: "Label" }), /* @__PURE__ */ c("th", { children: "Bar value" })] }) }),
|
|
1820
|
+
/* @__PURE__ */ c("tbody", { children: e.map((e) => /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: e.label }), /* @__PURE__ */ c("td", { children: e.value })] }, e.label)) })
|
|
1688
1821
|
] }),
|
|
1689
1822
|
className: m,
|
|
1690
1823
|
plain: h,
|
|
@@ -1695,19 +1828,19 @@ function ve({ bars: e, line: t, title: r, description: i, secondAxis: c = !1, wi
|
|
|
1695
1828
|
height: r - _.top - _.bottom
|
|
1696
1829
|
};
|
|
1697
1830
|
if (i.width <= 0) return;
|
|
1698
|
-
let
|
|
1831
|
+
let o = f(e.map((e) => e.label), [0, i.width], .2), s = u([0, v], [i.height, 0]), c = a ? u([b, x || b + 1], [i.height, 0]) : s, l = e.map((e, t) => ({
|
|
1699
1832
|
id: `bar-${t}`,
|
|
1700
|
-
cx: _.left + (
|
|
1701
|
-
cy: _.top +
|
|
1833
|
+
cx: _.left + (o.map(e.label) ?? 0) + o.bandwidth / 2,
|
|
1834
|
+
cy: _.top + s.map(e.value),
|
|
1702
1835
|
label: e.label,
|
|
1703
1836
|
value: e.value,
|
|
1704
1837
|
seriesId: "bars"
|
|
1705
1838
|
})), d = t.map((n, r) => {
|
|
1706
|
-
let
|
|
1839
|
+
let a = e[r] ? (o.map(e[r].label) ?? 0) + o.bandwidth / 2 : i.width * n.x / Math.max(1, t.length - 1);
|
|
1707
1840
|
return {
|
|
1708
1841
|
id: `line-${r}`,
|
|
1709
|
-
cx: _.left +
|
|
1710
|
-
cy: _.top +
|
|
1842
|
+
cx: _.left + a,
|
|
1843
|
+
cy: _.top + c.map(n.y),
|
|
1711
1844
|
label: e[r]?.label ?? String(n.x),
|
|
1712
1845
|
value: n.y,
|
|
1713
1846
|
seriesId: "line"
|
|
@@ -1721,28 +1854,28 @@ function ve({ bars: e, line: t, title: r, description: i, secondAxis: c = !1, wi
|
|
|
1721
1854
|
height: r - _.top - _.bottom
|
|
1722
1855
|
};
|
|
1723
1856
|
if (i.width <= 0 || e.length === 0) return null;
|
|
1724
|
-
let
|
|
1725
|
-
return /* @__PURE__ */
|
|
1857
|
+
let o = f(e.map((e) => e.label), [0, i.width], .2), d = u([0, v], [i.height, 0]), p = a ? u([b, x || b + 1], [i.height, 0]) : d, m = t.map((n, r) => [e[r] ? (o.map(e[r].label) ?? 0) + o.bandwidth / 2 : i.width * n.x / Math.max(1, t.length - 1), p.map(n.y)]), g = m.length > 1 ? y(m, "monotone") : "";
|
|
1858
|
+
return /* @__PURE__ */ l("g", {
|
|
1726
1859
|
transform: `translate(${_.left},${_.top})`,
|
|
1727
1860
|
children: [
|
|
1728
|
-
!h && /* @__PURE__ */
|
|
1861
|
+
!h && /* @__PURE__ */ c(V, {
|
|
1729
1862
|
scale: d,
|
|
1730
1863
|
orientation: "y",
|
|
1731
1864
|
length: i.width
|
|
1732
1865
|
}),
|
|
1733
1866
|
e.map((e) => {
|
|
1734
|
-
let t =
|
|
1735
|
-
return /* @__PURE__ */
|
|
1867
|
+
let t = o.map(e.label) ?? 0, n = d.map(e.value);
|
|
1868
|
+
return /* @__PURE__ */ c("rect", {
|
|
1736
1869
|
x: t,
|
|
1737
1870
|
y: n,
|
|
1738
|
-
width:
|
|
1871
|
+
width: o.bandwidth,
|
|
1739
1872
|
height: Math.max(0, i.height - n),
|
|
1740
1873
|
fill: "var(--cascivo-chart-1)",
|
|
1741
1874
|
opacity: .75,
|
|
1742
1875
|
"aria-label": `${e.label}: ${e.value}`
|
|
1743
1876
|
}, e.label);
|
|
1744
1877
|
}),
|
|
1745
|
-
g && /* @__PURE__ */
|
|
1878
|
+
g && /* @__PURE__ */ c("path", {
|
|
1746
1879
|
d: g,
|
|
1747
1880
|
fill: "none",
|
|
1748
1881
|
stroke: "var(--cascivo-chart-2)",
|
|
@@ -1750,19 +1883,19 @@ function ve({ bars: e, line: t, title: r, description: i, secondAxis: c = !1, wi
|
|
|
1750
1883
|
strokeLinejoin: "round",
|
|
1751
1884
|
strokeLinecap: "round"
|
|
1752
1885
|
}),
|
|
1753
|
-
!h && /* @__PURE__ */ s
|
|
1754
|
-
/* @__PURE__ */
|
|
1755
|
-
scale:
|
|
1886
|
+
!h && /* @__PURE__ */ l(s, { children: [
|
|
1887
|
+
/* @__PURE__ */ c(B, {
|
|
1888
|
+
scale: o,
|
|
1756
1889
|
orientation: "x",
|
|
1757
1890
|
length: i.width,
|
|
1758
1891
|
transform: `translate(0,${i.height})`
|
|
1759
1892
|
}),
|
|
1760
|
-
/* @__PURE__ */
|
|
1893
|
+
/* @__PURE__ */ c(B, {
|
|
1761
1894
|
scale: d,
|
|
1762
1895
|
orientation: "y",
|
|
1763
1896
|
length: i.height
|
|
1764
1897
|
}),
|
|
1765
|
-
|
|
1898
|
+
a && /* @__PURE__ */ c(B, {
|
|
1766
1899
|
scale: p,
|
|
1767
1900
|
orientation: "y",
|
|
1768
1901
|
length: i.height,
|
|
@@ -1776,33 +1909,33 @@ function ve({ bars: e, line: t, title: r, description: i, secondAxis: c = !1, wi
|
|
|
1776
1909
|
}
|
|
1777
1910
|
//#endregion
|
|
1778
1911
|
//#region src/charts/heatmap/heatmap.tsx
|
|
1779
|
-
function
|
|
1912
|
+
function xe({ data: e, title: t, description: r, width: i, height: a, className: o, plain: u }) {
|
|
1780
1913
|
n();
|
|
1781
|
-
let d =
|
|
1914
|
+
let d = a ?? (u ? 48 : 320), p = u ? I : {
|
|
1782
1915
|
top: 20,
|
|
1783
1916
|
right: 20,
|
|
1784
1917
|
bottom: 60,
|
|
1785
1918
|
left: 60
|
|
1786
|
-
}, m = [...new Set(e.map((e) => e.x))], h = [...new Set(e.map((e) => e.y))], [g, _] = e.length > 0 ?
|
|
1787
|
-
return /* @__PURE__ */
|
|
1919
|
+
}, m = [...new Set(e.map((e) => e.x))], h = [...new Set(e.map((e) => e.y))], [g, _] = e.length > 0 ? k(e.map((e) => e.value)) : [0, 1], v = _ - g || 1, y = (e) => Math.max(0, Math.min(1, (e - g) / v));
|
|
1920
|
+
return /* @__PURE__ */ c(z, {
|
|
1788
1921
|
title: t,
|
|
1789
1922
|
description: r,
|
|
1790
1923
|
width: i,
|
|
1791
1924
|
height: d,
|
|
1792
|
-
fallback: /* @__PURE__ */
|
|
1793
|
-
/* @__PURE__ */
|
|
1794
|
-
/* @__PURE__ */
|
|
1795
|
-
/* @__PURE__ */
|
|
1796
|
-
/* @__PURE__ */
|
|
1797
|
-
/* @__PURE__ */
|
|
1925
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
1926
|
+
/* @__PURE__ */ c("caption", { children: t }),
|
|
1927
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [
|
|
1928
|
+
/* @__PURE__ */ c("th", { children: "X" }),
|
|
1929
|
+
/* @__PURE__ */ c("th", { children: "Y" }),
|
|
1930
|
+
/* @__PURE__ */ c("th", { children: "Value" })
|
|
1798
1931
|
] }) }),
|
|
1799
|
-
/* @__PURE__ */
|
|
1800
|
-
/* @__PURE__ */
|
|
1801
|
-
/* @__PURE__ */
|
|
1802
|
-
/* @__PURE__ */
|
|
1932
|
+
/* @__PURE__ */ c("tbody", { children: e.map((e, t) => /* @__PURE__ */ l("tr", { children: [
|
|
1933
|
+
/* @__PURE__ */ c("td", { children: e.x }),
|
|
1934
|
+
/* @__PURE__ */ c("td", { children: e.y }),
|
|
1935
|
+
/* @__PURE__ */ c("td", { children: e.value })
|
|
1803
1936
|
] }, t)) })
|
|
1804
1937
|
] }),
|
|
1805
|
-
className:
|
|
1938
|
+
className: o,
|
|
1806
1939
|
plain: u,
|
|
1807
1940
|
tooltip: e.length > 0 ? ({ width: t, height: n }) => {
|
|
1808
1941
|
if (e.length === 0) return;
|
|
@@ -1826,28 +1959,28 @@ function ye({ data: e, title: t, description: r, width: i, height: c, className:
|
|
|
1826
1959
|
height: n - p.top - p.bottom
|
|
1827
1960
|
};
|
|
1828
1961
|
if (r.width <= 0 || e.length === 0) return null;
|
|
1829
|
-
let i = f(m, [0, r.width], .05),
|
|
1830
|
-
return /* @__PURE__ */
|
|
1962
|
+
let i = f(m, [0, r.width], .05), a = f(h, [0, r.height], .05);
|
|
1963
|
+
return /* @__PURE__ */ l("g", {
|
|
1831
1964
|
transform: `translate(${p.left},${p.top})`,
|
|
1832
1965
|
children: [e.map((e, t) => {
|
|
1833
|
-
let n = i.map(e.x) ?? 0, r =
|
|
1834
|
-
return /* @__PURE__ */
|
|
1966
|
+
let n = i.map(e.x) ?? 0, r = a.map(e.y) ?? 0, o = Math.round(y(e.value) * 100);
|
|
1967
|
+
return /* @__PURE__ */ c("rect", {
|
|
1835
1968
|
x: n,
|
|
1836
1969
|
y: r,
|
|
1837
1970
|
width: i.bandwidth,
|
|
1838
|
-
height:
|
|
1839
|
-
fill: `color-mix(in oklab, var(--cascivo-chart-1) ${
|
|
1971
|
+
height: a.bandwidth,
|
|
1972
|
+
fill: `color-mix(in oklab, var(--cascivo-chart-1) ${o}%, var(--cascivo-color-neutral-100))`,
|
|
1840
1973
|
stroke: "var(--cascivo-surface-base)",
|
|
1841
1974
|
strokeWidth: 1,
|
|
1842
1975
|
"aria-label": `${e.x}, ${e.y}: ${e.value}`
|
|
1843
1976
|
}, t);
|
|
1844
|
-
}), !u && /* @__PURE__ */ s
|
|
1977
|
+
}), !u && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(B, {
|
|
1845
1978
|
scale: i,
|
|
1846
1979
|
orientation: "x",
|
|
1847
1980
|
length: r.width,
|
|
1848
1981
|
transform: `translate(0,${r.height})`
|
|
1849
|
-
}), /* @__PURE__ */
|
|
1850
|
-
scale:
|
|
1982
|
+
}), /* @__PURE__ */ c(B, {
|
|
1983
|
+
scale: a,
|
|
1851
1984
|
orientation: "y",
|
|
1852
1985
|
length: r.height
|
|
1853
1986
|
})] })]
|
|
@@ -1857,24 +1990,24 @@ function ye({ data: e, title: t, description: r, width: i, height: c, className:
|
|
|
1857
1990
|
}
|
|
1858
1991
|
//#endregion
|
|
1859
1992
|
//#region src/charts/treemap/treemap.tsx
|
|
1860
|
-
var
|
|
1861
|
-
function
|
|
1993
|
+
var $ = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
1994
|
+
function Se({ data: e, title: t, description: r, width: i, height: o, className: u, plain: d }) {
|
|
1862
1995
|
n();
|
|
1863
|
-
let f =
|
|
1864
|
-
return /* @__PURE__ */
|
|
1996
|
+
let f = a();
|
|
1997
|
+
return /* @__PURE__ */ c(z, {
|
|
1865
1998
|
title: t,
|
|
1866
|
-
description:
|
|
1867
|
-
width:
|
|
1868
|
-
height:
|
|
1869
|
-
fallback: /* @__PURE__ */
|
|
1870
|
-
/* @__PURE__ */
|
|
1871
|
-
/* @__PURE__ */
|
|
1872
|
-
/* @__PURE__ */
|
|
1999
|
+
description: r,
|
|
2000
|
+
width: i,
|
|
2001
|
+
height: o ?? (d ? 48 : 320),
|
|
2002
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
2003
|
+
/* @__PURE__ */ c("caption", { children: t }),
|
|
2004
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("th", { children: "Label" }), /* @__PURE__ */ c("th", { children: "Value" })] }) }),
|
|
2005
|
+
/* @__PURE__ */ c("tbody", { children: e.map((e) => /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: e.label }), /* @__PURE__ */ c("td", { children: e.value })] }, e.id)) })
|
|
1873
2006
|
] }),
|
|
1874
2007
|
className: u,
|
|
1875
2008
|
plain: d,
|
|
1876
2009
|
tooltip: e.length > 0 ? ({ width: t, height: n }) => {
|
|
1877
|
-
if (e.length !== 0) return { points:
|
|
2010
|
+
if (e.length !== 0) return { points: N(e.map((e) => ({
|
|
1878
2011
|
id: e.id,
|
|
1879
2012
|
value: e.value
|
|
1880
2013
|
})), t, n).map((t) => {
|
|
@@ -1890,23 +2023,23 @@ function be({ data: e, title: t, description: i, width: c, height: l, className:
|
|
|
1890
2023
|
} : void 0,
|
|
1891
2024
|
children: ({ width: t, height: n }) => {
|
|
1892
2025
|
if (e.length === 0) return null;
|
|
1893
|
-
let r =
|
|
2026
|
+
let r = N(e.map((e) => ({
|
|
1894
2027
|
id: e.id,
|
|
1895
2028
|
value: e.value
|
|
1896
2029
|
})), t, n), i = new Map(e.map((e) => [e.id, e.label]));
|
|
1897
|
-
return /* @__PURE__ */ s
|
|
2030
|
+
return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("defs", { children: r.map((e) => /* @__PURE__ */ c("clipPath", {
|
|
1898
2031
|
id: `${f}-${e.id}`,
|
|
1899
|
-
children: /* @__PURE__ */
|
|
2032
|
+
children: /* @__PURE__ */ c("rect", {
|
|
1900
2033
|
x: e.x + 2,
|
|
1901
2034
|
y: e.y + 2,
|
|
1902
2035
|
width: Math.max(0, e.w - 4),
|
|
1903
2036
|
height: Math.max(0, e.h - 4)
|
|
1904
2037
|
})
|
|
1905
2038
|
}, e.id)) }), r.map((t, n) => {
|
|
1906
|
-
let r =
|
|
1907
|
-
return /* @__PURE__ */
|
|
2039
|
+
let r = $[n % $.length] ?? "var(--cascivo-chart-1)", a = i.get(t.id) ?? t.id;
|
|
2040
|
+
return /* @__PURE__ */ l("g", {
|
|
1908
2041
|
"aria-label": `${a}: ${e.find((e) => e.id === t.id)?.value}`,
|
|
1909
|
-
children: [/* @__PURE__ */
|
|
2042
|
+
children: [/* @__PURE__ */ c("rect", {
|
|
1910
2043
|
x: t.x,
|
|
1911
2044
|
y: t.y,
|
|
1912
2045
|
width: Math.max(0, t.w - 1),
|
|
@@ -1915,7 +2048,7 @@ function be({ data: e, title: t, description: i, width: c, height: l, className:
|
|
|
1915
2048
|
fillOpacity: .8,
|
|
1916
2049
|
stroke: "var(--cascivo-surface-base)",
|
|
1917
2050
|
strokeWidth: 1
|
|
1918
|
-
}), !d && t.w > 30 && t.h > 18 && /* @__PURE__ */
|
|
2051
|
+
}), !d && t.w > 30 && t.h > 18 && /* @__PURE__ */ c("text", {
|
|
1919
2052
|
x: t.x + 4,
|
|
1920
2053
|
y: t.y + 14,
|
|
1921
2054
|
fontSize: Math.min(12, t.w / 5),
|
|
@@ -1930,8 +2063,8 @@ function be({ data: e, title: t, description: i, width: c, height: l, className:
|
|
|
1930
2063
|
}
|
|
1931
2064
|
//#endregion
|
|
1932
2065
|
//#region src/charts/radar/radar.tsx
|
|
1933
|
-
var
|
|
1934
|
-
function
|
|
2066
|
+
var Ce = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`), we = 4;
|
|
2067
|
+
function Te(e, t, n, r, i) {
|
|
1935
2068
|
let a = e.length;
|
|
1936
2069
|
return e.map((e, o) => {
|
|
1937
2070
|
let s = o / a * 2 * Math.PI - Math.PI / 2, c = e / t * i;
|
|
@@ -1941,19 +2074,19 @@ function Se(e, t, n, r, i) {
|
|
|
1941
2074
|
};
|
|
1942
2075
|
});
|
|
1943
2076
|
}
|
|
1944
|
-
function
|
|
2077
|
+
function Ee({ axes: e, series: t, max: r, title: i, description: a, width: o, height: u, className: d, plain: f }) {
|
|
1945
2078
|
let p = u ?? (f ? 48 : 320);
|
|
1946
2079
|
n();
|
|
1947
2080
|
let m = r ?? Math.max(1, ...t.flatMap((e) => e.values)), h = e.length;
|
|
1948
|
-
return /* @__PURE__ */
|
|
2081
|
+
return /* @__PURE__ */ c(z, {
|
|
1949
2082
|
title: i,
|
|
1950
|
-
description:
|
|
1951
|
-
width:
|
|
2083
|
+
description: a,
|
|
2084
|
+
width: o,
|
|
1952
2085
|
height: p,
|
|
1953
|
-
fallback: /* @__PURE__ */
|
|
1954
|
-
/* @__PURE__ */
|
|
1955
|
-
/* @__PURE__ */
|
|
1956
|
-
/* @__PURE__ */
|
|
2086
|
+
fallback: /* @__PURE__ */ l("table", { children: [
|
|
2087
|
+
/* @__PURE__ */ c("caption", { children: i }),
|
|
2088
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("th", { children: "Series" }), e.map((e) => /* @__PURE__ */ c("th", { children: e }, e))] }) }),
|
|
2089
|
+
/* @__PURE__ */ c("tbody", { children: t.map((e) => /* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: e.label }), e.values.map((e, t) => /* @__PURE__ */ c("td", { children: e }, t))] }, e.id)) })
|
|
1957
2090
|
] }),
|
|
1958
2091
|
className: d,
|
|
1959
2092
|
plain: f,
|
|
@@ -1973,26 +2106,26 @@ function Ce({ axes: e, series: t, max: r, title: i, description: c, width: l, he
|
|
|
1973
2106
|
})) };
|
|
1974
2107
|
} : void 0,
|
|
1975
2108
|
children: ({ width: n, height: r }) => {
|
|
1976
|
-
let i = n / 2,
|
|
2109
|
+
let i = n / 2, a = r / 2, o = Math.min(i, a) * .72, u = Array.from({ length: we }, (e, t) => (t + 1) / we * o), d = Array.from({ length: h }, (e, t) => {
|
|
1977
2110
|
let n = t / h * 2 * Math.PI - Math.PI / 2;
|
|
1978
2111
|
return {
|
|
1979
|
-
x: i + Math.cos(n) *
|
|
1980
|
-
y:
|
|
2112
|
+
x: i + Math.cos(n) * o,
|
|
2113
|
+
y: a + Math.sin(n) * o
|
|
1981
2114
|
};
|
|
1982
2115
|
}), p = u.map((e) => Array.from({ length: h }, (t, n) => {
|
|
1983
2116
|
let r = n / h * 2 * Math.PI - Math.PI / 2;
|
|
1984
|
-
return `${i + Math.cos(r) * e},${
|
|
2117
|
+
return `${i + Math.cos(r) * e},${a + Math.sin(r) * e}`;
|
|
1985
2118
|
}).join(" "));
|
|
1986
|
-
return /* @__PURE__ */ s
|
|
1987
|
-
!f && p.map((e, t) => /* @__PURE__ */
|
|
2119
|
+
return /* @__PURE__ */ l(s, { children: [
|
|
2120
|
+
!f && p.map((e, t) => /* @__PURE__ */ c("polygon", {
|
|
1988
2121
|
points: e,
|
|
1989
2122
|
fill: "none",
|
|
1990
2123
|
stroke: "var(--cascivo-border-subtle)",
|
|
1991
2124
|
strokeWidth: 1
|
|
1992
2125
|
}, t)),
|
|
1993
|
-
!f && d.map((e, t) => /* @__PURE__ */
|
|
2126
|
+
!f && d.map((e, t) => /* @__PURE__ */ c("line", {
|
|
1994
2127
|
x1: i,
|
|
1995
|
-
y1:
|
|
2128
|
+
y1: a,
|
|
1996
2129
|
x2: e.x,
|
|
1997
2130
|
y2: e.y,
|
|
1998
2131
|
stroke: "var(--cascivo-border-subtle)",
|
|
@@ -2000,9 +2133,9 @@ function Ce({ axes: e, series: t, max: r, title: i, description: c, width: l, he
|
|
|
2000
2133
|
}, t)),
|
|
2001
2134
|
!f && d.map((t, n) => {
|
|
2002
2135
|
let r = n / h * 2 * Math.PI - Math.PI / 2;
|
|
2003
|
-
return /* @__PURE__ */
|
|
2004
|
-
x: i + Math.cos(r) * (
|
|
2005
|
-
y:
|
|
2136
|
+
return /* @__PURE__ */ c("text", {
|
|
2137
|
+
x: i + Math.cos(r) * (o + 18),
|
|
2138
|
+
y: a + Math.sin(r) * (o + 18),
|
|
2006
2139
|
fontSize: 11,
|
|
2007
2140
|
textAnchor: "middle",
|
|
2008
2141
|
dominantBaseline: "middle",
|
|
@@ -2011,8 +2144,8 @@ function Ce({ axes: e, series: t, max: r, title: i, description: c, width: l, he
|
|
|
2011
2144
|
}, n);
|
|
2012
2145
|
}),
|
|
2013
2146
|
t.map((e, t) => {
|
|
2014
|
-
let n =
|
|
2015
|
-
return /* @__PURE__ */
|
|
2147
|
+
let n = Te(e.values, m, i, a, o).map((e) => `${e.x},${e.y}`).join(" "), r = Ce[t % Ce.length] ?? "var(--cascivo-chart-1)";
|
|
2148
|
+
return /* @__PURE__ */ c("polygon", {
|
|
2016
2149
|
points: n,
|
|
2017
2150
|
fill: r,
|
|
2018
2151
|
fillOpacity: .15,
|
|
@@ -2027,19 +2160,19 @@ function Ce({ axes: e, series: t, max: r, title: i, description: c, width: l, he
|
|
|
2027
2160
|
}
|
|
2028
2161
|
//#endregion
|
|
2029
2162
|
//#region src/charts/bullet/bullet.tsx
|
|
2030
|
-
var
|
|
2163
|
+
var De = [
|
|
2031
2164
|
"var(--cascivo-color-neutral-200)",
|
|
2032
2165
|
"var(--cascivo-color-neutral-300)",
|
|
2033
2166
|
"var(--cascivo-color-neutral-400)"
|
|
2034
2167
|
];
|
|
2035
|
-
function
|
|
2168
|
+
function Oe({ value: e, target: t, ranges: r, label: i, min: a = 0, max: o, width: d = 300, height: f = 40, className: p }) {
|
|
2036
2169
|
n();
|
|
2037
|
-
let m = [...r].sort((e, t) => e - t), h = u([
|
|
2038
|
-
return /* @__PURE__ */
|
|
2170
|
+
let m = [...r].sort((e, t) => e - t), h = u([a, o ?? m[m.length - 1] ?? (Math.max(e, t) * 1.2 || 1)], [0, d]), g = f * .35, _ = (f - g) / 2, v = f * .7, y = (f - v) / 2;
|
|
2171
|
+
return /* @__PURE__ */ l("figure", {
|
|
2039
2172
|
className: p,
|
|
2040
2173
|
"aria-label": `${i}: value ${e}, target ${t}`,
|
|
2041
2174
|
style: { margin: 0 },
|
|
2042
|
-
children: [/* @__PURE__ */
|
|
2175
|
+
children: [/* @__PURE__ */ c(z, {
|
|
2043
2176
|
title: `${i} bullet chart`,
|
|
2044
2177
|
width: d,
|
|
2045
2178
|
height: f,
|
|
@@ -2051,26 +2184,26 @@ function Te({ value: e, target: t, ranges: r, label: i, min: c = 0, max: l, widt
|
|
|
2051
2184
|
label: i,
|
|
2052
2185
|
value: e
|
|
2053
2186
|
}] },
|
|
2054
|
-
children: () => /* @__PURE__ */ s
|
|
2187
|
+
children: () => /* @__PURE__ */ l(s, { children: [
|
|
2055
2188
|
m.map((e, t) => {
|
|
2056
|
-
let n = t === 0 ?
|
|
2057
|
-
return /* @__PURE__ */
|
|
2189
|
+
let n = t === 0 ? a : m[t - 1] ?? a, r = h.map(e) - h.map(n);
|
|
2190
|
+
return /* @__PURE__ */ c("rect", {
|
|
2058
2191
|
x: h.map(n),
|
|
2059
2192
|
y: 0,
|
|
2060
2193
|
width: Math.max(0, r),
|
|
2061
2194
|
height: f,
|
|
2062
|
-
fill:
|
|
2195
|
+
fill: De[t % De.length] ?? "var(--cascivo-color-neutral-200)"
|
|
2063
2196
|
}, t);
|
|
2064
2197
|
}),
|
|
2065
|
-
/* @__PURE__ */
|
|
2066
|
-
x: h.map(
|
|
2198
|
+
/* @__PURE__ */ c("rect", {
|
|
2199
|
+
x: h.map(a),
|
|
2067
2200
|
y: _,
|
|
2068
|
-
width: Math.max(0, h.map(e) - h.map(
|
|
2201
|
+
width: Math.max(0, h.map(e) - h.map(a)),
|
|
2069
2202
|
height: g,
|
|
2070
2203
|
fill: "var(--cascivo-chart-1)",
|
|
2071
2204
|
"aria-label": `Value: ${e}`
|
|
2072
2205
|
}),
|
|
2073
|
-
/* @__PURE__ */
|
|
2206
|
+
/* @__PURE__ */ c("line", {
|
|
2074
2207
|
x1: h.map(t),
|
|
2075
2208
|
y1: y,
|
|
2076
2209
|
x2: h.map(t),
|
|
@@ -2080,11 +2213,11 @@ function Te({ value: e, target: t, ranges: r, label: i, min: c = 0, max: l, widt
|
|
|
2080
2213
|
"aria-label": `Target: ${t}`
|
|
2081
2214
|
})
|
|
2082
2215
|
] })
|
|
2083
|
-
}), /* @__PURE__ */
|
|
2216
|
+
}), /* @__PURE__ */ c("figcaption", {
|
|
2084
2217
|
style: { fontSize: 12 },
|
|
2085
2218
|
children: i
|
|
2086
2219
|
})]
|
|
2087
2220
|
});
|
|
2088
2221
|
}
|
|
2089
2222
|
//#endregion
|
|
2090
|
-
export { oe as AreaChart,
|
|
2223
|
+
export { oe as AreaChart, B as Axis, ce as BarChart, ge as Boxplot, ye as BubbleChart, Oe as Bullet, z as ChartFrame, be as ComboChart, F as DEFAULT_MARGINS, V as GridLines, xe as Heatmap, he as Histogram, me as Kpi, U as Legend, ae as LineChart, pe as Meter, I as PLAIN_MARGINS, ue as PieChart, Ee as Radar, de as ScatterChart, Y as Sparkline, Se as Treemap, S as arcPath, x as areaPath, f as bandScale, D as binValues, O as boxStats, k as extent, y as linePath, u as linearScale, m as logScale, T as nearestIndex, d as niceTicks, p as sqrtScale, N as squarify, C as stackSeries, v as timeScale, w as toStackedSeries, P as useChartSize };
|