support changing renderer options like strokeWidth and add a test
authorDan Vanderkam <danvk@google.com>
Thu, 5 Aug 2010 21:05:24 +0000 (14:05 -0700)
committerDan Vanderkam <danvk@google.com>
Thu, 5 Aug 2010 21:05:24 +0000 (14:05 -0700)
dygraph.js
tests/layout-options.html [new file with mode: 0644]

index 34a387a..f5e7d38 100644 (file)
@@ -2198,6 +2198,7 @@ Dygraph.prototype.updateOptions = function(attrs) {
     this.valueRange_ = attrs.valueRange;
   }
   Dygraph.update(this.user_attrs_, attrs);
+  Dygraph.update(this.renderOptions_, attrs);
 
   this.labelsFromCSV_ = (this.attr_("labels") == null);
 
diff --git a/tests/layout-options.html b/tests/layout-options.html
new file mode 100644 (file)
index 0000000..fb1a3db
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+  <head>
+    <title>Layout Options</title>
+    <!--[if IE]>
+    <script type="text/javascript" src="excanvas.js"></script>
+    <![endif]-->
+    <script type="text/javascript" src="../strftime/strftime-min.js"></script>
+    <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script>
+    <script type="text/javascript" src="../dygraph-canvas.js"></script>
+    <script type="text/javascript" src="../dygraph.js"></script>
+    <script type="text/javascript" src="data.js"></script>
+  </head>
+  <body>
+    <h2>Layout Options Update</h2>
+    <div id="chart" style="width:600px; height:300px;"></div>
+    <script type="text/javascript">
+    g = new Dygraph(document.getElementById('chart'), data,
+    {
+      strokeWidth: 2
+    });
+
+    function change() {
+      g.updateOptions({strokeWidth:
+          parseFloat(document.getElementById("strokeWidth").value)});
+    }
+    </script>
+
+    <p>Stroke Width:
+    <input type=text id="strokeWidth" value="2.0" />
+    <input type=button value="Change Stroke Width" onClick="change()" />
+    </p>
+  </body>
+</html>