grid: don't overwrite nested graph label positions
This commit is contained in:
parent
962f3445f5
commit
297819dc35
1 changed files with 13 additions and 4 deletions
|
|
@ -139,7 +139,9 @@ func withoutGridDiagrams(ctx context.Context, g *d2graph.Graph, layout d2graph.L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if obj.LabelPosition == nil {
|
||||||
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
||||||
|
}
|
||||||
gridDiagrams[obj.AbsID()] = gd
|
gridDiagrams[obj.AbsID()] = gd
|
||||||
|
|
||||||
for _, o := range gd.objects {
|
for _, o := range gd.objects {
|
||||||
|
|
@ -191,12 +193,19 @@ func layoutGrid(g *d2graph.Graph, obj *d2graph.Object) (*gridDiagram, error) {
|
||||||
// position labels and icons
|
// position labels and icons
|
||||||
for _, o := range gd.objects {
|
for _, o := range gd.objects {
|
||||||
if o.Icon != nil {
|
if o.Icon != nil {
|
||||||
|
// don't overwrite position if nested graph layout positioned label/icon
|
||||||
|
if o.LabelPosition == nil {
|
||||||
o.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
o.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
||||||
|
}
|
||||||
|
if o.IconPosition == nil {
|
||||||
o.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
o.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if o.LabelPosition == nil {
|
||||||
o.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
o.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return gd, nil
|
return gd, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue