Skip to main content

Function: calculateLayout()

calculateLayout(params): Promise<CalculatedLayout>

Computes a layout on the specified diagram elements using specified graph layout algorithm function (LayoutFunction).

Example:

const layout = await calculateLayout({
layoutFunction: defaultLayout,
model,
sizeProvider: canvas.renderingState,
});

await canvas.animateGraph(() => {
applyLayout(layout, model);
});

Parameters

ParameterTypeDescription

params

object

params.fixedElements?

ReadonlySet<Element>

Set of elements which should not be moved by layout algorithm (if supported).

params.layoutFunction

LayoutFunction

Graph layout algorithm function.

params.model

DiagramModel

Model of a diagram to calculate layout for.

params.selectedElements?

ReadonlySet<Element>

Subset of elements from the diagram to layout.

params.signal?

AbortSignal

Cancellation signal.

params.sizeProvider

SizeProvider

Size provider for the elements.

params.typeProvider?

LayoutTypeProvider

Additional metadata provider for the elements.

Returns

Promise<CalculatedLayout>

See

applyLayout

Defined in

diagram/layout.ts:100