Documentation
¶
Overview ¶
Package layout places the nodes of a drawing with Graphviz's layered engine: a positions-only graph is laid out by `dot` and the boxes it settles on are read back, for the caller to route edges over and draw.
Index ¶
Constants ¶
const EnvVar = "OPENSYSML_DOT"
EnvVar names the dot executable to lay out with, ahead of the one on PATH.
const Points = 72.0
Points is Graphviz's points to the inch, the pixel scale the DOT and draw.io forms position with.
const Tool = "dot"
Tool is the Graphviz executable the layered layout runs.
Variables ¶
ErrUnavailable is why no layout runs on a host that starts no process: every Go WebAssembly target.
Functions ¶
func Locate ¶
Locate is the absolute path of the dot to run: the one EnvVar names, else the one on PATH. On a host that starts no process the error is ErrUnavailable.
Types ¶
type Box ¶
type Box struct {
X, Y, Width, Height float64
}
Box is a placed node: its top-left corner and size in pixels, y down.
type Edge ¶
type Edge struct {
From, To string
}
Edge joins two nodes by ID, either of which may be a container.
type Graph ¶
type Graph struct {
// Direction is the rank direction, Graphviz's rankdir: TB, LR, RL or BT;
// empty leaves dot's top-to-bottom.
Direction string
// Nodes are the drawing's roots; a node with children is a container.
Nodes []Node
// Edges are the edges laid out; an end naming no node is skipped.
Edges []Edge
// Gap is the room left between neighbouring nodes and ranks, in pixels.
Gap float64
// Pad is the room a container keeps between its border and its members.
Pad float64
}
Graph is a drawing to lay out: its nodes, nested where the drawing nests them, and the edges whose ends the layering keeps near each other.
type Node ¶
Node is one box to place. A leaf is placed at Width by Height; a container keeps a header Width by Height above its members and grows round them.
type NotFoundError ¶
type NotFoundError struct {
// Override is what EnvVar named, empty when it names nothing.
Override string
}
NotFoundError is a dot that is nowhere to be found: not at the override, when one is set, else not on PATH.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string