Skip to main content

GridLayout

A layout that places elements into a grid, optionally with fixed number of rows or columns. If you provide a fixed value for both rows and columns only the rows value will be honoured.

Elements are placed such that they are centered in their cell, where the width and height of each cell is fixed, and is determined by the maximum width/height of all the vertices in the layout. For that reason if you have a dataset where the size of your vertices varies largely you may not get the best results - there could be a lot of whitespace.

Extends

Extended by

Methods

begin()

begin(dataSource, positionGetter, positionSetter, sizes, parameters): void

Parameters

dataSource

DataSource

positionGetter

(id) => PointXY

positionSetter

(id, x, y) => void

sizes

Record<string, Size>

parameters

GridLayoutParameters

Returns

void

Overrides

AbstractLayout.begin


end()

end(dataSource, positionGetter, positionSetter, sizes, parameters): void

This is an abstract function that subclasses may implement if they wish. It will be called at the end of a layout.

Parameters

dataSource

DataSource

The associated VisuallyJs model

positionGetter

(id) => PointXY

Function to get position for some element

positionSetter

(id, x, y) => void

Function to set position for some element. Updates current extents as it sets the position.

sizes

Record<string, Size>

Map of element sizes.

parameters

GridLayoutParameters

Parameters configured for the layout.

Returns

void

Overrides

AbstractLayout.end


step()

step(dataSource, positionGetter, positionSetter, sizes, parameters?): void

Step through the layout. For some layouts there is only a single step, but others continue stepping until some condition is met. Once the condition is met, the subclass must set this.done = true, or the layout will continue looping indefinitely.

Parameters

dataSource

DataSource

The associated VisuallyJs model

positionGetter

(id) => PointXY

positionSetter

(id, x, y) => void

sizes

Record<string, Size>

parameters?

any

Parameters configured for the layout.

Returns

void

Overrides

AbstractLayout.step