@@ -426,6 +426,16 @@ describe('range selector interactions:', function() {
426426 } ) ;
427427 }
428428
429+ function checkButtonColor ( bgColor , activeColor ) {
430+ d3 . selectAll ( '.button' ) . each ( function ( d ) {
431+ var rect = d3 . select ( this ) . select ( 'rect' ) ;
432+
433+ expect ( rect . style ( 'fill' ) ) . toEqual (
434+ d . isActive ? activeColor : bgColor
435+ ) ;
436+ } ) ;
437+ }
438+
429439 it ( 'should display the correct nodes' , function ( ) {
430440 assertNodeCount ( '.rangeselector' , 1 ) ;
431441 assertNodeCount ( '.button' , mockCopy . layout . xaxis . rangeselector . buttons . length ) ;
@@ -456,6 +466,22 @@ describe('range selector interactions:', function() {
456466 } ) ;
457467 } ) ;
458468
469+ it ( 'should be able to change its style on `relayout`' , function ( done ) {
470+ var prefix = 'xaxis.rangeselector.' ;
471+
472+ checkButtonColor ( 'rgb(238, 238, 238)' , 'rgb(212, 212, 212)' ) ;
473+
474+ Plotly . relayout ( gd , prefix + 'bgcolor' , 'red' ) . then ( function ( ) {
475+ checkButtonColor ( 'rgb(255, 0, 0)' , 'rgb(255, 128, 128)' ) ;
476+
477+ return Plotly . relayout ( gd , prefix + 'activecolor' , 'blue' ) ;
478+ } ) . then ( function ( ) {
479+ checkButtonColor ( 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' ) ;
480+
481+ done ( ) ;
482+ } ) ;
483+ } ) ;
484+
459485 it ( 'should update range and active button when clicked' , function ( ) {
460486 var range0 = gd . layout . xaxis . range [ 0 ] ;
461487 var buttons = d3 . selectAll ( '.button' ) . select ( 'rect' ) ;
0 commit comments