Skip to content
D
Documentation

Layout — constants

reference
1 min readUpdated

Constants

Import these from @grafloria/engine.

Constants

AUTO_LAYOUT_NAME

The registered name of the auto-selecting layout.

ts
const AUTO_LAYOUT_NAME: "auto"

BAKEOFF_NODE_LIMIT

Above this many nodes the bake-off itself is the pathology: it runs EVERY candidate engine on the full graph, so its runtime is the SUM of the field — including whichever engine happens to hang at that scale (measured: 16s+ at 300 nodes, unbounded at 2,000). Past this limit the graph is classified structurally and ONE engine is picked directly; the choice is still deterministic and still explained in the selection report.

ts
const BAKEOFF_NODE_LIMIT: 200

DEFAULT_LAYOUT_NAME

The layout engine.layout() runs when the caller names none.

This is 'auto', not a fixed algorithm. A zero-config caller gets a bake-off (see layout-auto-select.ts) rather than whichever algorithm happened to be hard-coded, and can read back WHY it chose what it chose. Naming it here rather than inline in DiagramEngine keeps the decision in one place — a card that wants a different default (a Sugiyama, say) changes this constant and nothing else.

ts
const DEFAULT_LAYOUT_NAME: "auto"

DEFAULT_LAYOUT_SEED

The seed used when a caller asks for a layout without naming one.

A FIXED default (not a time-derived one) is the whole point: an author who never thinks about seeds still gets the same picture every time they open their diagram. Randomness is opt-in, by passing a different seed.

ts
const DEFAULT_LAYOUT_SEED: 24301

DEFAULT_NODE_HEIGHT

ts
const DEFAULT_NODE_HEIGHT: 50

DEFAULT_NODE_WIDTH

Dagre's fallbacks, reused so every layout agrees on what an unsized node is.

ts
const DEFAULT_NODE_WIDTH: 150

layoutService

Singleton instance of LayoutService

Can be used across the application for convenience.

ts
const layoutService: LayoutService

Was this page helpful?

Layout — constants — Grafloria