Skip to content

Commit

Permalink
d2sequence: fix self reference message alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Aug 5, 2024
1 parent 9b83a0f commit 5cbe1f8
Show file tree
Hide file tree
Showing 32 changed files with 2,862 additions and 1,160 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

- Sequence diagram edge groups account for edge label heights [#2038](https://github.com/terrastruct/d2/pull/2038)
- Sequence diagram self-referential edges account for edge label heights [#2040](https://github.com/terrastruct/d2/pull/2040)
- Sequence diagram: The spacing between self-referential edges and regular edges is uniform [#2043](https://github.com/terrastruct/d2/pull/2043)

#### Bugfixes ⛑️
9 changes: 3 additions & 6 deletions d2layouts/d2sequence/sequence_diagram.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ func (sd *sequenceDiagram) placeSpans() {
// in another step, routes are adjusted to spans borders when necessary
func (sd *sequenceDiagram) routeMessages() error {
var prevIsLoop bool
var prevGroup *d2graph.Object
messageOffset := sd.maxActorHeight + sd.yStep
for _, message := range sd.messages {
message.ZIndex = MESSAGE_Z_INDEX
Expand All @@ -547,12 +546,10 @@ func (sd *sequenceDiagram) routeMessages() error {
}
}

// we need extra space if the previous message is a loop in a different group
group := message.GetGroup()
if prevIsLoop && prevGroup != group {
messageOffset += MIN_MESSAGE_DISTANCE
// we need extra space if the previous message is a loop
if prevIsLoop {
messageOffset += MIN_MESSAGE_DISTANCE * 1.5
}
prevGroup = group

startY := messageOffset + noteOffset

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 5cbe1f8

Please sign in to comment.