@@ -879,45 +879,77 @@ describe('end-to-end scatter tests', function() {
879
879
. then ( done ) ;
880
880
} ) ;
881
881
882
- it ( 'should update axis range accordingly on marker.size edits' , function ( done ) {
883
- function _assert ( msg , xrng , yrng ) {
884
- var fullLayout = gd . _fullLayout ;
885
- expect ( fullLayout . xaxis . range ) . toBeCloseToArray ( xrng , 2 , msg + ' xrng' ) ;
886
- expect ( fullLayout . yaxis . range ) . toBeCloseToArray ( yrng , 2 , msg + ' yrng' ) ;
887
- }
882
+ function assertAxisRanges ( msg , xrng , yrng ) {
883
+ var fullLayout = gd . _fullLayout ;
884
+ expect ( fullLayout . xaxis . range ) . toBeCloseToArray ( xrng , 2 , msg + ' xrng' ) ;
885
+ expect ( fullLayout . yaxis . range ) . toBeCloseToArray ( yrng , 2 , msg + ' yrng' ) ;
886
+ }
888
887
888
+ var schema = Plotly . PlotSchema . get ( ) ;
889
+
890
+ it ( 'should update axis range accordingly on marker.size edits' , function ( done ) {
889
891
// edit types are important to this test
890
- var schema = Plotly . PlotSchema . get ( ) ;
891
892
expect ( schema . traces . scatter . attributes . marker . size . editType )
892
893
. toBe ( 'calc' , 'marker.size editType' ) ;
893
894
expect ( schema . layout . layoutAttributes . xaxis . autorange . editType )
894
895
. toBe ( 'axrange' , 'ax autorange editType' ) ;
895
896
896
897
Plotly . plot ( gd , [ { y : [ 1 , 2 , 1 ] } ] )
897
898
. then ( function ( ) {
898
- _assert ( 'auto rng / base marker.size' , [ - 0.13 , 2.13 ] , [ 0.93 , 2.07 ] ) ;
899
+ assertAxisRanges ( 'auto rng / base marker.size' , [ - 0.13 , 2.13 ] , [ 0.93 , 2.07 ] ) ;
899
900
return Plotly . relayout ( gd , {
900
901
'xaxis.range' : [ 0 , 2 ] ,
901
902
'yaxis.range' : [ 0 , 2 ]
902
903
} ) ;
903
904
} )
904
905
. then ( function ( ) {
905
- _assert ( 'set rng / base marker.size' , [ 0 , 2 ] , [ 0 , 2 ] ) ;
906
+ assertAxisRanges ( 'set rng / base marker.size' , [ 0 , 2 ] , [ 0 , 2 ] ) ;
906
907
return Plotly . restyle ( gd , 'marker.size' , 50 ) ;
907
908
} )
908
909
. then ( function ( ) {
909
- _assert ( 'set rng / big marker.size' , [ 0 , 2 ] , [ 0 , 2 ] ) ;
910
+ assertAxisRanges ( 'set rng / big marker.size' , [ 0 , 2 ] , [ 0 , 2 ] ) ;
910
911
return Plotly . relayout ( gd , {
911
912
'xaxis.autorange' : true ,
912
913
'yaxis.autorange' : true
913
914
} ) ;
914
915
} )
915
916
. then ( function ( ) {
916
- _assert ( 'auto rng / big marker.size' , [ - 0.28 , 2.28 ] , [ 0.75 , 2.25 ] ) ;
917
+ assertAxisRanges ( 'auto rng / big marker.size' , [ - 0.28 , 2.28 ] , [ 0.75 , 2.25 ] ) ;
917
918
return Plotly . restyle ( gd , 'marker.size' , null ) ;
918
919
} )
919
920
. then ( function ( ) {
920
- _assert ( 'auto rng / base marker.size' , [ - 0.13 , 2.13 ] , [ 0.93 , 2.07 ] ) ;
921
+ assertAxisRanges ( 'auto rng / base marker.size' , [ - 0.13 , 2.13 ] , [ 0.93 , 2.07 ] ) ;
922
+ } )
923
+ . catch ( failTest )
924
+ . then ( done ) ;
925
+ } ) ;
926
+
927
+ it ( 'should update axis range according to visible edits' , function ( done ) {
928
+ expect ( schema . traces . scatter . attributes . visible . editType )
929
+ . toBe ( 'plot' , 'visible editType' ) ;
930
+
931
+ Plotly . plot ( gd , [
932
+ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 1 ] } ,
933
+ { x : [ 4 , 5 , 6 ] , y : [ - 1 , - 2 , - 1 ] }
934
+ ] )
935
+ . then ( function ( ) {
936
+ assertAxisRanges ( 'both visible' , [ 0.676 , 6.323 ] , [ - 2.29 , 2.29 ] ) ;
937
+ return Plotly . restyle ( gd , 'visible' , false , [ 1 ] ) ;
938
+ } )
939
+ . then ( function ( ) {
940
+ assertAxisRanges ( 'visible [true,false]' , [ 0.87 , 3.128 ] , [ 0.926 , 2.07 ] ) ;
941
+ return Plotly . restyle ( gd , 'visible' , false , [ 0 ] ) ;
942
+ } )
943
+ . then ( function ( ) {
944
+ assertAxisRanges ( 'both invisible' , [ 0.87 , 3.128 ] , [ 0.926 , 2.07 ] ) ;
945
+ return Plotly . restyle ( gd , 'visible' , true , [ 1 ] ) ;
946
+ } )
947
+ . then ( function ( ) {
948
+ assertAxisRanges ( 'visible [false,true]' , [ 3.871 , 6.128 ] , [ - 2.07 , - 0.926 ] ) ;
949
+ return Plotly . restyle ( gd , 'visible' , true ) ;
950
+ } )
951
+ . then ( function ( ) {
952
+ assertAxisRanges ( 'back to both visible' , [ 0.676 , 6.323 ] , [ - 2.29 , 2.29 ] ) ;
921
953
} )
922
954
. catch ( failTest )
923
955
. then ( done ) ;
0 commit comments