Skip to content

Fix #341: Added highlight function for Choropleth#490

Merged
ocefpaf merged 20 commits intopython-visualization:masterfrom
joshuacano:highlight
Sep 22, 2016
Merged

Fix #341: Added highlight function for Choropleth#490
ocefpaf merged 20 commits intopython-visualization:masterfrom
joshuacano:highlight

Conversation

@joshuacano
Copy link
Copy Markdown
Contributor

This is how I was thinking of implementing this, just a minor tweak on your solution @BibMartin. I currently have hardcoded 2 and .2 for weight and fillOpacity for each shape that is highlighted. Let me know how this looks? Also I was hoping to had a legend functionality to add the custom info control functionality if desired by the user as well. (as described in the custom info section towards the bottom of this page http://leafletjs.com/examples/choropleth.html) Is this something that is wanted also? Should we include this. Thanks for reviewing this in advance.

Comment thread folium/map.py Outdated
_default_js = [
('leaflet',
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"),
"https://npmcdn.com/leaflet@1.0.0-rc.3/dist/leaflet.js"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update leaflet but a release candidate is not OK for a folium release!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally, I can change back to the current stable leaflet build.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will take a looking into testing the latest leaflet later. I will reserve this weekend for folium.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed back to stable build

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a release candidate, no? rc.3?

Still releases candidates are "stable enough." Let me just run the whole gallery with that version before merging this to be sure nothing is broken.

@ocefpaf
Copy link
Copy Markdown
Member

ocefpaf commented Aug 24, 2016

@joshuacano thanks for the PR!

Can you please:

  • update the tests to get them to pass
  • add a test for this feature when using the default function
  • add a notebook to the examples folder showing the new feature
  • add an entry to the changelog (CHANGES.TXT)

@joshuacano
Copy link
Copy Markdown
Contributor Author

Absolutely @ocefpaf . For some reason I never got notified about these comments, would have done em sooner. I'll make those changes specified.

@ocefpaf
Copy link
Copy Markdown
Member

ocefpaf commented Sep 1, 2016

Thanks. Things here are slow but (hopefully) steady. I am planning on a new release and this change will be an important addition.

@joshuacano
Copy link
Copy Markdown
Contributor Author

Sorry its taking me so long to address this, Is this gating your release??! I'll get to it ASAP this weekend.

@ocefpaf
Copy link
Copy Markdown
Member

ocefpaf commented Sep 9, 2016

Sorry its taking me so long to address this, Is this gating your release??! I'll get to it ASAP this weekend.

I would love to say so and find a scapegoat 😉 but no. I am overwhelmed with my day job and there are many other issues I need to address in folium.

So do not worry and take you time.

@joshuacano
Copy link
Copy Markdown
Contributor Author

joshuacano commented Sep 11, 2016

Question. Is this going to always be on for choropleth? Or should we have a switch in the method that specifies if this feature is on? (I.e. highlight=False in choropleth method signature) I'm gonna go with the assumption that it's always on. (Will just require a minor tweak to an existing test)

@joshuacano
Copy link
Copy Markdown
Contributor Author

joshuacano commented Sep 11, 2016

Two more questions @ocefpaf,

  1. should I go ahead and add the dynamic Legend feature? As that would require a new example to the notebooks to describe how to customize the legend. As of now, the feature is always on and will always highlight the region the user mouses over.
  2. Are there any selenium type tests in the test suite? I was trying to figure out how to test that when the user mouses over a region that the highlight function is called. But without any selenium type tests I'm not sure how to do so. Perhaps you have some guidance on how I can approach that?

@ocefpaf
Copy link
Copy Markdown
Member

ocefpaf commented Sep 12, 2016

Question. Is this going to always be on for choropleth? Or should we have a switch in the method that specifies if this feature is on? (I.e. highlight=False in choropleth method signature) I'm gonna go with the assumption that it's always on. (Will just require a minor tweak to an existing test)

Let's keep it turned off to preserve the current behavior. Specially b/c this has the potential to be expanded later on for other "functions" beyond the highlight. (Still thinking about this but I haven't got the time to look into it.)

  1. should I go ahead and add the dynamic Legend feature? As that would require a new example to the notebooks to describe how to customize the legend. As of now, the feature is always on and will always highlight the region the user mouses over.

That is up to you. (Maybe a new PR might be better to keep things simple.)

? 2. Are there any selenium type tests in the test suite? I was trying to figure out how to test that when the user mouses over a region that the highlight function is called. But without any selenium type tests I'm not sure how to do so. Perhaps you have some guidance on how I can approach that?

Nope. Maybe we do not need to be that complex 😄

@joshuacano
Copy link
Copy Markdown
Contributor Author

Got IT! I'll add a switch (as I should have seen in your earlier comment) and leave the default as off and add a test as well as an extra example to the notebook. Will push this shortly.

Furthermore, good point on the new PR, I'll do that for a new legend once I get these other items taken care of. Thanks a bunch @ocefpaf!

@joshuacano
Copy link
Copy Markdown
Contributor Author

I have added a test for highlight and added a highlight switch to the choropleth method. I also added some cells to the existing notebooks in the example directory. Is this along the lines of what you were looking for? Let me know I'll be glad to change.

@ocefpaf
Copy link
Copy Markdown
Member

ocefpaf commented Sep 16, 2016

@joshuacano looks good to me. There are conflicts here. Can you rebase and fix them?

If GitHub rebasing is not your forte let me know and I will send a new PR picking your commits.

@joshuacano
Copy link
Copy Markdown
Contributor Author

I'll give the rebasing a shot.

@joshuacano
Copy link
Copy Markdown
Contributor Author

@ocefpaf Alright, I think I have fixed the conflicts, do you mind reviewing for me?

"metadata": {
"collapsed": false
},
<<<<<<< HEAD
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we have a conflict remaining here. Don't worry I will fix this in another PR.

"metadata": {
"collapsed": true
},
"outputs": [],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this cell was not executed.

@ocefpaf
Copy link
Copy Markdown
Member

ocefpaf commented Sep 22, 2016

@joshuacano let's keep this in and I will fix the remaining issues. Thanks for the PR! Hope to see more 😜

@ocefpaf ocefpaf merged commit 6c87d75 into python-visualization:master Sep 22, 2016
@joshuacano joshuacano deleted the highlight branch September 23, 2016 19:50
sanga pushed a commit to sanga/folium that referenced this pull request Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants