diff --git a/simpleheat.js b/simpleheat.js index dc06eb9..7372165 100644 --- a/simpleheat.js +++ b/simpleheat.js @@ -111,6 +111,10 @@ simpleheat.prototype = { } // colorize the heatmap, using opacity value of each pixel to get the right color from our gradient + //some time,the canvas's width and height may be zero + if(this._width==0||this._height==0){ + this.resize(); + } var colored = ctx.getImageData(0, 0, this._width, this._height); this._colorize(colored.data, this._grad); ctx.putImageData(colored, 0, 0);