Documentation updates
[dygraphs.git] / tests / x-axis-formatter.html
index 96b3e06..3f8f01c 100644 (file)
@@ -1,13 +1,10 @@
+<!DOCTYPE html>
 <html>
   <head>
-    <title>hourly</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>
+    <link rel="stylesheet" href="../dist/dygraph.css">
+    <title>X Axis Label Formatting</title>
+    <script type="text/javascript" src="../dist/dygraph.js"></script>
+
   </head>
   <body>
     <p>Original data:</p>
           "2009/07/12 05:00:00,3,6\n" +
           "2009/07/12 06:00:00,4,6"
       }
+      function zeropad(x) {
+        return (x < 10) ? '0' + x : x;
+      }
 
-      new Dygraph(
+      var g1 = new Dygraph(
             document.getElementById("normal"),
             HourlyData()
           );
 
-      new Dygraph(
+      var g2 = new Dygraph(
             document.getElementById("offby2"),
             HourlyData(),
             { 
-              xAxisLabelFormatter:
-                function(d, gran) {
-                  return Dygraph.dateAxisFormatter(new Date(d.getTime() + 7200*1000), gran);
+              axes: {
+                x: {
+                  axisLabelFormatter: function(d, gran, opts) {
+                      return Dygraph.dateAxisLabelFormatter(new Date(d.getTime() + 7200*1000), gran, opts);
+                  }
                 }
+              }
             });
 
-      new Dygraph(
+      var g3 = new Dygraph(
             document.getElementById("seconds"),
             HourlyData(),
             { 
-              xAxisLabelWidth: 70,
-              xAxisLabelFormatter:
-                function(d, gran) {
-                  return Dygraph.zeropad(d.getHours()) + ":"
-                      + Dygraph.zeropad(d.getMinutes()) + ":"
-                      + Dygraph.zeropad(d.getSeconds());
+              axes: {
+                x: {
+                  axisLabelWidth: 70,
+                  axisLabelFormatter: function(d, gran) {
+                    return zeropad(d.getHours()) + ":"
+                        + zeropad(d.getMinutes()) + ":"
+                        + zeropad(d.getSeconds());
+                  }
                 }
+              }
             });
     </script>
   </body>