basic fix
This commit is contained in:
parent
a85ccf2f4a
commit
13a3edc4ba
1 changed files with 16 additions and 2 deletions
|
|
@ -109,6 +109,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
|
|
||||||
maxContainerLabelHeight := 0
|
maxContainerLabelHeight := 0
|
||||||
for _, obj := range g.Objects {
|
for _, obj := range g.Objects {
|
||||||
|
// TODO count root level container label sizes for ranksep
|
||||||
if len(obj.ChildrenArray) == 0 || obj.Parent == g.Root {
|
if len(obj.ChildrenArray) == 0 || obj.Parent == g.Root {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +135,20 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
}
|
}
|
||||||
maxLabelSize = go2.Max(maxLabelSize, size)
|
maxLabelSize = go2.Max(maxLabelSize, size)
|
||||||
}
|
}
|
||||||
rootAttrs.ranksep = go2.Max(go2.Max(100, maxLabelSize+40), maxContainerLabelHeight)
|
|
||||||
|
rootAttrs.ranksep = go2.Max(100, maxLabelSize+40)
|
||||||
|
vSep := go2.Max(rootAttrs.ranksep, maxContainerLabelHeight)
|
||||||
|
// var nonContainerVSep int
|
||||||
|
if !isHorizontal {
|
||||||
|
rootAttrs.ranksep = vSep
|
||||||
|
} else {
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
configJS := setGraphAttrs(rootAttrs)
|
configJS := setGraphAttrs(rootAttrs)
|
||||||
if _, err := vm.RunString(configJS); err != nil {
|
if _, err := vm.RunString(configJS); err != nil {
|
||||||
|
|
@ -286,7 +300,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, obj := range g.Objects {
|
for _, obj := range g.Objects {
|
||||||
if obj.LabelHeight == nil || len(obj.ChildrenArray) <= 0 {
|
if obj.LabelHeight == nil || len(obj.ChildrenArray) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue