@@ -2029,6 +2029,70 @@ describe('axis zoom/pan and main plot zoom', function() {
2029
2029
. catch ( failTest )
2030
2030
. then ( done ) ;
2031
2031
} ) ;
2032
+
2033
+ describe ( 'with axis breaks' , function ( ) {
2034
+ it ( 'should compute correct range updates - x-axis case' , function ( done ) {
2035
+ function _assert ( msg , xrng ) {
2036
+ expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( xrng , 2 , 'xrng - ' + msg ) ;
2037
+ }
2038
+
2039
+ Plotly . plot ( gd , [ {
2040
+ mode : 'lines' ,
2041
+ x : [ 0 , 10 , 50 , 90 , 100 , 150 , 190 , 200 ]
2042
+ } ] , {
2043
+ xaxis : {
2044
+ breaks : [
2045
+ { bounds : [ 11 , 89 ] } ,
2046
+ { bounds : [ 101 , 189 ] }
2047
+ ]
2048
+ } ,
2049
+ dragmode : 'zoom'
2050
+ } )
2051
+ . then ( function ( ) { _assert ( 'base' , [ 0 , 200 ] ) ; } )
2052
+ . then ( doDrag ( 'xy' , 'nsew' , 50 , 0 ) )
2053
+ // x range would be ~ [100, 118] w/o breaks
2054
+ . then ( function ( ) { _assert ( 'after x-only zoombox' , [ 95 , 98.148 ] ) ; } )
2055
+ . then ( doDblClick ( 'xy' , 'nsew' ) )
2056
+ . then ( function ( ) { _assert ( 'back to base' , [ 0 , 200 ] ) ; } )
2057
+ . then ( function ( ) { return Plotly . relayout ( gd , 'dragmode' , 'pan' ) ; } )
2058
+ . then ( doDrag ( 'xy' , 'nsew' , 50 , 0 ) )
2059
+ // x range would be ~ [-18, 181] w/o breaks
2060
+ . then ( function ( ) { _assert ( 'after x-only pan' , [ - 3.148 , 196.851 ] ) ; } )
2061
+ . catch ( failTest )
2062
+ . then ( done ) ;
2063
+ } ) ;
2064
+
2065
+ it ( 'should compute correct range updates - y-axis case' , function ( done ) {
2066
+ function _assert ( msg , yrng ) {
2067
+ expect ( gd . layout . yaxis . range ) . toBeCloseToArray ( yrng , 2 , 'yrng - ' + msg ) ;
2068
+ }
2069
+
2070
+ Plotly . plot ( gd , [ {
2071
+ mode : 'lines' ,
2072
+ y : [ 0 , 10 , 50 , 90 , 100 , 150 , 190 , 200 ]
2073
+ } ] , {
2074
+ yaxis : {
2075
+ breaks : [
2076
+ { bounds : [ 11 , 89 ] } ,
2077
+ { bounds : [ 101 , 189 ] }
2078
+ ]
2079
+ } ,
2080
+ dragmode : 'zoom'
2081
+ } )
2082
+ . then ( function ( ) { _assert ( 'base' , [ - 1.888 , 201.888 ] ) ; } )
2083
+ . then ( doDrag ( 'xy' , 'nsew' , 0 , 50 ) )
2084
+ // y range would be ~ [62, 100] w/o breaks
2085
+ . then ( function ( ) { _assert ( 'after y-only zoombox' , [ 10.004 , 95.00 ] ) ; } )
2086
+ . then ( doDblClick ( 'xy' , 'nsew' ) )
2087
+ . then ( function ( ) { _assert ( 'back to base' , [ - 1.888 , 201.888 ] ) ; } )
2088
+ . then ( function ( ) { return Plotly . relayout ( gd , 'dragmode' , 'pan' ) ; } )
2089
+ . then ( doDrag ( 'xy' , 'nsew' , 0 , 50 ) )
2090
+ // y range would be ~ [35, 239] w/o breaks
2091
+ . then ( function ( ) { _assert ( 'after y-only pan' , [ 5.106 , 208.884 ] ) ; } )
2092
+ . catch ( failTest )
2093
+ . then ( done ) ;
2094
+ } ) ;
2095
+ } ) ;
2032
2096
} ) ;
2033
2097
2034
2098
describe ( 'Event data:' , function ( ) {
0 commit comments