Skip to content

Commit b2f6b22

Browse files
committed
wrap d3.json requet in geo.plot in promise,
- so that Plotly.plot().then() works as expected.
1 parent c88fb5a commit b2f6b22

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/plot_api/plot_api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ function plotGeo(gd) {
484484
fullLayout[geoId]._geo = geo;
485485
}
486486

487-
geo.plot(fullGeoData, fullLayout);
487+
geo.plot(fullGeoData, fullLayout, gd._promises);
488488
}
489489
}
490490

src/plots/geo/geo.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module.exports = Geo;
6060

6161
var proto = Geo.prototype;
6262

63-
proto.plot = function(geoData, fullLayout) {
63+
proto.plot = function(geoData, fullLayout, promises) {
6464
var _this = this,
6565
geoLayout = fullLayout[_this.id],
6666
graphSize = fullLayout._size;
@@ -100,12 +100,16 @@ proto.plot = function(geoData, fullLayout) {
100100
_this.topojsonName
101101
);
102102

103-
// N.B this is async
104-
d3.json(topojsonPath, function(error, topojson) {
105-
_this.topojson = topojson;
106-
PlotlyGeoAssets.topojson[_this.topojsonName] = topojson;
107-
_this.onceTopojsonIsLoaded(geoData, geoLayout);
108-
});
103+
promises.push(new Promise(function(resolve) {
104+
d3.json(topojsonPath, function(error, topojson) {
105+
106+
_this.topojson = topojson;
107+
PlotlyGeoAssets.topojson[_this.topojsonName] = topojson;
108+
109+
_this.onceTopojsonIsLoaded(geoData, geoLayout);
110+
resolve();
111+
});
112+
}));
109113
}
110114
}
111115
else _this.onceTopojsonIsLoaded(geoData, geoLayout);

0 commit comments

Comments
 (0)