Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ proto.plot = function(geoCalcData, fullLayout, promises) {
break;
}
}
for(var i = 0; i < geoCalcData.length; i++) {
if(geoCalcData[0][0].trace.locationmode) {
needsTopojson = true;
break;
}
}
if(!needsTopojson) {
return _this.update(geoCalcData, fullLayout);
}
Expand Down
60 changes: 50 additions & 10 deletions test/jasmine/tests/geo_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1338,18 +1338,58 @@ describe('Test geo interactions', function() {
.then(done);
});

it('should not make request for topojson when not needed', function(done) {
var gd = createGraphDiv();
var fig = Lib.extendDeep({}, require('@mocks/geo_skymap.json'));
describe('should not make request for topojson when not needed', function() {
var gd;

spyOn(d3, 'json').and.callThrough();
beforeEach(function() {
if(window.PlotlyGeoAssets && window.PlotlyGeoAssets.topojson) {
delete window.PlotlyGeoAssets.topojson.world_110m;
}
gd = createGraphDiv();
spyOn(d3, 'json').and.callThrough();
});

Plotly.plot(gd, fig)
.then(function() {
expect(d3.json).toHaveBeenCalledTimes(0);
})
.catch(failTest)
.then(done);
function _assert(cnt) {
return function() {
expect(d3.json).toHaveBeenCalledTimes(cnt);
};
}

it('- no base layers + lon/lat traces', function(done) {
var fig = Lib.extendDeep({}, require('@mocks/geo_skymap.json'));

Plotly.plot(gd, fig)
.then(_assert(0))
.then(function() { return Plotly.relayout(gd, 'geo.showcoastlines', true); })
.then(_assert(1))
.catch(failTest)
.then(done);
});

it('- no base layers + choropleth', function(done) {
Plotly.plot(gd, [{
type: 'choropleth',
locations: ['CAN'],
z: [10]
}], {
geo: {showcoastlines: false}
})
.then(_assert(1))
.catch(failTest)
.then(done);
});

it('- no base layers + location scattergeo', function(done) {
Plotly.plot(gd, [{
type: 'scattergeo',
locations: ['CAN'],
}], {
geo: {showcoastlines: false}
})
.then(_assert(1))
.catch(failTest)
.then(done);
});
});
});

Expand Down