Skip to content

Releases: d3/d3-scale

v1.0.6

15 May 19:10
Compare
Choose a tag to compare

v1.0.5

10 Mar 17:50
Compare
Choose a tag to compare
  • Update dependencies.

v1.0.4

23 Nov 00:48
Compare
Choose a tag to compare
  • Update dependencies.

v1.0.3

02 Aug 21:32
Compare
Choose a tag to compare
  • Add module entry point to package.json.

v1.0.2

29 Jul 22:51
Compare
Choose a tag to compare
  • Edit the README.

v1.0.1

11 Jul 02:39
Compare
Choose a tag to compare

v1.0.0

24 Jun 17:54
Compare
Choose a tag to compare
  • First stable release.
  • Fix order of ticks with log scales with huge descending domains.
  • Add sequential.interpolator.

Changes since D3 3.x

Pursuant to the great namespace flattening:

Scales now generate ticks in the same order as the domain: if you have a descending domain, you now get descending ticks. This change affects the order of tick elements generated by axes. For example:

d3.scaleLinear().domain([10, 0]).ticks(5); // [10, 8, 6, 4, 2, 0]

Log tick formatting now assumes a default count of ten, not Infinity, if not specified. Log scales with domains that span many powers (such as from 1e+3 to 1e+29) now return only one tick per power rather than returning base ticks per power. Non-linear quantitative scales are slightly more accurate.

You can now control whether an ordinal scale’s domain is implicitly extended when the scale is passed a value that is not already in its domain. By default, ordinal.unknown is d3.scaleImplicit, causing unknown values to be added to the domain:

var x = d3.scaleOrdinal()
    .domain([0, 1])
    .range(["red", "green", "blue"]);

x.domain(); // [0, 1]
x(2); // "blue"
x.domain(); // [0, 1, 2]

By setting ordinal.unknown, you instead define the output value for unknown inputs. This is particularly useful for choropleth maps where you want to assign a color to missing data.

var x = d3.scaleOrdinal()
    .domain([0, 1])
    .range(["red", "green", "blue"])
    .unknown(undefined);

x.domain(); // [0, 1]
x(2); // undefined
x.domain(); // [0, 1]

The ordinal.rangeBands and ordinal.rangeRoundBands methods have been replaced with a new subclass of ordinal scale: band scales. The following code in 3.x:

var x = d3.scaleOrdinal()
    .domain(["a", "b", "c"])
    .rangeBands([0, width]);

Is equivalent to this in 4.0:

var x = d3.scaleBand()
    .domain(["a", "b", "c"])
    .range([0, width]);

The new band.padding, band.paddingInner and band.paddingOuter methods replace the optional arguments to ordinal.rangeBands. The new band.bandwidth and band.step methods replace ordinal.rangeBand. There’s also a new band.align method which you can use to control how the extra space outside the bands is distributed, say to shift columns closer to the y-axis.

Similarly, the ordinal.rangePoints and ordinal.rangeRoundPoints methods have been replaced with a new subclass of ordinal scale: point scales. The following code in 3.x:

var x = d3.scaleOrdinal()
    .domain(["a", "b", "c"])
    .rangePoints([0, width]);

Is equivalent to this in 4.0:

var x = d3.scalePoint()
    .domain(["a", "b", "c"])
    .range([0, width]);

The new point.padding method replaces the optional padding argument to ordinal.rangePoints. Like ordinal.rangeBand with ordinal.rangePoints, the point.bandwidth method always returns zero; a new point.step method returns the interval between adjacent points.

The ordinal scale constructor now takes an optional range for a shorter alternative to ordinal.range. This is especially useful now that the categorical color scales have been changed to simple arrays of colors rather than specialized ordinal scale constructors:

The following code in 3.x:

var color = d3.scaleCategory10();

Is equivalent to this in 4.0:

var color = d3.scaleOrdinal(d3.schemeCategory10);

Sequential scales, are a new class of scales with a fixed output interpolator instead of a range. Typically these scales are used to implement continuous sequential or diverging color schemes. Inspired by Matplotlib’s new perceptually-motived colormaps, 4.0 now features viridis, inferno, magma, plasma interpolators for use with sequential scales. Using d3.quantize, these interpolators can also be applied to quantile, quantize and threshold scales.

viridis
inferno
magma
plasma

4.0 also ships new Cubehelix schemes, including Dave Green’s default and a cyclical rainbow inspired by Matteo Niccoli:

cubehelix
rainbow
warm
cool

For even more sequential and categorical color schemes, see d3-scale-chromatic.

For an introduction to scales, see Introducing d3-scale.

See CHANGES for all D3 changes since 3.x.

v0.9.3

19 Jun 16:28
Compare
Choose a tag to compare
  • Update dependencies.

v0.9.2

15 Jun 19:38
Compare
Choose a tag to compare

v0.9.1

13 Jun 17:46
Compare
Choose a tag to compare