Skip to content

@graphty/layout / utils/rescale / rescaleLayout

Function: rescaleLayout() ​

rescaleLayout(pos, scale?, center?): PositionMap | number[][]

Defined in: utils/rescale.ts:22

Returns scaled position array/dict to (-scale, scale) in all axes.

Parameters ​

pos ​

PositionMap | number[][]

Position dictionary or array

scale? ​

number = 1

Scale factor for positions

center? ​

number[] | null

Coordinate pair around which to center the layout

Returns ​

PositionMap | number[][]

Rescaled positions dictionary

Deprecated ​

Use rescaleInPlace(positions, dim, scale, center) over a flat dim-stride array. For a plain id-keyed map, copy its rows into a Float64Array, rescale it and write the rows back. For the map of a layout run over a graph snapshot, fromPositionMap(pos, snapshot.ids, dim, fill) builds the array and toPositionMap({ positions, dim, n }, snapshot.ids) reads it back; both need the snapshot's NodeIdMap, and fromPositionMap builds a Float32Array, so values lose f64 precision. rescaleInPlace skips a NaN component in the mean and the distance where this function lets it spread, and it returns dim components per row whatever the length of center; toPositionMap also drops a row whose every component is NaN. Removed in 3.0.0.