From: Dan Vanderkam Date: Tue, 27 Apr 2010 23:05:58 +0000 (-0700) Subject: error on zero width/height X-Git-Tag: v1.0.0~688 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=10a6456d9d5385e723d93bd69ba6e20426721697;p=dygraphs.git error on zero width/height --- diff --git a/dygraph.js b/dygraph.js index 6e72efe..077a329 100644 --- a/dygraph.js +++ b/dygraph.js @@ -186,13 +186,19 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { // The div might have been specified as percent of the current window size, // convert that to an appropriate number of pixels. if (div.style.width.indexOf("%") == div.style.width.length - 1) { - // Minus ten pixels keeps scrollbars from showing up for a 100% width div. this.width_ = div.offsetWidth; } if (div.style.height.indexOf("%") == div.style.height.length - 1) { this.height_ = div.offsetHeight; } + if (this.width_ == 0) { + this.error("dygraph has zero width. Please specify a width in pixels."); + } + if (this.height_ == 0) { + this.error("dygraph has zero height. Please specify a height in pixels."); + } + // TODO(danvk): set fillGraph to be part of attrs_ here, not user_attrs_. if (attrs['stackedGraph']) { attrs['fillGraph'] = true;