I'm currently using the whole idea of
var myQuantizeFunction = d3.scale.quantize()
.domain(minMaxFromData) // the minmax using d3.extent
.range(['bla-1', 'bla-2', 'bla-3', 'bla-4', 'bla-5']);
So this works fine when you want to generate a legend across your min-max. The issue is, I have some data which comes back as 0.
Here is an example legend for context :
As you can see, it's first or lowest value from the range is 0 - 4.7, what I want to really do is have 0 (ie none) as it's own legend item and have everything above ie 1 - 33 in this case as the other ranges.
I want to be able to specify that the first range is 0 and then the domain is split equally between values > 0.
Is there a d3 way of doing this? I'm sure someone else must have had this same problem before, I can't seem to find it but I may not be using the right search terms.
I improved the latest solution to use
d3.min()
and added code to the test the quantize function. Also I added a small function to colorize the output.Everything done in the d3 datadriven way
View this code runing
Hope this helps, good luck!
Update: I stripped zero out of the scale to treat it as a special case as you pointed in the comment.