place elk edge labels on right with more padding
This commit is contained in:
parent
9f9774b142
commit
6bb39115d4
1 changed files with 19 additions and 13 deletions
|
|
@ -78,13 +78,15 @@ type ELKGraph struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ELKLayoutOptions struct {
|
type ELKLayoutOptions struct {
|
||||||
Algorithm string `json:"elk.algorithm,omitempty"`
|
Algorithm string `json:"elk.algorithm,omitempty"`
|
||||||
HierarchyHandling string `json:"elk.hierarchyHandling,omitempty"`
|
HierarchyHandling string `json:"elk.hierarchyHandling,omitempty"`
|
||||||
NodeSpacing float64 `json:"spacing.nodeNodeBetweenLayers,omitempty"`
|
NodeSpacing float64 `json:"spacing.nodeNodeBetweenLayers,omitempty"`
|
||||||
Padding string `json:"elk.padding,omitempty"`
|
Padding string `json:"elk.padding,omitempty"`
|
||||||
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) {
|
||||||
|
|
@ -107,11 +109,13 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) {
|
||||||
elkGraph := &ELKGraph{
|
elkGraph := &ELKGraph{
|
||||||
ID: "root",
|
ID: "root",
|
||||||
LayoutOptions: &ELKLayoutOptions{
|
LayoutOptions: &ELKLayoutOptions{
|
||||||
Algorithm: "layered",
|
Algorithm: "layered",
|
||||||
HierarchyHandling: "INCLUDE_CHILDREN",
|
HierarchyHandling: "INCLUDE_CHILDREN",
|
||||||
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 {
|
||||||
|
|
@ -155,7 +159,9 @@ 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",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue