@@ -124,31 +124,20 @@ exports.lsInner = function(gd) {
124
124
125
125
var xDomain = plotinfo . xaxis . domain ;
126
126
var yDomain = plotinfo . yaxis . domain ;
127
- var plotgroupBgData = [ ] ;
127
+ var plotgroup = plotinfo . plotgroup ;
128
+ var plotgroupBg ;
128
129
129
130
if ( overlappingDomain ( xDomain , yDomain , lowerDomains ) ) {
130
- plotgroupBgData = [ 0 ] ;
131
- }
132
- else {
131
+ var pgNode = plotgroup . node ( ) ;
132
+ plotgroupBg = plotinfo . bg = Lib . ensureSingle ( plotgroup , 'rect' , 'bg' ) ;
133
+ pgNode . insertBefore ( plotgroupBg . node ( ) , pgNode . childNodes [ 0 ] ) ;
134
+ } else {
135
+ plotgroupBg = plotgroup . select ( 'rect,bg' ) ;
136
+ if ( plotgroupBg . size ( ) ) plotgroupBg . remove ( ) ;
137
+
133
138
lowerBackgroundIDs . push ( subplot ) ;
134
139
lowerDomains . push ( [ xDomain , yDomain ] ) ;
135
140
}
136
-
137
- // create the plot group backgrounds now, since
138
- // they're all independent selections
139
- var plotgroupBg = plotinfo . plotgroup . selectAll ( '.bg' )
140
- . data ( plotgroupBgData ) ;
141
-
142
- plotgroupBg . enter ( ) . append ( 'rect' )
143
- . classed ( 'bg' , true ) ;
144
-
145
- plotgroupBg . exit ( ) . remove ( ) ;
146
-
147
- plotgroupBg . each ( function ( ) {
148
- plotinfo . bg = plotgroupBg ;
149
- var pgNode = plotinfo . plotgroup . node ( ) ;
150
- pgNode . insertBefore ( this , pgNode . childNodes [ 0 ] ) ;
151
- } ) ;
152
141
} ) ;
153
142
154
143
// now create all the lower-layer backgrounds at once now that
0 commit comments