// Land computed positions the way a built-in does: the finisher when the run asks for anything it owns — animate, animateFilter, transform, spacingFactor — and otherwise the bulk slot write followed by fit / zoom / pan
ctx.finish(slots: number[], xy: ArrayLike<number>, overrides?: LayoutBaseOptions): voidLand computed positions the way a built-in does: the finisher when the run asks for anything it owns — animate, animateFilter, transform, spacingFactor — and otherwise the bulk slot write followed by fit / zoom / pan. One rule for flow, force and any extension that computes into an array.
| Name | Description |
|---|---|
slots: number[] | the node slots the positions land on |
xy: ArrayLike<number> | the packed positions: |
overrides: LayoutBaseOptions?Default: {} | the impl's defaults, merged as |
Fields of overrides
| Name | Description |
|---|---|
eles: unknown? | the elements to lay out (set automatically by |
fit: boolean? | |
padding: number? | |
boundingBox: BoundingBoxInput? | |
nodeDimensionsIncludeLabels: boolean? | include labels in the node dimensions a layout spaces by — default
|
spacingFactor: number? | |
transform: (node: unknown, position: Position) => Position? | transform a computed position (e.g. to flip an axis) |
animate: boolean? | whether to animate node positions into place |
animationDuration: number? | |
animationEasing: string? | |
animateFilter: (node: unknown, i: number) => boolean? | which nodes animate (others jump); all by default |
ready: () => void? | callback on layoutready |
stop: () => void? | callback on layoutstop |
zoom: number? | zoom to set when fit is false |
pan: Position? | pan to set when fit is false |
voidExample
// Inside a custom layout, ctx is supplied by the library.cy.layout({ impl: { run(ctx) { const slots = Array.from(ctx.nodeSlots()); ctx.finish(slots, slots.flatMap((slot, i) => [i * 40, 0]), { fit: false });} } }).run();console.log(cy.getElementById('b').position('x')); // 40