Displays a fixed colour scale legend whose range is determined from the data range upon page load (ie no filters selected). Adapted from http://leafletjs.com/examples/choropleth.html.
The legend is defined in dc_leaflet.leafletBase so it gets called for each leaflet map. But the legend code uses .colorDomain() which is only defined for choropleths, not marker charts, so the existence of .colorDomain() has to be checked before executing the legend code. Should the legend code therefore be moved into dc_leaflet.choroplethChart?
The calculation for the legend scale was adapted from the equation in dc.js colorCalculator (before the verion based on colorMixin). It maps the counts to the bins of the colour scale (scale length defined by number of colours specified for the map).
Includes colorbrewer.js so that the choro chart colours can be easily changed (e.g. .colors(colorbrewer.YlGnBu[7])).
I'm rearranging it a bit, putting this code in a legend object like dc.js has. Of course this legend only works for color-based maps, but we can figure out how to generalize it in the future.
Displays a fixed colour scale legend whose range is determined from the data range upon page load (ie no filters selected). Adapted from http://leafletjs.com/examples/choropleth.html.
The legend is defined in
dc_leaflet.leafletBase
so it gets called for each leaflet map. But the legend code uses.colorDomain()
which is only defined for choropleths, not marker charts, so the existence of.colorDomain()
has to be checked before executing the legend code. Should the legend code therefore be moved intodc_leaflet.choroplethChart
?The calculation for the legend scale was adapted from the equation in dc.js
colorCalculator
(before the verion based on colorMixin). It maps the counts to the bins of the colour scale (scale length defined by number of colours specified for the map).Includes
colorbrewer.js
so that the choro chart colours can be easily changed (e.g..colors(colorbrewer.YlGnBu[7])
).