How to customize legend?

Dear all, just wondering how to customize legend colours, let say from #E0E0E0 to red?

color = d3.scaleSequential()
.domain([0, 10])
.interpolator(d3[interpolate${colorInterpolator}])
.unknown("#E0E0E0")

Thank you very much!

I think you’re looking for the .range() method, and possibly for scaleLinear() instead of scaleSequential()

color = d3.scaleLinear()
  .domain([0, 10])
  .range(["#E0E0E0", "red"])

It’s well explained in Introduction to D3’s scales / D3 / Observable.

1 Like