-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Upgrade d3 geo projections #5112
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
Changes from 5 commits
9f679fd
f17f3bf
a7735e6
7730d43
8dd4ba0
7e36f6c
557ebde
1b4fd15
f46e4af
d5d352c
b9be8c1
d5883d2
647b0dc
a046871
98c19b8
905eeb0
0a7ed9f
be527cf
32aeac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1353,46 +1353,6 @@ describe('Test geo interactions', function() { | |
.then(done, done.fail); | ||
}); | ||
|
||
it('should clear hover label when cursor slips off subplot', function(done) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did these 2 tests get removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I recall (as mentioned in the commit message) there used to be a bug in d3.geo where a function returned There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But these tests are just using the high-level API, not d3 geo itself. If they started failing, that means something changed about the user-facing behavior. What changed? Are we comfortable with that change? I'd much prefer if we can adapt the tests to the new version so we can see the difference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. Pointing to the fact that rebase somehow forgot to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test should still be able to pass though. Perhaps the exact pixel positions need to change because there's some small change in how the projection is applied? If I try to manually follow what's going on in the test (I believe it's hovering on the point off the coast of Africa, then slowly mousing off the edge of the globe) the behavior looks identical before/after the change. So we should be able to bring the test back, but if the exact values need to change a little ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call. Adjusted in 647b0dc. |
||
var gd = createGraphDiv(); | ||
var fig = Lib.extendDeep({}, require('@mocks/geo_orthographic.json')); | ||
|
||
function _assert(msg, hoverLabelCnt) { | ||
expect(d3SelectAll('g.hovertext').size()) | ||
.toBe(hoverLabelCnt, msg); | ||
} | ||
|
||
var px = 390; | ||
var py = 290; | ||
var cnt = 0; | ||
|
||
Plotly.newPlot(gd, fig).then(function() { | ||
gd.on('plotly_unhover', function() { cnt++; }); | ||
|
||
mouseEvent('mousemove', px, py); | ||
_assert('base state', 1); | ||
|
||
return new Promise(function(resolve) { | ||
var interval = setInterval(function() { | ||
px += 2; | ||
mouseEvent('mousemove', px, py); | ||
|
||
if(px < 402) { | ||
_assert('- px ' + px, 1); | ||
expect(cnt).toBe(0, 'no plotly_unhover event so far'); | ||
} else { | ||
_assert('- px ' + px, 0); | ||
expect(cnt).toBe(1, 'plotly_unhover event count'); | ||
|
||
clearInterval(interval); | ||
resolve(); | ||
} | ||
}, 100); | ||
}); | ||
}) | ||
.then(done, done.fail); | ||
}); | ||
|
||
it('should not confuse positions on either side of the globe', function(done) { | ||
var gd = createGraphDiv(); | ||
var fig = Lib.extendDeep({}, require('@mocks/geo_orthographic.json')); | ||
|
@@ -1421,66 +1381,6 @@ describe('Test geo interactions', function() { | |
.then(done, done.fail); | ||
}); | ||
|
||
it('should plot to scope defaults when user setting lead to NaN map bounds', function(done) { | ||
var gd = createGraphDiv(); | ||
|
||
spyOn(Lib, 'warn'); | ||
|
||
Plotly.newPlot(gd, [{ | ||
type: 'scattergeo', | ||
lon: [0], | ||
lat: [0] | ||
}], { | ||
geo: { | ||
projection: { | ||
type: 'kavrayskiy7', | ||
rotation: { | ||
lat: 38.794799, | ||
lon: -81.622334, | ||
} | ||
}, | ||
center: { | ||
lat: -81 | ||
}, | ||
lataxis: { | ||
range: [38.794799, 45.122292] | ||
}, | ||
lonaxis: { | ||
range: [-82.904731, -81.622334] | ||
} | ||
}, | ||
width: 700, | ||
heigth: 500 | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default view is the fallback resulted from catching There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I guess this makes sense. The map is still in a somewhat broken state at that point: if you scroll-zoom until you can see the map appear from above, you can drag it up and down but not left/right. If you then (or instead) use the zoom out button, now you can drag left/right. Can we detect and fix this in the scroll zoom handler perhaps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created an issue (see #5787) to track this edge case so that we could move on. |
||
.then(function() { | ||
var geoLayout = gd._fullLayout.geo; | ||
var geo = geoLayout._subplot; | ||
|
||
expect(geoLayout.projection.rotation).toEqual({ | ||
lon: 0, lat: 0, roll: 0, | ||
}); | ||
expect(geoLayout.center).toEqual({ | ||
lon: 0, lat: 0 | ||
}); | ||
expect(geoLayout.lonaxis.range).toEqual([-180, 180]); | ||
expect(geoLayout.lataxis.range).toEqual([-90, 90]); | ||
|
||
expect(geo.viewInitial).toEqual({ | ||
'fitbounds': false, | ||
'projection.rotation.lon': 0, | ||
'center.lon': 0, | ||
'center.lat': 0, | ||
'projection.scale': 1 | ||
}); | ||
|
||
expect(Lib.warn).toHaveBeenCalledTimes(1); | ||
expect(Lib.warn).toHaveBeenCalledWith( | ||
'Invalid geo settings, relayout\'ing to default view.' | ||
); | ||
}) | ||
.then(done, done.fail); | ||
}); | ||
|
||
it('should get hover right for choropleths involving landmasses that cross antimeridian', function(done) { | ||
var gd = createGraphDiv(); | ||
|
||
|
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.
plotly/d3@master...plotly:drop-geo