Commit 1c5dc8c
mthcore
Cover the speed graph, where being wrong still looks like a graph
Nothing in this hook throws when it breaks. A flipped scale draws the line
upside down, a stale width draws it at the wrong size, and both render as a
perfectly plausible graph — which is why its comments already read as a list of
things that shipped: a lead-in segment entering the plot from outside after a
spike aged out, a width frozen for as long as polling was paused, an autorun
that tore itself down on the frame it was created.
The path is checked by its shape and its endpoints rather than by matching a
string. The arithmetic is arithmetic; what the tests hold is that the newest
sample lands at the right edge, that a faster one sits higher than a slower one
because svg y grows downward, that an idle client draws a flat line instead of
dividing by zero, and that the window never reaches back past the left edge.
Resizing is covered on both paths. jsdom has no ResizeObserver, so the suite was
only ever going to exercise the window fallback — the one a browser without it
takes — and the observer path, which is the one that actually runs, needed a
stub. A faithful one: a real observer delivers its first entry the moment it
starts observing, and that immediate call is the whole reason the redraw does
not restart the autorun.
Two things this found rather than pinned:
- The single-sample branch in the path builder produced, character for
character, what the general loop already produced for one point. Removed.
- Resizing to zero width — a collapsing panel, a closing popup — is the case
that makes the redraw clear its cached width. Without that it keeps drawing
against the scales it had while visible. That now has a case of its own.
And one it cannot pin, said rather than papered over: disposing and recreating
the autorun on every redraw leaves an equally live autorun, so the graph draws
the same either way. That difference is cost per frame of a drag, not output.1 parent 9631039 commit 1c5dc8c
2 files changed
Lines changed: 528 additions & 5 deletions
0 commit comments