Skip to content

Commit

Permalink
Fix off-screen trace detection
Browse files Browse the repository at this point in the history
Make the condition test work regardless of the drawing method
  • Loading branch information
lvlte committed Apr 28, 2023
1 parent c25484b commit 4eaf62e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/traces/heatmap/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,18 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) {
// setup image nodes

// if image is entirely off-screen, don't even draw it
var isOffScreen = (imageWidth <= 0 || imageHeight <= 0);
var isOffScreen = (
left >= xa._length || right <= 0 || top >= ya._length || bottom <= 0
);

if(isOffScreen) {
// console.log('isOffScreen', drawingMethod);

var noImage = plotGroup.selectAll('image').data([]);
noImage.exit().remove();

removeLabels(plotGroup);
return;
}

// console.log('drawingMethod', drawingMethod);
// console.log(left, right);


// generate image data

var canvasW, canvasH;
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/heatmap_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ describe('heatmap plot', function() {

return Plotly.relayout(gd, 'xaxis.range', [2, 3]);
}).then(function() {
assertImageCnt(3);
assertImageCnt(2);

return Plotly.relayout(gd, 'xaxis.autorange', true);
}).then(function() {
Expand Down

0 comments on commit 4eaf62e

Please sign in to comment.