dc-js / dc.leaflet.js

DC charts using Leaflet maps
Apache License 2.0
52 stars 24 forks source link

Heat Map Functionality #38

Open fletcmd opened 6 years ago

fletcmd commented 6 years ago

I am a big fan of dc.js, but realized that it doesn't support heatmaps for leaflet, which my company would love to use. Is there any plans to add that? I know leaflet supports it natively, so hopefully getting it to connect to crossfilter is doable.

gordonwoodhull commented 6 years ago

I'd be very interested in this feature, and would love to help if you care to contribute.

It looks like Leaflet.heat is the standard plug-in for this.

One design consideration is that Leaflet.heat does aggregation, and crossfilter does too. Where to put this responsibility? I guess in most cases Leaflet.heat should do the aggregation for this dimension, because it knows the current zoom level and the right block size. So you'd expose a crossfilter dimension & group which is not aggregated, i.e. keyed on some unique id or the row number.

(Some parts of the library assume that the crossfilter group is aggregated at the latlong level by default, but I don't recommend this since then you'd have the confusion of two levels of aggregation.)

The heatmap should be pretty easy to implement, since the drawing is already done by Leaflet.heat. As you can see, this is a tiny library and not hard to extend. You'd just derive from dc_leaflet.leafletBase and override _postRender and _doRedraw.

Anyway, I'm here to help if you want to take this up!

fletcmd commented 6 years ago

AWESOME. So I'm hoping that the aggregations are similar to the MarkerCluster addon that does similar aggregations, just not as a heatmap. My first steps are going to be to look through that and see how they broke out the ags.