Skip to content

Commit 587b2e2

Browse files
committed
use d3-omatic pattern in heatmap plot
1 parent 64d304c commit 587b2e2

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/traces/heatmap/plot.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -369,20 +369,28 @@ function plotOne(gd, plotinfo, cd) {
369369
gd._hmpixcount = (gd._hmpixcount||0) + pixcount;
370370
gd._hmlumcount = (gd._hmlumcount||0) + pixcount * avgColor.getLuminance();
371371

372-
// put this right before making the new image, to minimize flicker
373-
fullLayout._paper.selectAll('.'+id).remove();
374-
plotinfo.plot.select('.imagelayer').append('svg:image')
375-
.classed(id, true)
376-
.datum(cd[0])
377-
.attr({
378-
xmlns: xmlnsNamespaces.svg,
379-
'xlink:href': canvas.toDataURL('image/png'),
380-
height: imageHeight,
381-
width: imageWidth,
382-
x: left,
383-
y: top,
384-
preserveAspectRatio: 'none'
385-
});
372+
var plotgroup = plotinfo.plot.select('.imagelayer')
373+
.selectAll('g.hm.' + id)
374+
.data([0]);
375+
plotgroup.enter().append('g')
376+
.classed('hm', true)
377+
.classed(id, true);
378+
plotgroup.exit().remove();
379+
380+
var image3 = plotgroup.selectAll('image')
381+
.data(cd);
382+
image3.enter().append('svg:image');
383+
image3.exit().remove();
384+
385+
image3.attr({
386+
xmlns: xmlnsNamespaces.svg,
387+
'xlink:href': canvas.toDataURL('image/png'),
388+
height: imageHeight,
389+
width: imageWidth,
390+
x: left,
391+
y: top,
392+
preserveAspectRatio: 'none'
393+
});
386394

387395
Lib.markTime('done showing png');
388396
}

0 commit comments

Comments
 (0)