-
Notifications
You must be signed in to change notification settings - Fork 228
Choropleth Maps
gka edited this page Feb 29, 2012
·
4 revisions
In choropleth maps, each map region will be colored according to some data value. Again, the data object should be a dictionary of region keys to whatever you want. Kartograph will call the function for every region of the specified layer. If you leave out the layer parameter, the last added layer will be used.
map.choropleth({
layer: 'countries',
data: mydata,
colors: function(d) {
return '#f94'; // return color based on data value/object
}
});
For more advanced color features like interpolation and color scales I'd suggest to use Chroma.js, which is kind of a side project of Kartograph.
colscale = new chroma.ColorScale({
colors: ['#F7E1C5', '#6A000B'],
limits: chroma.limits(mydata, 'quant', 5)
});
map.choropleth({
layer: 'countries',
data: mydata,
colors: function(d) {
return '#f94'; // return color based on data value/object
}
});