Documentation / @ripl/core / scaleRadial
Function: scaleRadial() ​
scaleRadial(
domain,range,options?):Scale<number,number>
Defined in: packages/core/src/scales/radial.ts:49
Creates a radial scale that maps a numeric magnitude to a ring radius.
The scale is a linear mapping from domain to range (typically [innerRadius, outerRadius] in pixels), sharing the same convert/invert symmetry as scaleContinuous. Unlike a plain continuous scale it clamps by default, so a value beyond the domain lands exactly on the outer ring rather than overshooting it, and a value below the domain lands on the inner radius.
A single-element domain of [max] is treated as [0, max], mapping magnitudes outward from the center.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
domain | number[] | The value domain [min, max] (or [max], treated as [0, max]). |
range | [number, number] | The radius range [innerRadius, outerRadius] in pixels. |
options? | RadialScaleOptions | Optional clamping and tick-padding configuration. |
Returns ​
Scale<number, number>
A scale mapping magnitudes to radii, with inverse reading a radius back to a magnitude.
Example ​
const radius = scaleRadial([0, 100], [0, 240]);
radius(50); // 120
radius.inverse(120); // 50
radius(200); // 240 (clamped to the outer ring)