diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 69d8d918d..7bc2ba1cc 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -39,7 +39,6 @@ func NewGraph(ast *d2ast.Map) *Graph { Parent: nil, Children: make(map[string]*Object), } - d.Root.Attributes.Direction.Value = "down" return d } @@ -445,9 +444,6 @@ func (obj *Object) newObject(id string) *Object { Label: Scalar{ Value: idval, }, - Direction: Scalar{ - Value: "down", - }, }, Graph: obj.Graph, diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index 9fa88ccc3..672871226 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -74,6 +74,8 @@ func Layout(ctx context.Context, d2graph *d2graph.Graph) (err error) { rootAttrs.rankdir = "RL" case "up": rootAttrs.rankdir = "BT" + default: + rootAttrs.rankdir = "TB" } configJS := setGraphAttrs(rootAttrs) if _, err := v8ctx.RunScript(configJS, "config.js"); err != nil { diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index 9365949b7..2df4c65be 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -131,6 +131,8 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { elkGraph.LayoutOptions.Direction = "RIGHT" case "left": elkGraph.LayoutOptions.Direction = "LEFT" + default: + elkGraph.LayoutOptions.Direction = "DOWN" } elkNodes := make(map[*d2graph.Object]*ELKNode)