d2grid

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: 12 Imported by: 1 module, 0 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

Index

Constants

View Source
const (
	// don't consider layouts with rows longer than targetSize*1.2 or shorter than targetSize/1.2
	STARTING_THRESHOLD = 1.2
	// next try layouts with a 25% larger threshold
	THRESHOLD_STEP_SIZE    = 0.25
	MIN_THRESHOLD_ATTEMPTS = 1
	MAX_THRESHOLD_ATTEMPTS = 3

	ATTEMPT_LIMIT = 100_000
	SKIP_LIMIT    = 10_000_000
)
View Source
const (
	CONTAINER_PADDING = 60
	DEFAULT_GAP       = 40
)

Variables

This section is empty.

Functions

func GenLayout

func GenLayout(objects []*d2graph.Object, cutIndices []int) [][]*d2graph.Object

generate a grid of objects from the given cut indices each cut index applies after the object at that index e.g. [0 1 2 3 4 5 6 7] with cutIndices [0, 2, 6] => [[0], [1, 2], [3,4,5,6], [7]]

func Layout

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

Layout places the grid and routes connections using straight joins between cells.

func PlaceCells added in v0.10.0

func PlaceCells(ctx context.Context, g *d2graph.Graph, router d2graph.RouteEdges) (fit func([]*d2graph.Edge), err error)

PlaceCells positions the cells and routes their direct edges. After nested diagrams have been restored and their cross-cell edges routed, call the returned function with those edges to size the container around the result.

func RouteEdges added in v0.10.0

func RouteEdges(ctx context.Context, _ *d2graph.Graph, edges []*d2graph.Edge) error

RouteEdges is the fallback router for placed cells and cross-graph edges. Parallel and reciprocal connections share a set of distinct attachment lanes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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