place elk edge labels on right with more padding

This commit is contained in:
Gavin Nishizawa 2022-12-20 14:51:59 -08:00
parent 9f9774b142
commit 6bb39115d4
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -85,6 +85,8 @@ type ELKLayoutOptions struct {
EdgeNodeSpacing float64 `json:"spacing.edgeNodeBetweenLayers,omitempty"` EdgeNodeSpacing float64 `json:"spacing.edgeNodeBetweenLayers,omitempty"`
Direction string `json:"elk.direction"` Direction string `json:"elk.direction"`
SelfLoopSpacing float64 `json:"elk.spacing.nodeSelfLoop"` SelfLoopSpacing float64 `json:"elk.spacing.nodeSelfLoop"`
EdgeLabelSpacing float64 `json:"spacing.edgeLabel,omitempty"`
LabelSideSelection string `json:"elk.layered.edgeLabels.sideSelection,omitempty"`
} }
func Layout(ctx context.Context, g *d2graph.Graph) (err error) { func Layout(ctx context.Context, g *d2graph.Graph) (err error) {
@ -112,6 +114,8 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) {
NodeSpacing: 100.0, NodeSpacing: 100.0,
EdgeNodeSpacing: 50.0, EdgeNodeSpacing: 50.0,
SelfLoopSpacing: 50.0, SelfLoopSpacing: 50.0,
EdgeLabelSpacing: 5.0,
LabelSideSelection: "SMART_UP",
}, },
} }
switch g.Root.Attributes.Direction.Value { switch g.Root.Attributes.Direction.Value {
@ -156,6 +160,8 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) {
if len(obj.ChildrenArray) > 0 { if len(obj.ChildrenArray) > 0 {
n.LayoutOptions = &ELKLayoutOptions{ n.LayoutOptions = &ELKLayoutOptions{
Padding: "[top=75,left=75,bottom=75,right=75]", Padding: "[top=75,left=75,bottom=75,right=75]",
EdgeLabelSpacing: 5.0,
LabelSideSelection: "SMART_UP",
} }
} }