Commit | Line | Data |
---|---|---|
54425b14 | 1 | <!DOCTYPE html> |
bf640e56 AV |
2 | <html> |
3 | <head> | |
10494b48 | 4 | <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9"> |
31eddad3 | 5 | <title>X Axis Label Formatting</title> |
bf640e56 | 6 | <!--[if IE]> |
a2b2c3a1 | 7 | <script type="text/javascript" src="../excanvas.js"></script> |
bf640e56 AV |
8 | <![endif]--> |
9 | <script type="text/javascript" src="../strftime/strftime-min.js"></script> | |
10 | <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script> | |
11 | <script type="text/javascript" src="../dygraph-canvas.js"></script> | |
12 | <script type="text/javascript" src="../dygraph.js"></script> | |
13 | </head> | |
14 | <body> | |
15 | <p>Original data:</p> | |
16 | <div id="normal" style="width:600px; height:300px;"></div> | |
17 | ||
18 | <p>Same data, but offset by 2 hours with the date formatter:</p> | |
19 | <div id="offby2" style="width:600px; height:300px;"></div> | |
20 | ||
21 | <p>Same data, but always displaying HH:MM:SS:</p> | |
22 | <div id="seconds" style="width:600px; height:300px;"></div> | |
23 | ||
24 | <script type="text/javascript"> | |
25 | function HourlyData() { | |
26 | return "" + | |
27 | "Date,A,B\n" + | |
28 | "2009/07/12 00:00:00,3,4\n" + | |
29 | "2009/07/12 01:00:00,5,6\n" + | |
30 | "2009/07/12 02:00:00,7,6\n" + | |
31 | "2009/07/12 03:00:00,6,5\n" + | |
32 | "2009/07/12 04:00:00,4,7\n" + | |
33 | "2009/07/12 05:00:00,3,6\n" + | |
34 | "2009/07/12 06:00:00,4,6" | |
35 | } | |
36 | ||
37 | new Dygraph( | |
38 | document.getElementById("normal"), | |
39 | HourlyData() | |
40 | ); | |
41 | ||
42 | new Dygraph( | |
43 | document.getElementById("offby2"), | |
44 | HourlyData(), | |
45 | { | |
46 | xAxisLabelFormatter: | |
47 | function(d, gran) { | |
48 | return Dygraph.dateAxisFormatter(new Date(d.getTime() + 7200*1000), gran); | |
49 | } | |
50 | }); | |
51 | ||
52 | new Dygraph( | |
53 | document.getElementById("seconds"), | |
54 | HourlyData(), | |
55 | { | |
56 | xAxisLabelWidth: 70, | |
57 | xAxisLabelFormatter: | |
58 | function(d, gran) { | |
59 | return Dygraph.zeropad(d.getHours()) + ":" | |
60 | + Dygraph.zeropad(d.getMinutes()) + ":" | |
61 | + Dygraph.zeropad(d.getSeconds()); | |
62 | } | |
63 | }); | |
64 | </script> | |
65 | </body> | |
66 | </html> |