Function: layoutDiagram()
function layoutDiagram(model, options?): Promise<DiagramGeometry>;
Auto-layout with ELK (default) — layered, ports on the referenced column rows, orthogonal ref
routes in geometry.edges, TableGroups as compound nodes. engine: 'dagre' | 'grid' runs the
synchronous engines. engine: 'auto' decides per connected component of free nodes: dagre (no
routes) for components of at most AUTO_DAGRE_MAX_NODES nodes without groups, ELK for the
others; elkjs is not loaded when no component needs it (needsElk). Deterministic: the same
input always gives the same geometry.
Parameters
model
options?
AutoLayoutOptions = {}
Returns
Promise<DiagramGeometry>
Example
import { compileDbml, layoutDiagram, layoutDiagramSync } from '@relvista/core';
const { model } = compileDbml(source);
if (model) {
const geometry = await layoutDiagram(model, { engine: 'auto', direction: 'RIGHT' });
geometry.nodes['public.users']; // { x, y, width, height, ... }
// Synchronous first picture (dagre), e.g. before the ELK result arrives:
const quick = layoutDiagramSync(model);
}