Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin-ts committed Mar 4, 2023
1 parent 7a552e9 commit bacb227
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions d2layouts/d2dagrelayout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,24 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
}
}

maxLabelSize := 0
maxLabelWidth := 0
maxLabelHeight := 0
for _, edge := range g.Edges {
size := edge.LabelDimensions.Width
if !isHorizontal {
size = edge.LabelDimensions.Height
}
maxLabelSize = go2.Max(maxLabelSize, size)
width := edge.LabelDimensions.Width
height := edge.LabelDimensions.Height
maxLabelWidth = go2.Max(maxLabelWidth, width)
maxLabelHeight = go2.Max(maxLabelHeight, height)
}

rootAttrs.ranksep = go2.Max(100, maxLabelSize+40)
vSep := go2.Max(rootAttrs.ranksep, maxContainerLabelHeight)
// var nonContainerVSep int
if !isHorizontal {
rootAttrs.ranksep = vSep
rootAttrs.ranksep = go2.Max(go2.Max(100, maxLabelHeight+40), maxContainerLabelHeight)
} else {
rootAttrs.ranksep = go2.Max(100, maxLabelWidth+40)
// use existing config
rootAttrs.NodeSep = rootAttrs.EdgeSep
// configure vertical padding
rootAttrs.EdgeSep = vSep
// non-containers have both of this as padding
// nonContainerVSep = rootAttrs.NodeSep + rootAttrs.EdgeSep
rootAttrs.EdgeSep = go2.Max(maxLabelHeight+40, maxContainerLabelHeight)
// Note: non-containers have both of these as padding (rootAttrs.NodeSep + rootAttrs.EdgeSep)
}

configJS := setGraphAttrs(rootAttrs)
Expand Down

0 comments on commit bacb227

Please sign in to comment.