@@ -624,7 +624,7 @@ describe('Test Geo layout defaults', function() {
624624 } ) ;
625625 } ) ;
626626
627- describe ( 'geo.visible should override show* defaults' , function ( ) {
627+ describe ( 'geo.visible should override show* defaults even with template any show* is true ' , function ( ) {
628628 var keys = [
629629 'lonaxis.showgrid' ,
630630 'lataxis.showgrid' ,
@@ -650,39 +650,93 @@ describe('Test Geo layout defaults', function() {
650650 } ) ;
651651 }
652652
653- it ( '- base case' , function ( ) {
654- layoutIn = {
655- geo : { visible : false }
656- } ;
653+ [ true , false , undefined ] . forEach ( function ( q ) {
654+ it ( '- base case | ' + q , function ( ) {
655+ layoutIn = {
656+ template : {
657+ layout : {
658+ geo : {
659+ showcoastlines : q ,
660+ showcountries : q ,
661+ showframe : q ,
662+ showland : q ,
663+ showlakes : q ,
664+ showocean : q ,
665+ showrivers : q ,
666+ showsubunits : q ,
667+ lonaxis : { showgrid : q } ,
668+ lataxis : { showgrid : q }
669+ }
670+ }
671+ } ,
672+ geo : { visible : false }
673+ } ;
657674
658- supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
659- _assert ( {
660- showsubunits : undefined
675+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
676+ _assert ( {
677+ showsubunits : undefined
678+ } ) ;
661679 } ) ;
662680 } ) ;
663681
664- it ( '- scoped case' , function ( ) {
665- layoutIn = {
666- geo : { scope : 'europe' , visible : false }
667- } ;
682+ [ true , false , undefined ] . forEach ( function ( q ) {
683+ it ( '- scoped case' , function ( ) {
684+ layoutIn = {
685+ template : {
686+ layout : {
687+ geo : {
688+ showcoastlines : q ,
689+ showcountries : q ,
690+ showframe : q ,
691+ showland : q ,
692+ showlakes : q ,
693+ showocean : q ,
694+ showrivers : q ,
695+ showsubunits : q ,
696+ lonaxis : { showgrid : q } ,
697+ lataxis : { showgrid : q }
698+ }
699+ }
700+ } ,
701+ geo : { scope : 'europe' , visible : false }
702+ } ;
668703
669- supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
670- _assert ( {
671- showframe : undefined ,
672- showsubunits : undefined
704+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
705+ _assert ( {
706+ showframe : undefined ,
707+ showsubunits : undefined
708+ } ) ;
673709 } ) ;
674710 } ) ;
675711
676- it ( '- scope:usa case' , function ( ) {
677- layoutIn = {
678- geo : { scope : 'usa' , visible : false }
679- } ;
712+ [ true , false , undefined ] . forEach ( function ( q ) {
713+ it ( '- scope:usa case' , function ( ) {
714+ layoutIn = {
715+ template : {
716+ layout : {
717+ geo : {
718+ showcoastlines : q ,
719+ showcountries : q ,
720+ showframe : q ,
721+ showland : q ,
722+ showlakes : q ,
723+ showocean : q ,
724+ showrivers : q ,
725+ showsubunits : q ,
726+ lonaxis : { showgrid : q } ,
727+ lataxis : { showgrid : q }
728+ }
729+ }
730+ } ,
731+ geo : { scope : 'usa' , visible : false }
732+ } ;
680733
681- supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
682- _assert ( {
683- showframe : undefined ,
684- showcoastlines : undefined ,
685- showocean : undefined
734+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
735+ _assert ( {
736+ showframe : undefined ,
737+ showcoastlines : undefined ,
738+ showocean : undefined
739+ } ) ;
686740 } ) ;
687741 } ) ;
688742 } ) ;
@@ -1566,6 +1620,94 @@ describe('Test geo interactions', function() {
15661620 . then ( done ) ;
15671621 } ) ;
15681622
1623+ it ( [
1624+ 'geo.visible should honor template.layout.geo.show* defaults' ,
1625+ 'when template.layout.geo.visible is set to false,' ,
1626+ 'and does NOT set layout.geo.visible template'
1627+ ] . join ( ' ' ) , function ( done ) {
1628+ var gd = createGraphDiv ( ) ;
1629+
1630+ Plotly . react ( gd , [ {
1631+ type : 'scattergeo' ,
1632+ lat : [ 0 ] ,
1633+ lon : [ 0 ] ,
1634+ marker : { size : 100 }
1635+ } ] , {
1636+ template : {
1637+ layout : {
1638+ geo : {
1639+ visible : false ,
1640+ showcoastlines : true ,
1641+ showcountries : true ,
1642+ showframe : true ,
1643+ showland : true ,
1644+ showlakes : true ,
1645+ showocean : true ,
1646+ showrivers : true ,
1647+ showsubunits : true ,
1648+ lonaxis : { showgrid : true } ,
1649+ lataxis : { showgrid : true }
1650+ }
1651+ }
1652+ } ,
1653+ geo : { }
1654+ } )
1655+ . then ( function ( ) {
1656+ expect ( gd . _fullLayout . geo . showcoastlines ) . toBe ( true ) ;
1657+ expect ( gd . _fullLayout . geo . showcountries ) . toBe ( true ) ;
1658+ expect ( gd . _fullLayout . geo . showframe ) . toBe ( true ) ;
1659+ expect ( gd . _fullLayout . geo . showland ) . toBe ( true ) ;
1660+ expect ( gd . _fullLayout . geo . showlakes ) . toBe ( true ) ;
1661+ expect ( gd . _fullLayout . geo . showocean ) . toBe ( true ) ;
1662+ expect ( gd . _fullLayout . geo . showrivers ) . toBe ( true ) ;
1663+ expect ( gd . _fullLayout . geo . showsubunits ) . toBe ( undefined ) ;
1664+ expect ( gd . _fullLayout . geo . lonaxis . showgrid ) . toBe ( true ) ;
1665+ expect ( gd . _fullLayout . geo . lataxis . showgrid ) . toBe ( true ) ;
1666+ } )
1667+ . then ( function ( ) {
1668+ return Plotly . react ( gd , [ {
1669+ type : 'scattergeo' ,
1670+ lat : [ 0 ] ,
1671+ lon : [ 0 ] ,
1672+ marker : { size : 100 }
1673+ } ] , {
1674+ template : {
1675+ layout : {
1676+ geo : {
1677+ showcoastlines : true ,
1678+ showcountries : true ,
1679+ showframe : true ,
1680+ showland : true ,
1681+ showlakes : true ,
1682+ showocean : true ,
1683+ showrivers : true ,
1684+ showsubunits : true ,
1685+ lonaxis : { showgrid : true } ,
1686+ lataxis : { showgrid : true }
1687+ }
1688+ }
1689+ } ,
1690+ geo : {
1691+ visible : false
1692+ }
1693+ } ) ;
1694+ } )
1695+ . then ( function ( ) {
1696+ expect ( gd . _fullLayout . geo . showcoastlines ) . toBe ( false ) ;
1697+ expect ( gd . _fullLayout . geo . showcountries ) . toBe ( false ) ;
1698+ expect ( gd . _fullLayout . geo . showframe ) . toBe ( false ) ;
1699+ expect ( gd . _fullLayout . geo . showland ) . toBe ( false ) ;
1700+ expect ( gd . _fullLayout . geo . showlakes ) . toBe ( false ) ;
1701+ expect ( gd . _fullLayout . geo . showocean ) . toBe ( false ) ;
1702+ expect ( gd . _fullLayout . geo . showrivers ) . toBe ( false ) ;
1703+ expect ( gd . _fullLayout . geo . showsubunits ) . toBe ( undefined ) ;
1704+ expect ( gd . _fullLayout . geo . lonaxis . showgrid ) . toBe ( false ) ;
1705+ expect ( gd . _fullLayout . geo . lataxis . showgrid ) . toBe ( false ) ;
1706+ } )
1707+ . catch ( failTest )
1708+ . then ( done ) ;
1709+ } ) ;
1710+
15691711 describe ( 'should not make request for topojson when not needed' , function ( ) {
15701712 var gd ;
15711713
0 commit comments