d2elklayout

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MPL-2.0 Imports: 19 Imported by: 7 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package d2elklayout adapts D2 graphs to the native Go port of ELK.

Coordinates are relative to parents. See https://www.eclipse.org/elk/documentation/tooldevelopers/graphdatastructure/coordinatesystem.html

Index

Constants

This section is empty.

Variables

View Source
var DefaultOpts = ConfigurableOpts{
	Algorithm:       "layered",
	NodeSpacing:     70.0,
	Padding:         "[top=50,left=50,bottom=50,right=50]",
	EdgeNodeSpacing: 40.0,
	EdgeEdgeSpacing: go2.Pointer(default_edge_edge_spacing),
	SelfLoopSpacing: 50.0,
}

Functions

func DefaultLayout

func DefaultLayout(ctx context.Context, g *d2graph.Graph) (err error)

func Layout

func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err error)

Types

type AlgorithmOptions added in v0.10.0

type AlgorithmOptions struct {
	ForceModel              string   `json:"elk.force.model,omitempty"`
	ForceRepulsion          *float64 `json:"elk.force.repulsion,omitempty"`
	StressDesiredEdgeLength *float64 `json:"elk.stress.desiredEdgeLength,omitempty"`
	MrTreeSearchOrder       string   `json:"elk.mrtree.searchOrder,omitempty"`
	MrTreeWeighting         string   `json:"elk.mrtree.weighting,omitempty"`
	RadialRadius            *float64 `json:"elk.radial.radius,omitempty"`
	RadialWedgeCriteria     string   `json:"elk.radial.wedgeCriteria,omitempty"`
	RadialCompactor         string   `json:"elk.radial.compactor,omitempty"`
}

AlgorithmOptions tune the algorithm selected at the diagram root. An omitted value lets the selected ELK provider use its own default.

type ConfigurableOpts

type ConfigurableOpts struct {
	LayeredOptions
	AlgorithmOptions
	Algorithm       string `json:"elk.algorithm,omitempty"`
	NodeSpacing     int    `json:"spacing.nodeNodeBetweenLayers,omitempty"`
	Padding         string `json:"elk.padding,omitempty"`
	EdgeNodeSpacing int    `json:"spacing.edgeNodeBetweenLayers,omitempty"`
	EdgeEdgeSpacing *int   `json:"spacing.edgeEdgeBetweenLayers,omitempty"`
	SelfLoopSpacing int    `json:"elk.spacing.nodeSelfLoop"`
}

func (*ConfigurableOpts) SetOption added in v0.10.0

func (options *ConfigurableOpts) SetOption(name, value string) error

SetOption sets one ELK diagram option using its CLI name and textual value.

type Direction

type Direction string
const (
	Down  Direction = "DOWN"
	Up    Direction = "UP"
	Right Direction = "RIGHT"
	Left  Direction = "LEFT"
)

type ELKEdge

type ELKEdge struct {
	ID        string           `json:"id"`
	Sources   []string         `json:"sources"`
	Targets   []string         `json:"targets"`
	Sections  []ELKEdgeSection `json:"sections,omitempty"`
	Labels    []*ELKLabel      `json:"labels,omitempty"`
	Container string           `json:"container"`
}

type ELKEdgeSection

type ELKEdgeSection struct {
	Start      ELKPoint   `json:"startPoint"`
	End        ELKPoint   `json:"endPoint"`
	BendPoints []ELKPoint `json:"bendPoints,omitempty"`
}

type ELKGraph

type ELKGraph struct {
	ID            string     `json:"id"`
	LayoutOptions *elkOpts   `json:"layoutOptions"`
	Children      []*ELKNode `json:"children,omitempty"`
	Edges         []*ELKEdge `json:"edges,omitempty"`
}

type ELKLabel

type ELKLabel struct {
	Text          string   `json:"text"`
	X             float64  `json:"x"`
	Y             float64  `json:"y"`
	Width         float64  `json:"width"`
	Height        float64  `json:"height"`
	LayoutOptions *elkOpts `json:"layoutOptions,omitempty"`
}

type ELKNode

type ELKNode struct {
	ID            string      `json:"id"`
	X             float64     `json:"x"`
	Y             float64     `json:"y"`
	Width         float64     `json:"width"`
	Height        float64     `json:"height"`
	Children      []*ELKNode  `json:"children,omitempty"`
	Ports         []*ELKPort  `json:"ports,omitempty"`
	Labels        []*ELKLabel `json:"labels,omitempty"`
	LayoutOptions *elkOpts    `json:"layoutOptions,omitempty"`
}

type ELKPoint

type ELKPoint struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type ELKPort

type ELKPort struct {
	ID            string   `json:"id"`
	X             float64  `json:"x"`
	Y             float64  `json:"y"`
	Width         float64  `json:"width"`
	Height        float64  `json:"height"`
	LayoutOptions *elkOpts `json:"layoutOptions,omitempty"`
}

type LayeredOptions added in v0.10.0

type LayeredOptions struct {
	NodeNode            *float64 `json:"elk.spacing.nodeNode,omitempty"`
	EdgeNode            *float64 `json:"elk.spacing.edgeNode,omitempty"`
	EdgeEdge            *float64 `json:"elk.spacing.edgeEdge,omitempty"`
	EdgeRouting         string   `json:"elk.edgeRouting,omitempty"`
	WrappingStrategy    string   `json:"elk.layered.wrapping.strategy,omitempty"`
	ForceNodeModelOrder bool     `json:"elk.layered.crossingMinimization.forceNodeModelOrder,omitempty"`
	FeedbackEdges       bool     `json:"elk.layered.feedbackEdges,omitempty"`
	MergeEdges          bool     `json:"elk.layered.mergeEdges,omitempty"`
}

LayeredOptions are applied to parent graphs. Nil spacing values keep the layout defaults, and an explicit zero requests zero clearance.

type PortSide

type PortSide string
const (
	South PortSide = "SOUTH"
	North PortSide = "NORTH"
	East  PortSide = "EAST"
	West  PortSide = "WEST"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL