d3.scaleSequential()

d3.scaleSequential(interpolator)

Constructs a new sequential scale with the given interpolator function. When the scale is applied, the interpolator will be invoked with a value typically in the range [0, 1], where 0 represents the start of the domain, and 1 represents the end of the domain. For example, to implement the ill-advised HSL rainbow scale:

1
2
3
var rainbow = d3.scaleSequential(function(t) {
  return d3.hsl(t * 360, 1, 0.5) + "";
});

A more aesthetically-pleasing and perceptually-effective cyclical hue encoding is to use d3.interpolateRainbow:

1
var rainbow = d3.scaleSequential(d3.interpolateRainbow);

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

doc_D3_Js
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.