dc-js / dc.leaflet.js

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

The popup in Choropleth doesn't work #22

Closed ackuser closed 4 years ago

ackuser commented 8 years ago

In dc.leaflet version 0.2.3 for the Choropleth Chart the popup doesn't work or it doesn't get rendered. Am I wrong or it happens to anybody else? I will be happy to fix that but I would need some help.

      .renderPopup(true)
      .popup(function(d,feature) {
        return feature.properties.name+" : "+d.value;
      });

Anyway, any help would be really appreciated

msimonin commented 4 years ago

Hi @ackuser,

The same here !

gordonwoodhull commented 4 years ago

Doesn't appear to work for the marker chart either. It looks like it's set up correctly but I don't know, maybe the clicks are getting through or something.

msimonin commented 4 years ago

image Popups seem ok with ClusterMarkers

msimonin commented 4 years ago

Ok I made a quick test: setting brushOn(false) on the chart makes the popup appears. Setting both onClick event and the bindPopup on the layers seems to an issue (leaflet issue ?)

gordonwoodhull commented 4 years ago

Thanks for testing. I dug into it a little more, and it looks like the event handling is fine, but the issue is that brushOn will cause filtering, which causes a redraw of the map. Redrawing erases the popup.

On the demo page, it looks like there is a similar issue with the cluster marker: clicking a cluster causes zooming, which erases the popup. The popup works on a non-cluster (fully expanded) marker.

Do you want to filter and show the popup at the same time?

gordonwoodhull commented 4 years ago

I haven't looked into how to implement this, but I suppose one or the other action could be triggered only when a modifier key is pressed.

msimonin commented 4 years ago

Hi @gordonwoodhull , That would be great to trigger one or another action with a modifier key :) In the time being wouldn't it be possible to bind a key event on the markers to show the popup and keep the click event for the filtering as it is ?

gordonwoodhull commented 4 years ago

I don’t understand the distinction. Either way you are enabling or disabling one of the actions based on what keys are pressed, right?

gordonwoodhull commented 4 years ago

Okay, I implemented .popupMod() and .filterMod() for the marker chart and choropleth in version 0.5.1.

@msimonin, please check if the documentation on LeafletBase is sufficient, and leave a comment here if it needs more explanation or doesn't work.

I changed the demo to display popups only when the control key (command key on Macs) is pressed.

msimonin commented 4 years ago

I just tested and it's perfect ! Thanks a lot @gordonwoodhull :)