Closed wahlatlas closed 8 years ago
Low priority but easy to do :stuck_out_tongue_winking_eye:
I implemented two new options that can be passed to mapmap.legend.html()
- reverse
(boolean) reverses the order of the classes (but the "undefined value" item will stay at the end), and order
takes a comparator function that compares two objects representing the legend classes for full customization (Like Array.sort). With this you could even do crazy things like sorting the legend by the number of items in each class like so:
mapmap.legend.html({order: function(a,b) {return b.count() - a.count(); })
This went into master in 081c0ca2b4ba5c11c3a6da6c8dc9fe3211ae3f39 and will be in next release (upcoming next week)
Currently the legend sorts values like an y-scale from low values at the bottom to high values on top. While that is fine with me and it is very obvious from the code where to change the behavior, it seems that there is no consensus in the mapping world how this should be handled (if that argument has been settled before, please let me know). Does it therefore make sense to add the ability to pass an
sort-order
option to the legend generation? Of course this has very low priority.