Hi fCC, I’m having trouble with the legend for the heat map project in the d3 cert.
The issue is that I don’t have much direction for how to efficiently create the legend. What I want to do is something like:
- generate an array of values to represent the intervals in the legend,
- create a scale for the x-axis (but I don’t really know what to do for the
.domain()
?), - create the x-axis for the legend using that scale, but the d3 docs are a little confusing imho about how exactly to format numbers on axes, which I’d probably need to do considering that the array I’d generate would store un-rounded floats (for use elsewhere in the code, in particular cleaning up what the code currently does to get the right color in each heat map cell).
Problem is, I really don’t know (1) how to specifically implement this idea, OR, if this idea isn’t feasible, (2) what my other options really are.
I’ve inspected the visible code of the demo to sleuth for clues, and I’ve read relevant posts on this forum, but to no avail. Can any of y’all help?