Repository navigation
Write Legend as D2's native legend - #18
Merged
Merged
Conversation
Legend was written as a top-level 'legend' key, which D2 draws as an ordinary container. It now goes under vars.d2-legend with its label as the title, so D2 draws a real legend. Connection endpoints that are not legend shapes are hidden, so an entry for a connection shows only its line and label. The diagram writes one vars block for d2-config, variables and the legend. Legend.near is removed: D2 places the legend itself and has no position for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
In 2.0.0,
d2.Legendwas written as a top-levellegend:key. D2 reads that as an ordinary container named "legend", so the "legend" was drawn as one more box in the diagram.d2 validateaccepted it, because a box namedlegendis valid D2.This change:
vars: { d2-legend: <label> { ... } }, so D2 draws its real legend card at the bottom right. The label becomes the card's title.varsblock withd2-config, the variables and the legend, instead of separate blocks.Legend.near. D2 always places the legend itself and has no setting for its position.nearwas released a few hours ago and only ever positioned the wrong box.Checked locally: all 244 tests pass. A new render test checks that D2 draws the legend title, and ruff and ty are clean. I also used it in the relationship map spike, where the legend now shows as a key with one sample arrow per color.
🤖 Generated with Claude Code