From 31eddad373355fb39fa948b65f9ba29e3f594e61 Mon Sep 17 00:00:00 2001 From: Adam Vartanian <flooey@google.com> Date: Wed, 24 Mar 2010 18:20:49 -0400 Subject: [PATCH] Properly format timestamps at 00:00:00 with non-zero milliseconds on x axis. Update docs for X axis formatting. --- docs/index.html | 7 +++++++ dygraph.js | 2 +- tests/x-axis-formatter.html | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/index.html b/docs/index.html index 757e660..1035783 100644 --- a/docs/index.html +++ b/docs/index.html @@ -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> diff --git a/dygraph.js b/dygraph.js index a83cbe2..26a3812 100644 --- a/dygraph.js +++ b/dygraph.js @@ -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 { diff --git a/tests/x-axis-formatter.html b/tests/x-axis-formatter.html index 96b3e06..04c2915 100644 --- a/tests/x-axis-formatter.html +++ b/tests/x-axis-formatter.html @@ -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]--> -- 2.7.4