@@ -879,45 +879,77 @@ describe('end-to-end scatter tests', function() {
879879 . then ( done ) ;
880880 } ) ;
881881
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+ }
888887
888+ var schema = Plotly . PlotSchema . get ( ) ;
889+
890+ it ( 'should update axis range accordingly on marker.size edits' , function ( done ) {
889891 // edit types are important to this test
890- var schema = Plotly . PlotSchema . get ( ) ;
891892 expect ( schema . traces . scatter . attributes . marker . size . editType )
892893 . toBe ( 'calc' , 'marker.size editType' ) ;
893894 expect ( schema . layout . layoutAttributes . xaxis . autorange . editType )
894895 . toBe ( 'axrange' , 'ax autorange editType' ) ;
895896
896897 Plotly . plot ( gd , [ { y : [ 1 , 2 , 1 ] } ] )
897898 . 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 ] ) ;
899900 return Plotly . relayout ( gd , {
900901 'xaxis.range' : [ 0 , 2 ] ,
901902 'yaxis.range' : [ 0 , 2 ]
902903 } ) ;
903904 } )
904905 . then ( function ( ) {
905- _assert ( 'set rng / base marker.size' , [ 0 , 2 ] , [ 0 , 2 ] ) ;
906+ assertAxisRanges ( 'set rng / base marker.size' , [ 0 , 2 ] , [ 0 , 2 ] ) ;
906907 return Plotly . restyle ( gd , 'marker.size' , 50 ) ;
907908 } )
908909 . then ( function ( ) {
909- _assert ( 'set rng / big marker.size' , [ 0 , 2 ] , [ 0 , 2 ] ) ;
910+ assertAxisRanges ( 'set rng / big marker.size' , [ 0 , 2 ] , [ 0 , 2 ] ) ;
910911 return Plotly . relayout ( gd , {
911912 'xaxis.autorange' : true ,
912913 'yaxis.autorange' : true
913914 } ) ;
914915 } )
915916 . 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 ] ) ;
917918 return Plotly . restyle ( gd , 'marker.size' , null ) ;
918919 } )
919920 . 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 ] ) ;
921953 } )
922954 . catch ( failTest )
923955 . then ( done ) ;
0 commit comments