src change

This commit is contained in:
Alexander Wang 2022-11-29 17:57:17 -08:00
parent 0de29f08c3
commit edff033308
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
3 changed files with 4 additions and 4 deletions

View file

@ -39,7 +39,6 @@ func NewGraph(ast *d2ast.Map) *Graph {
Parent: nil, Parent: nil,
Children: make(map[string]*Object), Children: make(map[string]*Object),
} }
d.Root.Attributes.Direction.Value = "down"
return d return d
} }
@ -445,9 +444,6 @@ func (obj *Object) newObject(id string) *Object {
Label: Scalar{ Label: Scalar{
Value: idval, Value: idval,
}, },
Direction: Scalar{
Value: "down",
},
}, },
Graph: obj.Graph, Graph: obj.Graph,

View file

@ -74,6 +74,8 @@ func Layout(ctx context.Context, d2graph *d2graph.Graph) (err error) {
rootAttrs.rankdir = "RL" rootAttrs.rankdir = "RL"
case "up": case "up":
rootAttrs.rankdir = "BT" rootAttrs.rankdir = "BT"
default:
rootAttrs.rankdir = "TB"
} }
configJS := setGraphAttrs(rootAttrs) configJS := setGraphAttrs(rootAttrs)
if _, err := v8ctx.RunScript(configJS, "config.js"); err != nil { if _, err := v8ctx.RunScript(configJS, "config.js"); err != nil {

View file

@ -131,6 +131,8 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) {
elkGraph.LayoutOptions.Direction = "RIGHT" elkGraph.LayoutOptions.Direction = "RIGHT"
case "left": case "left":
elkGraph.LayoutOptions.Direction = "LEFT" elkGraph.LayoutOptions.Direction = "LEFT"
default:
elkGraph.LayoutOptions.Direction = "DOWN"
} }
elkNodes := make(map[*d2graph.Object]*ELKNode) elkNodes := make(map[*d2graph.Object]*ELKNode)