Fix CSVs with a numeric (non-date) X axis and add a test for that case.
authorBen Winslow <rain@bluecherry.net>
Fri, 4 Mar 2011 07:47:44 +0000 (02:47 -0500)
committerBen Winslow <rain@bluecherry.net>
Fri, 4 Mar 2011 07:47:44 +0000 (02:47 -0500)
dygraph.js
tests/csv-numeric-x.html [new file with mode: 0644]

index 656d7a8..7f312b6 100644 (file)
@@ -2870,7 +2870,7 @@ Dygraph.prototype.detectTypeFromString_ = function(str) {
     this.attrs_.xTicker = Dygraph.dateTicker;
     this.attrs_.xAxisLabelFormatter = Dygraph.dateAxisFormatter;
   } else {
-    this.attrs_.xValueFormatter = this.attrs_.xValueFormatter;
+    this.attrs_.xValueFormatter = this.attrs_.yValueFormatter;
     this.attrs_.xValueParser = function(x) { return parseFloat(x); };
     this.attrs_.xTicker = Dygraph.numericTicks;
     this.attrs_.xAxisLabelFormatter = this.attrs_.xValueFormatter;
diff --git a/tests/csv-numeric-x.html b/tests/csv-numeric-x.html
new file mode 100644 (file)
index 0000000..29d5781
--- /dev/null
@@ -0,0 +1,27 @@
+<html>
+  <head>
+    <title>CSV with numeric X series</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>
+  </head>
+  <body>
+    <p>CSV data with a numeric (non-date) X series.</p>
+    <div id="graph"></div>
+    <script type="text/javascript">
+    new Dygraph(
+      document.getElementById("graph"),
+      "X,Y\n" +
+      "1,0\n" +
+      "2,10\n" +
+      "3,0\n" +
+      "4,-10\n" +
+      "5,0\n"
+    );
+    </script>
+  </body>
+</html>