Skip to content

Documentation / @ripl/core / scaleSymlog

Function: scaleSymlog() ​

scaleSymlog(domain, range, options?): Scale<number>

Defined in: packages/core/src/scales/symlog.ts:127

Creates a symmetric-log (symlog) scale that maps a numeric domain to a range through a sign-preserving logarithmic transform.

Unlike a plain logarithmic scale, symlog handles negative values and zero: values within the linear threshold constant of zero map approximately linearly, while larger magnitudes compress logarithmically. The transformed domain [t(min), t(max)] is mapped linearly onto range, so a domain symmetric about zero places zero at the range midpoint.

Parameters ​

ParameterTypeDescription
domainnumber[]The value domain [min, max] (may span negative through positive values).
rangenumber[]The output range [start, end].
options?SymlogScaleOptionsOptional linear threshold, clamping, and tick-padding configuration.

Returns ​

Scale<number>

A scale mapping domain values to the range, with inverse recovering the domain value.

Example ​

typescript
const scale = scaleSymlog([-100, 100], [0, 200]);
scale(0); // 100 (zero sits at the range midpoint)
scale.inverse(100); // 0