From: Dan Vanderkam Date: Fri, 23 Apr 2010 22:26:16 +0000 (-0700) Subject: some tweaks for divs with % sizes X-Git-Tag: v1.0.0~690 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=c6f45033360faf6265be6532e3045bfcf2abcb8e;p=dygraphs.git some tweaks for divs with % sizes --- diff --git a/dygraph.js b/dygraph.js index 5f344ba..6e72efe 100644 --- a/dygraph.js +++ b/dygraph.js @@ -187,10 +187,10 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { // 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_ = (this.width_ * self.innerWidth / 100) - 10; + this.width_ = div.offsetWidth; } if (div.style.height.indexOf("%") == div.style.height.length - 1) { - this.height_ = (this.height_ * self.innerHeight / 100) - 10; + this.height_ = div.offsetHeight; } // TODO(danvk): set fillGraph to be part of attrs_ here, not user_attrs_. diff --git a/tests/resize.html b/tests/resize.html index ab51fd2..13a9e3b 100644 --- a/tests/resize.html +++ b/tests/resize.html @@ -11,7 +11,7 @@ -
+