Skip to content

Commit a2c5c3d

Browse files
committed
use ensureSingle in plot bg lsInner routine
1 parent 928ff6d commit a2c5c3d

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

src/plot_api/subroutines.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,31 +124,20 @@ exports.lsInner = function(gd) {
124124

125125
var xDomain = plotinfo.xaxis.domain;
126126
var yDomain = plotinfo.yaxis.domain;
127-
var plotgroupBgData = [];
127+
var plotgroup = plotinfo.plotgroup;
128+
var plotgroupBg;
128129

129130
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+
133138
lowerBackgroundIDs.push(subplot);
134139
lowerDomains.push([xDomain, yDomain]);
135140
}
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-
});
152141
});
153142

154143
// now create all the lower-layer backgrounds at once now that

0 commit comments

Comments
 (0)