d3 / d3-color

Color spaces! RGB, HSL, Cubehelix, CIELAB, and more.
https://d3js.org/d3-color
ISC License
398 stars 91 forks source link

d3.hsl doesnt seem to work with grey scale values #73

Closed nonmetalhail closed 4 years ago

nonmetalhail commented 4 years ago

Seems like whenever I have a color where the saturation is 0% or the lightness is 0% or 100%, I get NaN values in the returned color object.

Easiest to see the various examples here: https://observablehq.com/d/f7636f7695376a03

But, for example: d3.hsl('#ffffff') returns {h: NaN, s: NaN, l: 1, opacity: 1}

mbostock commented 4 years ago

This is intended. See:

https://observablehq.com/@d3/achromatic-interpolation

mootari commented 4 years ago

Might be a good idea to add a note to the readme (unless it's already there and I missed it)?