diff --git a/simpleheat.js b/simpleheat.js index dc06eb9..4c50945 100644 --- a/simpleheat.js +++ b/simpleheat.js @@ -111,9 +111,11 @@ simpleheat.prototype = { } // colorize the heatmap, using opacity value of each pixel to get the right color from our gradient - var colored = ctx.getImageData(0, 0, this._width, this._height); - this._colorize(colored.data, this._grad); - ctx.putImageData(colored, 0, 0); + if(this._width!=0 && this._height!=0) { + var colored = ctx.getImageData(0, 0, this._width, this._height); + this._colorize(colored.data, this._grad); + ctx.putImageData(colored, 0, 0); + } return this; },