intellipharm-pty-ltd / dc-addons

dc.js chart addons
http://intellipharm.github.io/dc-addons/
MIT License
67 stars 27 forks source link

leaflet addon and filterByArea #15

Open patb23 opened 8 years ago

patb23 commented 8 years ago

Hi, I gather from the documentation that 'filterByArea(true)' on a leafletMarkerChart would enable event when the map is panned. I tried setting this to true in the leaflet example but am getting an error '_g' as undefined. If I turn this off the map is rendered but data filter depending on the map events are not happening. Just a copy/paste of the example code but providing here for completeness

` var marker = dc.leafletMarkerChart("#demo1 .map") .dimension(facilities) .group(facilitiesGroup) .width(600) .height(400) .filterByArea(true) .clusterOptions({maxClusterRadius: 5, showCoverageOnHover: true, spiderfyOnMaxZoom: true}) .cluster(true);

  var types = xf.dimension(function(d) { return d.type; });
  var typesGroup = types.group().reduceCount();

  var pie = dc.pieChart("#demo1 .pie")
    .dimension(types)
    .group(typesGroup)
    .width(200)
    .height(200)
    .renderLabel(true)
    .renderTitle(true)
    .ordering(function (p) {
      return -p.value;
    });

`

filterbyarea_error
gordonwoodhull commented 8 years ago

The error is coming from dc.js - is it possible that you are filtering the map before the pie chart is rendered? Or does this happen during the first renderAll? perhaps the map sends a filter event while it's being rendered, somewhat rude.

patb23 commented 8 years ago

Yes it is happening at the first render. Just noticed that I am able to cluster using the demo2 in the example page. The only difference being the addition of following .center([42.69,25.42]) .zoom(7) Would be helpful, if I could know how adding these 2 is rendering fixes the issue. Thanks