Closed curran closed 8 years ago
Curran,
Thanks for submitting this. In the latest version 2.13.0 I have added the ability for you to pass a function in with the labels parameter and created a helper function to deal with threshold labels but you could create any custom function you want.
Here is an example: http://d3-legend.susielu.com/#color-threshold Documentation on the new function has been updated on the labels section of each legend type:
labels([string] or function(options)) Passing a string: Sets the legend labels to the array of strings passed to the legend. If the array is not the same length as the array the legend calculates, it merges the values and gives the calculated labels for the remaining items.
Passing a function: This function is called for each generated label and gives you the options:
Hope this helps, Susie
Wow, this is fantastic! Thank you so much for your work on this.
I tried making a color legend using a d3.scaleThreshold, and here's what the legend looks like:
Here's the relevant bit of code for setting up the scale and the legend:
A nice solution to this would: