Properly format timestamps at 00:00:00 with non-zero milliseconds on x axis.
authorAdam Vartanian <flooey@google.com>
Wed, 24 Mar 2010 22:20:49 +0000 (18:20 -0400)
committerAdam Vartanian <flooey@google.com>
Wed, 24 Mar 2010 22:20:49 +0000 (18:20 -0400)
Update docs for X axis formatting.

docs/index.html
dygraph.js
tests/x-axis-formatter.html

index 757e660..1035783 100644 (file)
@@ -699,6 +699,13 @@ perl -ne 'BEGIN{print "Month,Nominal,Real\n"} chomp; ($m,$cpi,$low,$close,$high)
           </td>
         </tr>
         <tr>
+          <td><strong>xAxisLabelFormatter</strong></td>
+          <td><code>function(date, granularity)</code></td>
+          <td><code>Dygraph.dateAxisFormatter</code></td>
+          <td>Function to call to format values along the x axis.
+            <div class="tests">Tests: <a href="tests/x-axis-formatter.html">xAxisLabelFormatter</a></div>
+          </td>
+        <tr>
           <td><strong>rightGap</strong></td>
           <td><code>integer</code></td>
           <td><code></code></td>
index a83cbe2..26a3812 100644 (file)
@@ -1110,7 +1110,7 @@ Dygraph.dateAxisFormatter = function(date, granularity) {
   if (granularity >= Dygraph.MONTHLY) {
     return date.strftime('%b %y');
   } else {
-    var frac = date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds();
+    var frac = date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds() + date.getMilliseconds();
     if (frac == 0 || granularity >= Dygraph.DAILY) {
       return new Date(date.getTime() + 3600*1000).strftime('%d%b');
     } else {
index 96b3e06..04c2915 100644 (file)
@@ -1,6 +1,6 @@
 <html>
   <head>
-    <title>hourly</title>
+    <title>X Axis Label Formatting</title>
     <!--[if IE]>
     <script type="text/javascript" src="excanvas.js"></script>
     <![endif]-->