some tweaks for divs with % sizes
authorDan Vanderkam <danvk@google.com>
Fri, 23 Apr 2010 22:26:16 +0000 (15:26 -0700)
committerDan Vanderkam <danvk@google.com>
Fri, 23 Apr 2010 22:26:16 +0000 (15:26 -0700)
dygraph.js
tests/resize.html

index 5f344ba..6e72efe 100644 (file)
@@ -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_.
index ab51fd2..13a9e3b 100644 (file)
@@ -11,7 +11,7 @@
     <script type="text/javascript" src="data.js"></script>
   </head>
   <body>
-    <div id="div_g" style="width:100%; height:100%"></div>
+    <div id="div_g" style="width:95%; height:95%"></div>
 
     <script type="text/javascript">
       g = new Dygraph(