From b2ec5970e5fba61b19b7ccfcd3e8c5fcaf4dba3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20C=C3=A9sar=20Batista?= Date: Thu, 1 Dec 2022 17:11:41 -0800 Subject: [PATCH] Skip layout engine for root sequence diagrams --- d2layouts/d2sequence/layout.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/d2layouts/d2sequence/layout.go b/d2layouts/d2sequence/layout.go index 87e5e0147..85a9dfcc5 100644 --- a/d2layouts/d2sequence/layout.go +++ b/d2layouts/d2sequence/layout.go @@ -9,7 +9,7 @@ import ( "oss.terrastruct.com/d2/lib/geo" ) -// Layout identifies and layouts sequence diagrams within a graph +// Layout identifies and performs layout on sequence diagrams within a graph // first, it traverses the graph from Root and once it finds an object of shape `sequence_diagram` // it replaces the children with a rectangle with id `sequence_diagram`, collects all edges coming to this node and // flag the edges to be removed. Then, using the children and the edges, it lays out the sequence diagram and @@ -92,7 +92,10 @@ func Layout(ctx context.Context, g *d2graph.Graph, layout func(ctx context.Conte g.Objects = newObjects g.Edges = newEdges - if err := layout(ctx, g); err != nil { + if g.Root.Attributes.Shape.Value == d2target.ShapeSequenceDiagram { + // don't need to run the layout engine if the root is a sequence diagram + g.Root.ChildrenArray[0].TopLeft = geo.NewPoint(0, 0) + } else if err := layout(ctx, g); err != nil { return err }