Skip to content

Symlog scales

See A bi-symmetric log transformation for wide-range data by Webber for details. Unlike a log scale, a symlog scale domain can include zero.

scaleSymlog(domain, range)

Examples · Source · Constructs a new continuous scale with the specified domain and range, the constant 1, the default interpolator and clamping disabled.

js
const x = d3.scaleSymlog([0, 100], [0, 960]);

If a single argument is specified, it is interpreted as the range. If either domain or range are not specified, each defaults to [0, 1].

js
const color = d3.scaleSymlog(["red", "blue"]) // default domain of [0, 1]

symlog.constant(constant)

Examples · Source · If constant is specified, sets the symlog constant to the specified number and returns this scale. The constant defaults to 1.

js
const x = d3.scaleSymlog([0, 100], [0, 960]).constant(2);

If constant is not specified, returns the current value of the symlog constant.

js
x.constant() // 2