功率尺度
🌐 Power scales
幂(“pow”)尺度类似于线性尺度,只是输入域值在计算输出范围值之前会应用指数变换。每个范围值y可以表示为域值x的函数:y = mx^k + b,其中k是指数值。幂尺度还支持负域值,在这种情况下,输入值和得到的输出值都会乘以-1。
🌐 Power (“pow”) scales are similar to linear scales, except an exponential transform is applied to the input domain value before the output range value is computed. Each range value y can be expressed as a function of the domain value x: y = mx^k + b, where k is the exponent value. Power scales also support negative domain values, in which case the input value and the resulting output value are multiplied by -1.
scalePow(domain, range)
示例 · 来源 · 使用指定的 domain 和 range、指数 1、默认 插值器 并禁用 clamping 构建新的 pow 规模。
const x = d3.scalePow([0, 100], ["red", "blue"]).exponent(2);如果未指定 domain 或 range,每个默认为 [0, 1]。
🌐 If either domain or range are not specified, each defaults to [0, 1].
scaleSqrt(domain, range)
示例 · 来源 · 构建一个新的 pow 规模,具有指定的 域 和 值域,指数 为 0.5,默认 插值器 并且 夹紧 已禁用。
const x = d3.scaleSqrt([0, 100], ["red", "blue"]);如果未指定 domain 或 range,每个默认值为 [0, 1]。这是一个方便的方法,相当于 d3.scalePow(…).exponent(0.5)。
🌐 If either domain or range are not specified, each defaults to [0, 1]. This is a convenience method equivalent to d3.scalePow(…).exponent(0.5).
pow.指数(exponent)
🌐 pow.exponent(exponent)
示例 · 来源 · 如果指定了exponent,则将当前指数设置为给定的数值并返回此比例。
const x = d3.scalePow([0, 100], ["red", "blue"]).exponent(2);如果未指定 exponent,则返回当前指数,默认为 1。
🌐 If exponent is not specified, returns the current exponent, which defaults to 1.
x.exponent() // 2如果指数为1,则pow刻度实际上是线性刻度。
🌐 If the exponent is 1, the pow scale is effectively a linear scale.