@@ -1366,6 +1366,59 @@ describe('Plotly.react and uirevision attributes', function() {
13661366 . then ( done , done . fail ) ;
13671367 } ) ;
13681368
1369+ function setCartesianRanges ( xRange , yRange ) {
1370+ return function ( ) {
1371+ return Registry . call ( '_guiRelayout' , gd , {
1372+ 'xaxis.range' : xRange ,
1373+ 'yaxis.range' : yRange
1374+ } ) ;
1375+ } ;
1376+ }
1377+
1378+ function checkCartesianRanges ( xRange , yRange , msg ) {
1379+ return checkState ( [ ] , {
1380+ 'xaxis.range' : [ xRange ] ,
1381+ 'yaxis.range' : [ yRange ]
1382+ } , msg ) ;
1383+ }
1384+
1385+ it ( 'treats explicit and implicit cartesian autorange the same' , function ( done ) {
1386+ function fig ( explicit , uirevision ) {
1387+ return {
1388+ data : [ { z : [ [ 1 , 2 ] , [ 3 , 4 ] ] , type : 'heatmap' , x : [ 0 , 1 , 2 ] , y : [ 3 , 4 , 5 ] } ] ,
1389+ layout : {
1390+ xaxis : explicit ? { autorange : true , range : [ 0 , 2 ] } : { } ,
1391+ yaxis : explicit ? { autorange : true , range : [ 3 , 5 ] } : { } ,
1392+ uirevision : uirevision
1393+ }
1394+ } ;
1395+ }
1396+
1397+ // First go from implicit to explicit and back after zooming in
1398+ Plotly . newPlot ( gd , fig ( false , 'a' ) )
1399+ . then ( checkCartesianRanges ( [ 0 , 2 ] , [ 3 , 5 ] , 'initial implicit' ) )
1400+ . then ( setCartesianRanges ( [ 2 , 4 ] , [ 5 , 7 ] ) )
1401+ . then ( checkCartesianRanges ( [ 2 , 4 ] , [ 5 , 7 ] , 'zoomed from implicit' ) )
1402+ . then ( _react ( fig ( true , 'a' ) ) )
1403+ . then ( checkCartesianRanges ( [ 2 , 4 ] , [ 5 , 7 ] , 'react to explicit' ) )
1404+ . then ( _react ( fig ( true , 'a' ) ) )
1405+ . then ( checkCartesianRanges ( [ 2 , 4 ] , [ 5 , 7 ] , 'react to STAY explicit' ) )
1406+ . then ( _react ( fig ( false , 'a' ) ) )
1407+ . then ( checkCartesianRanges ( [ 2 , 4 ] , [ 5 , 7 ] , 'back to implicit' ) )
1408+ // then go from explicit to implicit and back after zooming in
1409+ . then ( _react ( fig ( true , 'b' ) ) )
1410+ . then ( checkCartesianRanges ( [ 0 , 2 ] , [ 3 , 5 ] , 'new uirevision explicit' ) )
1411+ . then ( setCartesianRanges ( [ 4 , 6 ] , [ 7 , 9 ] ) )
1412+ . then ( checkCartesianRanges ( [ 4 , 6 ] , [ 7 , 9 ] , 'zoomed from explicit' ) )
1413+ . then ( _react ( fig ( false , 'b' ) ) )
1414+ . then ( checkCartesianRanges ( [ 4 , 6 ] , [ 7 , 9 ] , 'react to implicit' ) )
1415+ . then ( _react ( fig ( false , 'b' ) ) )
1416+ . then ( checkCartesianRanges ( [ 4 , 6 ] , [ 7 , 9 ] , 'react to STAY implicit' ) )
1417+ . then ( _react ( fig ( true , 'b' ) ) )
1418+ . then ( checkCartesianRanges ( [ 4 , 6 ] , [ 7 , 9 ] , 'back to explicit' ) )
1419+ . then ( done , done . fail ) ;
1420+ } ) ;
1421+
13691422 it ( 'respects reverting an explicit cartesian axis range to auto' , function ( done ) {
13701423 function fig ( xRange , yRange ) {
13711424 return {
@@ -1378,28 +1431,12 @@ describe('Plotly.react and uirevision attributes', function() {
13781431 } ;
13791432 }
13801433
1381- function setRanges ( xRange , yRange ) {
1382- return function ( ) {
1383- return Registry . call ( '_guiRelayout' , gd , {
1384- 'xaxis.range' : xRange ,
1385- 'yaxis.range' : yRange
1386- } ) ;
1387- } ;
1388- }
1389-
1390- function checkRanges ( xRange , yRange ) {
1391- return checkState ( [ ] , {
1392- 'xaxis.range' : [ xRange ] ,
1393- 'yaxis.range' : [ yRange ]
1394- } ) ;
1395- }
1396-
13971434 Plotly . newPlot ( gd , fig ( [ 1 , 3 ] , [ 4 , 6 ] ) )
1398- . then ( checkRanges ( [ 1 , 3 ] , [ 4 , 6 ] ) )
1399- . then ( setRanges ( [ 2 , 4 ] , [ 5 , 7 ] ) )
1400- . then ( checkRanges ( [ 2 , 4 ] , [ 5 , 7 ] ) )
1435+ . then ( checkCartesianRanges ( [ 1 , 3 ] , [ 4 , 6 ] , 'initial explicit ranges' ) )
1436+ . then ( setCartesianRanges ( [ 2 , 4 ] , [ 5 , 7 ] ) )
1437+ . then ( checkCartesianRanges ( [ 2 , 4 ] , [ 5 , 7 ] , 'zoomed to different explicit' ) )
14011438 . then ( _react ( fig ( undefined , undefined ) ) )
1402- . then ( checkRanges ( [ 0 , 2 ] , [ 3 , 5 ] ) )
1439+ . then ( checkCartesianRanges ( [ 0 , 2 ] , [ 3 , 5 ] , 'react to autorange' ) )
14031440 . then ( done , done . fail ) ;
14041441 } ) ;
14051442
0 commit comments