Here's my code:
var color = d3.scaleLinear()
.domain([0, 10000])
.interpolate(d3.interpolateBlues);
console.log(color(5000));
Instead of telling me that 5000 corresponds to a light blue, I get the error "r0 is not a function". What am I doing wrong?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With