d2grid

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MPL-2.0 Imports: 10 Imported by: 1

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 added in v0.5.0

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 runs the grid layout on containers with rows/columns Note: children are not allowed edges or descendants 1. Run grid layout on the graph root 2. Set the resulting dimensions to the graph root

Types

This section is empty.

Jump to

Keyboard shortcuts

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