Merge pull request #820 from alixander/fix-dagre-disconnect

fix dagre disconnect edge case
This commit is contained in:
Alexander Wang 2023-02-14 11:43:27 -08:00 committed by GitHub
commit ba35a3173f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 3318 additions and 1 deletions

View file

@ -3,3 +3,5 @@
#### Improvements 🧹
#### Bugfixes ⛑️
- Fixes edge case where layouts with dagre show a connection from the bottom side of shapes being slightly disconnected from the shape. [#820](https://github.com/terrastruct/d2/pull/820)

View file

@ -350,7 +350,8 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
return true
}
// Edge should only move if it's not connected to the bottom side of the shrinking container
return p.Y != obj.TopLeft.Y+obj.Height
// Give some margin for error
return !(obj.TopLeft.Y+obj.Height-1 <= p.Y && obj.TopLeft.Y+obj.Height+1 >= p.Y && p.X != obj.TopLeft.X && p.X != (obj.TopLeft.X+obj.Width))
}
for _, e := range g.Edges {
if _, ok := movedEdges[e]; ok {

View file

@ -489,6 +489,32 @@ group: {
}
&foo
&&bar
`,
},
{
name: "dagre-disconnect",
script: `a: {
k.t -> f.i
f.g -> _.s.n
}
k
k.s <-> u.o
h.m.s -> a.f.g
a.f.j -> u.s.j
u: {
c -> _.s.z.c
}
s: {
n: {
style.stroke: red
f
}
}
s.n -> y.r: {style.stroke-width: 8; style.stroke: red}
y.r -> a.g.i: 1\n2\n3\n4
`,
},
}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 802 KiB

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 801 KiB