Skip to content

Commit 524b6dd

Browse files
committed
replace PLOTLYENV topojson url setting with 'topojsonURL' config opt
1 parent 2d34efe commit 524b6dd

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/lib/topojson_utils.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ topojsonUtils.getTopojsonName = function(geoLayout) {
1313
].join('');
1414
};
1515

16-
topojsonUtils.getTopojsonPath = function(topojsonName) {
17-
var topojsonUrl = (window.PLOTLYENV &&
18-
window.PLOTLYENV.TOPOJSON_URL) || './topojson/';
19-
20-
return topojsonUrl + topojsonName + '.json';
16+
topojsonUtils.getTopojsonPath = function(topojsonURL, topojsonName) {
17+
return topojsonURL + topojsonName + '.json';
2118
};
2219

2320
topojsonUtils.getTopojsonFeatures = function(trace, topojson) {

src/plot_api/plot_api.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ function plotGeo(gd) {
471471
geo = new Plotly.Geo(
472472
{
473473
id: geoId,
474-
container: fullLayout._geocontainer.node()
474+
container: fullLayout._geocontainer.node(),
475+
topojsonURL: gd._context.topojsonURL
475476
},
476477
fullLayout
477478
);

src/plots/geo/geo.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function Geo(options, fullLayout) {
2222

2323
this.id = options.id;
2424
this.container = options.container;
25+
this.topojsonURL = options.topojsonURL;
2526

2627
// add a few projection types to d3.geo,
2728
// a subset of https://github.com/d3/d3-geo-projection
@@ -85,7 +86,10 @@ proto.plot = function(geoData, fullLayout) {
8586
_this.onceTopojsonIsLoaded(geoData, geoLayout);
8687
}
8788
else {
88-
topojsonPath = topojsonUtils.getTopojsonPath(_this.topojsonName);
89+
topojsonPath = topojsonUtils.getTopojsonPath(
90+
_this.topojsonURL,
91+
_this.topojsonName
92+
);
8993

9094
// N.B this is async
9195
d3.json(topojsonPath, function(error, topojson) {

0 commit comments

Comments
 (0)