d3 / d3-scale-chromatic

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

Ordinal scales are broken #9

Closed thilomaurer closed 7 years ago

thilomaurer commented 7 years ago
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-scale-chromatic.v1.js"></script>
<script>
    var range = d3.schemeAccent;
    var range = d3.schemeSpectral;
    var c = d3.scaleOrdinal(range).domain(["a","b","c"]);
    var result = c("a");
</script>

For schemeAccent, result is #7fc97f. while for schemeSpectral, result is undefined.

mbostock commented 7 years ago

You have to specify the cardinality when you use a discrete scheme, such as d3.schemeSpectral[9]. Alternatively you can use d3.interpolateSpectral with d3.scaleSequential for a continuous color encoding.

thilomaurer commented 7 years ago

Understood. Thank you for updating the README.