- If you draw from the canvas center, put the centering offset into the initial zoom transform (
zoomIdentity.translate(size / 2, size / 2)). Otherwise zoom pivots around the wrong point. - Use the same transform for zoom, pan, drag and hit testing (
transform.invert). - Keep label size constant on screen: set the font to
LABEL_PX / k. - Draw labels in priority order (hovered, neighbors, then by link count) and skip a label that overlaps one already drawn.
- Keep the browser-free logic (radius, label fade, label layout) in a pure module. Unit-test it there.