This commit is contained in:
Gavin Nishizawa 2023-03-03 22:31:09 -08:00
parent 7a552e9a55
commit bacb22797c
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -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)