-
Notifications
You must be signed in to change notification settings - Fork 0
Colors
mbostock edited this page May 30, 2011
·
19 revisions
Constructing visualizations often involves working with colors. Even though your browser understands a lot about colors, it doesn't offer much help in manipulating colors through JavaScript. So D3 provides representations for both RGB and HSL colors, allowing interpolation in both color spaces, and making colors brighter or darker. For more about color manipulation, see the Wikipedia entries on RGB and HSL.
Note: while you can work with colors directly, you might also want to take a look at D3's built-in interpolateRgb, interpolateHsl and scales.
# d3.rgb(r, g, b)
# d3.rgb(color)
# rgb.brighter([k])
# rgb.darker([k])
# rgb.hsl()
# rgb.toString()
# d3.hsl(h, s, l)
# d3.hsl(color)
# hsl.brighter([k])
# hsl.darker([k])
# hsl.rgb()
# hsl.toString()