@@ -643,7 +643,7 @@ describe('Plotly.react transitions:', function() {
643
643
. then ( done ) ;
644
644
} ) ;
645
645
646
- it ( 'should transition layout when one or more axes has *autorange:true* ' , function ( done ) {
646
+ it ( 'should transition layout when one or more axis auto-ranged value changed ' , function ( done ) {
647
647
var data = [ { y : [ 1 , 2 , 1 ] } ] ;
648
648
var layout = { transition : { duration : 10 } } ;
649
649
@@ -662,6 +662,7 @@ describe('Plotly.react transitions:', function() {
662
662
assertAxAutorange ( 'axes are autorange:true by default' , true ) ;
663
663
} )
664
664
. then ( function ( ) {
665
+ // N.B. marker.size can expand axis range
665
666
data [ 0 ] . marker = { size : 30 } ;
666
667
return Plotly . react ( gd , data , layout ) ;
667
668
} )
@@ -698,6 +699,76 @@ describe('Plotly.react transitions:', function() {
698
699
. then ( done ) ;
699
700
} ) ;
700
701
702
+ it ( 'should not transition layout when axis auto-ranged value do not changed' , function ( done ) {
703
+ var data = [ { y : [ 1 , 2 , 1 ] } ] ;
704
+ var layout = { transition : { duration : 10 } } ;
705
+
706
+ function assertAxAutorange ( msg , exp ) {
707
+ expect ( gd . layout . xaxis . autorange ) . toBe ( exp , msg ) ;
708
+ expect ( gd . layout . yaxis . autorange ) . toBe ( exp , msg ) ;
709
+ expect ( gd . _fullLayout . xaxis . autorange ) . toBe ( exp , msg ) ;
710
+ expect ( gd . _fullLayout . yaxis . autorange ) . toBe ( exp , msg ) ;
711
+ }
712
+
713
+ Plotly . react ( gd , data , layout )
714
+ . then ( function ( ) {
715
+ methods . push ( [ gd . _fullLayout . _basePlotModules [ 0 ] , 'plot' ] ) ;
716
+ methods . push ( [ gd . _fullLayout . _basePlotModules [ 0 ] , 'transitionAxes2' ] ) ;
717
+ addSpies ( ) ;
718
+ assertAxAutorange ( 'axes are autorange:true by default' , true ) ;
719
+ } )
720
+ . then ( function ( ) {
721
+ // N.B. different coordinate, but same auto-range value
722
+ data [ 0 ] . y = [ 2 , 1 , 2 ] ;
723
+ return Plotly . react ( gd , data , layout ) ;
724
+ } )
725
+ . then ( function ( ) {
726
+ assertSpies ( 'do not transition autoranged axes, just the traces' , [
727
+ [ Plots , 'transition2' , 1 ] ,
728
+ [ gd . _fullLayout . _basePlotModules [ 0 ] , 'transitionAxes2' , 0 ] ,
729
+ [ gd . _fullLayout . _basePlotModules [ 0 ] , 'plot' , 1 ]
730
+ ] ) ;
731
+ assertAxAutorange ( 'axes are still autorange:true' , true ) ;
732
+ } )
733
+ . then ( function ( ) {
734
+ // N.B. different coordinates with different auto-range value
735
+ data [ 0 ] . y = [ 20 , 10 , 20 ] ;
736
+ return Plotly . react ( gd , data , layout ) ;
737
+ } )
738
+ . then ( function ( ) {
739
+ assertSpies ( 'both trace and layout transitions' , [
740
+ [ Plots , 'transition2' , 1 ] ,
741
+ [ gd . _fullLayout . _basePlotModules [ 0 ] , 'transitionAxes2' , 1 ] ,
742
+ [ Registry , 'call' , [
743
+ // xaxis call to _storeDirectGUIEdit from doAutoRange
744
+ [ '_storeDirectGUIEdit' , gd . layout , gd . _fullLayout . _preGUI , {
745
+ 'xaxis.range' : [ - 0.12852664576802508 , 2.128526645768025 ] ,
746
+ 'xaxis.autorange' : true
747
+ } ] ,
748
+ // yaxis call to _storeDirectGUIEdit from doAutoRange
749
+ [ '_storeDirectGUIEdit' , gd . layout , gd . _fullLayout . _preGUI , {
750
+ 'yaxis.range' : [ 9.26751592356688 , 20.73248407643312 ] ,
751
+ 'yaxis.autorange' : true
752
+ } ] ,
753
+ [ 'relayout' , gd , {
754
+ 'xaxis.range' : [ - 0.12852664576802508 , 2.128526645768025 ] ,
755
+ 'yaxis.range' : [ 9.26751592356688 , 20.73248407643312 ]
756
+ } ] ]
757
+ ] ,
758
+ [ gd . _fullLayout . _basePlotModules [ 0 ] , 'plot' , [
759
+ // one instantaneous transition options to halt
760
+ // other trace transitions (if any)
761
+ [ gd , null , { duration : 0 , easing : 'cubic-in-out' } , 'function' ] ,
762
+ // one _module.plot call from the relayout at end of axis transition
763
+ [ gd ]
764
+ ] ] ,
765
+ ] ) ;
766
+ assertAxAutorange ( 'axes are now autorange:false' , false ) ;
767
+ } )
768
+ . catch ( failTest )
769
+ . then ( done ) ;
770
+ } ) ;
771
+
701
772
it ( 'should emit transition events' , function ( done ) {
702
773
var events = [ 'transitioning' , 'transitioned' , 'react' ] ;
703
774
var store = { } ;
0 commit comments