update grid cell label/icon positioning
This commit is contained in:
parent
69ad220acd
commit
c647c6fb2e
1 changed files with 19 additions and 8 deletions
|
|
@ -156,16 +156,27 @@ 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 {
|
positionedLabel := false
|
||||||
|
if o.Icon != nil && o.IconPosition == nil {
|
||||||
|
if len(o.ChildrenArray) > 0 {
|
||||||
|
o.IconPosition = go2.Pointer(string(label.OutsideTopLeft))
|
||||||
// don't overwrite position if nested graph layout positioned label/icon
|
// don't overwrite position if nested graph layout positioned label/icon
|
||||||
if o.LabelPosition == nil {
|
if o.LabelPosition == nil {
|
||||||
o.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
o.LabelPosition = go2.Pointer(string(label.OutsideTopRight))
|
||||||
}
|
positionedLabel = true
|
||||||
if o.IconPosition == nil {
|
|
||||||
o.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if o.LabelPosition == nil {
|
o.IconPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !positionedLabel && o.HasLabel() && o.LabelPosition == nil {
|
||||||
|
if len(o.ChildrenArray) > 0 {
|
||||||
|
o.LabelPosition = go2.Pointer(string(label.OutsideTopCenter))
|
||||||
|
} else if o.HasOutsideBottomLabel() {
|
||||||
|
o.LabelPosition = go2.Pointer(string(label.OutsideBottomCenter))
|
||||||
|
} else if o.Icon != nil {
|
||||||
|
o.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
|
||||||
|
} else {
|
||||||
o.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
o.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue