Open GoogleCodeExporter opened 8 years ago
Hi,
I found the same problem in chrome. After some research I found the cause:
In method _prepareCanvas the canvas height is set according to the container's div height minus the paddingY
canvas.height=this.getHeight()-(this._paddingY*2);
According to the HTML5 reference (http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html) the canvas element can't have a negative height. So when this.getHeight() is 0 (because the div is hidden) canvas.height must be 0 not -(this._paddingY*2).
But chrome allows a negative value for canvas height, so when you reach the function _calculateGrid, you'll be stuck in a loop:
_calculateGrid : function(){
//code code
//this.toScreen(..) will return a negative value
var dy = this.toScreen(this._minValue + inc);
// dy is negative and it's value will increase towards a bigger negative value
while (dy < this._gridSpacing) {
inc = new Number(inc).add(unit);
dy = this.toScreen(this._minValue + inc);
}
//code code
}
The quickÇ/easy fix is to add an extra check at the beggining of _calculateGrid():
if (!this._canvas || this._valueRange == 0 || this._canvas.height <= 0) return grid;
Original comment by madtr...@gmail.com
on 8 Nov 2010 at 8:47
Original comment by ryan...@csail.mit.edu
on 23 Jun 2011 at 10:23
Original issue reported on code.google.com by
tobias.m...@gmail.com
on 10 Feb 2010 at 4:47