get HEX color
beocaca opened this issue · comments
beocaca commented
hello, i need to get the hex color
example document :
var color = d3.scaleLinear()
.domain([10, 100])
.range(["brown", "steelblue"]);
color(20); // "#9a3439"
color(50); // "#7b5167"
but i get the rgba color
color(20); // "rgb(154, 52, 57)"
color(50); // "rgb(123, 81, 103)"
Mike Bostock commented
You can use d3.rgb("rgb(154, 52, 57)").formatHex()
. You can also write your own interpolate that generates hexadecimal strings with the scale if you prefer.