Repository navigation
fix(diagram): keep edge labels off their arrowheads - #256
Merged
Merged
Conversation
A label's box sits above its anchor, and a line shorter than 80px only tried its midpoint, so on a short upward edge the text landed on the arrowhead. The label placer now knows the arrowheads of a line (edges: start/end per direction, dataflows: end) and scores a label on one like a covered node, short lines try the moderate positions after the midpoint, and when no fixed position is clear the spots right behind each arrowhead are tried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a short upward edge between two stacked nodes (40px, a
stackwithgap "40"), the label was drawn on top of the arrowhead. There were two causes:y - 6), so on an upward line it reaches toward the tip.The label placer didn't know about arrowheads at all.
Fix (
Renderer::LabelPlacer)place_label_along(..., arrow_start:, arrow_end:): the edge renderer passes the arrowhead length (MARKER_SIZE * EDGE_STROKE_WIDTH) for each end that has one (by direction); the dataflow renderer passes its end marker. A label box on an arrowhead (grown by 2px for the halo) costs as much as a covered node (ARROWHEAD_PENALTY).0.5, 0.35, 0.65, 0.25, 0.75, not just the midpoint. Node overlap is already scored, so a label still can't land on the nodes.The candidate scoring is extracted into
best_candidate, unchanged otherwise (native and Ruby paths stay identical;native_testpasses). Labels that were already clear don't move, so no existing test changed.Before/after on the reported diagram: the short upward "publish" edge moves from on the arrowhead to the shaft below it, and a short downward "reads" edge that touched its source node moves 6px clear of it.
Test plan
stackwith an upward labelled edge🤖 Generated with Claude Code