@@ -1459,11 +1459,13 @@ describe('Test event property of interactions on a geo plot:', function() {
1459
1459
} ) ;
1460
1460
1461
1461
describe ( 'Test geo base layers' , function ( ) {
1462
+ var gd ;
1463
+
1464
+ beforeEach ( function ( ) { gd = createGraphDiv ( ) ; } ) ;
1465
+
1462
1466
afterEach ( destroyGraphDiv ) ;
1463
1467
1464
1468
it ( 'should clear obsolete features and layers on *geo.scope* relayout calls' , function ( done ) {
1465
- var gd = createGraphDiv ( ) ;
1466
-
1467
1469
function _assert ( geojson , layers ) {
1468
1470
var cd0 = gd . calcdata [ 0 ] ;
1469
1471
var subplot = gd . _fullLayout . geo . _subplot ;
@@ -1518,6 +1520,63 @@ describe('Test geo base layers', function() {
1518
1520
. catch ( failTest )
1519
1521
. then ( done ) ;
1520
1522
} ) ;
1523
+
1524
+ it ( 'should be able to relayout axis grid *tick0* / *dtick*' , function ( done ) {
1525
+ function findGridPath ( axisName ) {
1526
+ return d3 . select ( gd ) . select ( axisName + ' > path' ) . attr ( 'd' ) ;
1527
+ }
1528
+
1529
+ function first ( parts ) {
1530
+ return parts [ 1 ] . split ( 'L' ) [ 0 ] . split ( ',' ) . map ( Number ) ;
1531
+ }
1532
+
1533
+ function _assert ( msg , exp ) {
1534
+ var lonParts = findGridPath ( '.lonaxis' ) . split ( 'M' ) ;
1535
+ var latParts = findGridPath ( '.lataxis' ) . split ( 'M' ) ;
1536
+
1537
+ expect ( lonParts . length ) . toBe ( exp . lonCnt , msg + ' - lonaxis grid segments' ) ;
1538
+ expect ( latParts . length ) . toBe ( exp . latCnt , msg + ' - lataxis grid segments' ) ;
1539
+
1540
+ expect ( first ( lonParts ) ) . toBeCloseToArray ( exp . lon0 , 1 , msg + ' - first lonaxis grid pt' ) ;
1541
+ expect ( first ( latParts ) ) . toBeCloseToArray ( exp . lat0 , 1 , msg + ' - first lataxis grid pt' ) ;
1542
+ }
1543
+
1544
+ Plotly . plot ( gd , [ { type : 'scattergeo' } ] , {
1545
+ geo : {
1546
+ lonaxis : { showgrid : true } ,
1547
+ lataxis : { showgrid : true }
1548
+ }
1549
+ } )
1550
+ . then ( function ( ) {
1551
+ _assert ( 'base' , {
1552
+ lonCnt : 12 , lon0 : [ 124.99 , 369.99 ] ,
1553
+ latCnt : 18 , lat0 : [ 80 , 355 ]
1554
+ } ) ;
1555
+ } )
1556
+ . then ( function ( ) { return Plotly . relayout ( gd , 'geo.lonaxis.tick0' , 25 ) ; } )
1557
+ . then ( function ( ) {
1558
+ _assert ( 'w/ lonaxis.tick0:25' , {
1559
+ lonCnt : 12 , lon0 : [ 117.49 , 369.99 ] ,
1560
+ latCnt : 18 , lat0 : [ 80 , 355 ]
1561
+ } ) ;
1562
+ } )
1563
+ . then ( function ( ) { return Plotly . relayout ( gd , 'geo.lataxis.tick0' , 41 ) ; } )
1564
+ . then ( function ( ) {
1565
+ _assert ( 'w/ lataxis.tick0:41' , {
1566
+ lonCnt : 12 , lon0 : [ 117.49 , 369.99 ] ,
1567
+ latCnt : 19 , lat0 : [ 80 , 368.5 ]
1568
+ } ) ;
1569
+ } )
1570
+ . then ( function ( ) { return Plotly . relayout ( gd , 'geo.lataxis.dtick' , 45 ) ; } )
1571
+ . then ( function ( ) {
1572
+ _assert ( 'w/ lataxis.dtick0:45' , {
1573
+ lonCnt : 12 , lon0 : [ 117.49 , 369.99 ] ,
1574
+ latCnt : 5 , lat0 : [ 80 , 308.5 ]
1575
+ } ) ;
1576
+ } )
1577
+ . catch ( failTest )
1578
+ . then ( done ) ;
1579
+ } ) ;
1521
1580
} ) ;
1522
1581
1523
1582
describe ( 'Test geo zoom/pan/drag interactions:' , function ( ) {
0 commit comments