d2grid

package
v0.0.0-...-e815181 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

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

Layout runs the grid layout on containers with rows/columns Note: children are not allowed edges or descendants

1. Traverse graph from root, skip objects with no rows/columns 2. Construct a grid with the container children 3. Remove the children from the main graph 4. Run grid layout 5. Set the resulting dimensions to the main graph shape 6. Run core layouts (without grid children) 7. Put grid children back in correct location

Types

This section is empty.

Jump to

Keyboard shortcuts

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