I\'m building a pie chart using d3.js, and visualizing a big data set. There are more than 137 items to visualize on the chart. I have just 10 color
A simple solution (with d3@5, not sure about earlier versions) that I'm surprised hasn't been mentioned yet is to use the interpolation functions combined with a function to derive a [0,1] ratio of your category respective to the categories set.
const color = d3.interpolateSpectral;
//...
.style("color", (d:any, i:number) => {
const t:number = i / data.columns.length;
return color(t) as string;
});
https://github.com/d3/d3-scale-chromatic