Dygraph.dateString_: shows milliseconds if any. (#774)
[dygraphs.git] / tests / labelsDateMilliseconds.html
diff --git a/tests/labelsDateMilliseconds.html b/tests/labelsDateMilliseconds.html
new file mode 100644 (file)
index 0000000..332e8c4
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Milliseconds date labels</title>
+    <!--
+    For production (minified) code, use:
+    <script type="text/javascript" src="dygraph-combined.js"></script>
+    -->
+    <script type="text/javascript" src="../dist/dygraph.js"></script>
+  </head>
+  <body>
+
+    <h2>Milliseconds display in date and time labels</h2>
+
+    <p>This shows how milliseconds are displayed when present.</p>
+
+    <div id="div_ms" style="width:600px; height:200px;"></div>
+    <div id="div_std" style="width:600px; height:200px;"></div>
+    
+    <p>You can check it by hovering over corresponding points and comparing
+    the value labels.</p>
+
+    <script type="text/javascript">
+      var values = (function () {
+        var rand10 = function () { return Math.round(10 * Math.random()); };
+        var a = [];
+        for (var n=0; n < 72; n++) {
+          a.push(rand10());
+        }
+        return a;
+      })();
+      function data(y,m,d,hh,mm,ss,ms) {
+        var a = [];
+        for (var n=0; n < 72; n++) {
+          a.push([new Date(Date.UTC(y, m, d, hh + n, mm, ss, ms)), values[n]]);
+        }
+        return a;
+      }
+      gms = new Dygraph(
+                   document.getElementById("div_ms"),
+                   data(2009, 6, 25, 14, 34, 56, 654),
+                   {
+                     labels: ['time with ms', 'random']
+                   }
+                 );
+      gstd = new Dygraph(
+                   document.getElementById("div_std"),
+                   data(2009, 6, 25, 14, 0, 0, 0),
+                   {
+                     labels: ['time', 'random']
+                   }
+                 );
+    </script>
+
+  </body>
+</html>