@@ -2802,7 +2802,7 @@ describe('Test select box and lasso per trace:', function() {
28022802 [ tv , bv , bv , tv , tv ]
28032803 ] ) ;
28042804 expect ( countUnSelectedPaths ( '.cartesianlayer .trace path' ) ) . toBe ( 2 ) ;
2805- expect ( countUnSelectedPaths ( '.rangeslider-rangeplot .trace path' ) ) . toBe ( 0 ) ;
2805+ expect ( countUnSelectedPaths ( '.rangeslider-rangeplot .trace path' ) ) . toBe ( 2 ) ;
28062806 } ,
28072807 null , LASSOEVENTS , type + ' lasso'
28082808 ) ;
@@ -3123,6 +3123,101 @@ describe('Test that selections persist:', function() {
31233123 } ) ;
31243124} ) ;
31253125
3126+ describe ( 'Test that selection styles propagate to range-slider plot:' , function ( ) {
3127+ var gd ;
3128+
3129+ beforeEach ( function ( ) {
3130+ gd = createGraphDiv ( ) ;
3131+ } ) ;
3132+
3133+ afterEach ( destroyGraphDiv ) ;
3134+
3135+ function makeAssertFn ( query ) {
3136+ return function ( msg , expected ) {
3137+ var gd3 = d3 . select ( gd ) ;
3138+ var mainPlot3 = gd3 . select ( '.cartesianlayer' ) ;
3139+ var rangePlot3 = gd3 . select ( '.rangeslider-rangeplot' ) ;
3140+
3141+ mainPlot3 . selectAll ( query ) . each ( function ( _ , i ) {
3142+ expect ( this . style . opacity ) . toBe ( String ( expected [ i ] ) , msg + ' opacity for mainPlot pt ' + i ) ;
3143+ } ) ;
3144+ rangePlot3 . selectAll ( query ) . each ( function ( _ , i ) {
3145+ expect ( this . style . opacity ) . toBe ( String ( expected [ i ] ) , msg + ' opacity for rangePlot pt ' + i ) ;
3146+ } ) ;
3147+ } ;
3148+ }
3149+
3150+ it ( '- svg points case' , function ( done ) {
3151+ var _assert = makeAssertFn ( 'path.point,.point>path' ) ;
3152+
3153+ Plotly . plot ( gd , [
3154+ { mode : 'markers' , x : [ 1 ] , y : [ 1 ] } ,
3155+ { type : 'bar' , x : [ 2 ] , y : [ 2 ] , } ,
3156+ { type : 'histogram' , x : [ 3 , 3 , 3 ] } ,
3157+ { type : 'box' , x : [ 4 ] , y : [ 4 ] , boxpoints : 'all' } ,
3158+ { type : 'violin' , x : [ 5 ] , y : [ 5 ] , points : 'all' } ,
3159+ { type : 'waterfall' , x : [ 6 ] , y : [ 6 ] } ,
3160+ { type : 'funnel' , x : [ 7 ] , y : [ 7 ] , orientation : 'v' }
3161+ ] , {
3162+ dragmode : 'select' ,
3163+ xaxis : { rangeslider : { visible : true } } ,
3164+ width : 500 ,
3165+ height : 500 ,
3166+ margin : { l : 10 , t : 10 , r : 10 , b : 10 } ,
3167+ showlegend : false
3168+ } )
3169+ . then ( function ( ) {
3170+ _assert ( 'base' , [ 1 , 1 , 1 , 1 , 1 , 1 , 1 ] ) ;
3171+ } )
3172+ . then ( function ( ) {
3173+ resetEvents ( gd ) ;
3174+ drag ( [ [ 20 , 20 ] , [ 40 , 40 ] ] ) ;
3175+ return selectedPromise ;
3176+ } )
3177+ . then ( function ( ) {
3178+ _assert ( 'after empty selection' , [ 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 ] ) ;
3179+ } )
3180+ . then ( function ( ) { return doubleClick ( 200 , 200 ) ; } )
3181+ . then ( function ( ) {
3182+ _assert ( 'after double-click reset' , [ 1 , 1 , 1 , 1 , 1 , 1 , 1 ] ) ;
3183+ } )
3184+ . catch ( failTest )
3185+ . then ( done ) ;
3186+ } ) ;
3187+
3188+ it ( '- svg finance case' , function ( done ) {
3189+ var _assert = makeAssertFn ( 'path.box,.ohlc>path' ) ;
3190+
3191+ Plotly . plot ( gd , [
3192+ { type : 'ohlc' , x : [ 6 ] , open : [ 6 ] , high : [ 6 ] , low : [ 6 ] , close : [ 6 ] } ,
3193+ { type : 'candlestick' , x : [ 7 ] , open : [ 7 ] , high : [ 7 ] , low : [ 7 ] , close : [ 7 ] } ,
3194+ ] , {
3195+ dragmode : 'select' ,
3196+ width : 500 ,
3197+ height : 500 ,
3198+ margin : { l : 10 , t : 10 , r : 10 , b : 10 } ,
3199+ showlegend : false
3200+ } )
3201+ . then ( function ( ) {
3202+ _assert ( 'base' , [ 1 , 1 ] ) ;
3203+ } )
3204+ . then ( function ( ) {
3205+ resetEvents ( gd ) ;
3206+ drag ( [ [ 20 , 20 ] , [ 40 , 40 ] ] ) ;
3207+ return selectedPromise ;
3208+ } )
3209+ . then ( function ( ) {
3210+ _assert ( 'after empty selection' , [ 0.3 , 0.3 ] ) ;
3211+ } )
3212+ . then ( function ( ) { return doubleClick ( 200 , 200 ) ; } )
3213+ . then ( function ( ) {
3214+ _assert ( 'after double-click reset' , [ 1 , 1 ] ) ;
3215+ } )
3216+ . catch ( failTest )
3217+ . then ( done ) ;
3218+ } ) ;
3219+ } ) ;
3220+
31263221// to make sure none of the above tests fail with extraneous invisible traces,
31273222// add a bunch of them here
31283223function addInvisible ( fig , canHaveLegend ) {
0 commit comments