// Separate the scope's disconnected components: a one-call, translation-only post-pass
ctx.packComponents(spacing?: number, options?: { bodies?: boolean; includeLabels?: boolean; positions?: Float32Array | Float64Array; }): voidSeparate the scope's disconnected components: a one-call, translation-only post-pass. Per-component bounding boxes at the current positions are shelf-packed largest-first with spacing between them, every member translated with its component, and the largest component's centre held fixed — the dominant structure keeps its place and the strays come to it.
The boxes are body boxes (nodeDimensions(), labels included by the run's option), so two singleton components end up spacing apart edge to edge rather than centre to centre; bodies: false restores the 87.1 point boxes.
Components are computed over the scope's own edges (an edge with an endpoint outside the scope connects nothing here), and only the nodeSlots() nodes move — a locked node neither moves nor holds its component in place, so a scope mixing locked and unlocked members of one component can separate them. The write lands through setPositions (one dirty span).
| Name | Description |
|---|---|
spacing: number?Default: 40 | the gap between packed component boxes (default 40, the force layout's |
options: { bodies?: boolean; includeLabels?: boolean; positions?: Float32Array | Float64Array; }?Default: {} |
|
Fields of options
| Name | Description |
|---|---|
bodies: boolean? | |
includeLabels: boolean? | |
positions: Float32Array | Float64Array? |
voidExample
cy.layout({ impl: { run(ctx) { ctx.packComponents(20); console.log(ctx.components().count); // 1} } }).run();