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