Skip to content

Commit 90d7a94

Browse files
committed
make sure off-srceen heatmap traces are disposes
1 parent 2ef4411 commit 90d7a94

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/traces/heatmap/plot.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,24 @@ function plotOne(gd, plotinfo, cd) {
137137
var imageWidth = Math.round(right - left),
138138
imageHeight = Math.round(bottom - top);
139139

140-
// now redraw
140+
// setup image nodes
141141

142142
// if image is entirely off-screen, don't even draw it
143-
if(imageWidth <= 0 || imageHeight <= 0) return;
143+
var isOffScreen = (imageWidth <= 0 || imageHeight <= 0);
144+
145+
var plotgroup = plotinfo.plot.select('.imagelayer')
146+
.selectAll('g.hm.' + id)
147+
.data(isOffScreen ? [] : [0]);
148+
149+
plotgroup.enter().append('g')
150+
.classed('hm', true)
151+
.classed(id, true);
152+
153+
plotgroup.exit().remove();
154+
155+
if(isOffScreen) return;
156+
157+
// generate image data
144158

145159
var canvasW, canvasH;
146160
if(zsmooth === 'fast') {
@@ -363,14 +377,6 @@ function plotOne(gd, plotinfo, cd) {
363377
gd._hmpixcount = (gd._hmpixcount||0) + pixcount;
364378
gd._hmlumcount = (gd._hmlumcount||0) + pixcount * avgColor.getLuminance();
365379

366-
var plotgroup = plotinfo.plot.select('.imagelayer')
367-
.selectAll('g.hm.' + id)
368-
.data([0]);
369-
plotgroup.enter().append('g')
370-
.classed('hm', true)
371-
.classed(id, true);
372-
plotgroup.exit().remove();
373-
374380
var image3 = plotgroup.selectAll('image')
375381
.data(cd);
376382

0 commit comments

Comments
 (0)