Closed KyleKing closed 6 years ago
You would just need to select all of the cells after the fact to iterate over your colors. Unfortunately this type of double encoding is not default behavior, but here's a codepen that does something similar with the size legend: https://codepen.io/susielu/pen/RjeNbL
The relevant line for you would be something like this:
svg.selectAll(".cell path").attr("fill", (d, i) => colorScheme[i])
Thanks!
Is it possible to specify both the color and shape for each legend element?
I just started working with D3, so hopefully, there is an easy answer. Normally, I would do something like:
.attr( 'fill', ( d, i ) => colorScheme[i] )
, but with d3-legend it doesn't look like the data binding is directly accessible this wayBelow is a modified example from the tutorial: