don't overwrite grid label position

This commit is contained in:
Gavin Nishizawa 2023-11-08 14:06:15 -08:00
parent 96053458bd
commit 107b556c20
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD
2 changed files with 4 additions and 4 deletions

View file

@ -89,10 +89,10 @@ func Layout(ctx context.Context, g *d2graph.Graph) error {
}
}
if obj.HasLabel() {
if obj.HasLabel() && obj.LabelPosition == nil {
obj.LabelPosition = go2.Pointer(label.InsideTopCenter.String())
}
if obj.Icon != nil {
if obj.Icon != nil && obj.IconPosition == nil {
obj.IconPosition = go2.Pointer(label.InsideTopLeft.String())
}
@ -119,8 +119,6 @@ func Layout(ctx context.Context, g *d2graph.Graph) error {
g.Root.TopLeft = geo.NewPoint(0, 0)
}
obj.LabelPosition = go2.Pointer(label.InsideTopCenter.String())
if g.RootLevel > 0 {
horizontalPadding, verticalPadding := CONTAINER_PADDING, CONTAINER_PADDING
if obj.GridGap != nil || obj.HorizontalGap != nil {

View file

@ -305,6 +305,8 @@ func ExtractSubgraph(container *d2graph.Object, includeSelf bool) (nestedGraph *
}
nestedGraph.Root.Attributes = container.Attributes
nestedGraph.Root.Box = &geo.Box{}
nestedGraph.Root.LabelPosition = container.LabelPosition
nestedGraph.Root.IconPosition = container.IconPosition
isNestedObject := func(obj *d2graph.Object) bool {
if includeSelf {