@cascivo/charts 0.3.4 → 0.3.8
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 +1 -1
- package/README.md +1 -1
- package/dist/index.d.ts +20 -2
- package/dist/index.js +951 -861
- package/package.json +3 -3
- package/readme.body.md +1 -1
package/dist/index.js
CHANGED
|
@@ -172,15 +172,15 @@ function w(e, t = "linear") {
|
|
|
172
172
|
if (e.length === 0) return "";
|
|
173
173
|
if (e.length === 1 || t === "linear") return e.map(([e, t], n) => `${n === 0 ? "M" : "L"}${e},${t}`).join("");
|
|
174
174
|
switch (t) {
|
|
175
|
-
case "monotone": return
|
|
175
|
+
case "monotone": return j(e);
|
|
176
176
|
case "step":
|
|
177
177
|
case "stepBefore":
|
|
178
178
|
case "stepAfter": return T(e, t);
|
|
179
|
-
case "natural": return
|
|
180
|
-
case "basis": return
|
|
181
|
-
case "cardinal": return
|
|
182
|
-
case "catmullRom": return
|
|
183
|
-
default: return
|
|
179
|
+
case "natural": return D(e);
|
|
180
|
+
case "basis": return O(e);
|
|
181
|
+
case "cardinal": return k(e, 0);
|
|
182
|
+
case "catmullRom": return A(e, .5);
|
|
183
|
+
default: return j(e);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
function T(e, t) {
|
|
@@ -213,14 +213,14 @@ function E(e) {
|
|
|
213
213
|
for (let n = 0; n < t - 1; n++) o[n] = 2 * e[n + 1] - a[n + 1];
|
|
214
214
|
return o[t - 1] = (e[t] + a[t - 1]) / 2, [a, o];
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function D(e) {
|
|
217
217
|
let t = e.length;
|
|
218
218
|
if (t < 3) return e.map(([e, t], n) => `${n === 0 ? "M" : "L"}${e},${t}`).join("");
|
|
219
219
|
let n = e.map((e) => e[0]), r = e.map((e) => e[1]), [i, a] = E(n), [o, s] = E(r), c = `M${n[0]},${r[0]}`;
|
|
220
220
|
for (let e = 0; e < t - 1; e++) c += `C${i[e]},${o[e]} ${a[e]},${s[e]} ${n[e + 1]},${r[e + 1]}`;
|
|
221
221
|
return c;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function O(e) {
|
|
224
224
|
let t = e.length;
|
|
225
225
|
if (t < 3) return e.map(([e, t], n) => `${n === 0 ? "M" : "L"}${e},${t}`).join("");
|
|
226
226
|
let n = (n) => e[Math.max(0, Math.min(t - 1, n))][0], r = (n) => e[Math.max(0, Math.min(t - 1, n))][1], i = `M${n(0)},${r(0)}`;
|
|
@@ -231,7 +231,7 @@ function D(e) {
|
|
|
231
231
|
let a = e[t - 1];
|
|
232
232
|
return i += `L${a[0]},${a[1]}`, i;
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function k(e, t) {
|
|
235
235
|
let n = e.length;
|
|
236
236
|
if (n < 3) return e.map(([e, t], n) => `${n === 0 ? "M" : "L"}${e},${t}`).join("");
|
|
237
237
|
let r = (1 - t) / 6, i = (t) => e[Math.max(0, Math.min(n - 1, t))], a = `M${e[0][0]},${e[0][1]}`;
|
|
@@ -241,7 +241,7 @@ function O(e, t) {
|
|
|
241
241
|
}
|
|
242
242
|
return a;
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function A(e, t) {
|
|
245
245
|
let n = e.length;
|
|
246
246
|
if (n < 3) return e.map(([e, t], n) => `${n === 0 ? "M" : "L"}${e},${t}`).join("");
|
|
247
247
|
let r = (t) => e[Math.max(0, Math.min(n - 1, t))], i = (e, t) => Math.hypot(t[0] - e[0], t[1] - e[1]), a = `M${e[0][0]},${e[0][1]}`;
|
|
@@ -251,7 +251,7 @@ function k(e, t) {
|
|
|
251
251
|
}
|
|
252
252
|
return a;
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function j(e) {
|
|
255
255
|
let t = e.length, n = [], r = [], i = [];
|
|
256
256
|
for (let a = 0; a < t - 1; a++) n[a] = e[a + 1][0] - e[a][0], r[a] = e[a + 1][1] - e[a][1], i[a] = n[a] === 0 ? 0 : r[a] / n[a];
|
|
257
257
|
let a = [i[0] ?? 0];
|
|
@@ -267,23 +267,23 @@ function A(e) {
|
|
|
267
267
|
}
|
|
268
268
|
return o;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function M(e, t, n = "linear") {
|
|
271
271
|
if (e.length === 0) return "";
|
|
272
272
|
let r = w(e, n), i = e[e.length - 1], a = e[0];
|
|
273
273
|
return `${r}L${i[0]},${t}L${a[0]},${t}Z`;
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function N(e, t, n, r, i, a) {
|
|
276
276
|
let o = 2 * Math.PI;
|
|
277
277
|
if (Math.abs(a - i) >= o - 1e-9) {
|
|
278
278
|
let a = i + Math.PI;
|
|
279
|
-
return
|
|
279
|
+
return N(e, t, n, r, i, a) + N(e, t, n, r, a, i + o - 1e-9);
|
|
280
280
|
}
|
|
281
281
|
let s = (n, r) => [e + n * Math.sin(r), t - n * Math.cos(r)], c = +(a - i > Math.PI), [l, u] = s(n, i), [d, f] = s(n, a);
|
|
282
282
|
if (r <= 0) return `M${e},${t}L${l},${u}A${n},${n} 0 ${c} 1 ${d},${f}Z`;
|
|
283
283
|
let [p, m] = s(r, a), [h, g] = s(r, i);
|
|
284
284
|
return `M${l},${u}A${n},${n} 0 ${c} 1 ${d},${f}L${p},${m}A${r},${r} 0 ${c} 0 ${h},${g}Z`;
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function P(e) {
|
|
287
287
|
let t = e[0]?.length ?? 0, n = Array.from({ length: t }, () => 0);
|
|
288
288
|
return e.map((e) => e.map((e, t) => {
|
|
289
289
|
let r = n[t];
|
|
@@ -292,7 +292,7 @@ function ne(e) {
|
|
|
292
292
|
}
|
|
293
293
|
//#endregion
|
|
294
294
|
//#region src/engine/stacked.ts
|
|
295
|
-
function
|
|
295
|
+
function F(e) {
|
|
296
296
|
let t = [], n = /* @__PURE__ */ new Map();
|
|
297
297
|
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));
|
|
298
298
|
return {
|
|
@@ -314,7 +314,7 @@ function M(e) {
|
|
|
314
314
|
}
|
|
315
315
|
//#endregion
|
|
316
316
|
//#region src/engine/nearest.ts
|
|
317
|
-
function
|
|
317
|
+
function I(e, t) {
|
|
318
318
|
if (e.length === 0) return -1;
|
|
319
319
|
if (e.length === 1) return 0;
|
|
320
320
|
let n = 0, r = e.length - 1;
|
|
@@ -326,7 +326,7 @@ function N(e, t) {
|
|
|
326
326
|
}
|
|
327
327
|
//#endregion
|
|
328
328
|
//#region src/engine/voronoi.ts
|
|
329
|
-
function
|
|
329
|
+
function L(e, t, n) {
|
|
330
330
|
let r = -1, i = Infinity;
|
|
331
331
|
for (let a = 0; a < e.length; a++) {
|
|
332
332
|
let o = e[a][0] - t, s = e[a][1] - n, c = o * o + s * s;
|
|
@@ -334,7 +334,7 @@ function P(e, t, n) {
|
|
|
334
334
|
}
|
|
335
335
|
return r;
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function R(e, t, n, r, i) {
|
|
338
338
|
if (e.length === 0) return e;
|
|
339
339
|
let a = [], o = (e) => (e[0] - r) * t + (e[1] - i) * n;
|
|
340
340
|
for (let t = 0; t < e.length; t++) {
|
|
@@ -346,7 +346,7 @@ function F(e, t, n, r, i) {
|
|
|
346
346
|
}
|
|
347
347
|
return a;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function ee(e, t) {
|
|
350
350
|
let n = [
|
|
351
351
|
[t.x0, t.y0],
|
|
352
352
|
[t.x1, t.y0],
|
|
@@ -358,21 +358,21 @@ function I(e, t) {
|
|
|
358
358
|
for (let n = 0; n < e.length && i.length > 0; n++) {
|
|
359
359
|
if (n === r) continue;
|
|
360
360
|
let a = e[n];
|
|
361
|
-
i =
|
|
361
|
+
i = R(i, a[0] - t[0], a[1] - t[1], (t[0] + a[0]) / 2, (t[1] + a[1]) / 2);
|
|
362
362
|
}
|
|
363
363
|
return i;
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function z(e) {
|
|
367
367
|
return e.length === 0 ? "" : `M${e.map((e) => `${e[0]},${e[1]}`).join("L")}Z`;
|
|
368
368
|
}
|
|
369
369
|
//#endregion
|
|
370
370
|
//#region src/engine/stats.ts
|
|
371
|
-
function
|
|
371
|
+
function B(e) {
|
|
372
372
|
let t = e.length, n = e[Math.floor(t * .25)] ?? 0;
|
|
373
373
|
return (e[Math.floor(t * .75)] ?? 0) - n;
|
|
374
374
|
}
|
|
375
|
-
function
|
|
375
|
+
function V(e, t) {
|
|
376
376
|
if (e.length === 0) return [];
|
|
377
377
|
let n = [...e].sort((e, t) => e - t), r = n.length, i = n[0] ?? 0, a = n[r - 1] ?? 0;
|
|
378
378
|
if (i === a) return [{
|
|
@@ -383,7 +383,7 @@ function z(e, t) {
|
|
|
383
383
|
let o;
|
|
384
384
|
if (t !== void 0 && t > 0) o = t;
|
|
385
385
|
else {
|
|
386
|
-
let e = 2 *
|
|
386
|
+
let e = 2 * B(n) * r ** (-1 / 3);
|
|
387
387
|
o = Math.ceil(e > 0 ? (a - i) / e : Math.sqrt(r)), o = Math.max(1, Math.min(o, 200));
|
|
388
388
|
}
|
|
389
389
|
let s = (a - i) / o, c = Array.from({ length: o }, (e, t) => ({
|
|
@@ -397,7 +397,7 @@ function z(e, t) {
|
|
|
397
397
|
}
|
|
398
398
|
return c;
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function H(e) {
|
|
401
401
|
if (e.length === 0) return {
|
|
402
402
|
min: 0,
|
|
403
403
|
q1: 0,
|
|
@@ -419,7 +419,7 @@ function B(e) {
|
|
|
419
419
|
outliers: d
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function U(e) {
|
|
423
423
|
if (e.length === 0) return [0, 1];
|
|
424
424
|
let t = e[0] ?? 0, n = e[0] ?? 0;
|
|
425
425
|
for (let r of e) r < t && (t = r), r > n && (n = r);
|
|
@@ -427,11 +427,11 @@ function V(e) {
|
|
|
427
427
|
}
|
|
428
428
|
//#endregion
|
|
429
429
|
//#region src/engine/treemap.ts
|
|
430
|
-
function
|
|
430
|
+
function W(e, t, n) {
|
|
431
431
|
let r = Math.max(...e), i = Math.min(...e);
|
|
432
432
|
return Math.max(t * t * r / (n * n), n * n / (t * t * i));
|
|
433
433
|
}
|
|
434
|
-
function
|
|
434
|
+
function G(e, t, n, r, i, a, o) {
|
|
435
435
|
let s = e.reduce((e, t) => e + t, 0), c = t, l = n;
|
|
436
436
|
for (let t = 0; t < e.length; t++) {
|
|
437
437
|
let n = e[t] ?? 0, u = a[t] ?? "";
|
|
@@ -456,40 +456,40 @@ function U(e, t, n, r, i, a, o) {
|
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function K(e, t, n, r, i, a) {
|
|
460
460
|
if (e.length === 0 || r <= 0 || i <= 0) return;
|
|
461
461
|
let o = e.reduce((e, t) => e + t.value, 0);
|
|
462
462
|
if (o === 0) return;
|
|
463
463
|
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;
|
|
464
464
|
for (; m < c.length;) {
|
|
465
465
|
let o = c[m] ?? 0, h = l[m] ?? "", g = [...u, o], _ = p + o;
|
|
466
|
-
if (u.length === 0 ||
|
|
466
|
+
if (u.length === 0 || W(g, f, _) <= W(u, f, p)) u = g, d = [...d, h], p = _, m++;
|
|
467
467
|
else {
|
|
468
468
|
let o = p / s;
|
|
469
469
|
if (r >= i) {
|
|
470
470
|
let s = o * r;
|
|
471
|
-
|
|
471
|
+
G(u, t, n, s, i, d, a), K(e.slice(m), t + s, n, r - s, i, a);
|
|
472
472
|
} else {
|
|
473
473
|
let s = o * i;
|
|
474
|
-
|
|
474
|
+
G(u, t, n, r, s, d, a), K(e.slice(m), t, n + s, r, i - s, a);
|
|
475
475
|
}
|
|
476
476
|
return;
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
if (u.length > 0) {
|
|
480
480
|
let e = p / s;
|
|
481
|
-
r >= i ?
|
|
481
|
+
r >= i ? G(u, t, n, e * r, i, d, a) : G(u, t, n, r, e * i, d, a);
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
-
function
|
|
484
|
+
function q(e, t, n) {
|
|
485
485
|
if (e.length === 0 || t <= 0 || n <= 0) return [];
|
|
486
486
|
let r = [...e].sort((e, t) => t.value - e.value), i = [];
|
|
487
|
-
return
|
|
487
|
+
return K(r, 0, 0, t, n, i), i;
|
|
488
488
|
}
|
|
489
489
|
//#endregion
|
|
490
490
|
//#region src/engine/stream.ts
|
|
491
|
-
function
|
|
492
|
-
let n =
|
|
491
|
+
function J(e, t = "silhouette") {
|
|
492
|
+
let n = P(e);
|
|
493
493
|
if (t === "zero") return n;
|
|
494
494
|
let r = e[0]?.length ?? 0, i = Array.from({ length: r }, (t, n) => e.reduce((e, t) => e + (t[n] ?? 0), 0));
|
|
495
495
|
return n.map((e) => e.map(([e, t], n) => {
|
|
@@ -497,39 +497,39 @@ function K(e, t = "silhouette") {
|
|
|
497
497
|
return [e - r, t - r];
|
|
498
498
|
}));
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function te(e) {
|
|
501
501
|
let t = 0, n = 0;
|
|
502
502
|
for (let r of e) for (let [e, i] of r) t = Math.min(t, e, i), n = Math.max(n, e, i);
|
|
503
503
|
return [t, n];
|
|
504
504
|
}
|
|
505
505
|
//#endregion
|
|
506
506
|
//#region src/engine/hierarchy.ts
|
|
507
|
-
function
|
|
508
|
-
return e.children && e.children.length > 0 ? e.children.reduce((e, t) => e +
|
|
507
|
+
function Y(e) {
|
|
508
|
+
return e.children && e.children.length > 0 ? e.children.reduce((e, t) => e + Y(t), 0) : e.value ?? 0;
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function X(e, t = 2 * Math.PI) {
|
|
511
511
|
let n = [], r = (e, t, i, a) => {
|
|
512
512
|
if (n.push({
|
|
513
513
|
node: e,
|
|
514
514
|
depth: t,
|
|
515
515
|
a0: i,
|
|
516
516
|
a1: a,
|
|
517
|
-
value:
|
|
517
|
+
value: Y(e)
|
|
518
518
|
}), !e.children) return;
|
|
519
|
-
let o = a - i, s =
|
|
519
|
+
let o = a - i, s = Y(e) || 1, c = i;
|
|
520
520
|
for (let n of e.children) {
|
|
521
|
-
let e = c + o *
|
|
521
|
+
let e = c + o * Y(n) / s;
|
|
522
522
|
r(n, t + 1, c, e), c = e;
|
|
523
523
|
}
|
|
524
524
|
};
|
|
525
525
|
return r(e, 0, 0, t), n;
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function ne(e) {
|
|
528
528
|
return e.reduce((e, t) => Math.max(e, t.depth), 0);
|
|
529
529
|
}
|
|
530
530
|
//#endregion
|
|
531
531
|
//#region src/engine/sankey.ts
|
|
532
|
-
function
|
|
532
|
+
function Z(e, t, { width: n, height: r, nodeWidth: i = 16, nodePadding: a = 12 }) {
|
|
533
533
|
let o = /* @__PURE__ */ new Map();
|
|
534
534
|
for (let t of e) o.set(t.id, {
|
|
535
535
|
...t,
|
|
@@ -583,61 +583,61 @@ function Y(e, t, { width: n, height: r, nodeWidth: i = 16, nodePadding: a = 12 }
|
|
|
583
583
|
links: v
|
|
584
584
|
};
|
|
585
585
|
}
|
|
586
|
-
function
|
|
586
|
+
function re(e) {
|
|
587
587
|
let t = e.source.x1, n = e.target.x0, r = (t + n) / 2, i = e.sy, a = e.sy + e.width, o = e.ty, s = e.ty + e.width;
|
|
588
588
|
return `M${t},${i}C${r},${i} ${r},${o} ${n},${o}L${n},${s}C${r},${s} ${r},${a} ${t},${a}Z`;
|
|
589
589
|
}
|
|
590
590
|
//#endregion
|
|
591
591
|
//#region src/engine/ramp.ts
|
|
592
|
-
var
|
|
593
|
-
l:
|
|
594
|
-
c:
|
|
595
|
-
h:
|
|
596
|
-
}),
|
|
592
|
+
var ie = (e) => e < 0 ? 0 : e > 1 ? 1 : e, ae = (e, t, n) => e + (t - e) * n, oe = (e, t, n) => ({
|
|
593
|
+
l: ae(e.l, t.l, n),
|
|
594
|
+
c: ae(e.c, t.c, n),
|
|
595
|
+
h: ae(e.h, t.h, n)
|
|
596
|
+
}), se = ({ l: e, c: t, h: n }) => `oklch(${e.toFixed(4)} ${t.toFixed(4)} ${n.toFixed(2)})`, ce = {
|
|
597
597
|
l: .95,
|
|
598
598
|
c: .04,
|
|
599
599
|
h: 232
|
|
600
|
-
},
|
|
600
|
+
}, le = {
|
|
601
601
|
l: .34,
|
|
602
602
|
c: .15,
|
|
603
603
|
h: 274
|
|
604
|
-
},
|
|
604
|
+
}, ue = {
|
|
605
605
|
l: .48,
|
|
606
606
|
c: .14,
|
|
607
607
|
h: 248
|
|
608
|
-
},
|
|
608
|
+
}, de = {
|
|
609
609
|
l: .96,
|
|
610
610
|
c: .02,
|
|
611
611
|
h: 110
|
|
612
|
-
},
|
|
612
|
+
}, fe = {
|
|
613
613
|
l: .52,
|
|
614
614
|
c: .15,
|
|
615
615
|
h: 42
|
|
616
616
|
};
|
|
617
|
-
function
|
|
618
|
-
return
|
|
617
|
+
function pe(e) {
|
|
618
|
+
return se(oe(ce, le, ie(e)));
|
|
619
619
|
}
|
|
620
|
-
function
|
|
621
|
-
let t =
|
|
622
|
-
return
|
|
620
|
+
function me(e) {
|
|
621
|
+
let t = ie(e);
|
|
622
|
+
return se(t < .5 ? oe(ue, de, t * 2) : oe(de, fe, (t - .5) * 2));
|
|
623
623
|
}
|
|
624
|
-
function
|
|
625
|
-
return e === "diverging" ?
|
|
624
|
+
function he(e) {
|
|
625
|
+
return e === "diverging" ? me : pe;
|
|
626
626
|
}
|
|
627
|
-
function
|
|
628
|
-
let n =
|
|
627
|
+
function ge(e, t = "sequential") {
|
|
628
|
+
let n = he(t);
|
|
629
629
|
return e <= 1 ? [n(0)] : Array.from({ length: e }, (t, r) => n(r / (e - 1)));
|
|
630
630
|
}
|
|
631
|
-
function
|
|
631
|
+
function _e(e) {
|
|
632
632
|
let t = /oklch\(([\d.]+)/.exec(e);
|
|
633
633
|
return t ? Number(t[1]) : NaN;
|
|
634
634
|
}
|
|
635
635
|
//#endregion
|
|
636
636
|
//#region src/engine/polar.ts
|
|
637
|
-
function
|
|
637
|
+
function ve(e, t, n, r) {
|
|
638
638
|
return [e + n * Math.sin(r), t - n * Math.cos(r)];
|
|
639
639
|
}
|
|
640
|
-
function
|
|
640
|
+
function ye(e, t = [0, 2 * Math.PI]) {
|
|
641
641
|
let n = Math.max(1, e.length), r = (t[1] - t[0]) / n, i = new Map(e.map((e, t) => [e, t])), a = (e) => {
|
|
642
642
|
let n = i.get(e);
|
|
643
643
|
return n === void 0 ? void 0 : t[0] + n * r;
|
|
@@ -652,25 +652,25 @@ function xe(e, t = [0, 2 * Math.PI]) {
|
|
|
652
652
|
step: r
|
|
653
653
|
};
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function be(e, t) {
|
|
656
656
|
return m(e, t);
|
|
657
657
|
}
|
|
658
658
|
//#endregion
|
|
659
659
|
//#region src/engine/transform.ts
|
|
660
|
-
function
|
|
660
|
+
function xe(e, t) {
|
|
661
661
|
return e.filter((e, n) => t(e, n));
|
|
662
662
|
}
|
|
663
|
-
function
|
|
663
|
+
function Se(e, t) {
|
|
664
664
|
return e == null && t == null ? 0 : e == null ? -1 : t == null ? 1 : e instanceof Date && t instanceof Date ? e.getTime() - t.getTime() : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t));
|
|
665
665
|
}
|
|
666
|
-
function
|
|
666
|
+
function Ce(e, t, n = "asc") {
|
|
667
667
|
let r = typeof t == "function" ? t : (e) => e[t], i = n === "desc" ? -1 : 1;
|
|
668
668
|
return e.map((e, t) => ({
|
|
669
669
|
row: e,
|
|
670
670
|
i: t
|
|
671
|
-
})).sort((e, t) =>
|
|
671
|
+
})).sort((e, t) => Se(r(e.row), r(t.row)) * i || e.i - t.i).map((e) => e.row);
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function we(e, t) {
|
|
674
674
|
if (e === "count") return t.length;
|
|
675
675
|
if (t.length === 0) return 0;
|
|
676
676
|
switch (e) {
|
|
@@ -684,7 +684,7 @@ function Ee(e, t) {
|
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
|
-
function
|
|
687
|
+
function Te(e, t) {
|
|
688
688
|
let n = typeof t.groupBy == "string" ? [t.groupBy] : t.groupBy, r = /* @__PURE__ */ new Map(), i = [];
|
|
689
689
|
for (let t of e) {
|
|
690
690
|
let e = n.map((e) => String(t[e])).join("\0"), a = r.get(e);
|
|
@@ -693,11 +693,11 @@ function De(e, t) {
|
|
|
693
693
|
return i.map((e) => {
|
|
694
694
|
let i = r.get(e), a = {};
|
|
695
695
|
for (let e of n) a[e] = i[0][e];
|
|
696
|
-
for (let [e, n] of Object.entries(t.ops)) a[e] =
|
|
696
|
+
for (let [e, n] of Object.entries(t.ops)) a[e] = we(n, i.map((t) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)));
|
|
697
697
|
return a;
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function Ee(e, t = {}) {
|
|
701
701
|
let n = e.filter((e) => Number.isFinite(e)), [r, i] = t.range ?? [Math.min(...n), Math.max(...n)], a = Math.max(1, t.bins ?? (Math.ceil(Math.sqrt(n.length)) || 1)), o = (i - r) / a || 1, s = Array.from({ length: a }, (e, t) => ({
|
|
702
702
|
x0: r + t * o,
|
|
703
703
|
x1: r + (t + 1) * o,
|
|
@@ -711,7 +711,7 @@ function Oe(e, t = {}) {
|
|
|
711
711
|
}
|
|
712
712
|
return s;
|
|
713
713
|
}
|
|
714
|
-
function
|
|
714
|
+
function De(e, t) {
|
|
715
715
|
let n = t.length, r = e.map((e, n) => [...e, t[n]]);
|
|
716
716
|
for (let e = 0; e < n; e++) {
|
|
717
717
|
let t = e;
|
|
@@ -729,12 +729,12 @@ function ke(e, t) {
|
|
|
729
729
|
return Math.abs(i) < 1e-12 ? 0 : r[t][n] / i;
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
|
-
function
|
|
732
|
+
function Oe(e, t) {
|
|
733
733
|
let n = e.map((e) => e[1]), r = n.reduce((e, t) => e + t, 0) / n.length, i = 0, a = 0;
|
|
734
734
|
for (let [n, o] of e) i += (o - t(n)) ** 2, a += (o - r) ** 2;
|
|
735
735
|
return a === 0 ? 1 : 1 - i / a;
|
|
736
736
|
}
|
|
737
|
-
function
|
|
737
|
+
function ke(e, t = {}) {
|
|
738
738
|
let n = t.type ?? "linear", r = [...e].sort((e, t) => e[0] - t[0]), i = r.map((e) => e[0]), a = () => {
|
|
739
739
|
let e = r.length ? r.reduce((e, t) => e + t[1], 0) / r.length : 0;
|
|
740
740
|
return {
|
|
@@ -748,11 +748,11 @@ function je(e, t = {}) {
|
|
|
748
748
|
if (n === "exponential") {
|
|
749
749
|
let e = r.filter((e) => e[1] > 0);
|
|
750
750
|
if (e.length < 2) return a();
|
|
751
|
-
let t =
|
|
751
|
+
let t = ke(e.map((e) => [e[0], Math.log(e[1])]), { type: "linear" }), n = Math.exp(t.coefficients[0]), o = t.coefficients[1], s = (e) => n * Math.exp(o * e);
|
|
752
752
|
return {
|
|
753
753
|
predict: s,
|
|
754
754
|
points: i.map((e) => [e, s(e)]),
|
|
755
|
-
r2:
|
|
755
|
+
r2: Oe(r, s),
|
|
756
756
|
coefficients: [n, o]
|
|
757
757
|
};
|
|
758
758
|
}
|
|
@@ -764,18 +764,18 @@ function je(e, t = {}) {
|
|
|
764
764
|
for (let t = 0; t < o; t++) s[e][t] += n[e] * n[t];
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
|
-
let l =
|
|
767
|
+
let l = De(s, c), u = (e) => l.reduce((t, n, r) => t + n * e ** r, 0);
|
|
768
768
|
return {
|
|
769
769
|
predict: u,
|
|
770
770
|
points: i.map((e) => [e, u(e)]),
|
|
771
|
-
r2:
|
|
771
|
+
r2: Oe(r, u),
|
|
772
772
|
coefficients: l
|
|
773
773
|
};
|
|
774
774
|
}
|
|
775
775
|
//#endregion
|
|
776
776
|
//#region src/engine/dataset.ts
|
|
777
|
-
var
|
|
778
|
-
function
|
|
777
|
+
var Ae = (e) => typeof e == "number" ? e : Number(e);
|
|
778
|
+
function je(e, t) {
|
|
779
779
|
let n = (e) => e.x, r = (e) => e.y;
|
|
780
780
|
if (!t.series) return {
|
|
781
781
|
series: [{
|
|
@@ -783,7 +783,7 @@ function Ne(e, t) {
|
|
|
783
783
|
label: t.label ?? t.y,
|
|
784
784
|
data: e.map((e) => ({
|
|
785
785
|
x: e[t.x],
|
|
786
|
-
y:
|
|
786
|
+
y: Ae(e[t.y])
|
|
787
787
|
}))
|
|
788
788
|
}],
|
|
789
789
|
x: n,
|
|
@@ -798,7 +798,7 @@ function Ne(e, t) {
|
|
|
798
798
|
data: []
|
|
799
799
|
}, i.set(e, r), a.push(e)), r.data.push({
|
|
800
800
|
x: n[t.x],
|
|
801
|
-
y:
|
|
801
|
+
y: Ae(n[t.y])
|
|
802
802
|
});
|
|
803
803
|
}
|
|
804
804
|
return {
|
|
@@ -807,15 +807,15 @@ function Ne(e, t) {
|
|
|
807
807
|
y: r
|
|
808
808
|
};
|
|
809
809
|
}
|
|
810
|
-
function
|
|
810
|
+
function Me(e, t) {
|
|
811
811
|
return e.map((e) => ({
|
|
812
812
|
label: String(e[t.category]),
|
|
813
|
-
value:
|
|
813
|
+
value: Ae(e[t.value])
|
|
814
814
|
}));
|
|
815
815
|
}
|
|
816
816
|
//#endregion
|
|
817
817
|
//#region src/engine/decimate.ts
|
|
818
|
-
function
|
|
818
|
+
function Ne(e, t) {
|
|
819
819
|
let n = e.length;
|
|
820
820
|
if (t >= n || t < 3) return e.slice();
|
|
821
821
|
let r = [e[0]], i = (n - 2) / (t - 2), a = 0;
|
|
@@ -832,7 +832,7 @@ function Fe(e, t) {
|
|
|
832
832
|
}
|
|
833
833
|
return r.push(e[n - 1]), r;
|
|
834
834
|
}
|
|
835
|
-
function
|
|
835
|
+
function Pe(e, t) {
|
|
836
836
|
let n = e.length;
|
|
837
837
|
if (t >= n || t < 4) return e.slice();
|
|
838
838
|
let r = Math.max(1, Math.floor(t / 2)), i = n / r, a = [e[0]];
|
|
@@ -845,27 +845,27 @@ function Ie(e, t) {
|
|
|
845
845
|
}
|
|
846
846
|
return a.push(e[n - 1]), a;
|
|
847
847
|
}
|
|
848
|
-
function
|
|
849
|
-
return n === "minmax" ?
|
|
848
|
+
function Fe(e, t, n = "lttb") {
|
|
849
|
+
return n === "minmax" ? Pe(e, t) : Ne(e, t);
|
|
850
850
|
}
|
|
851
851
|
//#endregion
|
|
852
852
|
//#region src/stream/use-stream-series.ts
|
|
853
|
-
function
|
|
854
|
-
return e.length <= t.to ? e :
|
|
853
|
+
function Ie(e, t) {
|
|
854
|
+
return e.length <= t.to ? e : Fe(e.map((e, n) => [n, t.y(e)]), t.to, t.method).map(([t]) => e[t]);
|
|
855
855
|
}
|
|
856
|
-
function
|
|
856
|
+
function Le(e) {
|
|
857
857
|
let { capacity: n, source: i, decimate: o } = e, s = c(t({ capacity: n })).current, l = c(i);
|
|
858
858
|
return l.current = i, a(() => {
|
|
859
859
|
let e = l.current((e) => s.append(e));
|
|
860
860
|
return () => {
|
|
861
861
|
e(), s.dispose();
|
|
862
862
|
};
|
|
863
|
-
}), r(() => o ?
|
|
863
|
+
}), r(() => o ? Ie(s.signal.value, o) : s.signal.value);
|
|
864
864
|
}
|
|
865
|
-
function
|
|
865
|
+
function Re(n) {
|
|
866
866
|
let { capacity: r, source: i, decimate: a } = n, o = t({ capacity: r }), s = i((e) => o.append(e));
|
|
867
867
|
return {
|
|
868
|
-
signal: a ? e(() =>
|
|
868
|
+
signal: a ? e(() => Ie(o.signal.value, a)) : o.signal,
|
|
869
869
|
stop: () => {
|
|
870
870
|
s(), o.dispose();
|
|
871
871
|
}
|
|
@@ -873,7 +873,7 @@ function Be(n) {
|
|
|
873
873
|
}
|
|
874
874
|
//#endregion
|
|
875
875
|
//#region src/core/use-chart.ts
|
|
876
|
-
function
|
|
876
|
+
function ze(e = 400, t = 300) {
|
|
877
877
|
let n = c(null), r = i(e), o = i(t);
|
|
878
878
|
return a(() => {
|
|
879
879
|
let e = n.current;
|
|
@@ -896,12 +896,12 @@ function Ve(e = 400, t = 300) {
|
|
|
896
896
|
height: o
|
|
897
897
|
};
|
|
898
898
|
}
|
|
899
|
-
var
|
|
899
|
+
var Be = {
|
|
900
900
|
top: 8,
|
|
901
901
|
right: 8,
|
|
902
902
|
bottom: 24,
|
|
903
903
|
left: 36
|
|
904
|
-
},
|
|
904
|
+
}, Ve = {
|
|
905
905
|
top: 2,
|
|
906
906
|
right: 2,
|
|
907
907
|
bottom: 2,
|
|
@@ -1122,11 +1122,20 @@ function rt(e, t) {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
//#endregion
|
|
1124
1124
|
//#region src/core/chart-frame.tsx
|
|
1125
|
-
|
|
1125
|
+
var it = {
|
|
1126
|
+
position: "absolute",
|
|
1127
|
+
insetInlineStart: "-9999px",
|
|
1128
|
+
inlineSize: "1px",
|
|
1129
|
+
blockSize: "1px",
|
|
1130
|
+
overflow: "hidden",
|
|
1131
|
+
clipPath: "inset(50%)",
|
|
1132
|
+
whiteSpace: "nowrap"
|
|
1133
|
+
};
|
|
1134
|
+
function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, children: h, className: g, "data-state": _, emptyLabel: v, plain: y, tooltip: b, onSelect: x, hover: S = "rect", renderer: C = "svg", paint: w, zoom: T, toolbox: E, onRestore: D, transition: O, onBeforeDraw: k, onAfterDraw: A }) {
|
|
1126
1135
|
o();
|
|
1127
|
-
let
|
|
1136
|
+
let j = s(), M = `${j}-desc`, N = `${j}-live`, { ref: P, width: F, height: I } = ze(n ?? 400, r), R = i(null), ee = i(!1), z = c(null), B = c(null), V = c(null), H = c(null);
|
|
1128
1137
|
a(() => {
|
|
1129
|
-
let e =
|
|
1138
|
+
let e = H.current;
|
|
1130
1139
|
if (!e || !T) return;
|
|
1131
1140
|
let t = (t) => {
|
|
1132
1141
|
t.preventDefault();
|
|
@@ -1135,56 +1144,56 @@ function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, c
|
|
|
1135
1144
|
};
|
|
1136
1145
|
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
1137
1146
|
});
|
|
1138
|
-
let
|
|
1147
|
+
let U = () => {
|
|
1139
1148
|
T && (T.window.value = [0, Math.max(0, T.count - 1)]);
|
|
1140
|
-
},
|
|
1141
|
-
let t =
|
|
1149
|
+
}, W = n ?? F.value, G = r ?? I.value, K = E === !0 ? {} : E || null, q = () => B.current ? tt(B.current) : null, J = () => {
|
|
1150
|
+
let t = q();
|
|
1142
1151
|
t && rt(t, `${e || "chart"}.svg`);
|
|
1143
|
-
},
|
|
1144
|
-
let t =
|
|
1152
|
+
}, te = () => {
|
|
1153
|
+
let t = q();
|
|
1145
1154
|
t && nt(t, {
|
|
1146
|
-
width:
|
|
1147
|
-
height:
|
|
1155
|
+
width: W,
|
|
1156
|
+
height: G,
|
|
1148
1157
|
dpr: 2
|
|
1149
1158
|
}).then((t) => {
|
|
1150
1159
|
t && rt(t, `${e || "chart"}.png`);
|
|
1151
1160
|
});
|
|
1152
|
-
},
|
|
1153
|
-
|
|
1154
|
-
},
|
|
1155
|
-
width:
|
|
1156
|
-
height:
|
|
1161
|
+
}, Y = () => {
|
|
1162
|
+
U(), D?.();
|
|
1163
|
+
}, X = typeof b == "function" ? b({
|
|
1164
|
+
width: W,
|
|
1165
|
+
height: G
|
|
1157
1166
|
}) : b;
|
|
1158
1167
|
a(() => {
|
|
1159
|
-
let e =
|
|
1160
|
-
if (!
|
|
1161
|
-
let t = e === null ? void 0 :
|
|
1162
|
-
|
|
1168
|
+
let e = R.value;
|
|
1169
|
+
if (!X || !z.current) return;
|
|
1170
|
+
let t = e === null ? void 0 : X.points[e];
|
|
1171
|
+
z.current.textContent = t ? (X.format ?? Ue)(t) : "";
|
|
1163
1172
|
});
|
|
1164
|
-
let
|
|
1173
|
+
let ne = {
|
|
1165
1174
|
position: "absolute",
|
|
1166
1175
|
inset: 0,
|
|
1167
1176
|
cursor: T ? "grab" : x ? "pointer" : "crosshair",
|
|
1168
1177
|
background: "transparent",
|
|
1169
1178
|
touchAction: T ? "none" : void 0
|
|
1170
|
-
},
|
|
1171
|
-
if (
|
|
1172
|
-
let e =
|
|
1173
|
-
|
|
1179
|
+
}, Z = C === "canvas" && w !== void 0, re = X !== void 0 || T !== void 0, ie = {};
|
|
1180
|
+
if (O && typeof O == "object") {
|
|
1181
|
+
let e = ie;
|
|
1182
|
+
O.duration !== void 0 && (e["--cascivo-chart-anim-dur"] = `${O.duration}ms`), O.easing && (e["--cascivo-chart-anim-ease"] = O.easing), O.properties && (e["--cascivo-chart-anim-props"] = O.properties.join(", "));
|
|
1174
1183
|
}
|
|
1175
|
-
let
|
|
1176
|
-
...
|
|
1177
|
-
...
|
|
1184
|
+
let ae = re || Z || K || Object.keys(ie).length > 0 ? {
|
|
1185
|
+
...ie,
|
|
1186
|
+
...re || Z || K ? { position: "relative" } : {}
|
|
1178
1187
|
} : void 0;
|
|
1179
1188
|
return /* @__PURE__ */ p("div", {
|
|
1180
|
-
ref:
|
|
1189
|
+
ref: P,
|
|
1181
1190
|
className: [He.frame, g].filter(Boolean).join(" "),
|
|
1182
|
-
style:
|
|
1191
|
+
style: ae,
|
|
1183
1192
|
..._ !== void 0 && { "data-state": _ },
|
|
1184
1193
|
...y === !0 && { "data-plain": "" },
|
|
1185
|
-
...
|
|
1194
|
+
...O === !1 && { "data-no-anim": "" },
|
|
1186
1195
|
children: [
|
|
1187
|
-
|
|
1196
|
+
K && /* @__PURE__ */ f("div", {
|
|
1188
1197
|
style: {
|
|
1189
1198
|
position: "absolute",
|
|
1190
1199
|
top: 4,
|
|
@@ -1192,51 +1201,51 @@ function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, c
|
|
|
1192
1201
|
zIndex: 12
|
|
1193
1202
|
},
|
|
1194
1203
|
children: /* @__PURE__ */ f($e, {
|
|
1195
|
-
options:
|
|
1196
|
-
onPng:
|
|
1197
|
-
onSvg:
|
|
1204
|
+
options: K,
|
|
1205
|
+
onPng: te,
|
|
1206
|
+
onSvg: J,
|
|
1198
1207
|
onToggleData: () => {
|
|
1199
|
-
|
|
1208
|
+
ee.value = !ee.value;
|
|
1200
1209
|
},
|
|
1201
|
-
onRestore:
|
|
1202
|
-
showData:
|
|
1210
|
+
onRestore: Y,
|
|
1211
|
+
showData: ee.value
|
|
1203
1212
|
})
|
|
1204
1213
|
}),
|
|
1205
|
-
|
|
1214
|
+
Z && /* @__PURE__ */ f(Ke, {
|
|
1206
1215
|
size: () => ({
|
|
1207
|
-
width: n ??
|
|
1208
|
-
height: r ??
|
|
1216
|
+
width: n ?? F.value,
|
|
1217
|
+
height: r ?? I.value
|
|
1209
1218
|
}),
|
|
1210
1219
|
paint: w
|
|
1211
1220
|
}),
|
|
1212
1221
|
/* @__PURE__ */ p("svg", {
|
|
1213
|
-
ref:
|
|
1222
|
+
ref: B,
|
|
1214
1223
|
role: "img",
|
|
1215
1224
|
"aria-label": e,
|
|
1216
|
-
"aria-describedby": t ?
|
|
1217
|
-
width:
|
|
1218
|
-
height:
|
|
1219
|
-
viewBox: `0 0 ${
|
|
1225
|
+
"aria-describedby": t ? M : void 0,
|
|
1226
|
+
width: W,
|
|
1227
|
+
height: G,
|
|
1228
|
+
viewBox: `0 0 ${W} ${G}`,
|
|
1220
1229
|
children: [
|
|
1221
1230
|
t && /* @__PURE__ */ f("desc", {
|
|
1222
|
-
id:
|
|
1231
|
+
id: M,
|
|
1223
1232
|
children: t
|
|
1224
1233
|
}),
|
|
1225
|
-
|
|
1226
|
-
width:
|
|
1227
|
-
height:
|
|
1234
|
+
k?.({
|
|
1235
|
+
width: W,
|
|
1236
|
+
height: G
|
|
1228
1237
|
}),
|
|
1229
1238
|
h({
|
|
1230
|
-
width:
|
|
1231
|
-
height:
|
|
1239
|
+
width: W,
|
|
1240
|
+
height: G
|
|
1232
1241
|
}),
|
|
1233
|
-
|
|
1234
|
-
width:
|
|
1235
|
-
height:
|
|
1242
|
+
A?.({
|
|
1243
|
+
width: W,
|
|
1244
|
+
height: G
|
|
1236
1245
|
}),
|
|
1237
1246
|
_ === "empty" && /* @__PURE__ */ f("text", {
|
|
1238
|
-
x:
|
|
1239
|
-
y:
|
|
1247
|
+
x: W / 2,
|
|
1248
|
+
y: G / 2,
|
|
1240
1249
|
textAnchor: "middle",
|
|
1241
1250
|
dominantBaseline: "central",
|
|
1242
1251
|
fill: "var(--cascivo-color-foreground-muted)",
|
|
@@ -1248,18 +1257,19 @@ function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, c
|
|
|
1248
1257
|
}),
|
|
1249
1258
|
m && /* @__PURE__ */ f("div", {
|
|
1250
1259
|
className: He.fallback,
|
|
1260
|
+
style: it,
|
|
1251
1261
|
children: m
|
|
1252
1262
|
}),
|
|
1253
|
-
|
|
1263
|
+
K && ee.value && m && /* @__PURE__ */ f("div", {
|
|
1254
1264
|
"data-data-view": "",
|
|
1255
1265
|
style: { overflowX: "auto" },
|
|
1256
1266
|
children: m
|
|
1257
1267
|
}),
|
|
1258
|
-
|
|
1259
|
-
|
|
1268
|
+
re && /* @__PURE__ */ p(d, { children: [
|
|
1269
|
+
X !== void 0 && /* @__PURE__ */ p(d, { children: [
|
|
1260
1270
|
/* @__PURE__ */ f("span", {
|
|
1261
|
-
id:
|
|
1262
|
-
ref:
|
|
1271
|
+
id: N,
|
|
1272
|
+
ref: z,
|
|
1263
1273
|
"aria-live": "polite",
|
|
1264
1274
|
style: {
|
|
1265
1275
|
position: "absolute",
|
|
@@ -1273,21 +1283,21 @@ function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, c
|
|
|
1273
1283
|
border: 0
|
|
1274
1284
|
}
|
|
1275
1285
|
}),
|
|
1276
|
-
|
|
1286
|
+
X.mode === "axis" && R.value !== null && X.points[R.value] !== void 0 && /* @__PURE__ */ f("div", {
|
|
1277
1287
|
"aria-hidden": "true",
|
|
1278
1288
|
style: {
|
|
1279
1289
|
position: "absolute",
|
|
1280
|
-
left:
|
|
1290
|
+
left: X.points[R.value].cx,
|
|
1281
1291
|
top: 0,
|
|
1282
1292
|
width: 1,
|
|
1283
|
-
height:
|
|
1293
|
+
height: G,
|
|
1284
1294
|
background: "var(--cascivo-chart-grid, currentColor)",
|
|
1285
1295
|
pointerEvents: "none",
|
|
1286
1296
|
zIndex: 9
|
|
1287
1297
|
}
|
|
1288
1298
|
}),
|
|
1289
|
-
|
|
1290
|
-
let e =
|
|
1299
|
+
R.value !== null && X.points[R.value] !== void 0 && (() => {
|
|
1300
|
+
let e = X.points[R.value];
|
|
1291
1301
|
return /* @__PURE__ */ f("div", {
|
|
1292
1302
|
"aria-hidden": "true",
|
|
1293
1303
|
style: {
|
|
@@ -1304,14 +1314,14 @@ function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, c
|
|
|
1304
1314
|
}
|
|
1305
1315
|
});
|
|
1306
1316
|
})(),
|
|
1307
|
-
|
|
1308
|
-
point:
|
|
1309
|
-
model:
|
|
1317
|
+
R.value !== null && X.points[R.value] !== void 0 && /* @__PURE__ */ f(We, {
|
|
1318
|
+
point: X.points[R.value],
|
|
1319
|
+
model: X
|
|
1310
1320
|
})
|
|
1311
1321
|
] }),
|
|
1312
|
-
T && !
|
|
1322
|
+
T && !K && Ze(T.window.value, T.count) && /* @__PURE__ */ f("button", {
|
|
1313
1323
|
type: "button",
|
|
1314
|
-
onClick:
|
|
1324
|
+
onClick: U,
|
|
1315
1325
|
style: {
|
|
1316
1326
|
position: "absolute",
|
|
1317
1327
|
top: 4,
|
|
@@ -1329,32 +1339,32 @@ function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, c
|
|
|
1329
1339
|
children: u(l.charts.resetZoom)
|
|
1330
1340
|
}),
|
|
1331
1341
|
/* @__PURE__ */ f("div", {
|
|
1332
|
-
ref:
|
|
1342
|
+
ref: H,
|
|
1333
1343
|
role: "application",
|
|
1334
1344
|
"aria-label": T ? "Chart — arrow keys navigate points; + and - zoom, 0 resets, drag to pan" : "Chart data — use arrow keys to navigate points",
|
|
1335
1345
|
tabIndex: 0,
|
|
1336
|
-
style:
|
|
1346
|
+
style: ne,
|
|
1337
1347
|
onPointerDown: (e) => {
|
|
1338
|
-
T && (
|
|
1348
|
+
T && (V.current = {
|
|
1339
1349
|
x: e.clientX,
|
|
1340
1350
|
win: [...T.window.value]
|
|
1341
1351
|
}, e.currentTarget.setPointerCapture(e.pointerId));
|
|
1342
1352
|
},
|
|
1343
1353
|
onPointerMove: (e) => {
|
|
1344
|
-
if (T &&
|
|
1345
|
-
let t = e.currentTarget.getBoundingClientRect(), n =
|
|
1346
|
-
T.window.value = Xe(
|
|
1354
|
+
if (T && V.current && e.buttons === 1) {
|
|
1355
|
+
let t = e.currentTarget.getBoundingClientRect(), n = V.current.win[1] - V.current.win[0] + 1, r = e.clientX - V.current.x, i = t.width ? -(r / t.width) * n : 0;
|
|
1356
|
+
T.window.value = Xe(V.current.win, T.count, i);
|
|
1347
1357
|
return;
|
|
1348
1358
|
}
|
|
1349
|
-
if (!
|
|
1359
|
+
if (!X || !X.points.length) return;
|
|
1350
1360
|
let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
|
|
1351
|
-
|
|
1361
|
+
R.value = X.mode === "axis" ? Ge(X.points, n, r, "x") : S === "voronoi" ? L(X.points.map((e) => [e.cx, e.cy]), n, r) : Ge(X.points, n, r, "xy");
|
|
1352
1362
|
},
|
|
1353
1363
|
onPointerUp: () => {
|
|
1354
|
-
|
|
1364
|
+
V.current = null;
|
|
1355
1365
|
},
|
|
1356
1366
|
onPointerLeave: () => {
|
|
1357
|
-
|
|
1367
|
+
V.current = null, X && (R.value = null);
|
|
1358
1368
|
},
|
|
1359
1369
|
onKeyDown: (e) => {
|
|
1360
1370
|
if (T) {
|
|
@@ -1367,33 +1377,33 @@ function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, c
|
|
|
1367
1377
|
return;
|
|
1368
1378
|
}
|
|
1369
1379
|
if (e.key === "0") {
|
|
1370
|
-
e.preventDefault(),
|
|
1380
|
+
e.preventDefault(), U();
|
|
1371
1381
|
return;
|
|
1372
1382
|
}
|
|
1373
1383
|
}
|
|
1374
|
-
if (!
|
|
1375
|
-
let t =
|
|
1376
|
-
if (e.key === "ArrowRight" || e.key === "ArrowDown") e.preventDefault(),
|
|
1377
|
-
else if (e.key === "ArrowLeft" || e.key === "ArrowUp") e.preventDefault(),
|
|
1378
|
-
else if (e.key === "Home") e.preventDefault(),
|
|
1379
|
-
else if (e.key === "End") e.preventDefault(),
|
|
1380
|
-
else if (e.key === "Escape")
|
|
1384
|
+
if (!X || !X.points.length) return;
|
|
1385
|
+
let t = R.value;
|
|
1386
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown") e.preventDefault(), R.value = t === null ? 0 : Math.min(t + 1, X.points.length - 1);
|
|
1387
|
+
else if (e.key === "ArrowLeft" || e.key === "ArrowUp") e.preventDefault(), R.value = t === null ? X.points.length - 1 : Math.max(t - 1, 0);
|
|
1388
|
+
else if (e.key === "Home") e.preventDefault(), R.value = 0;
|
|
1389
|
+
else if (e.key === "End") e.preventDefault(), R.value = X.points.length - 1;
|
|
1390
|
+
else if (e.key === "Escape") R.value = null;
|
|
1381
1391
|
else if (x && (e.key === "Enter" || e.key === " ")) {
|
|
1382
1392
|
e.preventDefault();
|
|
1383
|
-
let t =
|
|
1393
|
+
let t = R.value, n = t === null ? void 0 : X.points[t];
|
|
1384
1394
|
n && x(n);
|
|
1385
1395
|
}
|
|
1386
1396
|
},
|
|
1387
1397
|
onClick: () => {
|
|
1388
|
-
if (!
|
|
1389
|
-
let e =
|
|
1398
|
+
if (!X) return;
|
|
1399
|
+
let e = R.value, t = e === null ? void 0 : X.points[e];
|
|
1390
1400
|
x && t && x(t);
|
|
1391
1401
|
},
|
|
1392
1402
|
onFocus: () => {
|
|
1393
|
-
|
|
1403
|
+
X && X.points.length > 0 && R.value === null && (R.value = 0);
|
|
1394
1404
|
},
|
|
1395
1405
|
onBlur: () => {
|
|
1396
|
-
|
|
1406
|
+
X && (R.value = null);
|
|
1397
1407
|
}
|
|
1398
1408
|
})
|
|
1399
1409
|
] })
|
|
@@ -1402,45 +1412,45 @@ function Q({ title: e, description: t, width: n, height: r = 300, fallback: m, c
|
|
|
1402
1412
|
}
|
|
1403
1413
|
//#endregion
|
|
1404
1414
|
//#region src/core/sync.ts
|
|
1405
|
-
var
|
|
1406
|
-
function
|
|
1407
|
-
let t =
|
|
1415
|
+
var at = /* @__PURE__ */ new Map();
|
|
1416
|
+
function ot(e) {
|
|
1417
|
+
let t = at.get(e);
|
|
1408
1418
|
return t || (t = {
|
|
1409
1419
|
group: {
|
|
1410
1420
|
window: n(null),
|
|
1411
1421
|
hoverX: n(null)
|
|
1412
1422
|
},
|
|
1413
1423
|
refs: 0
|
|
1414
|
-
},
|
|
1424
|
+
}, at.set(e, t)), t.refs++, t.group;
|
|
1415
1425
|
}
|
|
1416
|
-
function
|
|
1417
|
-
let t =
|
|
1418
|
-
t && (t.refs--, t.refs <= 0 &&
|
|
1426
|
+
function st(e) {
|
|
1427
|
+
let t = at.get(e);
|
|
1428
|
+
t && (t.refs--, t.refs <= 0 && at.delete(e));
|
|
1419
1429
|
}
|
|
1420
|
-
function
|
|
1421
|
-
return
|
|
1430
|
+
function ct() {
|
|
1431
|
+
return at.size;
|
|
1422
1432
|
}
|
|
1423
1433
|
//#endregion
|
|
1424
1434
|
//#region src/chrome/axis.tsx
|
|
1425
|
-
function
|
|
1435
|
+
function lt(e) {
|
|
1426
1436
|
return "bandwidth" in e;
|
|
1427
1437
|
}
|
|
1428
|
-
function
|
|
1438
|
+
function ut(e) {
|
|
1429
1439
|
return "tickInterval" in e;
|
|
1430
1440
|
}
|
|
1431
|
-
function
|
|
1441
|
+
function dt(e) {
|
|
1432
1442
|
return e instanceof Date ? e.toLocaleDateString() : typeof e == "number" ? e.toLocaleString() : String(e);
|
|
1433
1443
|
}
|
|
1434
|
-
function $({ scale: e, orientation: t, length: n, format: r =
|
|
1444
|
+
function $({ scale: e, orientation: t, length: n, format: r = dt, tickCount: i = 5, labelEvery: a, transform: o }) {
|
|
1435
1445
|
let s;
|
|
1436
|
-
if (
|
|
1446
|
+
if (lt(e)) {
|
|
1437
1447
|
let t = e.domain.length - 1;
|
|
1438
1448
|
s = e.domain.map((t, n) => ({
|
|
1439
1449
|
position: (e.map(t) ?? 0) + e.bandwidth / 2,
|
|
1440
1450
|
label: r(t),
|
|
1441
1451
|
i: n
|
|
1442
1452
|
})).filter(({ i: e }) => a != null && a > 1 ? e % a === 0 || e === t : !0);
|
|
1443
|
-
} else if (
|
|
1453
|
+
} else if (ut(e)) s = e.ticks(i).map((t) => ({
|
|
1444
1454
|
position: e.map(t),
|
|
1445
1455
|
label: r(t)
|
|
1446
1456
|
}));
|
|
@@ -1484,7 +1494,7 @@ function $({ scale: e, orientation: t, length: n, format: r = ut, tickCount: i =
|
|
|
1484
1494
|
}
|
|
1485
1495
|
//#endregion
|
|
1486
1496
|
//#region src/chrome/grid-lines.tsx
|
|
1487
|
-
function
|
|
1497
|
+
function ft({ scale: e, orientation: t, length: n, tickCount: r = 5, transform: i }) {
|
|
1488
1498
|
let a = e.ticks(r), o = t === "x";
|
|
1489
1499
|
return /* @__PURE__ */ f("g", {
|
|
1490
1500
|
transform: i,
|
|
@@ -1505,17 +1515,17 @@ function dt({ scale: e, orientation: t, length: n, tickCount: r = 5, transform:
|
|
|
1505
1515
|
}
|
|
1506
1516
|
//#endregion
|
|
1507
1517
|
//#region src/chrome/reference.tsx
|
|
1508
|
-
var
|
|
1509
|
-
function
|
|
1518
|
+
var pt = "var(--cascivo-color-foreground-muted)", mt = "var(--cascivo-color-accent)";
|
|
1519
|
+
function ht(e, t) {
|
|
1510
1520
|
let n = e.map(t);
|
|
1511
1521
|
if (!(n == null || Number.isNaN(n))) return e.bandwidth ? n + e.bandwidth / 2 : n;
|
|
1512
1522
|
}
|
|
1513
|
-
function
|
|
1523
|
+
function gt(e, t, n) {
|
|
1514
1524
|
let { xScale: r, yScale: i, innerW: a, innerH: o } = t;
|
|
1515
1525
|
if (e.kind === "line") {
|
|
1516
|
-
let t =
|
|
1526
|
+
let t = ht(e.axis === "x" ? r : i, e.value);
|
|
1517
1527
|
if (t == null) return null;
|
|
1518
|
-
let s = e.color ??
|
|
1528
|
+
let s = e.color ?? pt, c = e.dash !== !1, l = e.axis === "x";
|
|
1519
1529
|
return /* @__PURE__ */ p("g", {
|
|
1520
1530
|
"data-annotation": "line",
|
|
1521
1531
|
"aria-hidden": "true",
|
|
@@ -1546,9 +1556,9 @@ function ht(e, t, n) {
|
|
|
1546
1556
|
}, n);
|
|
1547
1557
|
}
|
|
1548
1558
|
if (e.kind === "area") {
|
|
1549
|
-
let t = e.axis === "x" ? r : i, s =
|
|
1559
|
+
let t = e.axis === "x" ? r : i, s = ht(t, e.from), c = ht(t, e.to);
|
|
1550
1560
|
if (s == null || c == null) return null;
|
|
1551
|
-
let l = e.color ??
|
|
1561
|
+
let l = e.color ?? mt, u = e.axis === "x", d = Math.min(s, c), p = Math.abs(c - s);
|
|
1552
1562
|
return /* @__PURE__ */ f("g", {
|
|
1553
1563
|
"data-annotation": "area",
|
|
1554
1564
|
"aria-hidden": "true",
|
|
@@ -1564,9 +1574,9 @@ function ht(e, t, n) {
|
|
|
1564
1574
|
}, n);
|
|
1565
1575
|
}
|
|
1566
1576
|
if (e.kind === "note") {
|
|
1567
|
-
let t =
|
|
1577
|
+
let t = ht(r, e.x), s = ht(i, e.y);
|
|
1568
1578
|
if (t == null || s == null) return null;
|
|
1569
|
-
let c = e.color ??
|
|
1579
|
+
let c = e.color ?? mt, l = e.dx ?? 24, u = e.dy ?? -24, d = Math.max(2, Math.min(a - 2, t + l)), m = Math.max(8, Math.min(o - 2, s + u));
|
|
1570
1580
|
return /* @__PURE__ */ p("g", {
|
|
1571
1581
|
"data-annotation": "note",
|
|
1572
1582
|
children: [
|
|
@@ -1602,7 +1612,7 @@ function ht(e, t, n) {
|
|
|
1602
1612
|
if (e.kind === "threshold") {
|
|
1603
1613
|
let t = i.map(e.value);
|
|
1604
1614
|
if (t == null || Number.isNaN(t)) return null;
|
|
1605
|
-
let r = e.color ??
|
|
1615
|
+
let r = e.color ?? mt, s = e.side === "above" ? 0 : t, c = e.side === "above" ? t : o - t;
|
|
1606
1616
|
return /* @__PURE__ */ f("g", {
|
|
1607
1617
|
"data-annotation": "threshold",
|
|
1608
1618
|
"aria-hidden": "true",
|
|
@@ -1617,9 +1627,9 @@ function ht(e, t, n) {
|
|
|
1617
1627
|
})
|
|
1618
1628
|
}, n);
|
|
1619
1629
|
}
|
|
1620
|
-
let s =
|
|
1630
|
+
let s = ht(r, e.x), c = ht(i, e.y);
|
|
1621
1631
|
if (s == null || c == null) return null;
|
|
1622
|
-
let l = e.color ??
|
|
1632
|
+
let l = e.color ?? mt;
|
|
1623
1633
|
return /* @__PURE__ */ p("g", {
|
|
1624
1634
|
"data-annotation": "dot",
|
|
1625
1635
|
"aria-hidden": "true",
|
|
@@ -1641,28 +1651,28 @@ function ht(e, t, n) {
|
|
|
1641
1651
|
})]
|
|
1642
1652
|
}, n);
|
|
1643
1653
|
}
|
|
1644
|
-
function
|
|
1654
|
+
function _t(e, t) {
|
|
1645
1655
|
return !e || e.length === 0 ? null : /* @__PURE__ */ f("g", {
|
|
1646
1656
|
"data-annotations": "",
|
|
1647
|
-
children: e.map((e, n) =>
|
|
1657
|
+
children: e.map((e, n) => gt(e, t, n))
|
|
1648
1658
|
});
|
|
1649
1659
|
}
|
|
1650
|
-
function
|
|
1660
|
+
function vt(e) {
|
|
1651
1661
|
return e.kind === "line" ? e.label ?? `${e.axis}=${String(e.value)}` : e.kind === "area" ? e.label ?? `${e.axis} ${String(e.from)}–${String(e.to)}` : e.kind === "threshold" ? e.label ?? `${e.side} ${e.value}` : e.kind === "note" ? e.label : e.label ?? `(${String(e.x)}, ${e.y})`;
|
|
1652
1662
|
}
|
|
1653
1663
|
//#endregion
|
|
1654
1664
|
//#region src/chrome/data-label.tsx
|
|
1655
|
-
var
|
|
1656
|
-
function
|
|
1665
|
+
var yt = (e) => e.toLocaleString();
|
|
1666
|
+
function bt(e) {
|
|
1657
1667
|
return e ? e === !0 ? {
|
|
1658
|
-
format:
|
|
1668
|
+
format: yt,
|
|
1659
1669
|
position: "auto"
|
|
1660
1670
|
} : {
|
|
1661
|
-
format: e.format ??
|
|
1671
|
+
format: e.format ?? yt,
|
|
1662
1672
|
position: e.position ?? "auto"
|
|
1663
1673
|
} : null;
|
|
1664
1674
|
}
|
|
1665
|
-
function
|
|
1675
|
+
function xt({ x: e, y: t, text: n, tone: r = "default", anchor: i = "middle" }) {
|
|
1666
1676
|
return /* @__PURE__ */ f("text", {
|
|
1667
1677
|
x: e,
|
|
1668
1678
|
y: t,
|
|
@@ -1678,21 +1688,21 @@ function bt({ x: e, y: t, text: n, tone: r = "default", anchor: i = "middle" })
|
|
|
1678
1688
|
}
|
|
1679
1689
|
//#endregion
|
|
1680
1690
|
//#region src/chrome/defs.tsx
|
|
1681
|
-
function
|
|
1691
|
+
function St(e) {
|
|
1682
1692
|
return e.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
1683
1693
|
}
|
|
1684
|
-
function St(e, t) {
|
|
1685
|
-
return `${xt(e)}-grad-${xt(t)}`;
|
|
1686
|
-
}
|
|
1687
1694
|
function Ct(e, t) {
|
|
1688
|
-
return `${
|
|
1695
|
+
return `${St(e)}-grad-${St(t)}`;
|
|
1689
1696
|
}
|
|
1690
|
-
function wt(e, t
|
|
1691
|
-
return
|
|
1697
|
+
function wt(e, t) {
|
|
1698
|
+
return `${St(e)}-pat-${St(t)}`;
|
|
1692
1699
|
}
|
|
1693
|
-
function Tt(
|
|
1700
|
+
function Tt(e, t, n, r) {
|
|
1701
|
+
return n === "gradient" ? `url(#${Ct(e, t)})` : n === "pattern" ? `url(#${wt(e, t)})` : r;
|
|
1702
|
+
}
|
|
1703
|
+
function Et({ prefix: e, series: t, fill: n, patternKind: r = "dots" }) {
|
|
1694
1704
|
return n === "solid" ? null : /* @__PURE__ */ f("defs", { children: t.map((t) => n === "gradient" ? /* @__PURE__ */ p("linearGradient", {
|
|
1695
|
-
id:
|
|
1705
|
+
id: Ct(e, t.id),
|
|
1696
1706
|
x1: "0",
|
|
1697
1707
|
y1: "0",
|
|
1698
1708
|
x2: "0",
|
|
@@ -1707,7 +1717,7 @@ function Tt({ prefix: e, series: t, fill: n, patternKind: r = "dots" }) {
|
|
|
1707
1717
|
stopOpacity: .1
|
|
1708
1718
|
})]
|
|
1709
1719
|
}, t.id) : /* @__PURE__ */ p("pattern", {
|
|
1710
|
-
id:
|
|
1720
|
+
id: wt(e, t.id),
|
|
1711
1721
|
patternUnits: "userSpaceOnUse",
|
|
1712
1722
|
width: 6,
|
|
1713
1723
|
height: 6,
|
|
@@ -1753,7 +1763,7 @@ function Tt({ prefix: e, series: t, fill: n, patternKind: r = "dots" }) {
|
|
|
1753
1763
|
}
|
|
1754
1764
|
//#endregion
|
|
1755
1765
|
//#region src/chrome/glyph.tsx
|
|
1756
|
-
function
|
|
1766
|
+
function Dt(e, t) {
|
|
1757
1767
|
let n = t / 2;
|
|
1758
1768
|
switch (e) {
|
|
1759
1769
|
case "square": return `M${-n},${-n}h${t}v${t}h${-t}Z`;
|
|
@@ -1774,7 +1784,7 @@ function Et(e, t) {
|
|
|
1774
1784
|
default: return "";
|
|
1775
1785
|
}
|
|
1776
1786
|
}
|
|
1777
|
-
function
|
|
1787
|
+
function Ot({ shape: e, x: t, y: n, size: r, color: i, opacity: a = .85, stroke: o, strokeWidth: s }) {
|
|
1778
1788
|
let c = {
|
|
1779
1789
|
fill: i,
|
|
1780
1790
|
fillOpacity: a,
|
|
@@ -1789,33 +1799,33 @@ function Dt({ shape: e, x: t, y: n, size: r, color: i, opacity: a = .85, stroke:
|
|
|
1789
1799
|
r: r / 2,
|
|
1790
1800
|
...c
|
|
1791
1801
|
}) : /* @__PURE__ */ f("path", {
|
|
1792
|
-
d:
|
|
1802
|
+
d: Dt(e, r),
|
|
1793
1803
|
transform: `translate(${t},${n})`,
|
|
1794
1804
|
...c
|
|
1795
1805
|
});
|
|
1796
1806
|
}
|
|
1797
1807
|
//#endregion
|
|
1798
1808
|
//#region src/chrome/text.tsx
|
|
1799
|
-
var
|
|
1800
|
-
function
|
|
1801
|
-
if (
|
|
1802
|
-
|
|
1803
|
-
let n =
|
|
1809
|
+
var kt;
|
|
1810
|
+
function At(e, t) {
|
|
1811
|
+
if (kt === void 0 && (kt = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), kt) {
|
|
1812
|
+
kt.font = `${t}px sans-serif`;
|
|
1813
|
+
let n = kt.measureText(e).width;
|
|
1804
1814
|
if (n > 0) return n;
|
|
1805
1815
|
}
|
|
1806
1816
|
return e.length * t * .55;
|
|
1807
1817
|
}
|
|
1808
|
-
function
|
|
1818
|
+
function jt(e, t, n) {
|
|
1809
1819
|
if (!t || t <= 0) return [e];
|
|
1810
1820
|
let r = e.split(/\s+/).filter(Boolean), i = [], a = "";
|
|
1811
1821
|
for (let e of r) {
|
|
1812
1822
|
let r = a ? `${a} ${e}` : e;
|
|
1813
|
-
a &&
|
|
1823
|
+
a && At(r, n) > t ? (i.push(a), a = e) : a = r;
|
|
1814
1824
|
}
|
|
1815
1825
|
return a && i.push(a), i.length ? i : [e];
|
|
1816
1826
|
}
|
|
1817
|
-
function
|
|
1818
|
-
let l = r ?
|
|
1827
|
+
function Mt({ x: e, y: t, children: n, width: r, fontSize: i = 12, anchor: a = "start", fill: o, lineHeight: s = 1.2, className: c }) {
|
|
1828
|
+
let l = r ? jt(n, r, i) : [n];
|
|
1819
1829
|
return /* @__PURE__ */ f("text", {
|
|
1820
1830
|
x: e,
|
|
1821
1831
|
y: t,
|
|
@@ -1832,7 +1842,7 @@ function jt({ x: e, y: t, children: n, width: r, fontSize: i = 12, anchor: a = "
|
|
|
1832
1842
|
}
|
|
1833
1843
|
//#endregion
|
|
1834
1844
|
//#region src/chrome/brush.tsx
|
|
1835
|
-
function
|
|
1845
|
+
function Nt({ count: e, height: t = 28, window: n, label: r = "Range" }) {
|
|
1836
1846
|
o();
|
|
1837
1847
|
let i = Math.max(1, e - 1), a = (e) => e / i * 100, [s, c] = n.value, l = t - 8, u = (t, r) => {
|
|
1838
1848
|
let i = Math.max(0, Math.min(e - 1, r)), [a, o] = n.value;
|
|
@@ -1903,7 +1913,7 @@ function Mt({ count: e, height: t = 28, window: n, label: r = "Range" }) {
|
|
|
1903
1913
|
}
|
|
1904
1914
|
//#endregion
|
|
1905
1915
|
//#region src/chrome/data-zoom.tsx
|
|
1906
|
-
function
|
|
1916
|
+
function Pt({ count: e, height: t = 28, window: n, label: r = "Range" }) {
|
|
1907
1917
|
o();
|
|
1908
1918
|
let a = Math.max(1, e - 1), s = (e) => e / a * 100, [c, l] = n.value, u = t - 8, d = i(0), m = (e, t) => {
|
|
1909
1919
|
let n = t.getBoundingClientRect();
|
|
@@ -1998,27 +2008,27 @@ function Nt({ count: e, height: t = 28, window: n, label: r = "Range" }) {
|
|
|
1998
2008
|
}
|
|
1999
2009
|
//#endregion
|
|
2000
2010
|
//#region src/chrome/visual-map.tsx
|
|
2001
|
-
var
|
|
2002
|
-
function zt(e, t) {
|
|
2003
|
-
let n = t.pieces ?? Pt;
|
|
2004
|
-
return Math.min(n - 1, Math.max(0, Math.floor(Rt(e, t) * n)));
|
|
2005
|
-
}
|
|
2011
|
+
var Ft = 5, It = [3, 14], Lt = (e) => e < 0 ? 0 : e > 1 ? 1 : e, Rt = (e, t, n) => e + (t - e) * n, zt = (e, t) => Lt((e - t.min) / (t.max - t.min || 1));
|
|
2006
2012
|
function Bt(e, t) {
|
|
2007
|
-
let n = t.
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2013
|
+
let n = t.pieces ?? Ft;
|
|
2014
|
+
return Math.min(n - 1, Math.max(0, Math.floor(zt(e, t) * n)));
|
|
2015
|
+
}
|
|
2016
|
+
function Vt(e, t) {
|
|
2017
|
+
let n = t.channel ?? "color", r = t.ramp ?? "sequential", i = zt(e, t), a = {};
|
|
2018
|
+
if ((n === "color" || n === "both") && (a.color = (t.mode ?? "continuous") === "piecewise" ? ge(t.pieces ?? Ft, r)[Bt(e, t)] : he(r)(i)), n === "size" || n === "both") {
|
|
2019
|
+
let [e, n] = t.sizeRange ?? It;
|
|
2020
|
+
a.size = Rt(e, n, i);
|
|
2011
2021
|
}
|
|
2012
2022
|
return a;
|
|
2013
2023
|
}
|
|
2014
|
-
function
|
|
2015
|
-
return (t.mode ?? "continuous") === "piecewise" ? !r?.has(
|
|
2024
|
+
function Ht(e, t, n, r) {
|
|
2025
|
+
return (t.mode ?? "continuous") === "piecewise" ? !r?.has(Bt(e, t)) : n ? e >= n[0] && e <= n[1] : !0;
|
|
2016
2026
|
}
|
|
2017
|
-
function
|
|
2027
|
+
function Ut({ options: e, range: t, hidden: n, label: r = "Value", format: i }) {
|
|
2018
2028
|
o();
|
|
2019
2029
|
let a = i ?? ((e) => String(Math.round(e)));
|
|
2020
2030
|
if ((e.mode ?? "continuous") === "piecewise") {
|
|
2021
|
-
let t = e.pieces ??
|
|
2031
|
+
let t = e.pieces ?? Ft, i = ge(t, e.ramp ?? "sequential"), o = (e.max - e.min) / t, s = n?.value ?? /* @__PURE__ */ new Set(), c = (e) => {
|
|
2022
2032
|
if (!n) return;
|
|
2023
2033
|
let t = new Set(n.value);
|
|
2024
2034
|
t.has(e) ? t.delete(e) : t.add(e), n.value = t;
|
|
@@ -2066,9 +2076,9 @@ function Ht({ options: e, range: t, hidden: n, label: r = "Value", format: i })
|
|
|
2066
2076
|
})
|
|
2067
2077
|
});
|
|
2068
2078
|
}
|
|
2069
|
-
let { min: s, max: c } = e, l = c - s || 1, u =
|
|
2079
|
+
let { min: s, max: c } = e, l = c - s || 1, u = ge(8, e.ramp ?? "sequential"), m = (e) => (e - s) / l * 100, h = t?.value[0] ?? s, g = t?.value[1] ?? c, _ = `vm-grad-${u.length}`, v = (e, t) => {
|
|
2070
2080
|
let n = t.getBoundingClientRect();
|
|
2071
|
-
return n.width === 0 ? s : s +
|
|
2081
|
+
return n.width === 0 ? s : s + Lt((e - n.left) / n.width) * l;
|
|
2072
2082
|
}, y = (e, n) => {
|
|
2073
2083
|
if (!t) return;
|
|
2074
2084
|
let r = Math.max(s, Math.min(c, n)), [i, a] = t.value;
|
|
@@ -2153,22 +2163,23 @@ function Ht({ options: e, range: t, hidden: n, label: r = "Value", format: i })
|
|
|
2153
2163
|
]
|
|
2154
2164
|
});
|
|
2155
2165
|
}
|
|
2156
|
-
var
|
|
2166
|
+
var Wt = {
|
|
2157
2167
|
legend: "_legend_zczeh_2",
|
|
2158
2168
|
item: "_item_zczeh_9",
|
|
2159
2169
|
swatch: "_swatch_zczeh_27"
|
|
2160
2170
|
};
|
|
2161
2171
|
//#endregion
|
|
2162
2172
|
//#region src/chrome/legend.tsx
|
|
2163
|
-
function
|
|
2173
|
+
function Gt({ series: e, hidden: t }) {
|
|
2164
2174
|
return o(), /* @__PURE__ */ f("div", {
|
|
2165
|
-
className:
|
|
2175
|
+
className: Wt.legend,
|
|
2176
|
+
role: "group",
|
|
2166
2177
|
"aria-label": "Chart legend",
|
|
2167
2178
|
children: e.map((e, n) => {
|
|
2168
2179
|
let r = t.value.has(e.id);
|
|
2169
2180
|
return /* @__PURE__ */ p("button", {
|
|
2170
2181
|
type: "button",
|
|
2171
|
-
className:
|
|
2182
|
+
className: Wt.item,
|
|
2172
2183
|
"data-state": r ? "off" : "on",
|
|
2173
2184
|
"aria-pressed": !r,
|
|
2174
2185
|
"aria-label": u(l.charts.legendToggle, { name: e.label }),
|
|
@@ -2177,7 +2188,7 @@ function Wt({ series: e, hidden: t }) {
|
|
|
2177
2188
|
r ? n.delete(e.id) : n.add(e.id), t.value = n;
|
|
2178
2189
|
},
|
|
2179
2190
|
children: [/* @__PURE__ */ f("span", {
|
|
2180
|
-
className:
|
|
2191
|
+
className: Wt.swatch,
|
|
2181
2192
|
style: { background: e.color || `var(--cascivo-chart-${n + 1})` },
|
|
2182
2193
|
"aria-hidden": "true"
|
|
2183
2194
|
}), e.label]
|
|
@@ -2186,40 +2197,54 @@ function Wt({ series: e, hidden: t }) {
|
|
|
2186
2197
|
});
|
|
2187
2198
|
}
|
|
2188
2199
|
//#endregion
|
|
2200
|
+
//#region src/core/dev-warn.ts
|
|
2201
|
+
function Kt() {
|
|
2202
|
+
return typeof process < "u" && process.env.NODE_ENV === "production";
|
|
2203
|
+
}
|
|
2204
|
+
var qt = /* @__PURE__ */ new Set();
|
|
2205
|
+
function Jt(e, t) {
|
|
2206
|
+
if (Kt() || qt.has(e)) return;
|
|
2207
|
+
let n = 0;
|
|
2208
|
+
for (let e of t()) Number.isFinite(e) || n++;
|
|
2209
|
+
n !== 0 && (qt.add(e), console.warn(`[cascivo charts] ${e}: ${n} non-finite value(s) (NaN/Infinity/null) in series data. These are dropped from the chart, which can make it look wrong — check your data source.`));
|
|
2210
|
+
}
|
|
2211
|
+
//#endregion
|
|
2189
2212
|
//#region src/charts/line-chart/line-chart.tsx
|
|
2190
|
-
var
|
|
2191
|
-
function
|
|
2213
|
+
var Yt = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
2214
|
+
function Xt(e) {
|
|
2192
2215
|
return [Math.min(0, ...e), Math.max(...e)];
|
|
2193
2216
|
}
|
|
2194
|
-
function
|
|
2217
|
+
function Zt({ series: e, x: t, y: n, title: r, description: s, curve: l = "monotone", width: u, height: h, xTicks: g = 5, yTicks: _ = 5, legend: v, tooltip: y, formatTooltip: b, className: x, plain: T, annotations: E, labels: D, connectNulls: O, onSelect: k, brush: A, dataZoom: j, zoom: M, syncId: N, tooltipMode: P, secondAxis: F, decimate: I, toolbox: L, transition: R, onBeforeDraw: ee, onAfterDraw: z }) {
|
|
2195
2218
|
o();
|
|
2196
|
-
let
|
|
2219
|
+
let B = i(/* @__PURE__ */ new Set()), V = T ? null : bt(D), H = I === !0 ? {
|
|
2197
2220
|
method: "lttb",
|
|
2198
2221
|
threshold: 1e3
|
|
2199
|
-
} :
|
|
2200
|
-
method:
|
|
2201
|
-
threshold:
|
|
2202
|
-
} : null,
|
|
2203
|
-
|
|
2204
|
-
|
|
2222
|
+
} : I ? {
|
|
2223
|
+
method: I.method ?? "lttb",
|
|
2224
|
+
threshold: I.threshold ?? 1e3
|
|
2225
|
+
} : null, U = e.reduce((e, t) => Math.max(e, t.data.length), 0), W = (A || j || M || N !== void 0) && U > 0, G = i([0, Math.max(0, U - 1)]), K = c(null);
|
|
2226
|
+
N && !K.current && (K.current = ot(N)), a(() => () => {
|
|
2227
|
+
N && st(N);
|
|
2205
2228
|
}), a(() => {
|
|
2206
|
-
let e =
|
|
2229
|
+
let e = K.current;
|
|
2207
2230
|
if (!e) return;
|
|
2208
|
-
let t = e.window.value, n =
|
|
2209
|
-
t && (t[0] !== n[0] || t[1] !== n[1]) && (
|
|
2231
|
+
let t = e.window.value, n = G.peek();
|
|
2232
|
+
t && (t[0] !== n[0] || t[1] !== n[1]) && (G.value = t);
|
|
2210
2233
|
}), a(() => {
|
|
2211
|
-
let e =
|
|
2234
|
+
let e = K.current;
|
|
2212
2235
|
if (!e) return;
|
|
2213
|
-
let t =
|
|
2236
|
+
let t = G.value, n = e.window.peek();
|
|
2214
2237
|
(!n || n[0] !== t[0] || n[1] !== t[1]) && (e.window.value = t);
|
|
2215
2238
|
});
|
|
2216
|
-
let
|
|
2239
|
+
let q = W ? e.map((e) => ({
|
|
2217
2240
|
...e,
|
|
2218
|
-
data: e.data.slice(
|
|
2219
|
-
})) : e,
|
|
2220
|
-
...
|
|
2241
|
+
data: e.data.slice(G.value[0], G.value[1] + 1)
|
|
2242
|
+
})) : e, J = !T && q.some((e) => e.axis === "right"), te = T ? Ve : Be, Y = J ? {
|
|
2243
|
+
...te,
|
|
2221
2244
|
right: 60
|
|
2222
|
-
} :
|
|
2245
|
+
} : te, X = h ?? (T ? 48 : 300), ne = T ? !1 : v ?? q.length > 1, Z = q.flatMap((e) => e.data.map((e) => t(e))), re = (e) => e.flatMap((e) => e.data.map((e) => n(e))).filter((e) => Number.isFinite(e)), ie = re(J ? q.filter((e) => e.axis !== "right") : q), ae = J ? re(q.filter((e) => e.axis === "right")) : [];
|
|
2246
|
+
Jt("LineChart", () => q.flatMap((e) => e.data.map((e) => n(e))));
|
|
2247
|
+
let oe = Z.length > 0, se = oe && Z[0] instanceof Date;
|
|
2223
2248
|
return /* @__PURE__ */ p("div", {
|
|
2224
2249
|
style: {
|
|
2225
2250
|
display: "flex",
|
|
@@ -2231,24 +2256,24 @@ function qt({ series: e, x: t, y: n, title: r, description: s, curve: l = "monot
|
|
|
2231
2256
|
title: r,
|
|
2232
2257
|
description: s,
|
|
2233
2258
|
width: u,
|
|
2234
|
-
height:
|
|
2259
|
+
height: X,
|
|
2235
2260
|
fallback: /* @__PURE__ */ p("table", { children: [
|
|
2236
2261
|
/* @__PURE__ */ f("caption", { children: r }),
|
|
2237
|
-
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", { children: "X" }),
|
|
2238
|
-
/* @__PURE__ */ f("tbody", { children: (
|
|
2262
|
+
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", { children: "X" }), q.map((e) => /* @__PURE__ */ f("th", { children: e.label }, e.id))] }) }),
|
|
2263
|
+
/* @__PURE__ */ f("tbody", { children: (q[0]?.data ?? []).map((e, r) => /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("td", { children: String(q[0] ? t(q[0].data[r]) : "") }), q.map((e) => /* @__PURE__ */ f("td", { children: e.data[r] == null ? "" : n(e.data[r]) }, e.id))] }, r)) })
|
|
2239
2264
|
] }),
|
|
2240
2265
|
className: x,
|
|
2241
|
-
"data-state":
|
|
2266
|
+
"data-state": oe ? void 0 : "empty",
|
|
2242
2267
|
plain: T,
|
|
2243
|
-
tooltip: y !== !1 &&
|
|
2244
|
-
if (y === !1 || !
|
|
2245
|
-
let i = e -
|
|
2246
|
-
if (
|
|
2247
|
-
let e =
|
|
2268
|
+
tooltip: y !== !1 && oe ? ({ width: e, height: r }) => {
|
|
2269
|
+
if (y === !1 || !oe) return;
|
|
2270
|
+
let i = e - Y.left - Y.right, a = r - Y.top - Y.bottom, o = Math.min(...se ? Z.map((e) => e.getTime()) : Z), s = Math.max(...se ? Z.map((e) => e.getTime()) : Z), c = se ? S([new Date(o), new Date(s)], [0, i]) : m([o, s], [0, i]), l = m(Xt(ie), [a, 0]), u = J ? m(Xt(ae), [a, 0]) : l, d = (e) => e.axis === "right" ? u : l, f = (e) => c.map(e);
|
|
2271
|
+
if (P === "axis") {
|
|
2272
|
+
let e = q.reduce((e, t) => Math.max(e, t.data.length), 0), r = [];
|
|
2248
2273
|
for (let i = 0; i < e; i++) {
|
|
2249
2274
|
let e = [], a = 0, o = 0, s = Infinity, c = "";
|
|
2250
|
-
|
|
2251
|
-
if (
|
|
2275
|
+
q.forEach((r, l) => {
|
|
2276
|
+
if (B.value.has(r.id)) return;
|
|
2252
2277
|
let u = r.data[i];
|
|
2253
2278
|
if (u === void 0) return;
|
|
2254
2279
|
let p = n(u);
|
|
@@ -2257,12 +2282,12 @@ function qt({ series: e, x: t, y: n, title: r, description: s, curve: l = "monot
|
|
|
2257
2282
|
a += f(m), o++, s = Math.min(s, d(r).map(p)), c = m instanceof Date ? m.toLocaleDateString() : String(m), e.push({
|
|
2258
2283
|
label: r.label,
|
|
2259
2284
|
value: p,
|
|
2260
|
-
color: r.color ??
|
|
2285
|
+
color: r.color ?? Yt[l % Yt.length]
|
|
2261
2286
|
});
|
|
2262
2287
|
}), o !== 0 && r.push({
|
|
2263
2288
|
id: `x-${i}`,
|
|
2264
|
-
cx:
|
|
2265
|
-
cy:
|
|
2289
|
+
cx: Y.left + a / o,
|
|
2290
|
+
cy: Y.top + (s === Infinity ? 0 : s),
|
|
2266
2291
|
label: c,
|
|
2267
2292
|
value: c,
|
|
2268
2293
|
segments: e
|
|
@@ -2274,14 +2299,14 @@ function qt({ series: e, x: t, y: n, title: r, description: s, curve: l = "monot
|
|
|
2274
2299
|
format: (e) => `${e.label}: ${(e.segments ?? []).map((e) => `${e.label} ${e.value}`).join(", ")}`
|
|
2275
2300
|
};
|
|
2276
2301
|
}
|
|
2277
|
-
let p =
|
|
2302
|
+
let p = q.flatMap((e) => B.value.has(e.id) ? [] : e.data.flatMap((r, i) => {
|
|
2278
2303
|
let a = n(r);
|
|
2279
2304
|
if (!Number.isFinite(a)) return [];
|
|
2280
2305
|
let o = t(r), s = c.map(o), l = d(e).map(a), u = o instanceof Date ? o.toLocaleDateString() : String(o);
|
|
2281
2306
|
return {
|
|
2282
2307
|
id: `${e.id}-${i}`,
|
|
2283
|
-
cx:
|
|
2284
|
-
cy:
|
|
2308
|
+
cx: Y.left + s,
|
|
2309
|
+
cy: Y.top + l,
|
|
2285
2310
|
label: u,
|
|
2286
2311
|
value: n(r),
|
|
2287
2312
|
seriesId: e.id
|
|
@@ -2290,51 +2315,51 @@ function qt({ series: e, x: t, y: n, title: r, description: s, curve: l = "monot
|
|
|
2290
2315
|
return b ? {
|
|
2291
2316
|
points: p,
|
|
2292
2317
|
format: (e) => {
|
|
2293
|
-
let t =
|
|
2318
|
+
let t = q.find((t) => t.id === e.seriesId), n = parseInt(e.id.split("-").pop() ?? "0", 10);
|
|
2294
2319
|
return t && t.data[n] !== void 0 ? b(t.data[n], t) : `${e.label}: ${e.value}`;
|
|
2295
2320
|
}
|
|
2296
2321
|
} : { points: p };
|
|
2297
2322
|
} : void 0,
|
|
2298
|
-
onSelect:
|
|
2299
|
-
zoom:
|
|
2300
|
-
window:
|
|
2301
|
-
count:
|
|
2323
|
+
onSelect: k,
|
|
2324
|
+
zoom: M && U > 1 ? {
|
|
2325
|
+
window: G,
|
|
2326
|
+
count: U
|
|
2302
2327
|
} : void 0,
|
|
2303
|
-
toolbox:
|
|
2304
|
-
onRestore:
|
|
2305
|
-
|
|
2328
|
+
toolbox: L,
|
|
2329
|
+
onRestore: W ? () => {
|
|
2330
|
+
G.value = [0, Math.max(0, U - 1)];
|
|
2306
2331
|
} : void 0,
|
|
2307
|
-
transition:
|
|
2308
|
-
onBeforeDraw:
|
|
2309
|
-
onAfterDraw:
|
|
2332
|
+
transition: R,
|
|
2333
|
+
onBeforeDraw: ee,
|
|
2334
|
+
onAfterDraw: z,
|
|
2310
2335
|
children: ({ width: e, height: r }) => {
|
|
2311
|
-
let i = e -
|
|
2336
|
+
let i = e - Y.left - Y.right, a = r - Y.top - Y.bottom, o = Math.min(...se ? Z.map((e) => e.getTime()) : Z), s = Math.max(...se ? Z.map((e) => e.getTime()) : Z), c = se ? S([new Date(o), new Date(s)], [0, i]) : m([o, s], [0, i]), u = m(Xt(ie), [a, 0]), h = J ? m(Xt(ae), [a, 0]) : u;
|
|
2312
2337
|
return /* @__PURE__ */ f("g", { children: /* @__PURE__ */ p("g", {
|
|
2313
|
-
transform: `translate(${
|
|
2338
|
+
transform: `translate(${Y.left},${Y.top})`,
|
|
2314
2339
|
children: [
|
|
2315
|
-
!T && /* @__PURE__ */ f(
|
|
2340
|
+
!T && /* @__PURE__ */ f(ft, {
|
|
2316
2341
|
scale: u,
|
|
2317
2342
|
orientation: "y",
|
|
2318
2343
|
length: i,
|
|
2319
2344
|
tickCount: _
|
|
2320
2345
|
}),
|
|
2321
|
-
!T &&
|
|
2346
|
+
!T && _t(E, {
|
|
2322
2347
|
xScale: c,
|
|
2323
2348
|
yScale: u,
|
|
2324
2349
|
innerW: i,
|
|
2325
2350
|
innerH: a
|
|
2326
2351
|
}),
|
|
2327
|
-
|
|
2328
|
-
if (
|
|
2329
|
-
let i = e.color ??
|
|
2330
|
-
if (
|
|
2352
|
+
q.map((e, r) => {
|
|
2353
|
+
if (B.value.has(e.id)) return null;
|
|
2354
|
+
let i = e.color ?? Yt[r % Yt.length], a = e.axis === "right" ? h : u, o = (e) => c.map(e);
|
|
2355
|
+
if (H && e.data.length > H.threshold) {
|
|
2331
2356
|
let r = [];
|
|
2332
2357
|
for (let i of e.data) {
|
|
2333
2358
|
let e = n(i);
|
|
2334
2359
|
Number.isFinite(e) && r.push([o(t(i)), a.map(e)]);
|
|
2335
2360
|
}
|
|
2336
2361
|
return /* @__PURE__ */ f("path", {
|
|
2337
|
-
d: w(
|
|
2362
|
+
d: w(Fe(r, H.threshold, H.method).map((e) => [e[0], e[1]]), l),
|
|
2338
2363
|
fill: "none",
|
|
2339
2364
|
stroke: i,
|
|
2340
2365
|
strokeWidth: 2,
|
|
@@ -2347,7 +2372,7 @@ function qt({ series: e, x: t, y: n, title: r, description: s, curve: l = "monot
|
|
|
2347
2372
|
let r = n(e);
|
|
2348
2373
|
return Number.isFinite(r) ? [o(t(e)), a.map(r)] : null;
|
|
2349
2374
|
});
|
|
2350
|
-
return /* @__PURE__ */ p("g", { children: [C(s,
|
|
2375
|
+
return /* @__PURE__ */ p("g", { children: [C(s, O).map((t, n) => /* @__PURE__ */ f("path", {
|
|
2351
2376
|
d: w(t, l),
|
|
2352
2377
|
fill: "none",
|
|
2353
2378
|
stroke: i,
|
|
@@ -2355,12 +2380,12 @@ function qt({ series: e, x: t, y: n, title: r, description: s, curve: l = "monot
|
|
|
2355
2380
|
strokeLinecap: "round",
|
|
2356
2381
|
strokeLinejoin: "round",
|
|
2357
2382
|
"data-series": e.id
|
|
2358
|
-
}, n)),
|
|
2383
|
+
}, n)), V && e.data.map((e, t) => {
|
|
2359
2384
|
let r = s[t];
|
|
2360
|
-
return r ? /* @__PURE__ */ f(
|
|
2385
|
+
return r ? /* @__PURE__ */ f(xt, {
|
|
2361
2386
|
x: r[0],
|
|
2362
2387
|
y: r[1] - 8,
|
|
2363
|
-
text:
|
|
2388
|
+
text: V.format(n(e))
|
|
2364
2389
|
}, t) : null;
|
|
2365
2390
|
})] }, e.id);
|
|
2366
2391
|
}),
|
|
@@ -2378,72 +2403,74 @@ function qt({ series: e, x: t, y: n, title: r, description: s, curve: l = "monot
|
|
|
2378
2403
|
length: a,
|
|
2379
2404
|
tickCount: _
|
|
2380
2405
|
}),
|
|
2381
|
-
|
|
2406
|
+
J && /* @__PURE__ */ f($, {
|
|
2382
2407
|
scale: h,
|
|
2383
2408
|
orientation: "y",
|
|
2384
2409
|
length: a,
|
|
2385
2410
|
tickCount: _,
|
|
2386
2411
|
transform: `translate(${i},0)`,
|
|
2387
|
-
...
|
|
2412
|
+
...F?.format ? { format: (e) => F.format(Number(e)) } : {}
|
|
2388
2413
|
})
|
|
2389
2414
|
] })
|
|
2390
2415
|
]
|
|
2391
2416
|
}) });
|
|
2392
2417
|
}
|
|
2393
2418
|
}),
|
|
2394
|
-
|
|
2395
|
-
count:
|
|
2396
|
-
window:
|
|
2419
|
+
A && !j && U > 1 && /* @__PURE__ */ f(Nt, {
|
|
2420
|
+
count: U,
|
|
2421
|
+
window: G,
|
|
2397
2422
|
label: "Time range"
|
|
2398
2423
|
}),
|
|
2399
|
-
|
|
2400
|
-
count:
|
|
2401
|
-
window:
|
|
2424
|
+
j && U > 1 && /* @__PURE__ */ f(Pt, {
|
|
2425
|
+
count: U,
|
|
2426
|
+
window: G,
|
|
2402
2427
|
label: "Time range"
|
|
2403
2428
|
}),
|
|
2404
|
-
|
|
2405
|
-
series:
|
|
2429
|
+
ne && /* @__PURE__ */ f(Gt, {
|
|
2430
|
+
series: q.map((e, t) => ({
|
|
2406
2431
|
id: e.id,
|
|
2407
2432
|
label: e.label,
|
|
2408
|
-
color: e.color ??
|
|
2433
|
+
color: e.color ?? Yt[t % Yt.length]
|
|
2409
2434
|
})),
|
|
2410
|
-
hidden:
|
|
2435
|
+
hidden: B
|
|
2411
2436
|
})
|
|
2412
2437
|
]
|
|
2413
2438
|
});
|
|
2414
2439
|
}
|
|
2415
2440
|
//#endregion
|
|
2416
2441
|
//#region src/charts/area-chart/area-chart.tsx
|
|
2417
|
-
var
|
|
2418
|
-
function
|
|
2442
|
+
var Qt = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
2443
|
+
function $t({ series: e, x: t, y: n, title: r, description: l, stacked: u = !1, curve: h = "monotone", fill: g = "solid", patternKind: _, width: v, height: y, xTicks: b = 5, yTicks: x = 5, legend: S, tooltip: C, className: T, plain: E, annotations: D, labels: O, onSelect: k, brush: A, dataZoom: j, zoom: N, syncId: F, tooltipMode: I, secondAxis: L, decimate: R, toolbox: ee }) {
|
|
2419
2444
|
o();
|
|
2420
|
-
let
|
|
2445
|
+
let z = s(), B = i(/* @__PURE__ */ new Set()), V = E ? null : bt(O), H = R === !0 ? {
|
|
2421
2446
|
method: "lttb",
|
|
2422
2447
|
threshold: 1e3
|
|
2423
|
-
} :
|
|
2424
|
-
method:
|
|
2425
|
-
threshold:
|
|
2426
|
-
} : null,
|
|
2427
|
-
|
|
2428
|
-
|
|
2448
|
+
} : R ? {
|
|
2449
|
+
method: R.method ?? "lttb",
|
|
2450
|
+
threshold: R.threshold ?? 1e3
|
|
2451
|
+
} : null, U = e.reduce((e, t) => Math.max(e, t.data.length), 0), W = (A || j || N || F !== void 0) && U > 0, G = i([0, Math.max(0, U - 1)]), K = c(null);
|
|
2452
|
+
F && !K.current && (K.current = ot(F)), a(() => () => {
|
|
2453
|
+
F && st(F);
|
|
2429
2454
|
}), a(() => {
|
|
2430
|
-
let e =
|
|
2455
|
+
let e = K.current;
|
|
2431
2456
|
if (!e) return;
|
|
2432
|
-
let t = e.window.value, n =
|
|
2433
|
-
t && (t[0] !== n[0] || t[1] !== n[1]) && (
|
|
2457
|
+
let t = e.window.value, n = G.peek();
|
|
2458
|
+
t && (t[0] !== n[0] || t[1] !== n[1]) && (G.value = t);
|
|
2434
2459
|
}), a(() => {
|
|
2435
|
-
let e =
|
|
2460
|
+
let e = K.current;
|
|
2436
2461
|
if (!e) return;
|
|
2437
|
-
let t =
|
|
2462
|
+
let t = G.value, n = e.window.peek();
|
|
2438
2463
|
(!n || n[0] !== t[0] || n[1] !== t[1]) && (e.window.value = t);
|
|
2439
2464
|
});
|
|
2440
|
-
let
|
|
2465
|
+
let q = W ? e.map((e) => ({
|
|
2441
2466
|
...e,
|
|
2442
|
-
data: e.data.slice(
|
|
2443
|
-
})) : e,
|
|
2444
|
-
...
|
|
2467
|
+
data: e.data.slice(G.value[0], G.value[1] + 1)
|
|
2468
|
+
})) : e, J = !E && !u && q.some((e) => e.axis === "right"), te = E ? Ve : Be, Y = J ? {
|
|
2469
|
+
...te,
|
|
2445
2470
|
right: 60
|
|
2446
|
-
} :
|
|
2471
|
+
} : te, X = y ?? (E ? 48 : 300), ne = E ? !1 : S ?? q.length > 1, Z = (q[0]?.data ?? []).map((e) => t(e)), re = (J ? q.filter((e) => e.axis !== "right") : q).flatMap((e) => e.data.map((e) => n(e))), ie = J ? q.filter((e) => e.axis === "right").flatMap((e) => e.data.map((e) => n(e))) : [];
|
|
2472
|
+
Jt("AreaChart", () => [...re, ...ie]);
|
|
2473
|
+
let ae = Z.length > 0, oe = ae ? Math.min(...Z) : 0, se = ae ? Math.max(...Z) : 1, ce = u ? 0 : Math.min(0, ...re), le = Math.max(...u ? (q[0]?.data ?? []).map((e, t) => q.reduce((e, r) => e + n(r.data[t]), 0)) : re), ue = J ? Math.min(0, ...ie) : ce, de = J ? Math.max(...ie) : le;
|
|
2447
2474
|
return /* @__PURE__ */ p("div", {
|
|
2448
2475
|
style: {
|
|
2449
2476
|
display: "flex",
|
|
@@ -2455,36 +2482,36 @@ function Yt({ series: e, x: t, y: n, title: r, description: l, stacked: u = !1,
|
|
|
2455
2482
|
title: r,
|
|
2456
2483
|
description: l,
|
|
2457
2484
|
width: v,
|
|
2458
|
-
height:
|
|
2485
|
+
height: X,
|
|
2459
2486
|
fallback: /* @__PURE__ */ p("table", { children: [
|
|
2460
2487
|
/* @__PURE__ */ f("caption", { children: r }),
|
|
2461
|
-
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", { children: "X" }),
|
|
2462
|
-
/* @__PURE__ */ f("tbody", { children: (
|
|
2488
|
+
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", { children: "X" }), q.map((e) => /* @__PURE__ */ f("th", { children: e.label }, e.id))] }) }),
|
|
2489
|
+
/* @__PURE__ */ f("tbody", { children: (q[0]?.data ?? []).map((e, r) => /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("td", { children: q[0] ? String(t(q[0].data[r])) : "" }), q.map((e) => /* @__PURE__ */ f("td", { children: e.data[r] == null ? "" : n(e.data[r]) }, e.id))] }, r)) })
|
|
2463
2490
|
] }),
|
|
2464
2491
|
className: T,
|
|
2465
|
-
"data-state":
|
|
2492
|
+
"data-state": ae ? void 0 : "empty",
|
|
2466
2493
|
plain: E,
|
|
2467
|
-
tooltip: C !== !1 &&
|
|
2468
|
-
if (C === !1 || !
|
|
2469
|
-
let i = e -
|
|
2470
|
-
if (
|
|
2471
|
-
let e =
|
|
2494
|
+
tooltip: C !== !1 && ae ? ({ width: e, height: r }) => {
|
|
2495
|
+
if (C === !1 || !ae) return;
|
|
2496
|
+
let i = e - Y.left - Y.right, a = r - Y.top - Y.bottom, o = m([oe, se], [0, i]), s = m([ce, le], [a, 0]), c = J ? m([ue, de], [a, 0]) : s, l = (e) => e.axis === "right" ? c : s;
|
|
2497
|
+
if (I === "axis") {
|
|
2498
|
+
let e = q.reduce((e, t) => Math.max(e, t.data.length), 0), r = [];
|
|
2472
2499
|
for (let i = 0; i < e; i++) {
|
|
2473
|
-
let e = [], a = Infinity, s = "", c =
|
|
2474
|
-
|
|
2475
|
-
if (
|
|
2500
|
+
let e = [], a = Infinity, s = "", c = Y.left;
|
|
2501
|
+
q.forEach((r, u) => {
|
|
2502
|
+
if (B.value.has(r.id)) return;
|
|
2476
2503
|
let d = r.data[i];
|
|
2477
2504
|
if (d === void 0) return;
|
|
2478
2505
|
let f = n(d);
|
|
2479
|
-
Number.isFinite(f) && (c =
|
|
2506
|
+
Number.isFinite(f) && (c = Y.left + o.map(t(d)), a = Math.min(a, l(r).map(f)), s = String(t(d)), e.push({
|
|
2480
2507
|
label: r.label,
|
|
2481
2508
|
value: f,
|
|
2482
|
-
color: r.color ??
|
|
2509
|
+
color: r.color ?? Qt[u % Qt.length]
|
|
2483
2510
|
}));
|
|
2484
2511
|
}), e.length !== 0 && r.push({
|
|
2485
2512
|
id: `x-${i}`,
|
|
2486
2513
|
cx: c,
|
|
2487
|
-
cy:
|
|
2514
|
+
cy: Y.top + (a === Infinity ? 0 : a),
|
|
2488
2515
|
label: s,
|
|
2489
2516
|
value: s,
|
|
2490
2517
|
segments: e
|
|
@@ -2496,52 +2523,52 @@ function Yt({ series: e, x: t, y: n, title: r, description: l, stacked: u = !1,
|
|
|
2496
2523
|
format: (e) => `${e.label}: ${(e.segments ?? []).map((e) => `${e.label} ${e.value}`).join(", ")}`
|
|
2497
2524
|
};
|
|
2498
2525
|
}
|
|
2499
|
-
return { points:
|
|
2526
|
+
return { points: q.flatMap((e) => B.value.has(e.id) ? [] : e.data.map((r, i) => ({
|
|
2500
2527
|
id: `${e.id}-${i}`,
|
|
2501
|
-
cx:
|
|
2502
|
-
cy:
|
|
2528
|
+
cx: Y.left + o.map(t(r)),
|
|
2529
|
+
cy: Y.top + l(e).map(n(r)),
|
|
2503
2530
|
label: String(t(r)),
|
|
2504
2531
|
value: n(r),
|
|
2505
2532
|
seriesId: e.id
|
|
2506
2533
|
}))) };
|
|
2507
2534
|
} : void 0,
|
|
2508
|
-
onSelect:
|
|
2509
|
-
zoom:
|
|
2510
|
-
window:
|
|
2511
|
-
count:
|
|
2535
|
+
onSelect: k,
|
|
2536
|
+
zoom: N && U > 1 ? {
|
|
2537
|
+
window: G,
|
|
2538
|
+
count: U
|
|
2512
2539
|
} : void 0,
|
|
2513
|
-
toolbox:
|
|
2514
|
-
onRestore:
|
|
2515
|
-
|
|
2540
|
+
toolbox: ee,
|
|
2541
|
+
onRestore: W ? () => {
|
|
2542
|
+
G.value = [0, Math.max(0, U - 1)];
|
|
2516
2543
|
} : void 0,
|
|
2517
2544
|
children: ({ width: e, height: r }) => {
|
|
2518
|
-
let i = e -
|
|
2519
|
-
return u && (l =
|
|
2520
|
-
prefix:
|
|
2545
|
+
let i = e - Y.left - Y.right, a = r - Y.top - Y.bottom, o = m([oe, se], [0, i]), s = m([ce, le], [a, 0]), c = J ? m([ue, de], [a, 0]) : s, l = [];
|
|
2546
|
+
return u && (l = P(q.map((e) => e.data.map((e) => n(e))))), /* @__PURE__ */ p("g", { children: [g !== "solid" && /* @__PURE__ */ f(Et, {
|
|
2547
|
+
prefix: z,
|
|
2521
2548
|
fill: g,
|
|
2522
2549
|
patternKind: _,
|
|
2523
|
-
series:
|
|
2550
|
+
series: q.map((e, t) => ({
|
|
2524
2551
|
id: e.id,
|
|
2525
|
-
color: e.color ??
|
|
2552
|
+
color: e.color ?? Qt[t % Qt.length]
|
|
2526
2553
|
}))
|
|
2527
2554
|
}), /* @__PURE__ */ p("g", {
|
|
2528
|
-
transform: `translate(${
|
|
2555
|
+
transform: `translate(${Y.left},${Y.top})`,
|
|
2529
2556
|
children: [
|
|
2530
|
-
!E && /* @__PURE__ */ f(
|
|
2557
|
+
!E && /* @__PURE__ */ f(ft, {
|
|
2531
2558
|
scale: s,
|
|
2532
2559
|
orientation: "y",
|
|
2533
2560
|
length: i,
|
|
2534
2561
|
tickCount: x
|
|
2535
2562
|
}),
|
|
2536
|
-
!E &&
|
|
2563
|
+
!E && _t(D, {
|
|
2537
2564
|
xScale: o,
|
|
2538
2565
|
yScale: s,
|
|
2539
2566
|
innerW: i,
|
|
2540
2567
|
innerH: a
|
|
2541
2568
|
}),
|
|
2542
|
-
|
|
2543
|
-
if (
|
|
2544
|
-
let i = e.color ??
|
|
2569
|
+
q.map((e, r) => {
|
|
2570
|
+
if (B.value.has(e.id)) return null;
|
|
2571
|
+
let i = e.color ?? Qt[r % Qt.length], a, d;
|
|
2545
2572
|
if (u && l[r]) {
|
|
2546
2573
|
let c = l[r];
|
|
2547
2574
|
a = e.data.map((e, n) => [o.map(t(e)), s.map(c[n][1])]);
|
|
@@ -2553,7 +2580,7 @@ function Yt({ series: e, x: t, y: n, title: r, description: l, stacked: u = !1,
|
|
|
2553
2580
|
children: [
|
|
2554
2581
|
/* @__PURE__ */ f("path", {
|
|
2555
2582
|
d: b,
|
|
2556
|
-
fill:
|
|
2583
|
+
fill: Tt(z, e.id, g, i),
|
|
2557
2584
|
fillOpacity: g === "solid" ? .25 : 1,
|
|
2558
2585
|
stroke: "none"
|
|
2559
2586
|
}),
|
|
@@ -2563,22 +2590,22 @@ function Yt({ series: e, x: t, y: n, title: r, description: l, stacked: u = !1,
|
|
|
2563
2590
|
stroke: i,
|
|
2564
2591
|
strokeWidth: 2
|
|
2565
2592
|
}),
|
|
2566
|
-
|
|
2593
|
+
V && a.map((t, r) => /* @__PURE__ */ f(xt, {
|
|
2567
2594
|
x: t[0],
|
|
2568
2595
|
y: t[1] - 8,
|
|
2569
|
-
text:
|
|
2596
|
+
text: V.format(n(e.data[r]))
|
|
2570
2597
|
}, r))
|
|
2571
2598
|
]
|
|
2572
2599
|
}, e.id);
|
|
2573
2600
|
} else {
|
|
2574
2601
|
let r = e.axis === "right" ? c : s;
|
|
2575
|
-
if (a = e.data.map((e) => [o.map(t(e)), r.map(n(e))]), d = r.map(0),
|
|
2576
|
-
let t =
|
|
2602
|
+
if (a = e.data.map((e) => [o.map(t(e)), r.map(n(e))]), d = r.map(0), H && a.length > H.threshold) {
|
|
2603
|
+
let t = Fe(a, H.threshold, H.method).map((e) => [e[0], e[1]]);
|
|
2577
2604
|
return /* @__PURE__ */ p("g", {
|
|
2578
2605
|
"data-series": e.id,
|
|
2579
2606
|
children: [/* @__PURE__ */ f("path", {
|
|
2580
|
-
d:
|
|
2581
|
-
fill:
|
|
2607
|
+
d: M(t, d, h),
|
|
2608
|
+
fill: Tt(z, e.id, g, i),
|
|
2582
2609
|
fillOpacity: g === "solid" ? .25 : 1,
|
|
2583
2610
|
stroke: "none"
|
|
2584
2611
|
}), /* @__PURE__ */ f("path", {
|
|
@@ -2593,8 +2620,8 @@ function Yt({ series: e, x: t, y: n, title: r, description: l, stacked: u = !1,
|
|
|
2593
2620
|
"data-series": e.id,
|
|
2594
2621
|
children: [
|
|
2595
2622
|
/* @__PURE__ */ f("path", {
|
|
2596
|
-
d:
|
|
2597
|
-
fill:
|
|
2623
|
+
d: M(a, d, h),
|
|
2624
|
+
fill: Tt(z, e.id, g, i),
|
|
2598
2625
|
fillOpacity: g === "solid" ? .25 : 1,
|
|
2599
2626
|
stroke: "none"
|
|
2600
2627
|
}),
|
|
@@ -2604,10 +2631,10 @@ function Yt({ series: e, x: t, y: n, title: r, description: l, stacked: u = !1,
|
|
|
2604
2631
|
stroke: i,
|
|
2605
2632
|
strokeWidth: 2
|
|
2606
2633
|
}),
|
|
2607
|
-
|
|
2634
|
+
V && a.map((t, r) => /* @__PURE__ */ f(xt, {
|
|
2608
2635
|
x: t[0],
|
|
2609
2636
|
y: t[1] - 8,
|
|
2610
|
-
text:
|
|
2637
|
+
text: V.format(n(e.data[r]))
|
|
2611
2638
|
}, r))
|
|
2612
2639
|
]
|
|
2613
2640
|
}, e.id);
|
|
@@ -2627,56 +2654,56 @@ function Yt({ series: e, x: t, y: n, title: r, description: l, stacked: u = !1,
|
|
|
2627
2654
|
length: a,
|
|
2628
2655
|
tickCount: x
|
|
2629
2656
|
}),
|
|
2630
|
-
|
|
2657
|
+
J && /* @__PURE__ */ f($, {
|
|
2631
2658
|
scale: c,
|
|
2632
2659
|
orientation: "y",
|
|
2633
2660
|
length: a,
|
|
2634
2661
|
tickCount: x,
|
|
2635
2662
|
transform: `translate(${i},0)`,
|
|
2636
|
-
...
|
|
2663
|
+
...L?.format ? { format: (e) => L.format(Number(e)) } : {}
|
|
2637
2664
|
})
|
|
2638
2665
|
] })
|
|
2639
2666
|
]
|
|
2640
2667
|
})] });
|
|
2641
2668
|
}
|
|
2642
2669
|
}),
|
|
2643
|
-
|
|
2644
|
-
count:
|
|
2645
|
-
window:
|
|
2670
|
+
A && !j && U > 1 && /* @__PURE__ */ f(Nt, {
|
|
2671
|
+
count: U,
|
|
2672
|
+
window: G,
|
|
2646
2673
|
label: "Range"
|
|
2647
2674
|
}),
|
|
2648
|
-
|
|
2649
|
-
count:
|
|
2650
|
-
window:
|
|
2675
|
+
j && U > 1 && /* @__PURE__ */ f(Pt, {
|
|
2676
|
+
count: U,
|
|
2677
|
+
window: G,
|
|
2651
2678
|
label: "Range"
|
|
2652
2679
|
}),
|
|
2653
|
-
|
|
2654
|
-
series:
|
|
2680
|
+
ne && /* @__PURE__ */ f(Gt, {
|
|
2681
|
+
series: q.map((e, t) => ({
|
|
2655
2682
|
id: e.id,
|
|
2656
2683
|
label: e.label,
|
|
2657
|
-
color: e.color ??
|
|
2684
|
+
color: e.color ?? Qt[t % Qt.length]
|
|
2658
2685
|
})),
|
|
2659
|
-
hidden:
|
|
2686
|
+
hidden: B
|
|
2660
2687
|
})
|
|
2661
2688
|
]
|
|
2662
2689
|
});
|
|
2663
2690
|
}
|
|
2664
2691
|
//#endregion
|
|
2665
2692
|
//#region src/charts/bar-chart/bar-chart.tsx
|
|
2666
|
-
var
|
|
2667
|
-
function
|
|
2693
|
+
var en = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
2694
|
+
function tn(e) {
|
|
2668
2695
|
let t = e.segments?.filter((e) => e.value !== 0) ?? [], n = `${e.label} · ${e.value}`;
|
|
2669
2696
|
return t.length > 0 ? `${n} — ${t.map((e) => `${e.label}: ${e.value}`).join(", ")}` : n;
|
|
2670
2697
|
}
|
|
2671
|
-
function
|
|
2698
|
+
function nn({ series: e, x: t, y: n, title: r, description: a, orientation: c = "vertical", mode: l = "grouped", width: u, height: h, xTicks: _ = 5, yTicks: v = 5, xLabelEvery: y, legend: b, tooltip: x, tooltipFormat: S, className: C, plain: w, annotations: T, labels: E, onSelect: D, fill: O = "solid", patternKind: k }) {
|
|
2672
2699
|
o();
|
|
2673
|
-
let
|
|
2674
|
-
let t =
|
|
2700
|
+
let A = s(), j = w ? null : bt(E), M = i(/* @__PURE__ */ new Set()), N = w ? Ve : Be, F = h ?? (w ? 48 : 300), I = w ? !1 : b ?? e.length > 1, L = (e[0]?.data ?? []).map((e) => t(e)), R = e.flatMap((e) => e.data.map((e) => n(e))), ee = L.length > 0, z = l === "stacked" || l === "percent", B = L.map((t, r) => e.reduce((e, t) => e + n(t.data[r]), 0)), V = () => {
|
|
2701
|
+
let t = P(e.map((e) => e.data.map((e) => n(e))));
|
|
2675
2702
|
return l === "percent" ? t.map((e) => e.map(([e, t], n) => {
|
|
2676
|
-
let r =
|
|
2703
|
+
let r = B[n] || 1;
|
|
2677
2704
|
return [e / r, t / r];
|
|
2678
2705
|
})) : t;
|
|
2679
|
-
},
|
|
2706
|
+
}, H = z ? 0 : Math.min(0, ...R), U = ee ? Math.max(...B) : 1, W = l === "percent" ? 1 : l === "stacked" ? U : Math.max(1, ...R), G = l === "percent" ? (e) => `${Math.round(Number(e) * 100)}%` : void 0;
|
|
2680
2707
|
return /* @__PURE__ */ p("div", {
|
|
2681
2708
|
style: {
|
|
2682
2709
|
display: "flex",
|
|
@@ -2687,24 +2714,24 @@ function Qt({ series: e, x: t, y: n, title: r, description: a, orientation: c =
|
|
|
2687
2714
|
title: r,
|
|
2688
2715
|
description: a,
|
|
2689
2716
|
width: u,
|
|
2690
|
-
height:
|
|
2717
|
+
height: F,
|
|
2691
2718
|
fallback: /* @__PURE__ */ p("table", { children: [
|
|
2692
2719
|
/* @__PURE__ */ f("caption", { children: r }),
|
|
2693
2720
|
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", { children: "Category" }), e.map((e) => /* @__PURE__ */ f("th", { children: e.label }, e.id))] }) }),
|
|
2694
|
-
/* @__PURE__ */ f("tbody", { children:
|
|
2721
|
+
/* @__PURE__ */ f("tbody", { children: L.map((t, r) => /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("td", { children: t }), e.map((e) => /* @__PURE__ */ f("td", { children: e.data[r] == null ? "" : n(e.data[r]) }, e.id))] }, t)) })
|
|
2695
2722
|
] }),
|
|
2696
2723
|
className: C,
|
|
2697
|
-
"data-state":
|
|
2724
|
+
"data-state": ee ? void 0 : "empty",
|
|
2698
2725
|
plain: w,
|
|
2699
|
-
tooltip: x &&
|
|
2700
|
-
if (!x || !
|
|
2701
|
-
let a = r -
|
|
2702
|
-
|
|
2703
|
-
let h =
|
|
2726
|
+
tooltip: x && ee ? ({ width: r, height: i }) => {
|
|
2727
|
+
if (!x || !ee) return;
|
|
2728
|
+
let a = r - N.left - N.right, o = i - N.top - N.bottom, s = c === "vertical", u = g(L, s ? [0, a] : [0, o], .2), d = m([H, W], s ? [o, 0] : [0, a]), f = e.filter((e) => !M.value.has(e.id)), p = [];
|
|
2729
|
+
z && (p = V());
|
|
2730
|
+
let h = z && !S, _ = L.map((t, r) => {
|
|
2704
2731
|
let i = f.map((t) => ({
|
|
2705
2732
|
label: t.label,
|
|
2706
2733
|
value: n(t.data[r]),
|
|
2707
|
-
color: t.color ??
|
|
2734
|
+
color: t.color ?? en[e.indexOf(t) % en.length]
|
|
2708
2735
|
}));
|
|
2709
2736
|
return {
|
|
2710
2737
|
segs: i,
|
|
@@ -2714,71 +2741,71 @@ function Qt({ series: e, x: t, y: n, title: r, description: a, orientation: c =
|
|
|
2714
2741
|
let i = e.indexOf(r), a = l === "grouped" ? u.bandwidth / f.length : u.bandwidth;
|
|
2715
2742
|
return r.data.map((e, o) => {
|
|
2716
2743
|
let c = u.map(t(e)) ?? 0, m, g;
|
|
2717
|
-
if (
|
|
2744
|
+
if (z && p[i]) {
|
|
2718
2745
|
let e = p[i][o];
|
|
2719
2746
|
m = e[1], g = e[0];
|
|
2720
|
-
} else m = n(e), g =
|
|
2747
|
+
} else m = n(e), g = H;
|
|
2721
2748
|
let v = f.indexOf(r), y = c + (l === "grouped" ? v * a : 0) + a / 2, b = (Math.min(d.map(m), d.map(g)) + Math.max(d.map(m), d.map(g))) / 2;
|
|
2722
2749
|
return {
|
|
2723
2750
|
id: `${r.id}-${o}`,
|
|
2724
|
-
cx:
|
|
2725
|
-
cy:
|
|
2751
|
+
cx: N.left + (s ? y : b),
|
|
2752
|
+
cy: N.top + (s ? b : y),
|
|
2726
2753
|
label: t(e),
|
|
2727
2754
|
value: h ? _[o].total : n(e),
|
|
2728
2755
|
seriesId: r.id,
|
|
2729
2756
|
...h && { segments: _[o].segs }
|
|
2730
2757
|
};
|
|
2731
2758
|
});
|
|
2732
|
-
}), y = S ?? (h ?
|
|
2759
|
+
}), y = S ?? (h ? tn : void 0);
|
|
2733
2760
|
return y ? {
|
|
2734
2761
|
points: v,
|
|
2735
2762
|
format: y
|
|
2736
2763
|
} : { points: v };
|
|
2737
2764
|
} : void 0,
|
|
2738
|
-
onSelect:
|
|
2765
|
+
onSelect: D,
|
|
2739
2766
|
children: ({ width: r, height: i }) => {
|
|
2740
|
-
let a = r -
|
|
2741
|
-
return
|
|
2742
|
-
prefix:
|
|
2743
|
-
fill:
|
|
2744
|
-
patternKind:
|
|
2767
|
+
let a = r - N.left - N.right, o = i - N.top - N.bottom, s = c === "vertical", u = g(L, s ? [0, a] : [0, o], .2), h = m([H, W], s ? [o, 0] : [0, a]), b = e.filter((e) => !M.value.has(e.id)), x = [];
|
|
2768
|
+
return z && (x = V()), /* @__PURE__ */ p("g", { children: [O !== "solid" && /* @__PURE__ */ f(Et, {
|
|
2769
|
+
prefix: A,
|
|
2770
|
+
fill: O,
|
|
2771
|
+
patternKind: k,
|
|
2745
2772
|
series: e.map((e, t) => ({
|
|
2746
2773
|
id: e.id,
|
|
2747
|
-
color: e.color ??
|
|
2774
|
+
color: e.color ?? en[t % en.length]
|
|
2748
2775
|
}))
|
|
2749
2776
|
}), /* @__PURE__ */ p("g", {
|
|
2750
|
-
transform: `translate(${
|
|
2777
|
+
transform: `translate(${N.left},${N.top})`,
|
|
2751
2778
|
children: [
|
|
2752
|
-
!w && s && /* @__PURE__ */ f(
|
|
2779
|
+
!w && s && /* @__PURE__ */ f(ft, {
|
|
2753
2780
|
scale: h,
|
|
2754
2781
|
orientation: "y",
|
|
2755
2782
|
length: a,
|
|
2756
2783
|
tickCount: v
|
|
2757
2784
|
}),
|
|
2758
|
-
!w && !s && /* @__PURE__ */ f(
|
|
2785
|
+
!w && !s && /* @__PURE__ */ f(ft, {
|
|
2759
2786
|
scale: h,
|
|
2760
2787
|
orientation: "x",
|
|
2761
2788
|
length: o,
|
|
2762
2789
|
tickCount: _
|
|
2763
2790
|
}),
|
|
2764
|
-
!w &&
|
|
2791
|
+
!w && _t(T, {
|
|
2765
2792
|
xScale: s ? u : h,
|
|
2766
2793
|
yScale: s ? h : u,
|
|
2767
2794
|
innerW: a,
|
|
2768
2795
|
innerH: o
|
|
2769
2796
|
}),
|
|
2770
2797
|
b.map((r, i) => {
|
|
2771
|
-
let a = r.color ??
|
|
2798
|
+
let a = r.color ?? en[e.indexOf(r) % en.length], o = e.indexOf(r), c = l === "grouped" ? u.bandwidth / b.length : u.bandwidth;
|
|
2772
2799
|
return r.data.map((e, d) => {
|
|
2773
2800
|
let m = u.map(t(e)) ?? 0, g, _;
|
|
2774
|
-
if (
|
|
2801
|
+
if (z && x[o]) {
|
|
2775
2802
|
let e = x[o][d];
|
|
2776
2803
|
g = e[1], _ = e[0];
|
|
2777
|
-
} else g = n(e), _ =
|
|
2804
|
+
} else g = n(e), _ = H;
|
|
2778
2805
|
let v = m + (l === "grouped" ? i * c : 0), y = Math.min(h.map(g), h.map(_)), b = Math.abs(h.map(g) - h.map(_)), S = null;
|
|
2779
|
-
if (
|
|
2780
|
-
let t =
|
|
2781
|
-
if (s) S = /* @__PURE__ */ f(
|
|
2806
|
+
if (j) {
|
|
2807
|
+
let t = j.format(n(e)), r = v + c / 2, i = z || b < 18 || y < 14;
|
|
2808
|
+
if (s) S = /* @__PURE__ */ f(xt, {
|
|
2782
2809
|
x: r,
|
|
2783
2810
|
y: i ? y + 13 : y - 4,
|
|
2784
2811
|
text: t,
|
|
@@ -2786,7 +2813,7 @@ function Qt({ series: e, x: t, y: n, title: r, description: a, orientation: c =
|
|
|
2786
2813
|
});
|
|
2787
2814
|
else {
|
|
2788
2815
|
let e = y + b;
|
|
2789
|
-
S = /* @__PURE__ */ f(
|
|
2816
|
+
S = /* @__PURE__ */ f(xt, {
|
|
2790
2817
|
x: i ? e - 4 : e + 4,
|
|
2791
2818
|
y: r + 4,
|
|
2792
2819
|
text: t,
|
|
@@ -2794,14 +2821,14 @@ function Qt({ series: e, x: t, y: n, title: r, description: a, orientation: c =
|
|
|
2794
2821
|
tone: i ? "muted" : "default"
|
|
2795
2822
|
});
|
|
2796
2823
|
}
|
|
2797
|
-
|
|
2824
|
+
z && b < 14 && (S = null);
|
|
2798
2825
|
}
|
|
2799
2826
|
return /* @__PURE__ */ p("g", { children: [s ? /* @__PURE__ */ f("rect", {
|
|
2800
2827
|
x: v,
|
|
2801
2828
|
y,
|
|
2802
2829
|
width: c,
|
|
2803
2830
|
height: b,
|
|
2804
|
-
fill:
|
|
2831
|
+
fill: Tt(A, r.id, O, a),
|
|
2805
2832
|
rx: 2,
|
|
2806
2833
|
"data-series": r.id
|
|
2807
2834
|
}) : /* @__PURE__ */ f("rect", {
|
|
@@ -2809,7 +2836,7 @@ function Qt({ series: e, x: t, y: n, title: r, description: a, orientation: c =
|
|
|
2809
2836
|
y: v,
|
|
2810
2837
|
width: b,
|
|
2811
2838
|
height: c,
|
|
2812
|
-
fill:
|
|
2839
|
+
fill: Tt(A, r.id, O, a),
|
|
2813
2840
|
rx: 2,
|
|
2814
2841
|
"data-series": r.id
|
|
2815
2842
|
}), S] }, `${r.id}-${d}`);
|
|
@@ -2827,14 +2854,14 @@ function Qt({ series: e, x: t, y: n, title: r, description: a, orientation: c =
|
|
|
2827
2854
|
orientation: "y",
|
|
2828
2855
|
length: o,
|
|
2829
2856
|
tickCount: v,
|
|
2830
|
-
...
|
|
2857
|
+
...G && { format: G }
|
|
2831
2858
|
})] }),
|
|
2832
2859
|
!w && !s && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f($, {
|
|
2833
2860
|
scale: h,
|
|
2834
2861
|
orientation: "x",
|
|
2835
2862
|
length: a,
|
|
2836
2863
|
tickCount: _,
|
|
2837
|
-
...
|
|
2864
|
+
...G && { format: G },
|
|
2838
2865
|
transform: `translate(0,${o})`
|
|
2839
2866
|
}), /* @__PURE__ */ f($, {
|
|
2840
2867
|
scale: u,
|
|
@@ -2846,27 +2873,27 @@ function Qt({ series: e, x: t, y: n, title: r, description: a, orientation: c =
|
|
|
2846
2873
|
]
|
|
2847
2874
|
})] });
|
|
2848
2875
|
}
|
|
2849
|
-
}),
|
|
2876
|
+
}), I && /* @__PURE__ */ f(Gt, {
|
|
2850
2877
|
series: e.map((e, t) => ({
|
|
2851
2878
|
id: e.id,
|
|
2852
2879
|
label: e.label,
|
|
2853
|
-
color: e.color ??
|
|
2880
|
+
color: e.color ?? en[t % en.length]
|
|
2854
2881
|
})),
|
|
2855
|
-
hidden:
|
|
2882
|
+
hidden: M
|
|
2856
2883
|
})]
|
|
2857
2884
|
});
|
|
2858
2885
|
}
|
|
2859
2886
|
//#endregion
|
|
2860
2887
|
//#region src/charts/pie-chart/pie-chart.tsx
|
|
2861
|
-
function
|
|
2888
|
+
function rn(e) {
|
|
2862
2889
|
let t = e.percent == null ? 0 : Math.round(e.percent);
|
|
2863
2890
|
return `${e.value} (${t}%)`;
|
|
2864
2891
|
}
|
|
2865
|
-
var
|
|
2866
|
-
function
|
|
2867
|
-
let C = b ? null :
|
|
2892
|
+
var an = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
2893
|
+
function on({ data: e, title: t, description: n, donut: r = !1, width: a, height: s, size: c, thickness: l, innerRadius: u, centerValue: d, centerLabel: m, centerSlot: h, emptyLabel: g, tooltipFormat: _, legend: v, className: y, plain: b, labels: x, onSelect: S }) {
|
|
2894
|
+
let C = b ? null : bt(x), w = typeof x == "object" && !!x && x.format != null, T = a ?? c, E = s ?? c ?? (b ? 48 : 300), D = b ? !1 : v ?? !0;
|
|
2868
2895
|
o();
|
|
2869
|
-
let
|
|
2896
|
+
let O = i(/* @__PURE__ */ new Set()), k = e.length > 0;
|
|
2870
2897
|
return /* @__PURE__ */ p("div", {
|
|
2871
2898
|
style: {
|
|
2872
2899
|
display: "flex",
|
|
@@ -2895,12 +2922,12 @@ function tn({ data: e, title: t, description: n, donut: r = !1, width: a, height
|
|
|
2895
2922
|
}) })
|
|
2896
2923
|
] }),
|
|
2897
2924
|
className: y,
|
|
2898
|
-
"data-state":
|
|
2925
|
+
"data-state": k ? void 0 : "empty",
|
|
2899
2926
|
emptyLabel: g,
|
|
2900
2927
|
plain: b,
|
|
2901
|
-
tooltip:
|
|
2902
|
-
if (!
|
|
2903
|
-
let r = t / 2, i = n / 2, a = Math.min(r, i) - 8, o = e.filter((e) => !
|
|
2928
|
+
tooltip: k ? ({ width: t, height: n }) => {
|
|
2929
|
+
if (!k) return;
|
|
2930
|
+
let r = t / 2, i = n / 2, a = Math.min(r, i) - 8, o = e.filter((e) => !O.value.has(e.id)), s = o.reduce((e, t) => e + t.value, 0), c = 0;
|
|
2904
2931
|
return {
|
|
2905
2932
|
points: o.map((e, t) => {
|
|
2906
2933
|
let n = s > 0 ? e.value / s * 2 * Math.PI : 0, o = c + n, l = (c + o) / 2;
|
|
@@ -2912,17 +2939,17 @@ function tn({ data: e, title: t, description: n, donut: r = !1, width: a, height
|
|
|
2912
2939
|
value: e.value,
|
|
2913
2940
|
seriesId: String(t),
|
|
2914
2941
|
percent: s > 0 ? e.value / s * 100 : 0,
|
|
2915
|
-
color: e.color ??
|
|
2942
|
+
color: e.color ?? an[t % an.length]
|
|
2916
2943
|
};
|
|
2917
2944
|
}),
|
|
2918
|
-
format: _ ??
|
|
2945
|
+
format: _ ?? rn
|
|
2919
2946
|
};
|
|
2920
2947
|
} : void 0,
|
|
2921
2948
|
onSelect: S,
|
|
2922
2949
|
children: ({ width: t, height: n }) => {
|
|
2923
|
-
let i = t / 2, a = n / 2, o = Math.min(i, a) - 8, s = u ?? (l == null ? o * .6 : o - l), c = r ? Math.max(0, Math.min(s, o)) : 0, g = e.filter((e) => !
|
|
2950
|
+
let i = t / 2, a = n / 2, o = Math.min(i, a) - 8, s = u ?? (l == null ? o * .6 : o - l), c = r ? Math.max(0, Math.min(s, o)) : 0, g = e.filter((e) => !O.value.has(e.id)), _ = g.reduce((e, t) => e + t.value, 0), v = 0, y = r && (d != null || m != null || h != null);
|
|
2924
2951
|
return /* @__PURE__ */ p("g", { children: [g.map((e, t) => {
|
|
2925
|
-
let n = _ > 0 ? e.value / _ * 2 * Math.PI : 0, r = v + n, s = (v + r) / 2, l = e.color ??
|
|
2952
|
+
let n = _ > 0 ? e.value / _ * 2 * Math.PI : 0, r = v + n, s = (v + r) / 2, l = e.color ?? an[t % an.length], u = N(i, a, o, c, v, r);
|
|
2926
2953
|
v = r;
|
|
2927
2954
|
let d = _ > 0 ? e.value / _ * 100 : 0, m = C && d >= 4, h = c > 0 ? (c + o) / 2 : o * .6;
|
|
2928
2955
|
return /* @__PURE__ */ p("g", { children: [/* @__PURE__ */ f("path", {
|
|
@@ -2931,7 +2958,7 @@ function tn({ data: e, title: t, description: n, donut: r = !1, width: a, height
|
|
|
2931
2958
|
stroke: "var(--cascivo-color-surface)",
|
|
2932
2959
|
strokeWidth: 1,
|
|
2933
2960
|
"data-series": e.id
|
|
2934
|
-
}), m && /* @__PURE__ */ f(
|
|
2961
|
+
}), m && /* @__PURE__ */ f(xt, {
|
|
2935
2962
|
x: i + Math.sin(s) * h,
|
|
2936
2963
|
y: a - Math.cos(s) * h + 4,
|
|
2937
2964
|
text: w ? C.format(e.value) : `${Math.round(d)}%`,
|
|
@@ -2977,35 +3004,35 @@ function tn({ data: e, title: t, description: n, donut: r = !1, width: a, height
|
|
|
2977
3004
|
})
|
|
2978
3005
|
}))] });
|
|
2979
3006
|
}
|
|
2980
|
-
}),
|
|
3007
|
+
}), D && /* @__PURE__ */ f(Gt, {
|
|
2981
3008
|
series: e.map((e, t) => ({
|
|
2982
3009
|
id: e.id,
|
|
2983
3010
|
label: e.label,
|
|
2984
|
-
color: e.color ??
|
|
3011
|
+
color: e.color ?? an[t % an.length]
|
|
2985
3012
|
})),
|
|
2986
|
-
hidden:
|
|
3013
|
+
hidden: O
|
|
2987
3014
|
})]
|
|
2988
3015
|
});
|
|
2989
3016
|
}
|
|
2990
3017
|
//#endregion
|
|
2991
3018
|
//#region src/charts/scatter-chart/scatter-chart.tsx
|
|
2992
|
-
var
|
|
2993
|
-
function
|
|
3019
|
+
var sn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
3020
|
+
function cn({ series: e, title: t, description: n, r = 4, width: a, height: s, xTicks: c = 5, yTicks: l = 5, legend: u, tooltip: h, className: g, plain: _, annotations: v, onSelect: y, glyph: b, renderer: x = "svg", visualMap: S, toolbox: C }) {
|
|
2994
3021
|
o();
|
|
2995
|
-
let w = i(/* @__PURE__ */ new Set()), T = _ ?
|
|
3022
|
+
let w = i(/* @__PURE__ */ new Set()), T = _ ? Ve : Be, E = s ?? (_ ? 48 : 300), D = _ ? !1 : u ?? e.length > 1, O = e.reduce((e, t) => e + t.data.length, 0), k = !S && (x === "canvas" || x === "auto" && O > 2e3), A = i([S?.min ?? 0, S?.max ?? 1]), j = i(/* @__PURE__ */ new Set()), M = (t, { width: n, height: i }) => {
|
|
2996
3023
|
let a = n - T.left - T.right, o = i - T.top - T.bottom;
|
|
2997
3024
|
if (a <= 0 || o <= 0) return;
|
|
2998
|
-
let s = m([
|
|
3025
|
+
let s = m([I, L], [0, a]), c = m([R, ee], [o, 0]);
|
|
2999
3026
|
e.forEach((e, n) => {
|
|
3000
3027
|
if (!w.value.has(e.id)) {
|
|
3001
|
-
t.fillStyle = qe(t, e.color ??
|
|
3028
|
+
t.fillStyle = qe(t, e.color ?? sn[n % sn.length]), t.globalAlpha = .7;
|
|
3002
3029
|
for (let n of e.data) {
|
|
3003
3030
|
let e = typeof r == "function" ? r(n) : n.r ?? r;
|
|
3004
3031
|
t.beginPath(), t.arc(T.left + s.map(n.x), T.top + c.map(n.y), e, 0, Math.PI * 2), t.fill();
|
|
3005
3032
|
}
|
|
3006
3033
|
}
|
|
3007
3034
|
}), t.globalAlpha = 1;
|
|
3008
|
-
},
|
|
3035
|
+
}, N = e.flatMap((e) => e.data.map((e) => e.x)), P = e.flatMap((e) => e.data.map((e) => e.y)), F = N.length > 0, I = F ? Math.min(...N) : 0, L = F ? Math.max(...N) : 1, R = F ? Math.min(0, ...P) : 0, ee = F ? Math.max(...P) : 1;
|
|
3009
3036
|
return /* @__PURE__ */ p("div", {
|
|
3010
3037
|
style: {
|
|
3011
3038
|
display: "flex",
|
|
@@ -3032,11 +3059,11 @@ function rn({ series: e, title: t, description: n, r = 4, width: a, height: s, x
|
|
|
3032
3059
|
] }, `${e.id}-${n}`))) })
|
|
3033
3060
|
] }),
|
|
3034
3061
|
className: g,
|
|
3035
|
-
"data-state":
|
|
3062
|
+
"data-state": F ? void 0 : "empty",
|
|
3036
3063
|
plain: _,
|
|
3037
|
-
tooltip: h !== !1 &&
|
|
3038
|
-
if (h === !1 || !
|
|
3039
|
-
let r = t - T.left - T.right, i = n - T.top - T.bottom, a = m([
|
|
3064
|
+
tooltip: h !== !1 && F ? ({ width: t, height: n }) => {
|
|
3065
|
+
if (h === !1 || !F) return;
|
|
3066
|
+
let r = t - T.left - T.right, i = n - T.top - T.bottom, a = m([I, L], [0, r]), o = m([R, ee], [i, 0]);
|
|
3040
3067
|
return { points: e.flatMap((e) => w.value.has(e.id) ? [] : e.data.map((t, n) => ({
|
|
3041
3068
|
id: `${e.id}-${n}`,
|
|
3042
3069
|
cx: T.left + a.map(t.x),
|
|
@@ -3048,37 +3075,37 @@ function rn({ series: e, title: t, description: n, r = 4, width: a, height: s, x
|
|
|
3048
3075
|
} : void 0,
|
|
3049
3076
|
onSelect: y,
|
|
3050
3077
|
hover: "voronoi",
|
|
3051
|
-
renderer:
|
|
3052
|
-
paint:
|
|
3078
|
+
renderer: k ? "canvas" : "svg",
|
|
3079
|
+
paint: k ? M : void 0,
|
|
3053
3080
|
toolbox: C,
|
|
3054
3081
|
onRestore: S ? () => {
|
|
3055
|
-
|
|
3082
|
+
A.value = [S.min, S.max], j.value = /* @__PURE__ */ new Set();
|
|
3056
3083
|
} : void 0,
|
|
3057
3084
|
children: ({ width: t, height: n }) => {
|
|
3058
|
-
let i = t - T.left - T.right, a = n - T.top - T.bottom, o = m([
|
|
3085
|
+
let i = t - T.left - T.right, a = n - T.top - T.bottom, o = m([I, L], [0, i]), s = m([R, ee], [a, 0]);
|
|
3059
3086
|
return /* @__PURE__ */ f("g", { children: /* @__PURE__ */ p("g", {
|
|
3060
3087
|
transform: `translate(${T.left},${T.top})`,
|
|
3061
3088
|
children: [
|
|
3062
|
-
!_ && /* @__PURE__ */ f(
|
|
3089
|
+
!_ && /* @__PURE__ */ f(ft, {
|
|
3063
3090
|
scale: s,
|
|
3064
3091
|
orientation: "y",
|
|
3065
3092
|
length: i,
|
|
3066
3093
|
tickCount: l
|
|
3067
3094
|
}),
|
|
3068
|
-
!_ &&
|
|
3095
|
+
!_ && _t(v, {
|
|
3069
3096
|
xScale: o,
|
|
3070
3097
|
yScale: s,
|
|
3071
3098
|
innerW: i,
|
|
3072
3099
|
innerH: a
|
|
3073
3100
|
}),
|
|
3074
|
-
!
|
|
3101
|
+
!k && e.map((e, t) => {
|
|
3075
3102
|
if (w.value.has(e.id)) return null;
|
|
3076
|
-
let n = e.color ??
|
|
3103
|
+
let n = e.color ?? sn[t % sn.length];
|
|
3077
3104
|
return /* @__PURE__ */ f("g", {
|
|
3078
3105
|
"data-series": e.id,
|
|
3079
3106
|
children: e.data.map((t, i) => {
|
|
3080
|
-
let a = typeof r == "function" ? r(t) : t.r ?? r, c = S ?
|
|
3081
|
-
return m && m !== "circle" ? /* @__PURE__ */ f(
|
|
3107
|
+
let a = typeof r == "function" ? r(t) : t.r ?? r, c = S ? Vt(t.y, S) : void 0, l = c?.size ?? a, u = c?.color ?? n, d = S ? Ht(t.y, S, A.value, j.value) : !0, p = d ? .7 : .1, m = typeof b == "function" ? b(t, e.id) : b;
|
|
3108
|
+
return m && m !== "circle" ? /* @__PURE__ */ f(Ot, {
|
|
3082
3109
|
shape: m,
|
|
3083
3110
|
x: o.map(t.x),
|
|
3084
3111
|
y: s.map(t.y),
|
|
@@ -3115,17 +3142,17 @@ function rn({ series: e, title: t, description: n, r = 4, width: a, height: s, x
|
|
|
3115
3142
|
}) });
|
|
3116
3143
|
}
|
|
3117
3144
|
}),
|
|
3118
|
-
S &&
|
|
3145
|
+
S && F && /* @__PURE__ */ f(Ut, {
|
|
3119
3146
|
options: S,
|
|
3120
|
-
range:
|
|
3121
|
-
hidden:
|
|
3147
|
+
range: A,
|
|
3148
|
+
hidden: j,
|
|
3122
3149
|
label: t
|
|
3123
3150
|
}),
|
|
3124
|
-
|
|
3151
|
+
D && /* @__PURE__ */ f(Gt, {
|
|
3125
3152
|
series: e.map((e, t) => ({
|
|
3126
3153
|
id: e.id,
|
|
3127
3154
|
label: e.label,
|
|
3128
|
-
color: e.color ??
|
|
3155
|
+
color: e.color ?? sn[t % sn.length]
|
|
3129
3156
|
})),
|
|
3130
3157
|
hidden: w
|
|
3131
3158
|
})
|
|
@@ -3134,7 +3161,7 @@ function rn({ series: e, title: t, description: n, r = 4, width: a, height: s, x
|
|
|
3134
3161
|
}
|
|
3135
3162
|
//#endregion
|
|
3136
3163
|
//#region src/charts/sparkline/sparkline.tsx
|
|
3137
|
-
function
|
|
3164
|
+
function ln({ data: e, width: t = 120, height: n = 32, label: r, color: i = "var(--cascivo-chart-1)", endDot: a = !0 }) {
|
|
3138
3165
|
return /* @__PURE__ */ f(Q, {
|
|
3139
3166
|
title: r,
|
|
3140
3167
|
width: t,
|
|
@@ -3172,15 +3199,15 @@ function an({ data: e, width: t = 120, height: n = 32, label: r, color: i = "var
|
|
|
3172
3199
|
}
|
|
3173
3200
|
//#endregion
|
|
3174
3201
|
//#region src/charts/meter/meter.tsx
|
|
3175
|
-
function
|
|
3202
|
+
function un(e, t, n, r) {
|
|
3176
3203
|
if (!r) return "var(--cascivo-chart-1)";
|
|
3177
3204
|
let { warning: i, critical: a } = r;
|
|
3178
3205
|
return a != null && e >= a ? "var(--cascivo-color-destructive)" : i != null && e >= i ? "var(--cascivo-color-warning)" : "var(--cascivo-color-success)";
|
|
3179
3206
|
}
|
|
3180
|
-
function
|
|
3181
|
-
let c = n > t ? (Math.min(n, Math.max(t, e)) - t) / (n - t) : 0, l =
|
|
3207
|
+
function dn({ value: e, min: t = 0, max: n = 100, label: r, variant: i = "bar", thresholds: a, width: o = 200, height: s }) {
|
|
3208
|
+
let c = n > t ? (Math.min(n, Math.max(t, e)) - t) / (n - t) : 0, l = un(e, t, n, a);
|
|
3182
3209
|
if (i === "gauge") {
|
|
3183
|
-
let i = s ?? 100, a = o, u = a / 2, d = i * .9, m = Math.min(u, d) - 4, h = m * .65, g = Math.PI, _ =
|
|
3210
|
+
let i = s ?? 100, a = o, u = a / 2, d = i * .9, m = Math.min(u, d) - 4, h = m * .65, g = Math.PI, _ = N(u, d, m, h, g, 2 * Math.PI), v = g + c * Math.PI, y = c > 0 ? N(u, d, m, h, g, v) : "";
|
|
3184
3211
|
return /* @__PURE__ */ p("div", {
|
|
3185
3212
|
"aria-label": r,
|
|
3186
3213
|
role: "meter",
|
|
@@ -3256,10 +3283,10 @@ function sn({ value: e, min: t = 0, max: n = 100, label: r, variant: i = "bar",
|
|
|
3256
3283
|
}
|
|
3257
3284
|
//#endregion
|
|
3258
3285
|
//#region src/charts/kpi/kpi.tsx
|
|
3259
|
-
function
|
|
3286
|
+
function fn(e) {
|
|
3260
3287
|
return `${e >= 0 ? "+" : ""}${e.toLocaleString()}`;
|
|
3261
3288
|
}
|
|
3262
|
-
function
|
|
3289
|
+
function pn({ value: e, label: t, delta: n, deltaLabel: r, icon: i, sparkline: a, className: o }) {
|
|
3263
3290
|
let s = n != null && n >= 0, c = n != null && n < 0;
|
|
3264
3291
|
return /* @__PURE__ */ p("div", {
|
|
3265
3292
|
className: o,
|
|
@@ -3305,21 +3332,22 @@ function ln({ value: e, label: t, delta: n, deltaLabel: r, icon: i, sparkline: a
|
|
|
3305
3332
|
},
|
|
3306
3333
|
children: typeof e == "number" ? e.toLocaleString() : e
|
|
3307
3334
|
}), n != null && /* @__PURE__ */ p("span", {
|
|
3335
|
+
role: "img",
|
|
3308
3336
|
style: {
|
|
3309
3337
|
fontSize: "var(--cascivo-text-sm)",
|
|
3310
3338
|
fontWeight: 500,
|
|
3311
|
-
color: s ? "var(--cascivo-color-success)" : c ? "var(--cascivo-color-destructive)" : "var(--cascivo-color-foreground-muted)"
|
|
3339
|
+
color: s ? "var(--cascivo-color-success-foreground)" : c ? "var(--cascivo-color-destructive-foreground)" : "var(--cascivo-color-foreground-muted)"
|
|
3312
3340
|
},
|
|
3313
|
-
"aria-label": `Trend: ${
|
|
3341
|
+
"aria-label": `Trend: ${fn(n)}${r ? ` ${r}` : ""}`,
|
|
3314
3342
|
children: [
|
|
3315
3343
|
s ? "▲" : c ? "▼" : "–",
|
|
3316
3344
|
" ",
|
|
3317
|
-
|
|
3345
|
+
fn(n),
|
|
3318
3346
|
r && ` ${r}`
|
|
3319
3347
|
]
|
|
3320
3348
|
})]
|
|
3321
3349
|
}),
|
|
3322
|
-
a && a.length > 0 && /* @__PURE__ */ f(
|
|
3350
|
+
a && a.length > 0 && /* @__PURE__ */ f(ln, {
|
|
3323
3351
|
data: a,
|
|
3324
3352
|
label: `${t} trend`,
|
|
3325
3353
|
width: 120,
|
|
@@ -3330,9 +3358,9 @@ function ln({ value: e, label: t, delta: n, deltaLabel: r, icon: i, sparkline: a
|
|
|
3330
3358
|
}
|
|
3331
3359
|
//#endregion
|
|
3332
3360
|
//#region src/charts/histogram/histogram.tsx
|
|
3333
|
-
function
|
|
3361
|
+
function mn({ data: e, bins: t, title: n, label: r, description: i, width: a, height: s, className: c, plain: l }) {
|
|
3334
3362
|
o();
|
|
3335
|
-
let u = l ?
|
|
3363
|
+
let u = l ? Ve : Be, h = s ?? (l ? 48 : 300), g = V(e, t), _ = g.reduce((e, t) => Math.max(e, t.count), 0);
|
|
3336
3364
|
return /* @__PURE__ */ f(Q, {
|
|
3337
3365
|
title: n,
|
|
3338
3366
|
description: i,
|
|
@@ -3373,7 +3401,7 @@ function un({ data: e, bins: t, title: n, label: r, description: i, width: a, he
|
|
|
3373
3401
|
return /* @__PURE__ */ p("g", {
|
|
3374
3402
|
transform: `translate(${u.left},${u.top})`,
|
|
3375
3403
|
children: [
|
|
3376
|
-
!l && /* @__PURE__ */ f(
|
|
3404
|
+
!l && /* @__PURE__ */ f(ft, {
|
|
3377
3405
|
scale: i,
|
|
3378
3406
|
orientation: "y",
|
|
3379
3407
|
length: n.width
|
|
@@ -3386,8 +3414,7 @@ function un({ data: e, bins: t, title: n, label: r, description: i, width: a, he
|
|
|
3386
3414
|
width: o,
|
|
3387
3415
|
height: Math.max(0, c),
|
|
3388
3416
|
fill: "var(--cascivo-chart-1)",
|
|
3389
|
-
opacity: .85
|
|
3390
|
-
"aria-label": `${e.x0.toFixed(1)}–${e.x1.toFixed(1)}: ${e.count}`
|
|
3417
|
+
opacity: .85
|
|
3391
3418
|
}, t);
|
|
3392
3419
|
}),
|
|
3393
3420
|
!l && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f($, {
|
|
@@ -3407,13 +3434,13 @@ function un({ data: e, bins: t, title: n, label: r, description: i, width: a, he
|
|
|
3407
3434
|
}
|
|
3408
3435
|
//#endregion
|
|
3409
3436
|
//#region src/charts/boxplot/boxplot.tsx
|
|
3410
|
-
var
|
|
3411
|
-
function
|
|
3437
|
+
var hn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
3438
|
+
function gn({ series: e, title: t, description: n, width: r, height: i, className: a, plain: s }) {
|
|
3412
3439
|
o();
|
|
3413
|
-
let c = s ?
|
|
3440
|
+
let c = s ? Ve : Be, l = i ?? (s ? 48 : 320), u = e.map((e) => ({
|
|
3414
3441
|
...e,
|
|
3415
|
-
stats:
|
|
3416
|
-
})), h = e.flatMap((e) => e.values), [_, v] = h.length > 0 ?
|
|
3442
|
+
stats: H(e.values)
|
|
3443
|
+
})), h = e.flatMap((e) => e.values), [_, v] = h.length > 0 ? U(h) : [0, 1];
|
|
3417
3444
|
return /* @__PURE__ */ f(Q, {
|
|
3418
3445
|
title: t,
|
|
3419
3446
|
description: n,
|
|
@@ -3472,71 +3499,67 @@ function fn({ series: e, title: t, description: n, width: r, height: i, classNam
|
|
|
3472
3499
|
return /* @__PURE__ */ p("g", {
|
|
3473
3500
|
transform: `translate(${c.left},${c.top})`,
|
|
3474
3501
|
children: [u.map((e, t) => {
|
|
3475
|
-
let n =
|
|
3476
|
-
return /* @__PURE__ */ p("g", {
|
|
3477
|
-
"
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
"aria-label": `Outlier: ${e.toFixed(2)}`
|
|
3537
|
-
}, t))
|
|
3538
|
-
]
|
|
3539
|
-
}, e.id);
|
|
3502
|
+
let n = hn[t % hn.length] ?? "var(--cascivo-chart-1)", i = (r.map(e.id) ?? 0) + r.bandwidth / 2, o = r.bandwidth * .6, s = i - o / 2, c = a.map(e.stats.q1), l = a.map(e.stats.q3), u = a.map(e.stats.median), d = a.map(e.stats.min), m = a.map(e.stats.max);
|
|
3503
|
+
return /* @__PURE__ */ p("g", { children: [
|
|
3504
|
+
/* @__PURE__ */ f("line", {
|
|
3505
|
+
x1: i,
|
|
3506
|
+
y1: l,
|
|
3507
|
+
x2: i,
|
|
3508
|
+
y2: m,
|
|
3509
|
+
stroke: n,
|
|
3510
|
+
strokeWidth: 1.5
|
|
3511
|
+
}),
|
|
3512
|
+
/* @__PURE__ */ f("line", {
|
|
3513
|
+
x1: i,
|
|
3514
|
+
y1: c,
|
|
3515
|
+
x2: i,
|
|
3516
|
+
y2: d,
|
|
3517
|
+
stroke: n,
|
|
3518
|
+
strokeWidth: 1.5
|
|
3519
|
+
}),
|
|
3520
|
+
/* @__PURE__ */ f("line", {
|
|
3521
|
+
x1: i - o / 4,
|
|
3522
|
+
y1: m,
|
|
3523
|
+
x2: i + o / 4,
|
|
3524
|
+
y2: m,
|
|
3525
|
+
stroke: n,
|
|
3526
|
+
strokeWidth: 1.5
|
|
3527
|
+
}),
|
|
3528
|
+
/* @__PURE__ */ f("line", {
|
|
3529
|
+
x1: i - o / 4,
|
|
3530
|
+
y1: d,
|
|
3531
|
+
x2: i + o / 4,
|
|
3532
|
+
y2: d,
|
|
3533
|
+
stroke: n,
|
|
3534
|
+
strokeWidth: 1.5
|
|
3535
|
+
}),
|
|
3536
|
+
/* @__PURE__ */ f("rect", {
|
|
3537
|
+
x: s,
|
|
3538
|
+
y: l,
|
|
3539
|
+
width: o,
|
|
3540
|
+
height: Math.max(0, c - l),
|
|
3541
|
+
fill: n,
|
|
3542
|
+
fillOpacity: .25,
|
|
3543
|
+
stroke: n,
|
|
3544
|
+
strokeWidth: 1.5
|
|
3545
|
+
}),
|
|
3546
|
+
/* @__PURE__ */ f("line", {
|
|
3547
|
+
x1: s,
|
|
3548
|
+
y1: u,
|
|
3549
|
+
x2: s + o,
|
|
3550
|
+
y2: u,
|
|
3551
|
+
stroke: n,
|
|
3552
|
+
strokeWidth: 2.5
|
|
3553
|
+
}),
|
|
3554
|
+
e.stats.outliers.map((e, t) => /* @__PURE__ */ f("circle", {
|
|
3555
|
+
cx: i,
|
|
3556
|
+
cy: a.map(e),
|
|
3557
|
+
r: 3,
|
|
3558
|
+
fill: "none",
|
|
3559
|
+
stroke: n,
|
|
3560
|
+
strokeWidth: 1.5
|
|
3561
|
+
}, t))
|
|
3562
|
+
] }, e.id);
|
|
3540
3563
|
}), !s && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f($, {
|
|
3541
3564
|
scale: r,
|
|
3542
3565
|
orientation: "x",
|
|
@@ -3553,10 +3576,10 @@ function fn({ series: e, title: t, description: n, width: r, height: i, classNam
|
|
|
3553
3576
|
}
|
|
3554
3577
|
//#endregion
|
|
3555
3578
|
//#region src/charts/bubble-chart/bubble-chart.tsx
|
|
3556
|
-
var
|
|
3557
|
-
function
|
|
3579
|
+
var _n = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`), vn = 3, yn = 24;
|
|
3580
|
+
function bn({ series: e, title: t, description: n, width: r, height: a, tooltip: s, className: c, plain: l, glyph: u }) {
|
|
3558
3581
|
o();
|
|
3559
|
-
let h = i(null), g = l ?
|
|
3582
|
+
let h = i(null), g = l ? Ve : Be, v = a ?? (l ? 48 : 320), y = e.flatMap((e) => e.data), [b, x] = y.length > 0 ? U(y.map((e) => e.x)) : [0, 1], [S, C] = y.length > 0 ? U(y.map((e) => e.y)) : [0, 1], [w, T] = y.length > 0 ? U(y.map((e) => e.size)) : [0, 1], E = _([w, T], [vn, yn]), D = y.length > 0;
|
|
3560
3583
|
return /* @__PURE__ */ f(Q, {
|
|
3561
3584
|
title: t,
|
|
3562
3585
|
description: n,
|
|
@@ -3579,8 +3602,8 @@ function gn({ series: e, title: t, description: n, width: r, height: a, tooltip:
|
|
|
3579
3602
|
] }),
|
|
3580
3603
|
className: c,
|
|
3581
3604
|
plain: l,
|
|
3582
|
-
tooltip: s !== !1 &&
|
|
3583
|
-
if (s === !1 || !
|
|
3605
|
+
tooltip: s !== !1 && D ? ({ width: t, height: n }) => {
|
|
3606
|
+
if (s === !1 || !D) return;
|
|
3584
3607
|
let r = {
|
|
3585
3608
|
width: t - g.left - g.right,
|
|
3586
3609
|
height: n - g.top - g.bottom
|
|
@@ -3607,13 +3630,13 @@ function gn({ series: e, title: t, description: n, width: r, height: a, tooltip:
|
|
|
3607
3630
|
return /* @__PURE__ */ p("g", {
|
|
3608
3631
|
transform: `translate(${g.left},${g.top})`,
|
|
3609
3632
|
children: [
|
|
3610
|
-
!l && /* @__PURE__ */ f(
|
|
3633
|
+
!l && /* @__PURE__ */ f(ft, {
|
|
3611
3634
|
scale: s,
|
|
3612
3635
|
orientation: "y",
|
|
3613
3636
|
length: r.width
|
|
3614
3637
|
}),
|
|
3615
3638
|
e.map((e, t) => {
|
|
3616
|
-
let n =
|
|
3639
|
+
let n = _n[t % _n.length] ?? "var(--cascivo-chart-1)";
|
|
3617
3640
|
return /* @__PURE__ */ f("g", {
|
|
3618
3641
|
opacity: h.value !== null && h.value !== e.name ? .2 : 1,
|
|
3619
3642
|
onMouseEnter: () => {
|
|
@@ -3623,28 +3646,24 @@ function gn({ series: e, title: t, description: n, width: r, height: a, tooltip:
|
|
|
3623
3646
|
h.value = null;
|
|
3624
3647
|
},
|
|
3625
3648
|
children: e.data.map((t, r) => {
|
|
3626
|
-
let i = typeof u == "function" ? u(t, e.name) : u
|
|
3627
|
-
return i && i !== "circle" ? /* @__PURE__ */ f("g", {
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
strokeWidth: 1
|
|
3638
|
-
})
|
|
3639
|
-
}, r) : /* @__PURE__ */ f("circle", {
|
|
3649
|
+
let i = typeof u == "function" ? u(t, e.name) : u;
|
|
3650
|
+
return i && i !== "circle" ? /* @__PURE__ */ f("g", { children: /* @__PURE__ */ f(Ot, {
|
|
3651
|
+
shape: i,
|
|
3652
|
+
x: o.map(t.x),
|
|
3653
|
+
y: s.map(t.y),
|
|
3654
|
+
size: E(t.size) * 2,
|
|
3655
|
+
color: n,
|
|
3656
|
+
opacity: .6,
|
|
3657
|
+
stroke: n,
|
|
3658
|
+
strokeWidth: 1
|
|
3659
|
+
}) }, r) : /* @__PURE__ */ f("circle", {
|
|
3640
3660
|
cx: o.map(t.x),
|
|
3641
3661
|
cy: s.map(t.y),
|
|
3642
3662
|
r: E(t.size),
|
|
3643
3663
|
fill: n,
|
|
3644
3664
|
fillOpacity: .6,
|
|
3645
3665
|
stroke: n,
|
|
3646
|
-
strokeWidth: 1
|
|
3647
|
-
"aria-label": a
|
|
3666
|
+
strokeWidth: 1
|
|
3648
3667
|
}, r);
|
|
3649
3668
|
})
|
|
3650
3669
|
}, e.name);
|
|
@@ -3666,11 +3685,11 @@ function gn({ series: e, title: t, description: n, width: r, height: a, tooltip:
|
|
|
3666
3685
|
}
|
|
3667
3686
|
//#endregion
|
|
3668
3687
|
//#region src/charts/combo-chart/combo-chart.tsx
|
|
3669
|
-
function
|
|
3688
|
+
function xn({ bars: e, line: t, title: n, description: r, secondAxis: i = !1, width: a, height: s, tooltip: c, className: l, plain: u, annotations: h }) {
|
|
3670
3689
|
o();
|
|
3671
|
-
let _ = s ?? (u ? 48 : 320), v = u ?
|
|
3672
|
-
...
|
|
3673
|
-
right: i ? 60 :
|
|
3690
|
+
let _ = s ?? (u ? 48 : 320), v = u ? Ve : {
|
|
3691
|
+
...Be,
|
|
3692
|
+
right: i ? 60 : Be.right
|
|
3674
3693
|
}, y = 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;
|
|
3675
3694
|
return /* @__PURE__ */ f(Q, {
|
|
3676
3695
|
title: n,
|
|
@@ -3721,12 +3740,12 @@ function _n({ bars: e, line: t, title: n, description: r, secondAxis: i = !1, wi
|
|
|
3721
3740
|
return /* @__PURE__ */ p("g", {
|
|
3722
3741
|
transform: `translate(${v.left},${v.top})`,
|
|
3723
3742
|
children: [
|
|
3724
|
-
!u && /* @__PURE__ */ f(
|
|
3743
|
+
!u && /* @__PURE__ */ f(ft, {
|
|
3725
3744
|
scale: s,
|
|
3726
3745
|
orientation: "y",
|
|
3727
3746
|
length: a.width
|
|
3728
3747
|
}),
|
|
3729
|
-
!u &&
|
|
3748
|
+
!u && _t(h, {
|
|
3730
3749
|
xScale: o,
|
|
3731
3750
|
yScale: s,
|
|
3732
3751
|
innerW: a.width,
|
|
@@ -3740,8 +3759,7 @@ function _n({ bars: e, line: t, title: n, description: r, secondAxis: i = !1, wi
|
|
|
3740
3759
|
width: o.bandwidth,
|
|
3741
3760
|
height: Math.max(0, a.height - n),
|
|
3742
3761
|
fill: "var(--cascivo-chart-1)",
|
|
3743
|
-
opacity: .75
|
|
3744
|
-
"aria-label": `${e.label}: ${e.value}`
|
|
3762
|
+
opacity: .75
|
|
3745
3763
|
}, e.label);
|
|
3746
3764
|
}),
|
|
3747
3765
|
_ && /* @__PURE__ */ f("path", {
|
|
@@ -3778,14 +3796,14 @@ function _n({ bars: e, line: t, title: n, description: r, secondAxis: i = !1, wi
|
|
|
3778
3796
|
}
|
|
3779
3797
|
//#endregion
|
|
3780
3798
|
//#region src/charts/heatmap/heatmap.tsx
|
|
3781
|
-
function
|
|
3799
|
+
function Sn({ data: e, title: t, description: n, width: r, height: a, className: s, plain: c, visualMap: l, toolbox: u }) {
|
|
3782
3800
|
o();
|
|
3783
|
-
let m = a ?? (c ? 48 : 320), h = c ?
|
|
3801
|
+
let m = a ?? (c ? 48 : 320), h = c ? Ve : {
|
|
3784
3802
|
top: 20,
|
|
3785
3803
|
right: 20,
|
|
3786
3804
|
bottom: 60,
|
|
3787
3805
|
left: 60
|
|
3788
|
-
}, _ = [...new Set(e.map((e) => e.x))], v = [...new Set(e.map((e) => e.y))], [y, b] = e.length > 0 ?
|
|
3806
|
+
}, _ = [...new Set(e.map((e) => e.x))], v = [...new Set(e.map((e) => e.y))], [y, b] = e.length > 0 ? U(e.map((e) => e.value)) : [0, 1], x = b - y || 1, S = (e) => Math.max(0, Math.min(1, (e - y) / x)), C = i([l?.min ?? y, l?.max ?? b]), w = i(/* @__PURE__ */ new Set()), T = /* @__PURE__ */ f(Q, {
|
|
3789
3807
|
title: t,
|
|
3790
3808
|
description: n,
|
|
3791
3809
|
width: r,
|
|
@@ -3835,7 +3853,7 @@ function vn({ data: e, title: t, description: n, width: r, height: a, className:
|
|
|
3835
3853
|
return /* @__PURE__ */ p("g", {
|
|
3836
3854
|
transform: `translate(${h.left},${h.top})`,
|
|
3837
3855
|
children: [e.map((e, t) => {
|
|
3838
|
-
let n = i.map(e.x) ?? 0, r = a.map(e.y) ?? 0, o = Math.round(S(e.value) * 100), s = l ?
|
|
3856
|
+
let n = i.map(e.x) ?? 0, r = a.map(e.y) ?? 0, o = Math.round(S(e.value) * 100), s = l ? Vt(e.value, l).color ?? "var(--cascivo-chart-1)" : `color-mix(in oklab, var(--cascivo-chart-1) ${o}%, var(--cascivo-color-neutral-100))`, c = l ? Ht(e.value, l, C.value, w.value) : !0;
|
|
3839
3857
|
return /* @__PURE__ */ f("rect", {
|
|
3840
3858
|
x: n,
|
|
3841
3859
|
y: r,
|
|
@@ -3844,8 +3862,7 @@ function vn({ data: e, title: t, description: n, width: r, height: a, className:
|
|
|
3844
3862
|
fill: s,
|
|
3845
3863
|
fillOpacity: c ? 1 : .12,
|
|
3846
3864
|
stroke: "var(--cascivo-surface-base)",
|
|
3847
|
-
strokeWidth: 1
|
|
3848
|
-
"aria-label": `${e.x}, ${e.y}: ${e.value}`
|
|
3865
|
+
strokeWidth: 1
|
|
3849
3866
|
}, t);
|
|
3850
3867
|
}), !c && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f($, {
|
|
3851
3868
|
scale: i,
|
|
@@ -3866,7 +3883,7 @@ function vn({ data: e, title: t, description: n, width: r, height: a, className:
|
|
|
3866
3883
|
flexDirection: "column",
|
|
3867
3884
|
gap: "0.5rem"
|
|
3868
3885
|
},
|
|
3869
|
-
children: [T, /* @__PURE__ */ f(
|
|
3886
|
+
children: [T, /* @__PURE__ */ f(Ut, {
|
|
3870
3887
|
options: l,
|
|
3871
3888
|
range: C,
|
|
3872
3889
|
hidden: w,
|
|
@@ -3876,8 +3893,8 @@ function vn({ data: e, title: t, description: n, width: r, height: a, className:
|
|
|
3876
3893
|
}
|
|
3877
3894
|
//#endregion
|
|
3878
3895
|
//#region src/charts/treemap/treemap.tsx
|
|
3879
|
-
var
|
|
3880
|
-
function
|
|
3896
|
+
var Cn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
3897
|
+
function wn({ data: e, title: t, description: n, width: r, height: i, className: a, plain: c }) {
|
|
3881
3898
|
o();
|
|
3882
3899
|
let l = s();
|
|
3883
3900
|
return /* @__PURE__ */ f(Q, {
|
|
@@ -3893,7 +3910,7 @@ function bn({ data: e, title: t, description: n, width: r, height: i, className:
|
|
|
3893
3910
|
className: a,
|
|
3894
3911
|
plain: c,
|
|
3895
3912
|
tooltip: e.length > 0 ? ({ width: t, height: n }) => {
|
|
3896
|
-
if (e.length !== 0) return { points:
|
|
3913
|
+
if (e.length !== 0) return { points: q(e.map((e) => ({
|
|
3897
3914
|
id: e.id,
|
|
3898
3915
|
value: e.value
|
|
3899
3916
|
})), t, n).map((t) => {
|
|
@@ -3909,7 +3926,7 @@ function bn({ data: e, title: t, description: n, width: r, height: i, className:
|
|
|
3909
3926
|
} : void 0,
|
|
3910
3927
|
children: ({ width: t, height: n }) => {
|
|
3911
3928
|
if (e.length === 0) return null;
|
|
3912
|
-
let r =
|
|
3929
|
+
let r = q(e.map((e) => ({
|
|
3913
3930
|
id: e.id,
|
|
3914
3931
|
value: e.value
|
|
3915
3932
|
})), t, n), i = new Map(e.map((e) => [e.id, e.label]));
|
|
@@ -3921,36 +3938,33 @@ function bn({ data: e, title: t, description: n, width: r, height: i, className:
|
|
|
3921
3938
|
width: Math.max(0, e.w - 4),
|
|
3922
3939
|
height: Math.max(0, e.h - 4)
|
|
3923
3940
|
})
|
|
3924
|
-
}, e.id)) }), r.map((
|
|
3925
|
-
let
|
|
3926
|
-
return /* @__PURE__ */ p("g", {
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
children: a
|
|
3944
|
-
})]
|
|
3945
|
-
}, t.id);
|
|
3941
|
+
}, e.id)) }), r.map((e, t) => {
|
|
3942
|
+
let n = Cn[t % Cn.length] ?? "var(--cascivo-chart-1)", r = i.get(e.id) ?? e.id;
|
|
3943
|
+
return /* @__PURE__ */ p("g", { children: [/* @__PURE__ */ f("rect", {
|
|
3944
|
+
x: e.x,
|
|
3945
|
+
y: e.y,
|
|
3946
|
+
width: Math.max(0, e.w - 1),
|
|
3947
|
+
height: Math.max(0, e.h - 1),
|
|
3948
|
+
fill: n,
|
|
3949
|
+
fillOpacity: .8,
|
|
3950
|
+
stroke: "var(--cascivo-surface-base)",
|
|
3951
|
+
strokeWidth: 1
|
|
3952
|
+
}), !c && e.w > 30 && e.h > 18 && /* @__PURE__ */ f("text", {
|
|
3953
|
+
x: e.x + 4,
|
|
3954
|
+
y: e.y + 14,
|
|
3955
|
+
fontSize: Math.min(12, e.w / 5),
|
|
3956
|
+
fill: "currentColor",
|
|
3957
|
+
clipPath: `url(#${l}-${e.id})`,
|
|
3958
|
+
children: r
|
|
3959
|
+
})] }, e.id);
|
|
3946
3960
|
})] });
|
|
3947
3961
|
}
|
|
3948
3962
|
});
|
|
3949
3963
|
}
|
|
3950
3964
|
//#endregion
|
|
3951
3965
|
//#region src/charts/radar/radar.tsx
|
|
3952
|
-
var
|
|
3953
|
-
function
|
|
3966
|
+
var Tn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`), En = 4;
|
|
3967
|
+
function Dn(e, t, n, r, i) {
|
|
3954
3968
|
let a = e.length;
|
|
3955
3969
|
return e.map((e, o) => {
|
|
3956
3970
|
let s = o / a * 2 * Math.PI - Math.PI / 2, c = e / t * i;
|
|
@@ -3960,7 +3974,7 @@ function Cn(e, t, n, r, i) {
|
|
|
3960
3974
|
};
|
|
3961
3975
|
});
|
|
3962
3976
|
}
|
|
3963
|
-
function
|
|
3977
|
+
function On({ axes: e, series: t, max: n, title: r, description: i, width: a, height: s, className: c, plain: l }) {
|
|
3964
3978
|
let u = s ?? (l ? 48 : 320);
|
|
3965
3979
|
o();
|
|
3966
3980
|
let m = n ?? Math.max(1, ...t.flatMap((e) => e.values)), h = e.length;
|
|
@@ -3992,7 +4006,7 @@ function wn({ axes: e, series: t, max: n, title: r, description: i, width: a, he
|
|
|
3992
4006
|
})) };
|
|
3993
4007
|
} : void 0,
|
|
3994
4008
|
children: ({ width: n, height: r }) => {
|
|
3995
|
-
let i = n / 2, a = r / 2, o = Math.min(i, a) * .72, s = Array.from({ length:
|
|
4009
|
+
let i = n / 2, a = r / 2, o = Math.min(i, a) * .72, s = Array.from({ length: En }, (e, t) => (t + 1) / En * o), c = Array.from({ length: h }, (e, t) => {
|
|
3996
4010
|
let n = t / h * 2 * Math.PI - Math.PI / 2;
|
|
3997
4011
|
return {
|
|
3998
4012
|
x: i + Math.cos(n) * o,
|
|
@@ -4030,14 +4044,13 @@ function wn({ axes: e, series: t, max: n, title: r, description: i, width: a, he
|
|
|
4030
4044
|
}, n);
|
|
4031
4045
|
}),
|
|
4032
4046
|
t.map((e, t) => {
|
|
4033
|
-
let n =
|
|
4047
|
+
let n = Dn(e.values, m, i, a, o).map((e) => `${e.x},${e.y}`).join(" "), r = Tn[t % Tn.length] ?? "var(--cascivo-chart-1)";
|
|
4034
4048
|
return /* @__PURE__ */ f("polygon", {
|
|
4035
4049
|
points: n,
|
|
4036
4050
|
fill: r,
|
|
4037
4051
|
fillOpacity: .15,
|
|
4038
4052
|
stroke: r,
|
|
4039
|
-
strokeWidth: 2
|
|
4040
|
-
"aria-label": `${e.label}: ${e.values.join(", ")}`
|
|
4053
|
+
strokeWidth: 2
|
|
4041
4054
|
}, e.id);
|
|
4042
4055
|
})
|
|
4043
4056
|
] });
|
|
@@ -4046,12 +4059,12 @@ function wn({ axes: e, series: t, max: n, title: r, description: i, width: a, he
|
|
|
4046
4059
|
}
|
|
4047
4060
|
//#endregion
|
|
4048
4061
|
//#region src/charts/bullet/bullet.tsx
|
|
4049
|
-
var
|
|
4062
|
+
var kn = [
|
|
4050
4063
|
"var(--cascivo-color-neutral-200)",
|
|
4051
4064
|
"var(--cascivo-color-neutral-300)",
|
|
4052
4065
|
"var(--cascivo-color-neutral-400)"
|
|
4053
4066
|
];
|
|
4054
|
-
function
|
|
4067
|
+
function An({ value: e, target: t, ranges: n, label: r, min: i = 0, max: a, width: s = 300, height: c = 40, className: l }) {
|
|
4055
4068
|
o();
|
|
4056
4069
|
let u = [...n].sort((e, t) => e - t), h = m([i, a ?? u[u.length - 1] ?? (Math.max(e, t) * 1.2 || 1)], [0, s]), g = c * .35, _ = (c - g) / 2, v = c * .7, y = (c - v) / 2;
|
|
4057
4070
|
return /* @__PURE__ */ p("figure", {
|
|
@@ -4078,7 +4091,7 @@ function En({ value: e, target: t, ranges: n, label: r, min: i = 0, max: a, widt
|
|
|
4078
4091
|
y: 0,
|
|
4079
4092
|
width: Math.max(0, r),
|
|
4080
4093
|
height: c,
|
|
4081
|
-
fill:
|
|
4094
|
+
fill: kn[t % kn.length] ?? "var(--cascivo-color-neutral-200)"
|
|
4082
4095
|
}, t);
|
|
4083
4096
|
}),
|
|
4084
4097
|
/* @__PURE__ */ f("rect", {
|
|
@@ -4086,8 +4099,7 @@ function En({ value: e, target: t, ranges: n, label: r, min: i = 0, max: a, widt
|
|
|
4086
4099
|
y: _,
|
|
4087
4100
|
width: Math.max(0, h.map(e) - h.map(i)),
|
|
4088
4101
|
height: g,
|
|
4089
|
-
fill: "var(--cascivo-chart-1)"
|
|
4090
|
-
"aria-label": `Value: ${e}`
|
|
4102
|
+
fill: "var(--cascivo-chart-1)"
|
|
4091
4103
|
}),
|
|
4092
4104
|
/* @__PURE__ */ f("line", {
|
|
4093
4105
|
x1: h.map(t),
|
|
@@ -4095,8 +4107,7 @@ function En({ value: e, target: t, ranges: n, label: r, min: i = 0, max: a, widt
|
|
|
4095
4107
|
x2: h.map(t),
|
|
4096
4108
|
y2: y + v,
|
|
4097
4109
|
stroke: "var(--cascivo-text-primary)",
|
|
4098
|
-
strokeWidth: 2.5
|
|
4099
|
-
"aria-label": `Target: ${t}`
|
|
4110
|
+
strokeWidth: 2.5
|
|
4100
4111
|
})
|
|
4101
4112
|
] })
|
|
4102
4113
|
}), /* @__PURE__ */ f("figcaption", {
|
|
@@ -4107,10 +4118,10 @@ function En({ value: e, target: t, ranges: n, label: r, min: i = 0, max: a, widt
|
|
|
4107
4118
|
}
|
|
4108
4119
|
//#endregion
|
|
4109
4120
|
//#region src/charts/radial-bar/radial-bar.tsx
|
|
4110
|
-
var
|
|
4111
|
-
function
|
|
4121
|
+
var jn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
4122
|
+
function Mn({ data: e, title: t, description: n, size: r, width: a, height: s, max: c, sweep: l = 270, centerValue: u, centerLabel: d, centerSlot: m, tooltip: h, legend: g, className: _, plain: v }) {
|
|
4112
4123
|
o();
|
|
4113
|
-
let y = i(/* @__PURE__ */ new Set()), b = a ?? r, x = s ?? r ?? (v ? 48 : 300), S = v ? !1 : g ?? e.length > 1, C = e.length > 0, w = c ?? Math.max(1, ...e.map((e) => e.value)), T = Math.min(360, Math.max(0, l)) * Math.PI / 180, E = -T / 2,
|
|
4124
|
+
let y = i(/* @__PURE__ */ new Set()), b = a ?? r, x = s ?? r ?? (v ? 48 : 300), S = v ? !1 : g ?? e.length > 1, C = e.length > 0, w = c ?? Math.max(1, ...e.map((e) => e.value)), T = Math.min(360, Math.max(0, l)) * Math.PI / 180, E = -T / 2, D = (t, n) => {
|
|
4114
4125
|
let r = t / 2, i = n / 2, a = Math.min(r, i) - 8, o = a * .32, s = e.filter((e) => !y.value.has(e.id));
|
|
4115
4126
|
return {
|
|
4116
4127
|
cx: r,
|
|
@@ -4120,9 +4131,9 @@ function On({ data: e, title: t, description: n, size: r, width: a, height: s, m
|
|
|
4120
4131
|
span: s.length > 0 ? (a - o) / s.length : 0,
|
|
4121
4132
|
visible: s
|
|
4122
4133
|
};
|
|
4123
|
-
},
|
|
4134
|
+
}, O = ({ width: e, height: t }) => {
|
|
4124
4135
|
if (h === !1 || !C) return;
|
|
4125
|
-
let { cx: n, cy: r, maxR: i, span: a, visible: o } =
|
|
4136
|
+
let { cx: n, cy: r, maxR: i, span: a, visible: o } = D(e, t);
|
|
4126
4137
|
return { points: o.map((e, t) => {
|
|
4127
4138
|
let o = i - t * a, s = (o + (o - a * .7)) / 2, c = E + T * Math.min(1, e.value / w);
|
|
4128
4139
|
return {
|
|
@@ -4133,14 +4144,14 @@ function On({ data: e, title: t, description: n, size: r, width: a, height: s, m
|
|
|
4133
4144
|
value: e.value,
|
|
4134
4145
|
seriesId: e.id,
|
|
4135
4146
|
percent: w > 0 ? e.value / w * 100 : 0,
|
|
4136
|
-
color: e.color ??
|
|
4147
|
+
color: e.color ?? jn[t % jn.length]
|
|
4137
4148
|
};
|
|
4138
4149
|
}) };
|
|
4139
|
-
},
|
|
4150
|
+
}, k = /* @__PURE__ */ p("table", { children: [
|
|
4140
4151
|
/* @__PURE__ */ f("caption", { children: t }),
|
|
4141
4152
|
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", { children: "Label" }), /* @__PURE__ */ f("th", { children: "Value" })] }) }),
|
|
4142
4153
|
/* @__PURE__ */ f("tbody", { children: e.map((e) => /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("td", { children: e.label }), /* @__PURE__ */ f("td", { children: e.value })] }, e.id)) })
|
|
4143
|
-
] }),
|
|
4154
|
+
] }), A = u != null || d != null || m != null;
|
|
4144
4155
|
return /* @__PURE__ */ p("div", {
|
|
4145
4156
|
style: {
|
|
4146
4157
|
display: "flex",
|
|
@@ -4152,27 +4163,27 @@ function On({ data: e, title: t, description: n, size: r, width: a, height: s, m
|
|
|
4152
4163
|
description: n,
|
|
4153
4164
|
width: b,
|
|
4154
4165
|
height: x,
|
|
4155
|
-
fallback:
|
|
4166
|
+
fallback: k,
|
|
4156
4167
|
className: _,
|
|
4157
4168
|
"data-state": C ? void 0 : "empty",
|
|
4158
4169
|
plain: v,
|
|
4159
|
-
tooltip: h !== !1 && C ?
|
|
4170
|
+
tooltip: h !== !1 && C ? O : void 0,
|
|
4160
4171
|
children: ({ width: e, height: t }) => {
|
|
4161
|
-
let { cx: n, cy: r, maxR: i, holeR: a, span: o, visible: s } =
|
|
4172
|
+
let { cx: n, cy: r, maxR: i, holeR: a, span: o, visible: s } = D(e, t);
|
|
4162
4173
|
return /* @__PURE__ */ p("g", { children: [s.map((e, t) => {
|
|
4163
|
-
let a = i - t * o, s = a - o * .7, c = e.color ??
|
|
4174
|
+
let a = i - t * o, s = a - o * .7, c = e.color ?? jn[t % jn.length], l = Math.max(0, Math.min(1, e.value / w)), u = E + T * l;
|
|
4164
4175
|
return /* @__PURE__ */ p("g", {
|
|
4165
4176
|
"data-series": e.id,
|
|
4166
4177
|
children: [/* @__PURE__ */ f("path", {
|
|
4167
|
-
d:
|
|
4178
|
+
d: N(n, r, a, s, E, E + T),
|
|
4168
4179
|
fill: "var(--cascivo-chart-grid)",
|
|
4169
4180
|
fillOpacity: .35
|
|
4170
4181
|
}), l > 0 && /* @__PURE__ */ f("path", {
|
|
4171
|
-
d:
|
|
4182
|
+
d: N(n, r, a, s, E, u),
|
|
4172
4183
|
fill: c
|
|
4173
4184
|
})]
|
|
4174
4185
|
}, e.id);
|
|
4175
|
-
}), !v &&
|
|
4186
|
+
}), !v && A && (m == null ? /* @__PURE__ */ p("g", {
|
|
4176
4187
|
"data-center": "",
|
|
4177
4188
|
children: [u != null && /* @__PURE__ */ f("text", {
|
|
4178
4189
|
x: n,
|
|
@@ -4212,11 +4223,11 @@ function On({ data: e, title: t, description: n, size: r, width: a, height: s, m
|
|
|
4212
4223
|
})
|
|
4213
4224
|
}))] });
|
|
4214
4225
|
}
|
|
4215
|
-
}), S && /* @__PURE__ */ f(
|
|
4226
|
+
}), S && /* @__PURE__ */ f(Gt, {
|
|
4216
4227
|
series: e.map((e, t) => ({
|
|
4217
4228
|
id: e.id,
|
|
4218
4229
|
label: e.label,
|
|
4219
|
-
color: e.color ??
|
|
4230
|
+
color: e.color ?? jn[t % jn.length]
|
|
4220
4231
|
})),
|
|
4221
4232
|
hidden: y
|
|
4222
4233
|
})]
|
|
@@ -4224,10 +4235,10 @@ function On({ data: e, title: t, description: n, size: r, width: a, height: s, m
|
|
|
4224
4235
|
}
|
|
4225
4236
|
//#endregion
|
|
4226
4237
|
//#region src/charts/funnel/funnel.tsx
|
|
4227
|
-
var
|
|
4228
|
-
function
|
|
4238
|
+
var Nn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
4239
|
+
function Pn({ data: e, title: t, description: n, width: r, height: i, showConversion: a = !1, tooltip: s, className: c, plain: l }) {
|
|
4229
4240
|
o();
|
|
4230
|
-
let u = l ?
|
|
4241
|
+
let u = l ? Ve : Be, d = i ?? (l ? 48 : 320), h = e.length > 0, g = e[0]?.value ?? 0, _ = Math.max(1, ...e.map((e) => e.value));
|
|
4231
4242
|
return /* @__PURE__ */ f(Q, {
|
|
4232
4243
|
title: t,
|
|
4233
4244
|
description: n,
|
|
@@ -4261,7 +4272,7 @@ function An({ data: e, title: t, description: n, width: r, height: i, showConver
|
|
|
4261
4272
|
value: e.value,
|
|
4262
4273
|
seriesId: e.id,
|
|
4263
4274
|
percent: g > 0 ? e.value / g * 100 : 0,
|
|
4264
|
-
color: e.color ??
|
|
4275
|
+
color: e.color ?? Nn[t % Nn.length]
|
|
4265
4276
|
})),
|
|
4266
4277
|
format: (e) => `${e.label}: ${e.value} (${Math.round(e.percent ?? 0)}%)`
|
|
4267
4278
|
};
|
|
@@ -4271,7 +4282,7 @@ function An({ data: e, title: t, description: n, width: r, height: i, showConver
|
|
|
4271
4282
|
if (r <= 0 || e.length === 0) return null;
|
|
4272
4283
|
let o = i / e.length, s = m([0, _], [0, r]), c = (e) => s.map(e) / 2, d = u.left + r / 2;
|
|
4273
4284
|
return /* @__PURE__ */ f("g", { children: e.map((t, n) => {
|
|
4274
|
-
let r = e[n + 1], i = c(t.value), s = c(r ? r.value : t.value), m = u.top + n * o, h = m + o * (r ? 1 : .9), _ = t.color ??
|
|
4285
|
+
let r = e[n + 1], i = c(t.value), s = c(r ? r.value : t.value), m = u.top + n * o, h = m + o * (r ? 1 : .9), _ = t.color ?? Nn[n % Nn.length], v = [
|
|
4275
4286
|
[d - i, m],
|
|
4276
4287
|
[d + i, m],
|
|
4277
4288
|
[d + s, h],
|
|
@@ -4283,7 +4294,7 @@ function An({ data: e, title: t, description: n, width: r, height: i, showConver
|
|
|
4283
4294
|
points: v,
|
|
4284
4295
|
fill: _,
|
|
4285
4296
|
fillOpacity: .85
|
|
4286
|
-
}), !l && /* @__PURE__ */ f(
|
|
4297
|
+
}), !l && /* @__PURE__ */ f(xt, {
|
|
4287
4298
|
x: d,
|
|
4288
4299
|
y: m + o / 2,
|
|
4289
4300
|
text: a ? `${t.label} · ${t.value} (${y}%)` : `${t.label} · ${t.value}`,
|
|
@@ -4296,10 +4307,10 @@ function An({ data: e, title: t, description: n, width: r, height: i, showConver
|
|
|
4296
4307
|
}
|
|
4297
4308
|
//#endregion
|
|
4298
4309
|
//#region src/charts/stream/stream.tsx
|
|
4299
|
-
var
|
|
4300
|
-
function
|
|
4310
|
+
var Fn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
4311
|
+
function In({ series: e, categories: t, title: n, description: r, offset: a = "silhouette", curve: s = "basis", width: c, height: l, legend: u, tooltip: d, className: h, plain: _ }) {
|
|
4301
4312
|
o();
|
|
4302
|
-
let v = i(/* @__PURE__ */ new Set()), y = _ ?
|
|
4313
|
+
let v = i(/* @__PURE__ */ new Set()), y = _ ? Ve : Be, b = l ?? (_ ? 48 : 300), x = _ ? !1 : u ?? e.length > 1, S = t.length > 0 && e.length > 0, C = J(e.map((e) => e.values), a), [T, E] = te(C);
|
|
4303
4314
|
return /* @__PURE__ */ p("div", {
|
|
4304
4315
|
style: {
|
|
4305
4316
|
display: "flex",
|
|
@@ -4334,7 +4345,7 @@ function Mn({ series: e, categories: t, title: n, description: r, offset: a = "s
|
|
|
4334
4345
|
label: `${e.label} · ${String(t)}`,
|
|
4335
4346
|
value: e.values[i] ?? 0,
|
|
4336
4347
|
seriesId: e.id,
|
|
4337
|
-
color: e.color ??
|
|
4348
|
+
color: e.color ?? Fn[n % Fn.length]
|
|
4338
4349
|
};
|
|
4339
4350
|
});
|
|
4340
4351
|
}) };
|
|
@@ -4347,7 +4358,7 @@ function Mn({ series: e, categories: t, title: n, description: r, offset: a = "s
|
|
|
4347
4358
|
transform: `translate(${y.left},${y.top})`,
|
|
4348
4359
|
children: [e.map((e, n) => {
|
|
4349
4360
|
if (v.value.has(e.id)) return null;
|
|
4350
|
-
let r = C[n], i = e.color ??
|
|
4361
|
+
let r = C[n], i = e.color ?? Fn[n % Fn.length], a = t.map((e, t) => [l(t), c.map(r[t][1])]), o = t.map((e, t) => [l(t), c.map(r[t][0])]);
|
|
4351
4362
|
return /* @__PURE__ */ f("path", {
|
|
4352
4363
|
d: `${w(a, s)}${w([...o].reverse(), s).replace(/^M/, "L")}Z`,
|
|
4353
4364
|
fill: i,
|
|
@@ -4362,11 +4373,11 @@ function Mn({ series: e, categories: t, title: n, description: r, offset: a = "s
|
|
|
4362
4373
|
})]
|
|
4363
4374
|
});
|
|
4364
4375
|
}
|
|
4365
|
-
}), x && /* @__PURE__ */ f(
|
|
4376
|
+
}), x && /* @__PURE__ */ f(Gt, {
|
|
4366
4377
|
series: e.map((e, t) => ({
|
|
4367
4378
|
id: e.id,
|
|
4368
4379
|
label: e.label,
|
|
4369
|
-
color: e.color ??
|
|
4380
|
+
color: e.color ?? Fn[t % Fn.length]
|
|
4370
4381
|
})),
|
|
4371
4382
|
hidden: v
|
|
4372
4383
|
})]
|
|
@@ -4374,10 +4385,10 @@ function Mn({ series: e, categories: t, title: n, description: r, offset: a = "s
|
|
|
4374
4385
|
}
|
|
4375
4386
|
//#endregion
|
|
4376
4387
|
//#region src/charts/sunburst/sunburst.tsx
|
|
4377
|
-
var
|
|
4378
|
-
function
|
|
4388
|
+
var Ln = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
4389
|
+
function Rn({ data: e, title: t, description: n, size: r, width: i, height: a, tooltip: s, className: c, plain: l }) {
|
|
4379
4390
|
o();
|
|
4380
|
-
let u = i ?? r, d = a ?? r ?? (l ? 48 : 300), m =
|
|
4391
|
+
let u = i ?? r, d = a ?? r ?? (l ? 48 : 300), m = Y(e), h = m > 0, g = X(e), _ = Math.max(1, ne(g));
|
|
4381
4392
|
return /* @__PURE__ */ f(Q, {
|
|
4382
4393
|
title: t,
|
|
4383
4394
|
description: n,
|
|
@@ -4404,7 +4415,7 @@ function Pn({ data: e, title: t, description: n, size: r, width: i, height: a, t
|
|
|
4404
4415
|
label: e.node.label,
|
|
4405
4416
|
value: e.value,
|
|
4406
4417
|
percent: m > 0 ? e.value / m * 100 : 0,
|
|
4407
|
-
color: e.node.color ??
|
|
4418
|
+
color: e.node.color ?? Ln[t % Ln.length]
|
|
4408
4419
|
};
|
|
4409
4420
|
}),
|
|
4410
4421
|
format: (e) => `${e.label}: ${e.value} (${Math.round(e.percent ?? 0)}%)`
|
|
@@ -4413,9 +4424,9 @@ function Pn({ data: e, title: t, description: n, size: r, width: i, height: a, t
|
|
|
4413
4424
|
children: ({ width: e, height: t }) => {
|
|
4414
4425
|
let n = e / 2, r = t / 2, i = (Math.min(n, r) - 8) / _;
|
|
4415
4426
|
return /* @__PURE__ */ f("g", { children: g.filter((e) => e.depth > 0).map((e, t) => {
|
|
4416
|
-
let a = (e.depth - 1) * i, o = e.depth * i, s = e.node.color ??
|
|
4427
|
+
let a = (e.depth - 1) * i, o = e.depth * i, s = e.node.color ?? Ln[t % Ln.length];
|
|
4417
4428
|
return /* @__PURE__ */ f("path", {
|
|
4418
|
-
d:
|
|
4429
|
+
d: N(n, r, o, a, e.a0, e.a1),
|
|
4419
4430
|
fill: s,
|
|
4420
4431
|
fillOpacity: 1 - (e.depth - 1) * .18,
|
|
4421
4432
|
stroke: "var(--cascivo-color-surface)",
|
|
@@ -4428,10 +4439,10 @@ function Pn({ data: e, title: t, description: n, size: r, width: i, height: a, t
|
|
|
4428
4439
|
}
|
|
4429
4440
|
//#endregion
|
|
4430
4441
|
//#region src/charts/sankey/sankey.tsx
|
|
4431
|
-
var
|
|
4432
|
-
function
|
|
4442
|
+
var zn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
4443
|
+
function Bn({ nodes: e, links: t, title: n, description: r, width: i, height: a, tooltip: s, className: c, plain: l }) {
|
|
4433
4444
|
o();
|
|
4434
|
-
let u = l ?
|
|
4445
|
+
let u = l ? Ve : Be, d = a ?? (l ? 48 : 320), m = e.length > 0 && t.length > 0, h = (t, n) => e.find((e) => e.id === t)?.color ?? zn[n % zn.length];
|
|
4435
4446
|
return /* @__PURE__ */ f(Q, {
|
|
4436
4447
|
title: n,
|
|
4437
4448
|
description: r,
|
|
@@ -4455,7 +4466,7 @@ function In({ nodes: e, links: t, title: n, description: r, width: i, height: a,
|
|
|
4455
4466
|
plain: l,
|
|
4456
4467
|
tooltip: s && m ? ({ width: n, height: r }) => {
|
|
4457
4468
|
if (!s || !m) return;
|
|
4458
|
-
let { nodes: i } =
|
|
4469
|
+
let { nodes: i } = Z(e, t, {
|
|
4459
4470
|
width: n - u.left - u.right,
|
|
4460
4471
|
height: r - u.top - u.bottom
|
|
4461
4472
|
});
|
|
@@ -4471,14 +4482,14 @@ function In({ nodes: e, links: t, title: n, description: r, width: i, height: a,
|
|
|
4471
4482
|
children: ({ width: n, height: r }) => {
|
|
4472
4483
|
let i = n - u.left - u.right, a = r - u.top - u.bottom;
|
|
4473
4484
|
if (i <= 0 || !m) return null;
|
|
4474
|
-
let { nodes: o, links: s } =
|
|
4485
|
+
let { nodes: o, links: s } = Z(e, t, {
|
|
4475
4486
|
width: i,
|
|
4476
4487
|
height: a
|
|
4477
4488
|
});
|
|
4478
4489
|
return /* @__PURE__ */ p("g", {
|
|
4479
4490
|
transform: `translate(${u.left},${u.top})`,
|
|
4480
4491
|
children: [s.map((e, t) => /* @__PURE__ */ f("path", {
|
|
4481
|
-
d:
|
|
4492
|
+
d: re(e),
|
|
4482
4493
|
fill: h(e.source.id, o.indexOf(e.source)),
|
|
4483
4494
|
fillOpacity: .32,
|
|
4484
4495
|
"data-link": ""
|
|
@@ -4507,23 +4518,23 @@ function In({ nodes: e, links: t, title: n, description: r, width: i, height: a,
|
|
|
4507
4518
|
}
|
|
4508
4519
|
//#endregion
|
|
4509
4520
|
//#region src/charts/calendar/calendar.tsx
|
|
4510
|
-
var
|
|
4511
|
-
function
|
|
4521
|
+
var Vn = 864e5, Hn = (e) => e instanceof Date ? e : new Date(e), Un = (e) => e.toISOString().slice(0, 10);
|
|
4522
|
+
function Wn(e) {
|
|
4512
4523
|
let t = new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate()));
|
|
4513
4524
|
return t.setUTCDate(t.getUTCDate() - t.getUTCDay()), t;
|
|
4514
4525
|
}
|
|
4515
|
-
function
|
|
4526
|
+
function Gn({ data: e, title: t, description: n, from: r, to: a, width: s, height: c, tooltip: l, className: u, plain: d, visualMap: m }) {
|
|
4516
4527
|
o();
|
|
4517
4528
|
let h = e.length > 0, g = i([m?.min ?? 0, m?.max ?? 1]), _ = i(/* @__PURE__ */ new Set()), v = /* @__PURE__ */ new Map();
|
|
4518
|
-
for (let t of e) v.set(
|
|
4519
|
-
let y = e.map((e) =>
|
|
4529
|
+
for (let t of e) v.set(Un(Hn(t.day)), t.value);
|
|
4530
|
+
let y = e.map((e) => Hn(e.day)), b = Wn(r ? Hn(r) : y.reduce((e, t) => t < e ? t : e, y[0] ?? /* @__PURE__ */ new Date())), x = a ? Hn(a) : y.reduce((e, t) => t > e ? t : e, y[0] ?? /* @__PURE__ */ new Date()), S = h ? Math.max(1, Math.ceil((x.getTime() - b.getTime()) / Vn / 7)) : 1, C = Math.max(1, ...e.map((e) => e.value)), w = c ?? (d ? 48 : 160), T = [];
|
|
4520
4531
|
for (let e = 0; e < S; e++) for (let t = 0; t < 7; t++) {
|
|
4521
|
-
let n = new Date(b.getTime() + (e * 7 + t) *
|
|
4532
|
+
let n = new Date(b.getTime() + (e * 7 + t) * Vn);
|
|
4522
4533
|
n > x || T.push({
|
|
4523
4534
|
col: e,
|
|
4524
4535
|
row: t,
|
|
4525
4536
|
date: n,
|
|
4526
|
-
value: v.get(
|
|
4537
|
+
value: v.get(Un(n)) ?? 0
|
|
4527
4538
|
});
|
|
4528
4539
|
}
|
|
4529
4540
|
let E = /* @__PURE__ */ f(Q, {
|
|
@@ -4534,7 +4545,7 @@ function Vn({ data: e, title: t, description: n, from: r, to: a, width: s, heigh
|
|
|
4534
4545
|
fallback: /* @__PURE__ */ p("table", { children: [
|
|
4535
4546
|
/* @__PURE__ */ f("caption", { children: t }),
|
|
4536
4547
|
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", { children: "Day" }), /* @__PURE__ */ f("th", { children: "Value" })] }) }),
|
|
4537
|
-
/* @__PURE__ */ f("tbody", { children: e.map((e, t) => /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("td", { children:
|
|
4548
|
+
/* @__PURE__ */ f("tbody", { children: e.map((e, t) => /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("td", { children: Un(Hn(e.day)) }), /* @__PURE__ */ f("td", { children: e.value })] }, t)) })
|
|
4538
4549
|
] }),
|
|
4539
4550
|
className: u,
|
|
4540
4551
|
"data-state": h ? void 0 : "empty",
|
|
@@ -4544,10 +4555,10 @@ function Vn({ data: e, title: t, description: n, from: r, to: a, width: s, heigh
|
|
|
4544
4555
|
let t = Math.max(2, (e - (S - 1) * 2) / S);
|
|
4545
4556
|
return {
|
|
4546
4557
|
points: T.map((e, n) => ({
|
|
4547
|
-
id: `${
|
|
4558
|
+
id: `${Un(e.date)}-${n}`,
|
|
4548
4559
|
cx: e.col * (t + 2) + t / 2,
|
|
4549
4560
|
cy: e.row * (t + 2) + t / 2,
|
|
4550
|
-
label:
|
|
4561
|
+
label: Un(e.date),
|
|
4551
4562
|
value: e.value
|
|
4552
4563
|
})),
|
|
4553
4564
|
format: (e) => `${e.label}: ${e.value}`
|
|
@@ -4556,7 +4567,7 @@ function Vn({ data: e, title: t, description: n, from: r, to: a, width: s, heigh
|
|
|
4556
4567
|
children: ({ width: e }) => {
|
|
4557
4568
|
let t = Math.max(2, (e - (S - 1) * 2) / S);
|
|
4558
4569
|
return /* @__PURE__ */ f("g", { children: T.map((e, n) => {
|
|
4559
|
-
let r = m ?
|
|
4570
|
+
let r = m ? Vt(e.value, m).color : void 0, i = m ? Ht(e.value, m, g.value, _.value) : !0;
|
|
4560
4571
|
return /* @__PURE__ */ f("rect", {
|
|
4561
4572
|
x: e.col * (t + 2),
|
|
4562
4573
|
y: e.row * (t + 2),
|
|
@@ -4565,7 +4576,7 @@ function Vn({ data: e, title: t, description: n, from: r, to: a, width: s, heigh
|
|
|
4565
4576
|
rx: 1.5,
|
|
4566
4577
|
fill: r ?? "var(--cascivo-chart-2)",
|
|
4567
4578
|
fillOpacity: m ? e.value > 0 && i ? 1 : .08 : e.value > 0 ? .15 + .85 * (e.value / C) : .06,
|
|
4568
|
-
"data-day":
|
|
4579
|
+
"data-day": Un(e.date)
|
|
4569
4580
|
}, n);
|
|
4570
4581
|
}) });
|
|
4571
4582
|
}
|
|
@@ -4576,7 +4587,7 @@ function Vn({ data: e, title: t, description: n, from: r, to: a, width: s, heigh
|
|
|
4576
4587
|
flexDirection: "column",
|
|
4577
4588
|
gap: "0.5rem"
|
|
4578
4589
|
},
|
|
4579
|
-
children: [E, /* @__PURE__ */ f(
|
|
4590
|
+
children: [E, /* @__PURE__ */ f(Ut, {
|
|
4580
4591
|
options: m,
|
|
4581
4592
|
range: g,
|
|
4582
4593
|
hidden: _,
|
|
@@ -4586,122 +4597,201 @@ function Vn({ data: e, title: t, description: n, from: r, to: a, width: s, heigh
|
|
|
4586
4597
|
}
|
|
4587
4598
|
//#endregion
|
|
4588
4599
|
//#region src/charts/candlestick/candlestick.tsx
|
|
4589
|
-
function
|
|
4600
|
+
function Kn({ data: e, title: t, description: n, width: r, height: s, yTicks: l = 5, upColor: u = "var(--cascivo-chart-2)", downColor: h = "var(--cascivo-chart-4)", volume: _, tooltip: v, className: y, plain: b, annotations: x, brush: S, dataZoom: C, zoom: w, syncId: T, tooltipMode: E }) {
|
|
4590
4601
|
o();
|
|
4591
|
-
let
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
}
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
height: m,
|
|
4668
|
-
fill: i,
|
|
4669
|
-
"data-body": ""
|
|
4670
|
-
}),
|
|
4671
|
-
l && e.volume !== void 0 && /* @__PURE__ */ f("rect", {
|
|
4672
|
-
x: n - E / 2,
|
|
4673
|
-
y: y + (h - e.volume / C * h),
|
|
4674
|
-
width: E,
|
|
4675
|
-
height: e.volume / C * h,
|
|
4676
|
-
fill: i,
|
|
4677
|
-
fillOpacity: .4,
|
|
4678
|
-
"data-volume": ""
|
|
4679
|
-
})
|
|
4602
|
+
let D = b ? Ve : Be, O = s ?? (b ? 64 : 320), k = e.length, A = (S || C || w || T !== void 0) && k > 0, j = i([0, Math.max(0, k - 1)]), M = c(null);
|
|
4603
|
+
T && !M.current && (M.current = ot(T)), a(() => () => {
|
|
4604
|
+
T && st(T);
|
|
4605
|
+
}), a(() => {
|
|
4606
|
+
let e = M.current;
|
|
4607
|
+
if (!e) return;
|
|
4608
|
+
let t = e.window.value, n = j.peek();
|
|
4609
|
+
t && (t[0] !== n[0] || t[1] !== n[1]) && (j.value = t);
|
|
4610
|
+
}), a(() => {
|
|
4611
|
+
let e = M.current;
|
|
4612
|
+
if (!e) return;
|
|
4613
|
+
let t = j.value, n = e.window.peek();
|
|
4614
|
+
(!n || n[0] !== t[0] || n[1] !== t[1]) && (e.window.value = t);
|
|
4615
|
+
});
|
|
4616
|
+
let N = A ? e.slice(j.value[0], j.value[1] + 1) : e, P = N.length > 0, F = P ? Math.min(...N.map((e) => e.low)) : 0, I = P ? Math.max(...N.map((e) => e.high)) : 1, L = P ? Math.max(1, ...N.map((e) => e.volume ?? 0)) : 1, R = N.map((e) => e.t);
|
|
4617
|
+
return /* @__PURE__ */ p("div", {
|
|
4618
|
+
style: {
|
|
4619
|
+
display: "flex",
|
|
4620
|
+
flexDirection: "column",
|
|
4621
|
+
gap: "0.5rem"
|
|
4622
|
+
},
|
|
4623
|
+
children: [
|
|
4624
|
+
/* @__PURE__ */ f(Q, {
|
|
4625
|
+
title: t,
|
|
4626
|
+
description: n,
|
|
4627
|
+
width: r,
|
|
4628
|
+
height: O,
|
|
4629
|
+
fallback: /* @__PURE__ */ p("table", { children: [
|
|
4630
|
+
/* @__PURE__ */ f("caption", { children: t }),
|
|
4631
|
+
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [
|
|
4632
|
+
/* @__PURE__ */ f("th", { children: "Period" }),
|
|
4633
|
+
/* @__PURE__ */ f("th", { children: "Open" }),
|
|
4634
|
+
/* @__PURE__ */ f("th", { children: "High" }),
|
|
4635
|
+
/* @__PURE__ */ f("th", { children: "Low" }),
|
|
4636
|
+
/* @__PURE__ */ f("th", { children: "Close" })
|
|
4637
|
+
] }) }),
|
|
4638
|
+
/* @__PURE__ */ f("tbody", { children: N.map((e, t) => /* @__PURE__ */ p("tr", { children: [
|
|
4639
|
+
/* @__PURE__ */ f("td", { children: e.t }),
|
|
4640
|
+
/* @__PURE__ */ f("td", { children: e.open }),
|
|
4641
|
+
/* @__PURE__ */ f("td", { children: e.high }),
|
|
4642
|
+
/* @__PURE__ */ f("td", { children: e.low }),
|
|
4643
|
+
/* @__PURE__ */ f("td", { children: e.close })
|
|
4644
|
+
] }, t)) })
|
|
4645
|
+
] }),
|
|
4646
|
+
className: y,
|
|
4647
|
+
"data-state": P ? void 0 : "empty",
|
|
4648
|
+
plain: b,
|
|
4649
|
+
tooltip: v !== !1 && P ? ({ width: e, height: t }) => {
|
|
4650
|
+
if (v === !1 || !P) return;
|
|
4651
|
+
let n = e - D.left - D.right, r = t - D.top - D.bottom;
|
|
4652
|
+
if (n <= 0) return;
|
|
4653
|
+
let i = g(R, [0, n], .3), a = r - (_ ? Math.min(r * .2, 60) : 0), o = m([F, I], [a, 0]);
|
|
4654
|
+
if (E === "axis") return {
|
|
4655
|
+
points: N.map((e, t) => ({
|
|
4656
|
+
id: `c-${t}`,
|
|
4657
|
+
cx: D.left + (i.map(e.t) ?? 0) + i.bandwidth / 2,
|
|
4658
|
+
cy: D.top + o.map(e.high),
|
|
4659
|
+
label: e.t,
|
|
4660
|
+
value: e.close,
|
|
4661
|
+
segments: [
|
|
4662
|
+
{
|
|
4663
|
+
label: "O",
|
|
4664
|
+
value: e.open
|
|
4665
|
+
},
|
|
4666
|
+
{
|
|
4667
|
+
label: "H",
|
|
4668
|
+
value: e.high
|
|
4669
|
+
},
|
|
4670
|
+
{
|
|
4671
|
+
label: "L",
|
|
4672
|
+
value: e.low
|
|
4673
|
+
},
|
|
4674
|
+
{
|
|
4675
|
+
label: "C",
|
|
4676
|
+
value: e.close
|
|
4677
|
+
}
|
|
4680
4678
|
]
|
|
4681
|
-
},
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4679
|
+
})),
|
|
4680
|
+
mode: "axis",
|
|
4681
|
+
format: (e) => {
|
|
4682
|
+
let t = N[parseInt(e.id.split("-")[1] ?? "0", 10)];
|
|
4683
|
+
return t ? `${t.t} — O ${t.open} H ${t.high} L ${t.low} C ${t.close}` : `${e.label}: ${e.value}`;
|
|
4684
|
+
}
|
|
4685
|
+
};
|
|
4686
|
+
let s = m([F, I], [r, 0]);
|
|
4687
|
+
return {
|
|
4688
|
+
points: N.map((e, t) => ({
|
|
4689
|
+
id: `c-${t}`,
|
|
4690
|
+
cx: D.left + (i.map(e.t) ?? 0) + i.bandwidth / 2,
|
|
4691
|
+
cy: D.top + s.map(e.high),
|
|
4692
|
+
label: e.t,
|
|
4693
|
+
value: e.close
|
|
4694
|
+
})),
|
|
4695
|
+
format: (e) => {
|
|
4696
|
+
let t = N[parseInt(e.id.split("-")[1] ?? "0", 10)];
|
|
4697
|
+
return t ? `${t.t} — O ${t.open} H ${t.high} L ${t.low} C ${t.close}` : `${e.label}: ${e.value}`;
|
|
4698
|
+
}
|
|
4699
|
+
};
|
|
4700
|
+
} : void 0,
|
|
4701
|
+
zoom: w && k > 1 ? {
|
|
4702
|
+
window: j,
|
|
4703
|
+
count: k
|
|
4704
|
+
} : void 0,
|
|
4705
|
+
onRestore: A ? () => {
|
|
4706
|
+
j.value = [0, Math.max(0, k - 1)];
|
|
4707
|
+
} : void 0,
|
|
4708
|
+
children: ({ width: e, height: t }) => {
|
|
4709
|
+
let n = e - D.left - D.right, r = t - D.top - D.bottom;
|
|
4710
|
+
if (n <= 0 || !P) return null;
|
|
4711
|
+
let i = g(R, [0, n], .3), a = m([F, I], [r, 0]), o = _ ? Math.min(r * .2, 60) : 0, s = r - o, c = m([F, I], [s, 0]), v = i.bandwidth;
|
|
4712
|
+
return /* @__PURE__ */ p("g", {
|
|
4713
|
+
transform: `translate(${D.left},${D.top})`,
|
|
4714
|
+
children: [
|
|
4715
|
+
!b && /* @__PURE__ */ f(ft, {
|
|
4716
|
+
scale: a,
|
|
4717
|
+
orientation: "y",
|
|
4718
|
+
length: n,
|
|
4719
|
+
tickCount: l
|
|
4720
|
+
}),
|
|
4721
|
+
N.map((e, t) => {
|
|
4722
|
+
let n = (i.map(e.t) ?? 0) + v / 2, r = e.close >= e.open, a = r ? u : h, l = c.map(e.open), d = c.map(e.close), m = Math.min(l, d), g = Math.max(1, Math.abs(d - l));
|
|
4723
|
+
return /* @__PURE__ */ p("g", {
|
|
4724
|
+
"data-candle": r ? "up" : "down",
|
|
4725
|
+
children: [
|
|
4726
|
+
/* @__PURE__ */ f("line", {
|
|
4727
|
+
x1: n,
|
|
4728
|
+
x2: n,
|
|
4729
|
+
y1: c.map(e.high),
|
|
4730
|
+
y2: c.map(e.low),
|
|
4731
|
+
stroke: a,
|
|
4732
|
+
strokeWidth: 1,
|
|
4733
|
+
"data-wick": ""
|
|
4734
|
+
}),
|
|
4735
|
+
/* @__PURE__ */ f("rect", {
|
|
4736
|
+
x: n - v / 2,
|
|
4737
|
+
y: m,
|
|
4738
|
+
width: v,
|
|
4739
|
+
height: g,
|
|
4740
|
+
fill: a,
|
|
4741
|
+
"data-body": ""
|
|
4742
|
+
}),
|
|
4743
|
+
_ && e.volume !== void 0 && /* @__PURE__ */ f("rect", {
|
|
4744
|
+
x: n - v / 2,
|
|
4745
|
+
y: s + (o - e.volume / L * o),
|
|
4746
|
+
width: v,
|
|
4747
|
+
height: e.volume / L * o,
|
|
4748
|
+
fill: a,
|
|
4749
|
+
fillOpacity: .4,
|
|
4750
|
+
"data-volume": ""
|
|
4751
|
+
})
|
|
4752
|
+
]
|
|
4753
|
+
}, t);
|
|
4754
|
+
}),
|
|
4755
|
+
!b && _t(x, {
|
|
4756
|
+
xScale: i,
|
|
4757
|
+
yScale: c,
|
|
4758
|
+
innerW: n,
|
|
4759
|
+
innerH: s
|
|
4760
|
+
}),
|
|
4761
|
+
!b && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f($, {
|
|
4762
|
+
scale: i,
|
|
4763
|
+
orientation: "x",
|
|
4764
|
+
length: n,
|
|
4765
|
+
transform: `translate(0,${r})`
|
|
4766
|
+
}), /* @__PURE__ */ f($, {
|
|
4767
|
+
scale: a,
|
|
4768
|
+
orientation: "y",
|
|
4769
|
+
length: s,
|
|
4770
|
+
tickCount: l
|
|
4771
|
+
})] })
|
|
4772
|
+
]
|
|
4773
|
+
});
|
|
4774
|
+
}
|
|
4775
|
+
}),
|
|
4776
|
+
S && !C && k > 1 && /* @__PURE__ */ f(Nt, {
|
|
4777
|
+
count: k,
|
|
4778
|
+
window: j,
|
|
4779
|
+
label: "Time range"
|
|
4780
|
+
}),
|
|
4781
|
+
C && k > 1 && /* @__PURE__ */ f(Pt, {
|
|
4782
|
+
count: k,
|
|
4783
|
+
window: j,
|
|
4784
|
+
label: "Time range"
|
|
4785
|
+
})
|
|
4786
|
+
]
|
|
4697
4787
|
});
|
|
4698
4788
|
}
|
|
4699
4789
|
//#endregion
|
|
4700
4790
|
//#region src/charts/polar/polar.tsx
|
|
4701
|
-
var
|
|
4702
|
-
function
|
|
4791
|
+
var qn = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
|
|
4792
|
+
function Jn({ data: e, title: t, description: n, mode: r = "bar", width: i, height: a, rings: s = 4, max: c, tooltip: l, className: u, plain: m }) {
|
|
4703
4793
|
o();
|
|
4704
|
-
let h = a ?? 320, g = e.length > 0, _ = e.map((e) => e.label), v = c ?? (g ? Math.max(1, ...e.map((e) => e.value)) : 1), y =
|
|
4794
|
+
let h = a ?? 320, g = e.length > 0, _ = e.map((e) => e.label), v = c ?? (g ? Math.max(1, ...e.map((e) => e.value)) : 1), y = ye(_), b = /* @__PURE__ */ p("table", { children: [
|
|
4705
4795
|
/* @__PURE__ */ f("caption", { children: t }),
|
|
4706
4796
|
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("th", { children: "Category" }), /* @__PURE__ */ f("th", { children: "Value" })] }) }),
|
|
4707
4797
|
/* @__PURE__ */ f("tbody", { children: e.map((e, t) => /* @__PURE__ */ p("tr", { children: [/* @__PURE__ */ f("td", { children: e.label }), /* @__PURE__ */ f("td", { children: e.value })] }, t)) })
|
|
@@ -4711,7 +4801,7 @@ function Wn({ data: e, title: t, description: n, mode: r = "bar", width: i, heig
|
|
|
4711
4801
|
cx: n,
|
|
4712
4802
|
cy: r,
|
|
4713
4803
|
outerR: i,
|
|
4714
|
-
rScale:
|
|
4804
|
+
rScale: be([0, v], [0, i])
|
|
4715
4805
|
};
|
|
4716
4806
|
};
|
|
4717
4807
|
return /* @__PURE__ */ f(Q, {
|
|
@@ -4728,7 +4818,7 @@ function Wn({ data: e, title: t, description: n, mode: r = "bar", width: i, heig
|
|
|
4728
4818
|
let { cx: r, cy: i, rScale: a } = x(t, n);
|
|
4729
4819
|
return {
|
|
4730
4820
|
points: e.map((e, t) => {
|
|
4731
|
-
let n = y.center(e.label) ?? 0, [o, s] =
|
|
4821
|
+
let n = y.center(e.label) ?? 0, [o, s] = ve(r, i, a.map(e.value), n);
|
|
4732
4822
|
return {
|
|
4733
4823
|
id: `p-${t}`,
|
|
4734
4824
|
cx: o,
|
|
@@ -4744,7 +4834,7 @@ function Wn({ data: e, title: t, description: n, mode: r = "bar", width: i, heig
|
|
|
4744
4834
|
if (!g) return null;
|
|
4745
4835
|
let { cx: i, cy: a, outerR: o, rScale: c } = x(t, n), l = Array.from({ length: s }, (e, t) => o * (t + 1) / s), u = e.map((e) => {
|
|
4746
4836
|
let t = y.center(e.label) ?? 0;
|
|
4747
|
-
return
|
|
4837
|
+
return ve(i, a, c.map(e.value), t);
|
|
4748
4838
|
});
|
|
4749
4839
|
return /* @__PURE__ */ p("g", { children: [
|
|
4750
4840
|
!m && l.map((e, t) => /* @__PURE__ */ f("circle", {
|
|
@@ -4759,13 +4849,13 @@ function Wn({ data: e, title: t, description: n, mode: r = "bar", width: i, heig
|
|
|
4759
4849
|
r === "bar" ? e.map((e, t) => {
|
|
4760
4850
|
let n = y.map(e.label) ?? 0, r = y.bandwidth * .1;
|
|
4761
4851
|
return /* @__PURE__ */ f("path", {
|
|
4762
|
-
d:
|
|
4763
|
-
fill: e.color ??
|
|
4852
|
+
d: N(i, a, c.map(e.value), 0, n + r, n + y.bandwidth - r),
|
|
4853
|
+
fill: e.color ?? qn[t % qn.length],
|
|
4764
4854
|
fillOpacity: .85,
|
|
4765
4855
|
"data-wedge": ""
|
|
4766
4856
|
}, t);
|
|
4767
4857
|
}) : (() => {
|
|
4768
|
-
let t = [...u, u[0]], n = e[0]?.color ??
|
|
4858
|
+
let t = [...u, u[0]], n = e[0]?.color ?? qn[0];
|
|
4769
4859
|
return /* @__PURE__ */ p(d, { children: [r === "area" && /* @__PURE__ */ f("path", {
|
|
4770
4860
|
d: `${w(t, "linear")}Z`,
|
|
4771
4861
|
fill: n,
|
|
@@ -4781,7 +4871,7 @@ function Wn({ data: e, title: t, description: n, mode: r = "bar", width: i, heig
|
|
|
4781
4871
|
})] });
|
|
4782
4872
|
})(),
|
|
4783
4873
|
!m && e.map((e, t) => {
|
|
4784
|
-
let n = y.center(e.label) ?? 0, [r, s] =
|
|
4874
|
+
let n = y.center(e.label) ?? 0, [r, s] = ve(i, a, o + 12, n);
|
|
4785
4875
|
return /* @__PURE__ */ f("text", {
|
|
4786
4876
|
x: r,
|
|
4787
4877
|
y: s,
|
|
@@ -4799,10 +4889,10 @@ function Wn({ data: e, title: t, description: n, mode: r = "bar", width: i, heig
|
|
|
4799
4889
|
}
|
|
4800
4890
|
//#endregion
|
|
4801
4891
|
//#region src/charts/gauge/gauge.tsx
|
|
4802
|
-
var
|
|
4803
|
-
function
|
|
4892
|
+
var Yn = Math.PI / 180;
|
|
4893
|
+
function Xn({ value: e, min: t = 0, max: n = 100, thresholds: r, unit: i = "", sweep: a = 270, ticks: s = 5, title: c, description: l, width: u, height: d, className: m, plain: h }) {
|
|
4804
4894
|
o();
|
|
4805
|
-
let g = d ?? 240, _ = n - t || 1, v = Math.max(t, Math.min(n, e)), y = (v - t) / _, b = a *
|
|
4895
|
+
let g = d ?? 240, _ = n - t || 1, v = Math.max(t, Math.min(n, e)), y = (v - t) / _, b = a * Yn, x = -b / 2, S = (e) => x + (e - t) / _ * b;
|
|
4806
4896
|
return /* @__PURE__ */ f(Q, {
|
|
4807
4897
|
title: c,
|
|
4808
4898
|
description: l,
|
|
@@ -4822,7 +4912,7 @@ function Kn({ value: e, min: t = 0, max: n = 100, thresholds: r, unit: i = "", s
|
|
|
4822
4912
|
}], w = t, T = Array.from({ length: s + 1 }, (e, n) => t + _ * n / s);
|
|
4823
4913
|
return /* @__PURE__ */ p("g", { children: [
|
|
4824
4914
|
/* @__PURE__ */ f("path", {
|
|
4825
|
-
d:
|
|
4915
|
+
d: N(c, l, u, m, x, x + b),
|
|
4826
4916
|
fill: "var(--cascivo-chart-grid)",
|
|
4827
4917
|
fillOpacity: .25,
|
|
4828
4918
|
"data-track": ""
|
|
@@ -4830,13 +4920,13 @@ function Kn({ value: e, min: t = 0, max: n = 100, thresholds: r, unit: i = "", s
|
|
|
4830
4920
|
C.map((e, t) => {
|
|
4831
4921
|
let r = S(w), i = S(Math.min(n, e.upTo));
|
|
4832
4922
|
return w = e.upTo, /* @__PURE__ */ f("path", {
|
|
4833
|
-
d:
|
|
4923
|
+
d: N(c, l, u, m, r, i),
|
|
4834
4924
|
fill: e.color,
|
|
4835
4925
|
"data-zone": ""
|
|
4836
4926
|
}, t);
|
|
4837
4927
|
}),
|
|
4838
4928
|
!h && T.map((e, t) => {
|
|
4839
|
-
let n = S(e), [r, i] =
|
|
4929
|
+
let n = S(e), [r, i] = ve(c, l, m - 2, n), [a, o] = ve(c, l, m - 8, n), [s, u] = ve(c, l, m - 18, n);
|
|
4840
4930
|
return /* @__PURE__ */ p("g", { children: [/* @__PURE__ */ f("line", {
|
|
4841
4931
|
x1: r,
|
|
4842
4932
|
y1: i,
|
|
@@ -4856,7 +4946,7 @@ function Kn({ value: e, min: t = 0, max: n = 100, thresholds: r, unit: i = "", s
|
|
|
4856
4946
|
})] }, t);
|
|
4857
4947
|
}),
|
|
4858
4948
|
(() => {
|
|
4859
|
-
let [e, t] =
|
|
4949
|
+
let [e, t] = ve(c, l, g, S(v));
|
|
4860
4950
|
return /* @__PURE__ */ f("line", {
|
|
4861
4951
|
x1: c,
|
|
4862
4952
|
y1: l,
|
|
@@ -4890,4 +4980,4 @@ function Kn({ value: e, min: t = 0, max: n = 100, thresholds: r, unit: i = "", s
|
|
|
4890
4980
|
});
|
|
4891
4981
|
}
|
|
4892
4982
|
//#endregion
|
|
4893
|
-
export {
|
|
4983
|
+
export { $t as AreaChart, $ as Axis, nn as BarChart, gn as Boxplot, Nt as Brush, bn as BubbleChart, An as Bullet, Gn as Calendar, Kn as Candlestick, Ke as CanvasLayer, Et as ChartDefs, Q as ChartFrame, xn as ComboChart, Be as DEFAULT_MARGINS, xt as DataLabel, Pt as DataZoom, Pn as Funnel, Xn as Gauge, Ot as Glyph, ft as GridLines, Sn as Heatmap, mn as Histogram, pn as Kpi, Gt as Legend, Zt as LineChart, dn as Meter, Ve as PLAIN_MARGINS, on as PieChart, Jn as Polar, On as Radar, Mn as RadialBar, Bn as Sankey, cn as ScatterChart, ln as Sparkline, In as Stream, Rn as Sunburst, Mt as Text, $e as Toolbox, wn as Treemap, Ut as VisualMap, ct as _syncGroupCount, Te as aggregate, ye as angleBand, vt as annotationSummary, N as arcPath, M as areaPath, g as bandScale, Ee as bin, V as binValues, Re as bindStream, H as boxStats, z as cellPath, Fe as decimate, me as divergingRamp, rt as download, je as encode, Me as encodeCategory, U as extent, Tt as fillFor, xe as filter, ot as getSyncGroup, Dt as glyphPath, Ct as gradientId, Ze as isZoomed, w as linePath, m as linearScale, re as linkPath, v as logScale, Ne as lttb, Vt as mapVisual, ne as maxDepth, Pe as minmax, I as nearestIndex, h as niceTicks, Xe as panWindow, X as partition, wt as patternId, Bt as pieceIndex, ve as polarPoint, be as radiusScale, _e as rampLightness, he as rampOf, ge as rampStops, ke as regression, st as releaseSyncGroup, gt as renderAnnotation, _t as renderAnnotations, qe as resolveColor, bt as resolveLabels, Z as sankeyLayout, pe as sequentialRamp, tt as serializeSvg, Ce as sort, C as splitDefined, _ as sqrtScale, q as squarify, P as stackSeries, te as streamExtent, J as streamLayout, Y as sumValue, nt as svgToPngBlob, S as timeScale, F as toStackedSeries, ze as useChartSize, Le as useStreamSeries, Ht as visualVisible, ee as voronoiCells, L as voronoiFind, jt as wrapText, Ye as zoomWindow };
|