I think I figured it out. d3.scaleQuantize() returns a value if you input a number in parentheses. However, just doing color like it was a regular array gave me each color individually, which could be fed into the legend.

.style("fill", function (d, i) {return d};)


you can use function variable of i, these i variable follows the sequence. For example

.style("fill", function (d,i) {
                    return color(i);//or color.range(i);

Related Query

More Query from same tag