Skip to content

Symlog 尺度

¥Symlog scales

详情请参阅 Webber 编写的 适用于大范围数据的双对称对数变换。Unlike a 对数比例尺, a symlog scale domain can include zero.

¥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)

示例 · 源代码 · 使用指定的 domainrange 构造一个新的连续比例尺,constant 为 1,defaultinterpolatorclamping 禁用。

¥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]);

如果指定了单个参数,则将其解释为范围。如果未指定域或范围,则每个值默认为 [0, 1]。

¥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) {#symlog_constant}

示例 · 源代码 · 如果指定了常量,则将 symlog 常量设置为指定的数字并返回此比例尺。常量默认为 1。

¥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);

如果未指定 constrain,则返回 symlog 常量的当前值。

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

js
x.constant() // 2