This is not an "issue" per se with d3-color, but just an idea / research problem that you may want to consider.
I always thought it would be great to have an algorithm that automagically picks N distinct colors that are as far apart perceptually as possible, for representing categorical values. Perhaps d3.scale.category20()
and friends fills this need currently in practice, but I feel like there should be an algorithm for this.
Here is a first attempt at such an algorithm that places points on a circle in LAB space (L is fixed, and the points vary only in (A, B), so they have equal luminance but different hue) http://bl.ocks.org/curran/dd73d3d8925cdf50df86.
Perhaps a better solution would be use Mitchell’s best-candidate algorithm for generating a Poisson-disc distribution in a limited region of (A, B) color space (perhaps a circle?), where the user could specify as input a fixed L value and the desired number of distinct colors. Also Lloyd relaxation might be another nice way to do this.
The API documentation might look something like this:
color.distinct(n, [L])
Returns an array of n
colors that are perceptually distinct. If L
is specified, it controls the fixed L value in LAB color space that the algorithm uses. If L is not specified, it defaults to 50.
Just an idea.
It's great to see all this activity on the new D3, excited to try it out!