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