D3 Scale

https://blog.csdn.net/qq_34832846/article/details/90510150

1.Continuous Scales(连续型比例尺)

方法 描述
d3.scaleLinear 创建一个 continuous scale
continuous(value) 根据domain(定义域)计算range(值域)
continuous.invert(value) 根据定义域计算值域
continuous.domain([domain]) 设置值域
continuous.range([range]) 设置定义域
continuous.rangeRound([range]) 代替range,比例尺会四舍五入
continuous.clamp(clamp) 设置边界,如果超出值域或者定义域,就去最大或最小的边界值
continuous.interpolate(interpolate) 设置输出的差值算法
continuous.unknown([value]) set the output value for unknown inputs.
continuous.ticks compute representative values from the domain.
continuous.tickFormat format ticks for human consumption.
continuous.nice([count]) extend the domain to nice round numbers.
continuous.copy() create a copy of this scale.
d3.scalePow continuous scale with the specified domain and range, the exponent 1
d3.scaleSqrt continuous power scale with the specified domain and range, the exponent 0.5
pow compute the range value corresponding to a given domain value.
pow.invert compute the domain value corresponding to a given range value.
pow.exponent set the power exponent.
pow.domain set the input domain.
pow.range set the output range.
pow.rangeRound set the output range and enable rounding.
pow.clamp enable clamping to the domain or range.
pow.interpolate set the output interpolator.
pow.ticks compute representative values from the domain.
pow.tickFormat format ticks for human consumption.
pow.nice extend the domain to nice round numbers.
pow.copy create a copy of this scale.
d3.scaleLog continuous scale with the specified domain and range, the base 10
d3.scaleSymlog continuous scale with the specified domain and range, the constant 1
log compute the range value corresponding to a given domain value.
log.invert compute the domain value corresponding to a given range value.
log.base set the logarithm base.
log.domain set the input domain.
log.range set the output range.
log.rangeRound set the output range and enable rounding.
log.clamp enable clamping to the domain or range.
log.interpolate set the output interpolator.
log.ticks compute representative values from the domain.
log.tickFormat format ticks for human consumption.
log.nice extend the domain to nice round numbers.
log.copy create a copy of this scale.
d3.scaleIdentity a special case of linear scales where the domain and range are identical
d3.scaleTime create a linear scale for time.
time compute the range value corresponding to a given domain value.
time.invert compute the domain value corresponding to a given range value.
time.domain set the input domain.
time.range set the output range.
time.rangeRound set the output range and enable rounding.
time.clamp enable clamping to the domain or range.
time.interpolate set the output interpolator.
time.ticks compute representative values from the domain.
time.tickFormat format ticks for human consumption.
time.nice extend the domain to nice round times.
time.copy create a copy of this scale.
d3.scaleUtc crete a linear scale for UTC.
d3.tickFormat format ticks for human consumption.

2.Sequential Scales(序列比例尺)
与连续比例尺不同的是,序列比例尺的值域是根据指定的插值器内置且不可配置,并且它的插值方式也不可配置。序列比例尺也没有反转invert、值域range、值域求整rangeRound、插值器interpolate方法。

方法 描述
d3.scaleSequential create a sequential scale.
sequential.interpolator set the scale’s output interpolator.
d3.scaleSequentialLog
d3.scaleSequentialPow
d3.scaleSequentialSqrt
d3.scaleSequentialSymlog
d3.scaleSequentialQuantile

3.Diverging Scales
发散比例尺的输出是根据插值器计算并且不可配置。同样没有反转invert、值域range、值域求整rangeRound、插值器interpolate方法。

方法 描述
d3.scaleDiverging create a diverging scale.
diverging.interpolator set the scale’s output interpolator.
d3.scaleDivergingLog
d3.scaleDivergingPow
d3.scaleDivergingSqrt
d3.scaleDivergingSymlog

4.Quantize Scales
量化比例尺类似于线性比例尺,其定义域也是连续的,但值域是离散的,连续的定义域值会被分割成均匀的片段。

方法 描述
d3.scaleQuantize create a uniform quantizing linear scale.
quantize compute the range value corresponding to a given domain value.
quantize.invertExtent compute the domain values corresponding to a given range value.
quantize.domain set the input domain.
quantize.range set the output range.
quantize.nice extend the domain to nice round numbers.
quantize.ticks compute representative values from the domain.
quantize.tickFormat format ticks for human consumption.
quantize.copy create a copy of this scale.
d3.scaleQuantile create a quantile quantizing linear scale.
quantile compute the range value corresponding to a given domain value.
quantile.invertExtent compute the domain values corresponding to a given range value.
quantile.domain set the input domain.
quantile.range set the output range.
quantile.quantiles get the quantile thresholds.
quantile.copy create a copy of this scale.
d3.scaleThreshold create an arbitrary quantizing linear scale.
threshold compute the range value corresponding to a given domain value.
threshold.invertExtent compute the domain values corresponding to a given range value.
threshold.domain set the input domain.
threshold.range set the output range.
threshold.copy create a copy of this scale.

5.Ordinal Scales(xus
序数比例尺的的定义域和值域都是离散的

分段比例尺类似于序数比例尺,区别在于分段比例尺的的定义域的值可以是连续的数值类型,而离散的值域则是将连续的定义域范围划分为均匀的分段。

方法 描述
d3.scaleOrdinal create an ordinal scale.
ordinal compute the range value corresponding to a given domain value.
ordinal.domain set the input domain.
ordinal.range set the output range.
ordinal.unknown set the output value for unknown inputs.
ordinal.copy create a copy of this scale.
d3.scaleImplicit a special unknown value for implicit domains.
d3.scaleBand create an ordinal band scale.
band compute the band start corresponding to a given domain value.
band.domain set the input domain.
band.range set the output range.
band.rangeRound set the output range and enable rounding.
band.round enable rounding.
band.paddingInner set padding between bands.
band.paddingOuter set padding outside the first and last bands.
band.padding set padding outside and between bands.
band.align set band alignment, if there is extra space.
band.bandwidth get the width of each band.
band.step get the distance between the starts of adjacent bands.
band.copy create a copy of this scale.
d3.scalePoint create an ordinal point scale.
point compute the point corresponding to a given domain value.
point.domain set the input domain.
point.range set the output range.
point.rangeRound set the output range and enable rounding.
point.round enable rounding.
point.padding set padding outside the first and last point.
point.align set point alignment, if there is extra space.
point.bandwidth returns zero.
point.step get the distance between the starts of adjacent points.
point.copy create a copy of this scale.

参考:
https://blog.csdn.net/qq_34832846/article/details/90510150