-
Notifications
You must be signed in to change notification settings - Fork 1.8k
GeoChoropleth refactor #719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Cool! Is this change interface-compatible? Not that it matters. I'll queue this up for the 2.1 release (and if we switch to gitflow I'll be able to merge it to a develop branch once you've written tests). There should no license concerns with Jason Davies' code - it's BSD licensed like d3. I wonder if it's distributed anywhere. We pulled in his box plot implementation from d3-plugins but at a glance it doesn't look like he's published d3.geo.zoom there. |
By interface compatible, do you mean with leaflet.js? So two things about the projection transitions vs. projection zooms. I couldn't get them to work together (also with the automatic zoom to projection). There was just too much path-projection manipulation going on at the same time. I was however able to get |
Also, I updated the web demo so you can try out the new features. |
His code links to a LICENSE.txt in the same directory which is BSD, so we're good there. We should link to his source and expand the license link in our copy. As for interface compatibility, I was asking whether existing uses of geoChoropleth will be broken by the changes. It sounds like at least CSS customizations might get lost. It's fine to change the interface with a version bump (we won't try to cram this into 2.0) but I'm asking out of curiosity, and it would be nice to document any changes to help folks migrate. |
Sounds good. Do you like the idea of a |
Excited about this :) Do you have any examples you could share? |
Sure.. but maybe we should start the changelog after 2.0 - I don't even know half the things that went into 2.0. |
@seriousben You can check out my fork and use the 'geo-refactor' branch. After you run
After trying it, I noticed there is something strange with the auto zoom. I think it's related to the GeoJSON and bounding box calculation, rather than the code itself because it does fit the view, but not as you would expect. |
Alrighty, I just fixed the web demo by using a fresh copy of the US states from Natural Earth (public domain license). Also required me to change the key accessor on the layer to return |
src/geo-choropleth-chart.js
Outdated
_chart._doRedraw = function () { | ||
var data = _layeredData(_chart.data()); | ||
|
||
for (var layerName in _layers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtraynham, does this cover the layer-removed case? I haven't reviewed this thoroughly, but thought of this case because I was looking at #698.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not since we never bind the layer data using d3 and instead just loop them. Should be a fairly easy change.
Hey Gordon, My thoughts are:
If there is an optimum case here, I'd rather support that than handling both cases (adding/removing layers during I don't know if I have ever brought up the case of benchmarking certain features, but let's do what's more performant or more common since there seems to be no right or wrong solution. |
@ThomasRobertFr maybe you could comment on that. |
I doubt that the logic of removing layers would create any performance penalty at all. In general, you can do as almost much computation as you want, but once you start modifying the DOM, then you have to worry about efficiency. That's why, if you are removing layers, it's much more efficient to redraw than to rerender. Probably the loganalysis team can describe it better, but my understanding is that they are adding/removing layers without doing a full render because they have implemented semantic zoom on territories, as you can see in their demo. So in this use case, the application would have called It would be cool to use d3 data binding instead of a loop, but again I doubt there is any performance impact, and it's really a code clarity concern. Anyway, I hope that @mtraynham and the loganalysis team will work together on this refactor for 2.1! This is the area of dc.js that I am least familiar with. (It's not supported by dcplot yet, though my colleagues have requested it.) |
mtraynham@68bbf23#diff-ff506ba8d9c0b671b44c576a6aa64674R283 Also, removed most of the unnecessary functions. |
3b1cadb
to
94de367
Compare
Zoom is such a cool feature, but when using a flat-surface projection like mercator, it adds strange effects (as i believe geo.zoom intends for). Is it possible to use the new zoom to get a straight normal zoom onto a flat projection? Thanks! |
@dberger1989 It's been awhile since I've looked at the code, so it would need a bit of investigation. I do remember that some of the projections do not support rotation and that may be throwing things off. There are a few if-statements that may need to be fixed:
Is there a new d3.geo.zoom? I couldn't find one other than the examples from those sites. Davies seemingly has a newer version which looks a bit more fluent, but the source is all minified. |
94de367
to
90e117c
Compare
Noticed this was getting out of date, rebased against master. |
90e117c
to
9ed5009
Compare
9ed5009
to
a2aaa39
Compare
a2aaa39
to
adb2569
Compare
adb2569
to
cb27901
Compare
…o drive removal/adds rather than us waiting for a redraw and our own looping process.
cb27901
to
a178f03
Compare
so these changes were never pulled in? |
Hi @d3netxer, that's correct. I'm in favor of pulling this in for 3.0 but the rebase is probably going to be difficult, given that we've already ported I also understand that this may not be backward-compatible. May need more tests too. So definitely not trivial, but welcome if @mtraynham and/or @kum-deepak want to take it on. |
Actually probably the easier thing to do would be check if there were any changes made to the original chart and then port this PR to d3v4, replacing this chart. Then we can re-apply #1382 |
Kind of a large refactor, which adds:
TODO:
Fix tests (changes to SVG class names don't match)DocumentFuture:
d3.geo.zoom (Jason Davies license?)Strikethroughs have been completed.