@@ -911,6 +911,67 @@ describe('rangesliders in general', function() {
911911 . catch ( failTest )
912912 . then ( done ) ;
913913 } ) ;
914+
915+ it ( 'should be able to turn on rangeslider x/y autorange if initially specified' , function ( done ) {
916+ Plotly . plot ( gd , [ {
917+ // use a heatmap because it doesn't add any padding
918+ x0 : 0 , dx : 1 ,
919+ y0 : 1 , dy : 1 ,
920+ z : [ [ 1 , 2 , 3 ] , [ 2 , 3 , 4 ] , [ 3 , 4 , 5 ] ] ,
921+ type : 'heatmap'
922+ } ] , {
923+ xaxis : {
924+ range : [ 0.1 , 1.9 ] ,
925+ rangeslider : { range : [ 0 , 2 ] , yaxis : { range : [ 1 , 3 ] } }
926+ } ,
927+ yaxis : { range : [ 1.1 , 2.9 ] }
928+ } )
929+ . then ( function ( ) {
930+ expect ( gd . _fullLayout . xaxis . rangeslider . range ) . toBeCloseToArray ( [ 0 , 2 ] , 3 ) ;
931+ expect ( gd . _fullLayout . xaxis . rangeslider . yaxis . range ) . toBeCloseToArray ( [ 1 , 3 ] , 3 ) ;
932+
933+ return Plotly . relayout ( gd , { 'xaxis.rangeslider.yaxis.rangemode' : 'auto' } ) ;
934+ } )
935+ . then ( function ( ) {
936+ expect ( gd . _fullLayout . xaxis . rangeslider . range ) . toBeCloseToArray ( [ 0 , 2 ] , 3 ) ;
937+ expect ( gd . _fullLayout . xaxis . rangeslider . yaxis . range ) . toBeCloseToArray ( [ 0.5 , 3.5 ] , 3 ) ;
938+
939+ return Plotly . relayout ( gd , { 'xaxis.rangeslider.autorange' : true } ) ;
940+ } )
941+ . then ( function ( ) {
942+ expect ( gd . _fullLayout . xaxis . rangeslider . range ) . toBeCloseToArray ( [ - 0.5 , 2.5 ] , 3 ) ;
943+ expect ( gd . _fullLayout . xaxis . rangeslider . yaxis . range ) . toBeCloseToArray ( [ 0.5 , 3.5 ] , 3 ) ;
944+ } )
945+ . catch ( failTest )
946+ . then ( done ) ;
947+ } ) ;
948+
949+ it ( 'should be able to turn on rangeslider x/y autorange implicitly by deleting x range' , function ( done ) {
950+ // this does not apply to y ranges, because the default there is 'match'
951+ Plotly . plot ( gd , [ {
952+ // use a heatmap because it doesn't add any padding
953+ x0 : 0 , dx : 1 ,
954+ y0 : 1 , dy : 1 ,
955+ z : [ [ 1 , 2 , 3 ] , [ 2 , 3 , 4 ] , [ 3 , 4 , 5 ] ] ,
956+ type : 'heatmap'
957+ } ] , {
958+ xaxis : {
959+ range : [ 0.1 , 1.9 ] ,
960+ rangeslider : { range : [ 0 , 2 ] , yaxis : { range : [ 1 , 3 ] } }
961+ } ,
962+ yaxis : { range : [ 1.1 , 2.9 ] }
963+ } )
964+ . then ( function ( ) {
965+ expect ( gd . _fullLayout . xaxis . rangeslider . range ) . toBeCloseToArray ( [ 0 , 2 ] , 3 ) ;
966+
967+ return Plotly . relayout ( gd , { 'xaxis.rangeslider.range' : null } ) ;
968+ } )
969+ . then ( function ( ) {
970+ expect ( gd . _fullLayout . xaxis . rangeslider . range ) . toBeCloseToArray ( [ - 0.5 , 2.5 ] , 3 ) ;
971+ } )
972+ . catch ( failTest )
973+ . then ( done ) ;
974+ } ) ;
914975} ) ;
915976
916977function slide ( fromX , fromY , toX , toY ) {
0 commit comments