Sometimes data needs to be converted from a continuous range, like test scores, to a discrete set of output values, like letter grades. In this lesson we’ll see how to use d3.scaleQuantize()
to do exactly that.
function scaleQuantize(){ var quantizeScale = d3.scaleQuantize() .domain([0, 100]) .range(["red", "white", "green"]); console.log(quantizeScale(22)); // red console.log(quantizeScale(50)); // white console.log(quantizeScale(88)); // green // Get the boundaries domain for "white" color console.log(quantizeScale.invertExtent('white')); }