Record flags in history and draw them as steps
A bool was excluded from the history as "not a measurement", so a true/false port had no curve in the node panel and none on an edge — only the word. It is recorded as 0/1 now and drawn as steps, since a bezier through two states slopes through readings that never happened. The axis is pinned to 0..1, so a flag that was never on sits at the floor rather than mid-box.
This commit is contained in:
@@ -83,11 +83,13 @@ export function MessageSparkline({
|
||||
const ts = live?.ts
|
||||
const value = live?.value
|
||||
useEffect(() => {
|
||||
if (typeof value !== "number" || !ts) return
|
||||
// A flag is recorded as 0/1, the way the server keeps it.
|
||||
if ((typeof value !== "number" && typeof value !== "boolean") || !ts) return
|
||||
const reading = Number(value)
|
||||
setTail((previous) =>
|
||||
previous[previous.length - 1]?.ts === ts
|
||||
? previous
|
||||
: [...previous, { ts, value }].slice(-WINDOW),
|
||||
: [...previous, { ts, value: reading }].slice(-WINDOW),
|
||||
)
|
||||
}, [ts, value])
|
||||
|
||||
@@ -127,7 +129,10 @@ export function MessageSparkline({
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div>
|
||||
<Sparkline points={points} />
|
||||
<Sparkline
|
||||
points={points}
|
||||
bool={dtype === "bool" || typeof live?.value === "boolean"}
|
||||
/>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{caption(points)}</TooltipContent>
|
||||
|
||||
Reference in New Issue
Block a user