From 59ef4ad832d35fa1df81a38f09e885cbdbe0ddf3 Mon Sep 17 00:00:00 2001 From: donglixiaoche Date: Fri, 7 Apr 2023 10:33:19 +0800 Subject: [PATCH] fix: cr, attach objects of tempGraph --- d2layouts/d2near/layout.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) 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)