Skip to content

Commit

Permalink
[heatmap] Fix #6214 (Throw error when height is 0)
Browse files Browse the repository at this point in the history
  • Loading branch information
100pah committed Jul 18, 2017
1 parent 1064b3f commit f7f7cee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/chart/heatmap/HeatmapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@ define(function (require) {
ctx.drawImage(brush, x - r, y - r);
}

if (!canvas.width || !canvas.height) {
// Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
// 'CanvasRenderingContext2D': The source height is 0."
return canvas;
}

// colorize the canvas using alpha value and set with gradient
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);

var pixels = imageData.data;
var offset = 0;
var pixelLen = pixels.length;
Expand Down

0 comments on commit f7f7cee

Please sign in to comment.