d3 / d3-scale-chromatic

Sequential, diverging and categorical color scales.
https://d3js.org/d3-scale-chromatic
Other
801 stars 106 forks source link

programatically get a color scheme's range #1

Closed Fil closed 8 years ago

Fil commented 8 years ago

Could the API let us get the list of schemes, and range of acceptable parameters for any scheme? Then we could auto-write the documentation and create color schemes choosers.

Here's a block that implements the idea http://bl.ocks.org/Fil/0bf58d23011ab244c657a1262bcbe4b2

To be complete it would also have to expose the schemes' categories (Categorical, Diverging, etc).

mbostock commented 8 years ago

I’m planning on making them all continuous using b-splines, so the API will probably change and obviate the need to inspect the allowable range.

I don’t feel like there needs to be an API for getting the list of schemes; you can use a for…in loop on the exported symbols if you really need it, although yes, that won’t tell you the type of scheme. But at any rate, I think such metadata could easily belong in the color scheme chooser itself rather than this library, since a color scheme chooser may readily use color schemes from multiple sources and there is no standard definition of a color scheme.