Skip to content

Symlog 尺度

🌐 Symlog scales

详情请参阅 Webber 的《用于宽范围数据的双对称对数变换》(https://www.researchgate.net/profile/John_Webber4/publication/233967063_A_bi-symmetric_log_transformation_for_wide-range_data/links/0fcfd50d791c85082e000000.pdf)。与对数刻度不同,symlog 刻度的定义域可以包含零。

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

示例 · 来源 · 构建一个新的连续刻度,具有指定的范围常量1,默认插值器和禁用的钳制

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)

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

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

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

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

js
x.constant() // 2