@tangle-network/charts 0.12.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/index.d.ts +20 -2
- package/dist/react/index.js +104 -12
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -220,11 +220,29 @@ export declare function Meter({ used, total, format, tone, text, segments, untra
|
|
|
220
220
|
segments?: MeterSegment[];
|
|
221
221
|
untraced?: string;
|
|
222
222
|
}): import("react").JSX.Element;
|
|
223
|
-
/** A small line of one series for a row in a list (one hue; the row's label carries identity).
|
|
224
|
-
|
|
223
|
+
/** A small line of one series for a row in a list (one hue; the row's label carries identity). `max` sets the top of
|
|
224
|
+
* the scale (any positive value; the default 1 suits shares). With `label`, the line is an image with that name and
|
|
225
|
+
* hovering it reads the nearest point through `format` and `time`. */
|
|
226
|
+
export declare function Spark({ points, max, color, label, format, time }: {
|
|
225
227
|
points: [number, number][];
|
|
226
228
|
max?: number;
|
|
227
229
|
color?: string;
|
|
230
|
+
label?: string;
|
|
231
|
+
format?: (v: number) => string;
|
|
232
|
+
time?: (t: number) => string;
|
|
233
|
+
}): import("react").JSX.Element;
|
|
234
|
+
/** Recorded instants on one time axis, such as process restarts or deploys: a tick per event in `[from, to]`, with
|
|
235
|
+
* `ticks` evenly spaced axis labels under it. Hovering a tick names its time through `time`. The strip keeps its type
|
|
236
|
+
* size at any width, and `label` names it for assistive tech. */
|
|
237
|
+
export declare function Events({ at, from, to, label, color, ticks, axis, time }: {
|
|
238
|
+
at: number[];
|
|
239
|
+
from: number;
|
|
240
|
+
to: number;
|
|
241
|
+
label: string;
|
|
242
|
+
color?: string;
|
|
243
|
+
ticks?: number;
|
|
244
|
+
axis?: (t: number) => string;
|
|
245
|
+
time?: (t: number) => string;
|
|
228
246
|
}): import("react").JSX.Element;
|
|
229
247
|
/** One bar per row on a shared time axis (who worked when): each row's bar spans its start to its end, coloured by its
|
|
230
248
|
* state; hovering a span names it, its state and its span. Times are epoch ms; `axis` labels the time axis.
|
package/dist/react/index.js
CHANGED
|
@@ -1449,8 +1449,11 @@ function SegmentMeter({ segments, total, format, text, untraced }) {
|
|
|
1449
1449
|
]
|
|
1450
1450
|
});
|
|
1451
1451
|
}
|
|
1452
|
-
/** A small line of one series for a row in a list (one hue; the row's label carries identity).
|
|
1453
|
-
|
|
1452
|
+
/** A small line of one series for a row in a list (one hue; the row's label carries identity). `max` sets the top of
|
|
1453
|
+
* the scale (any positive value; the default 1 suits shares). With `label`, the line is an image with that name and
|
|
1454
|
+
* hovering it reads the nearest point through `format` and `time`. */
|
|
1455
|
+
function Spark({ points, max = 1, color = LIVE_SERIES[0], label, format = formatCompact, time }) {
|
|
1456
|
+
const [hover, setHover] = useState(null);
|
|
1454
1457
|
if (points.length < 2) return /* @__PURE__ */ jsx("span", {
|
|
1455
1458
|
className: "ov-spark-empty",
|
|
1456
1459
|
children: "collecting"
|
|
@@ -1459,17 +1462,106 @@ function Spark({ points, max = 1, color = LIVE_SERIES[0] }) {
|
|
|
1459
1462
|
const t1 = points.at(-1)[0];
|
|
1460
1463
|
const w = 160;
|
|
1461
1464
|
const h = 32;
|
|
1462
|
-
const domain =
|
|
1463
|
-
const
|
|
1464
|
-
|
|
1465
|
+
const domain = max > 0 && Number.isFinite(max) ? max : 1;
|
|
1466
|
+
const px = (t) => (t - t0) / Math.max(1, t1 - t0) * w;
|
|
1467
|
+
const py = (v) => 30 - Math.min(domain, v) / domain * 28;
|
|
1468
|
+
const d = points.map((p) => `${px(p[0])},${py(p[1])}`).join(" ");
|
|
1469
|
+
const hovered = hover === null ? null : points[hover];
|
|
1470
|
+
const reading = hovered ? `${time ? `${time(hovered[0])} · ` : ""}${format(hovered[1])}` : null;
|
|
1471
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
1465
1472
|
viewBox: `0 0 ${w} ${h}`,
|
|
1466
1473
|
className: "ov-spark",
|
|
1467
|
-
"
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1474
|
+
role: label ? "img" : void 0,
|
|
1475
|
+
"aria-label": label,
|
|
1476
|
+
"aria-hidden": label ? void 0 : true,
|
|
1477
|
+
onMouseLeave: label ? () => setHover(null) : void 0,
|
|
1478
|
+
onMouseMove: label ? (event) => {
|
|
1479
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
1480
|
+
const t = t0 + (event.clientX - box.left) / Math.max(1, box.width) * (t1 - t0);
|
|
1481
|
+
let best = 0;
|
|
1482
|
+
for (let i = 1; i < points.length; i++) if (Math.abs(points[i][0] - t) < Math.abs(points[best][0] - t)) best = i;
|
|
1483
|
+
setHover(best);
|
|
1484
|
+
} : void 0,
|
|
1485
|
+
children: [
|
|
1486
|
+
label && /* @__PURE__ */ jsx("title", { children: reading ?? label }),
|
|
1487
|
+
/* @__PURE__ */ jsx("polyline", {
|
|
1488
|
+
fill: "none",
|
|
1489
|
+
stroke: color,
|
|
1490
|
+
strokeWidth: 1.6,
|
|
1491
|
+
points: d
|
|
1492
|
+
}),
|
|
1493
|
+
hovered && /* @__PURE__ */ jsx("circle", {
|
|
1494
|
+
cx: px(hovered[0]),
|
|
1495
|
+
cy: py(hovered[1]),
|
|
1496
|
+
r: 3,
|
|
1497
|
+
fill: color,
|
|
1498
|
+
stroke: "var(--chart-live-surface, #fff)",
|
|
1499
|
+
strokeWidth: 1.5
|
|
1500
|
+
})
|
|
1501
|
+
]
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
/** Recorded instants on one time axis, such as process restarts or deploys: a tick per event in `[from, to]`, with
|
|
1505
|
+
* `ticks` evenly spaced axis labels under it. Hovering a tick names its time through `time`. The strip keeps its type
|
|
1506
|
+
* size at any width, and `label` names it for assistive tech. */
|
|
1507
|
+
function Events({ at, from, to, label, color = LIVE_SERIES[0], ticks = 7, axis = (t) => new Date(t).toLocaleDateString(void 0, { weekday: "short" }), time = (t) => new Date(t).toLocaleString() }) {
|
|
1508
|
+
const [ref, width, em] = useWidth();
|
|
1509
|
+
if (!Number.isFinite(from) || !Number.isFinite(to) || to <= from) throw new RangeError("Events needs a window with to after from.");
|
|
1510
|
+
const shown = at.filter((t) => Number.isFinite(t) && t >= from && t <= to).sort((a, b) => a - b);
|
|
1511
|
+
const strip = Math.round(2.2 * em);
|
|
1512
|
+
const height = strip + Math.round(1.5 * em);
|
|
1513
|
+
const pad = 6;
|
|
1514
|
+
const x = (t) => pad + (t - from) / (to - from) * Math.max(0, width - 12);
|
|
1515
|
+
const steps = Math.max(1, Math.round(ticks));
|
|
1516
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1517
|
+
ref,
|
|
1518
|
+
className: "ov-plot",
|
|
1519
|
+
children: width > 0 && /* @__PURE__ */ jsxs("svg", {
|
|
1520
|
+
width,
|
|
1521
|
+
height,
|
|
1522
|
+
role: "img",
|
|
1523
|
+
"aria-label": `${label}: ${shown.length} in the window`,
|
|
1524
|
+
children: [
|
|
1525
|
+
/* @__PURE__ */ jsx("line", {
|
|
1526
|
+
x1: pad,
|
|
1527
|
+
x2: width - pad,
|
|
1528
|
+
y1: strip / 2,
|
|
1529
|
+
y2: strip / 2,
|
|
1530
|
+
className: "ov-gridline"
|
|
1531
|
+
}),
|
|
1532
|
+
shown.map((t, i) => /* @__PURE__ */ jsxs("g", {
|
|
1533
|
+
"data-event": t,
|
|
1534
|
+
children: [
|
|
1535
|
+
/* @__PURE__ */ jsx("title", { children: time(t) }),
|
|
1536
|
+
/* @__PURE__ */ jsx("rect", {
|
|
1537
|
+
x: x(t) - 6,
|
|
1538
|
+
y: 0,
|
|
1539
|
+
width: 12,
|
|
1540
|
+
height: strip,
|
|
1541
|
+
fill: "transparent"
|
|
1542
|
+
}),
|
|
1543
|
+
/* @__PURE__ */ jsx("line", {
|
|
1544
|
+
x1: x(t),
|
|
1545
|
+
x2: x(t),
|
|
1546
|
+
y1: 4,
|
|
1547
|
+
y2: strip - 4,
|
|
1548
|
+
stroke: color,
|
|
1549
|
+
strokeWidth: 2,
|
|
1550
|
+
strokeLinecap: "round"
|
|
1551
|
+
})
|
|
1552
|
+
]
|
|
1553
|
+
}, `${t}-${i}`)),
|
|
1554
|
+
Array.from({ length: steps + 1 }, (_, i) => {
|
|
1555
|
+
const t = from + i / steps * (to - from);
|
|
1556
|
+
return /* @__PURE__ */ jsx("text", {
|
|
1557
|
+
x: x(t),
|
|
1558
|
+
y: height - em * .35,
|
|
1559
|
+
className: "ov-axis",
|
|
1560
|
+
textAnchor: i === 0 ? "start" : i === steps ? "end" : "middle",
|
|
1561
|
+
children: axis(t)
|
|
1562
|
+
}, i);
|
|
1563
|
+
})
|
|
1564
|
+
]
|
|
1473
1565
|
})
|
|
1474
1566
|
});
|
|
1475
1567
|
}
|
|
@@ -2200,4 +2292,4 @@ function DotMap({ positions, radii, colors, palette, extent, rects, labels, dimm
|
|
|
2200
2292
|
});
|
|
2201
2293
|
}
|
|
2202
2294
|
//#endregion
|
|
2203
|
-
export { DEFAULT_SPARKLINE_EMPTY_LABEL, DEFAULT_SPARKLINE_HEIGHT, DEFAULT_SPARKLINE_LABEL, DEFAULT_SPARKLINE_UNAVAILABLE_LABEL, DEFAULT_SPARKLINE_WIDTH, DOT_MAP_CATEGORIES, DayBars, DotMap, FigureView, Gantt, HBars, Histogram, LIVE_SERIES, Lines, Meter, Spark, Sparkline, StackedBarChart, TimelineView, WaterfallBar, WaterfallHeader, WaterfallRow, WaterfallTimeAxis, formatCompact, formatSparklineValue, formatWaterfallDuration, sparklineGeometry, sparklineLabel, sparklinePointsAttribute, sparklineReadings, waterfallSpanGeometry, waterfallTicks };
|
|
2295
|
+
export { DEFAULT_SPARKLINE_EMPTY_LABEL, DEFAULT_SPARKLINE_HEIGHT, DEFAULT_SPARKLINE_LABEL, DEFAULT_SPARKLINE_UNAVAILABLE_LABEL, DEFAULT_SPARKLINE_WIDTH, DOT_MAP_CATEGORIES, DayBars, DotMap, Events, FigureView, Gantt, HBars, Histogram, LIVE_SERIES, Lines, Meter, Spark, Sparkline, StackedBarChart, TimelineView, WaterfallBar, WaterfallHeader, WaterfallRow, WaterfallTimeAxis, formatCompact, formatSparklineValue, formatWaterfallDuration, sparklineGeometry, sparklineLabel, sparklinePointsAttribute, sparklineReadings, waterfallSpanGeometry, waterfallTicks };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/charts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Static SVG and HTML figures for benchmarks and operational timing. Draws from producer data and refuses what it cannot draw honestly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|