@@ -1352,6 +1352,68 @@ describe('Test event property of interactions on a geo plot:', function() {
1352
1352
} ) ;
1353
1353
} ) ;
1354
1354
1355
+ describe ( 'Test geo base layers' , function ( ) {
1356
+ afterEach ( destroyGraphDiv ) ;
1357
+
1358
+ it ( 'should clear obsolete features and layers on *geo.scope* relayout calls' , function ( done ) {
1359
+ var gd = createGraphDiv ( ) ;
1360
+
1361
+ function _assert ( geojson , layers ) {
1362
+ var cd0 = gd . calcdata [ 0 ] ;
1363
+ var subplot = gd . _fullLayout . geo . _subplot ;
1364
+
1365
+ expect ( cd0 [ 0 ] . geojson ) . negateIf ( geojson [ 0 ] ) . toBe ( null ) ;
1366
+ expect ( cd0 [ 1 ] . geojson ) . negateIf ( geojson [ 1 ] ) . toBe ( null ) ;
1367
+
1368
+ expect ( Object . keys ( subplot . layers ) . length ) . toEqual ( layers . length , '# of layers' ) ;
1369
+
1370
+ d3 . select ( gd ) . selectAll ( '.geo > .layer' ) . each ( function ( d , i ) {
1371
+ expect ( d ) . toBe ( layers [ i ] , 'layer ' + d + ' at position ' + i ) ;
1372
+ } ) ;
1373
+ }
1374
+
1375
+ Plotly . plot ( gd , [ {
1376
+ type : 'choropleth' ,
1377
+ locations : [ 'CAN' , 'FRA' ] ,
1378
+ z : [ 10 , 20 ]
1379
+ } ] , {
1380
+ geo : { showframe : true }
1381
+ } )
1382
+ . then ( function ( ) {
1383
+ _assert (
1384
+ [ true , true ] ,
1385
+ [ 'bg' , 'coastlines' , 'frame' , 'backplot' , 'frontplot' ]
1386
+ ) ;
1387
+ return Plotly . relayout ( gd , 'geo.scope' , 'europe' ) ;
1388
+ } )
1389
+ . then ( function ( ) {
1390
+ _assert (
1391
+ // 'CAN' is not drawn on 'europe' scope
1392
+ [ false , true ] ,
1393
+ // 'frame' is not drawn on scoped maps
1394
+ // 'countries' are there by default on scoped maps
1395
+ [ 'bg' , 'countries' , 'backplot' , 'frontplot' ]
1396
+ ) ;
1397
+ return Plotly . relayout ( gd , 'geo.scope' , 'africa' ) ;
1398
+ } )
1399
+ . then ( function ( ) {
1400
+ _assert (
1401
+ [ false , false ] ,
1402
+ [ 'bg' , 'countries' , 'backplot' , 'frontplot' ]
1403
+ ) ;
1404
+ return Plotly . relayout ( gd , 'geo.scope' , 'world' ) ;
1405
+ } )
1406
+ . then ( function ( ) {
1407
+ _assert (
1408
+ [ true , true ] ,
1409
+ [ 'bg' , 'coastlines' , 'frame' , 'backplot' , 'frontplot' ]
1410
+ ) ;
1411
+ } )
1412
+ . catch ( fail )
1413
+ . then ( done ) ;
1414
+ } ) ;
1415
+ } ) ;
1416
+
1355
1417
describe ( 'Test geo zoom/pan/drag interactions:' , function ( ) {
1356
1418
var gd ;
1357
1419
var eventData ;
0 commit comments