@@ -840,19 +840,41 @@ describe('animating scatter traces', function() {
840
840
} ) ;
841
841
842
842
it ( 'should animate axis ranges using the less number of steps' , function ( done ) {
843
+ // sanity-check that scatter points and bars are still there
844
+ function _assertNodeCnt ( ) {
845
+ var gd3 = d3 . select ( gd ) ;
846
+ expect ( gd3 . select ( '.scatterlayer' ) . selectAll ( '.point' ) . size ( ) )
847
+ . toBe ( 3 , '# of pts on graph' ) ;
848
+ expect ( gd3 . select ( '.barlayer' ) . selectAll ( '.point' ) . size ( ) )
849
+ . toBe ( 3 , '# of bars on graph' ) ;
850
+ }
851
+
852
+ // assert what Cartesian.transitionAxes does
853
+ function getSubplotTranslate ( ) {
854
+ var sp = d3 . select ( gd ) . select ( '.subplot.xy > .plot' ) ;
855
+ return sp . attr ( 'transform' )
856
+ . split ( 'translate(' ) [ 1 ] . split ( ')' ) [ 0 ]
857
+ . split ( ',' )
858
+ . map ( Number ) ;
859
+ }
860
+
843
861
Plotly . plot ( gd , [ {
844
862
y : [ 1 , 2 , 1 ]
845
863
} , {
846
864
type : 'bar' ,
847
865
y : [ 2 , 1 , 2 ]
848
866
} ] )
849
867
. then ( function ( ) {
868
+ var t = getSubplotTranslate ( ) ;
869
+ expect ( t [ 0 ] ) . toBe ( 80 , 'subplot translate[0]' ) ;
870
+ expect ( t [ 1 ] ) . toBe ( 100 , 'subplot translate[1]' ) ;
871
+
850
872
spyOn ( gd . _fullData [ 0 ] . _module . basePlotModule , 'transitionAxes' ) . and . callThrough ( ) ;
851
873
spyOn ( gd . _fullData [ 0 ] . _module , 'plot' ) . and . callThrough ( ) ;
852
874
spyOn ( gd . _fullData [ 1 ] . _module , 'plot' ) . and . callThrough ( ) ;
853
875
spyOn ( Registry , 'call' ) . and . callThrough ( ) ;
854
876
855
- return Plotly . animate ( 'graph' , {
877
+ var promise = Plotly . animate ( 'graph' , {
856
878
layout : {
857
879
xaxis : { range : [ 0.45 , 0.55 ] } ,
858
880
yaxis : { range : [ 0.45 , 0.55 ] }
@@ -861,12 +883,21 @@ describe('animating scatter traces', function() {
861
883
transition : { duration : 500 } ,
862
884
frame : { redraw : false }
863
885
} ) ;
886
+
887
+ setTimeout ( function ( ) {
888
+ _assertNodeCnt ( ) ;
889
+ var t = getSubplotTranslate ( ) ;
890
+ expect ( t [ 0 ] ) . toBeLessThan ( 80 , 'subplot translate[0]' ) ;
891
+ expect ( t [ 1 ] ) . toBeLessThan ( 100 , 'subplot translate[1]' ) ;
892
+ } , 100 ) ;
893
+
894
+ return promise ;
864
895
} )
865
896
. then ( function ( ) {
866
- // sanity-check that scatter points and bars are still there
867
- var gd3 = d3 . select ( gd ) ;
868
- expect ( gd3 . select ( '.scatterlayer' ) . selectAll ( '.point' ) . size ( ) ) . toBe ( 3 , '# of pts on graph ' ) ;
869
- expect ( gd3 . select ( '.barlayer' ) . selectAll ( '.point' ) . size ( ) ) . toBe ( 3 , '# of bars on graph ' ) ;
897
+ _assertNodeCnt ( ) ;
898
+ var t = getSubplotTranslate ( ) ;
899
+ expect ( t [ 0 ] ) . toBe ( 80 , 'subplot translate[0] ' ) ;
900
+ expect ( t [ 1 ] ) . toBe ( 100 , 'subplot translate[1] ' ) ;
870
901
871
902
// the only redraw should occur during Cartesian.transitionAxes,
872
903
// where Registry.call('relayout') is called leading to a _module.plot call
0 commit comments