diff --git a/d2layouts/d2near/layout.go b/d2layouts/d2near/layout.go index 88b8382d8..0359b2b70 100644 --- a/d2layouts/d2near/layout.go +++ b/d2layouts/d2near/layout.go @@ -52,18 +52,16 @@ func Layout(ctx context.Context, g *d2graph.Graph, constantNearGraphs []*d2graph point.Y += dy } } - - g.Edges = append(g.Edges, tempGraph.Edges...) } } for _, tempGraph := range constantNearGraphs { obj := tempGraph.Root.ChildrenArray[0] if processCenters == strings.Contains(d2graph.Key(obj.Attributes.NearKey)[0], "-center") { // The z-index for constant nears does not matter, as it will not collide - g.Objects = append(g.Objects, obj) + g.Objects = append(g.Objects, tempGraph.Objects...) obj.Parent.Children[obj.ID] = obj obj.Parent.ChildrenArray = append(obj.Parent.ChildrenArray, obj) - attachChildren(g, obj) + g.Edges = append(g.Edges, tempGraph.Edges...) } } } @@ -71,13 +69,6 @@ func Layout(ctx context.Context, g *d2graph.Graph, constantNearGraphs []*d2graph return nil } -func attachChildren(g *d2graph.Graph, obj *d2graph.Object) { - for _, child := range obj.ChildrenArray { - g.Objects = append(g.Objects, child) - attachChildren(g, child) - } -} - // place returns the position of obj, taking into consideration its near value and the diagram func place(obj *d2graph.Object) (float64, float64) { tl, br := boundingBox(obj.Graph)