Skip to content

Commit

Permalink
Merge pull request #2264 from alixander/fix-note-overlap
Browse files Browse the repository at this point in the history
d2sequence: fix note overlap
  • Loading branch information
alixander authored Dec 29, 2024
2 parents 21a9aec + 41b8655 commit 8e94f36
Show file tree
Hide file tree
Showing 8 changed files with 1,274 additions and 81 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
- Imports: fixes using substitutions in `icon` values [#2207](https://github.com/terrastruct/d2/pull/2207)
- Markdown: fixes ampersands in URLs in markdown [#2219](https://github.com/terrastruct/d2/pull/2219)
- Globs: fixes edge case where globs with imported boards would create empty boards [#2247](https://github.com/terrastruct/d2/pull/2247)
- Sequence diagrams: fixes alignment of notes when self messages are above it [#2264](https://github.com/terrastruct/d2/pull/2264)
7 changes: 6 additions & 1 deletion d2layouts/d2sequence/sequence_diagram.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,12 @@ func (sd *sequenceDiagram) placeNotes() {

for _, msg := range sd.messages {
if sd.verticalIndices[msg.AbsID()] < verticalIndex {
y += sd.yStep + float64(msg.LabelDimensions.Height)
if msg.Src == msg.Dst {
// For self-messages, account for the full vertical space they occupy
y += sd.yStep + math.Max(float64(msg.LabelDimensions.Height), MIN_MESSAGE_DISTANCE)*1.5
} else {
y += sd.yStep + float64(msg.LabelDimensions.Height)
}
}
}
for _, otherNote := range sd.notes {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8e94f36

Please sign in to comment.