Fix Kenny's numeric gviz bug and add a test
authorDan Vanderkam <danvdk@gmail.com>
Sun, 31 Jan 2010 03:41:08 +0000 (19:41 -0800)
committerDan Vanderkam <danvdk@gmail.com>
Sun, 31 Jan 2010 03:41:08 +0000 (19:41 -0800)
dygraph.js
tests/numeric-gviz.html [new file with mode: 0644]

index a08f668..ea25980 100644 (file)
@@ -1693,7 +1693,7 @@ Dygraph.prototype.parseDataTable_ = function(data) {
   cols = labels.length;
 
   var indepType = data.getColumnType(0);
-  if (indepType == 'date' || 'datetime') {
+  if (indepType == 'date' || indepType == 'datetime') {
     this.attrs_.xValueFormatter = Dygraph.dateString_;
     this.attrs_.xValueParser = Dygraph.dateParser;
     this.attrs_.xTicker = Dygraph.dateTicker;
diff --git a/tests/numeric-gviz.html b/tests/numeric-gviz.html
new file mode 100644 (file)
index 0000000..11457a8
--- /dev/null
@@ -0,0 +1,35 @@
+<html>
+  <head>
+    <title>numeric gviz</title>
+    <!--[if IE]>
+    <script type="text/javascript" src="excanvas.js"></script>
+    <![endif]-->
+    <script type="text/javascript" src="../dygraph-combined.js"></script>
+    <script type="text/javascript" src="../dygraph-canvas.js"></script>
+    <script type="text/javascript" src="../dygraph.js"></script>
+
+    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+
+    <script type="text/javascript">
+      google.load("visualization", "1", {"packages":[ "columnchart"]});
+      google.setOnLoadCallback(drawchart);
+
+      function drawchart() {
+          var tableString =
+              "{cols:[{id:'point',label:'n',type:'number',pattern:''}," +
+              "{id:'0',label:'0',type:'number',pattern:''}," +
+              "{id:'stddev',label:'stddev',type:'number',pattern:''}]," +
+              "rows:[{c:[{v:0.0},{v:41.97},{v:17.86}]},{c:[{v:1.0},{v:11.71},{v:17.86}]},{c:[{v:2.0},{v:43.26},{v:17.86}]}]}";
+          data = new google.visualization.DataTable(eval('(' + tableString + ')'));
+          chart = new Dygraph.GVizChart(document.getElementById(
+                "graph"));
+          chart.draw(data, {errorBars: true, showRoller: true, includeZero: true });
+      }
+    </script>
+  </head>
+  <body>
+  <p>This tests that dygraphs can display gviz DataTable's with a numeric
+  x-axis.</p>
+  <div id="graph" style="width: 800px; height: 400px;"></div>
+  </body>
+</html>