score:10

Accepted answer

Okay, figured it out. If using a function such as d3.interpolateBlues which defines the range itself, d3.scaleSequential must be used instead of d3.scaleLinear. The correct code is:

var color = d3.scaleSequential(d3.interpolateBlues)
    .domain([0, 10000])
console.log(color(5000));

See https://github.com/d3/d3-scale#sequential-scales


Related Query