Fix issue #65
authorDan Vanderkam <danvdk@gmail.com>
Tue, 26 Jan 2010 08:50:55 +0000 (00:50 -0800)
committerDan Vanderkam <danvdk@gmail.com>
Tue, 26 Jan 2010 08:50:55 +0000 (00:50 -0800)
dygraph.js
tests/no-range.html [new file with mode: 0644]

index d187aa9..30bb7e6 100644 (file)
@@ -1290,6 +1290,8 @@ Dygraph.prototype.drawGraph_ = function(data) {
   } else {
     // Add some padding and round up to an integer to be human-friendly.
     var span = maxY - minY;
+    // special case: if we have no sense of scale, use +/-10% of the sole value.
+    if (span == 0) { span = maxY; }
     var maxAxisY = maxY + 0.1 * span;
     var minAxisY = minY - 0.1 * span;
 
diff --git a/tests/no-range.html b/tests/no-range.html
new file mode 100644 (file)
index 0000000..ba31dc1
--- /dev/null
@@ -0,0 +1,19 @@
+<html>
+  <head>
+    <title>no range</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>
+  </head>
+  <body>
+    <div id="blah"></div>
+    <script type="text/javascript">
+    new Dygraph(document.getElementById("blah"),
+                "X,Y\n10,12345\n11,12345\n",
+                { width: 640, height: 480 });
+    </script>
+  </body>
+</html>