You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Choropleth maps don't reset accurately when layout.geo.scope is changed #3831
First and foremost, I thought I would mention that this issue is only occurring with Plotly.react as I was able to implement a correct alternative by using Plotly.newPlot but unfortunately means that I won't be able to use react-plotly for this component.
With that out of the way, the bug occurs when the layout scope is changed and either 1. a double click event is triggered or 2. reset is pressed in the mode bar. When the plot is changed through the dropdown though, there is no issue. All examples below can be reproduced in this code pen.
In cases where scope is not 'usa', the reset changed the lon/lat values to whatever the initial plot's geo scope was set at. This is very pronounced when switching from 'world' to 'north america', thus I chose that for the example, but this occurs in any situation. If the initial plot is set to 'north america', then it would be the reverse.
In cases where the plot is changed to 'usa' though, the js actually throws an error! The error is: TypeError: centerPx is null.
So this is actually two errors, but they both seem to have the same root cause.
@etpinard, I'm not sure how far along you are in this, but I spent some time inspecting geo.js and it seems like we can mitigate by resetting viewInitial in the conditional below.
I've also been trying to level up my js, so I wouldn't mind submitting a PR if this hasn't made it down your pipeline yet. Let me know.
Activity
mbkupfer commentedon May 3, 2019
Here is a gif that illustrates what I'm talking about.

etpinard commentedon May 3, 2019
Thanks very much for the report!
Something must be up with
plotly.js/src/plots/geo/geo.js
Lines 515 to 540 in 03b7e09
where we should probably clear the thing on update call involving
geo.scopembkupfer commentedon May 7, 2019
@etpinard, I'm not sure how far along you are in this, but I spent some time inspecting
geo.jsand it seems like we can mitigate by resettingviewInitialin the conditional below.I've also been trying to level up my js, so I wouldn't mind submitting a PR if this hasn't made it down your pipeline yet. Let me know.
plotly.js/src/plots/geo/geo.js
Line 76 in 03b7e09
fix #3831 - reset viewInitial stash on *geo.scope* updates
etpinard commentedon May 9, 2019
@mbkupfer We'll have a fix for this bug merged before we release 1.48.0
Here's your codepen demo using a "fixed" bundle: https://codepen.io/etpinard/pen/XwXqrN?editors=1010
Thanks again for using (and potentially contributing to 😏 ) plotly.js!
mbkupfer commentedon May 10, 2019
Awesome, thanks for fixing this so quickly!
Thanks for making plotly such a great library.
etpinard commentedon May 13, 2019
No problem! Thanks for the very clear bug report!