@@ -520,7 +520,8 @@ describe('subplot creation / deletion:', function() {
520
520
yaxis2 : { domain : [ 0.5 , 1 ] , anchor : 'x2' } ,
521
521
yaxis3 : { overlaying : 'y' } ,
522
522
// legend makes its own .bg rect - delete so we can ignore that here
523
- showlegend : false
523
+ showlegend : false ,
524
+ plot_bgcolor : '#d3d3d3'
524
525
} )
525
526
. then ( function ( ) {
526
527
// touching but not overlapping: all backgrounds are in back
@@ -553,6 +554,74 @@ describe('subplot creation / deletion:', function() {
553
554
. then ( done ) ;
554
555
} ) ;
555
556
557
+ it ( 'puts not have backgrounds nodes when plot and paper color match' , function ( done ) {
558
+ Plotly . plot ( gd , [
559
+ { y : [ 1 , 2 , 3 ] } ,
560
+ { y : [ 2 , 3 , 1 ] , xaxis : 'x2' , yaxis : 'y2' } ,
561
+ { y : [ 3 , 1 , 2 ] , yaxis : 'y3' }
562
+ ] , {
563
+ xaxis : { domain : [ 0 , 0.5 ] } ,
564
+ xaxis2 : { domain : [ 0.5 , 1 ] , anchor : 'y2' } ,
565
+ yaxis : { domain : [ 0 , 1 ] } ,
566
+ yaxis2 : { domain : [ 0.5 , 1 ] , anchor : 'x2' } ,
567
+ yaxis3 : { overlaying : 'y' } ,
568
+ // legend makes its own .bg rect - delete so we can ignore that here
569
+ showlegend : false ,
570
+ plot_bgcolor : 'white' ,
571
+ paper_bgcolor : 'white'
572
+ } )
573
+ . then ( function ( ) {
574
+ // touching but not overlapping, matching colors -> no <rect.bg>
575
+ checkBGLayers ( 0 , 0 , [ 'xy' , 'x2y2' , 'xy3' ] ) ;
576
+
577
+ // now add a slight overlap: that's enough to put x2y2 in front
578
+ return Plotly . relayout ( gd , { 'xaxis2.domain' : [ 0.49 , 1 ] } ) ;
579
+ } )
580
+ . then ( function ( ) {
581
+ // need to draw one backgroud <rect>
582
+ checkBGLayers ( 0 , 1 , [ 'xy' , 'x2y2' , 'xy3' ] ) ;
583
+
584
+ // x ranges overlap, but now y ranges are disjoint
585
+ return Plotly . relayout ( gd , { 'xaxis2.domain' : [ 0 , 1 ] , 'yaxis.domain' : [ 0 , 0.5 ] } ) ;
586
+ } )
587
+ . then ( function ( ) {
588
+ // disjoint, matching colors -> no <rect.bg>
589
+ checkBGLayers ( 0 , 0 , [ 'xy' , 'x2y2' , 'xy3' ] ) ;
590
+
591
+ // regular inset
592
+ return Plotly . relayout ( gd , {
593
+ 'xaxis.domain' : [ 0 , 1 ] ,
594
+ 'yaxis.domain' : [ 0 , 1 ] ,
595
+ 'xaxis2.domain' : [ 0.6 , 0.9 ] ,
596
+ 'yaxis2.domain' : [ 0.6 , 0.9 ]
597
+ } ) ;
598
+ } )
599
+ . then ( function ( ) {
600
+ // need to draw one backgroud <rect>
601
+ checkBGLayers ( 0 , 1 , [ 'xy' , 'x2y2' , 'xy3' ] ) ;
602
+
603
+ // change paper color
604
+ return Plotly . relayout ( gd , 'paper_bgcolor' , 'black' ) ;
605
+ } )
606
+ . then ( function ( ) {
607
+ // need a backgroud <rect> on main subplot to distinguish plot from
608
+ // paper color
609
+ checkBGLayers ( 1 , 1 , [ 'xy' , 'x2y2' , 'xy3' ] ) ;
610
+
611
+ // change bg colors to same semi-transparent color
612
+ return Plotly . relayout ( gd , {
613
+ 'paper_bgcolor' : 'rgba(255,0,0,0.2)' ,
614
+ 'plot_bgcolor' : 'rgba(255,0,0,0.2)'
615
+ } ) ;
616
+ } )
617
+ . then ( function ( ) {
618
+ // still need a <rect.bg> to get correct semi-transparent look
619
+ checkBGLayers ( 1 , 1 , [ 'xy' , 'x2y2' , 'xy3' ] ) ;
620
+ } )
621
+ . catch ( failTest )
622
+ . then ( done ) ;
623
+ } ) ;
624
+
556
625
it ( 'should clear overlaid subplot trace layers on restyle' , function ( done ) {
557
626
var fig = Lib . extendDeep ( { } , require ( '@mocks/overlaying-axis-lines.json' ) ) ;
558
627
0 commit comments