REFACTORING: moved option retrieving out of the for loop for better
[dygraphs.git] / tests / daylight-savings.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
5 <title>Daylight Savings</title>
6 <!--[if IE]>
7 <script type="text/javascript" src="../excanvas.js"></script>
8 <![endif]-->
9 <!--
10 For production (minified) code, use:
11 <script type="text/javascript" src="dygraph-combined.js"></script>
12 -->
13 <script type="text/javascript" src="../dygraph-dev.js"></script>
14
15 <style>
16 body {
17 max-width: 1024px;
18 }
19 </style>
20
21 </head>
22 <body>
23 <h2>DST</h2>
24 <p>This tests that tick marks don't break when the axis crosses into
25 daylight savings time.</p>
26
27 <div id="demodiv"></div>
28
29 <p>The tick marks should all be on day boundaries or nice hours (6, 12, 18),
30 rather than on odd time boundaries like 5, 11, 17 and 23.</p>
31
32 <hr/>
33 <div id="chart2"></div>
34 <p>This chart shows a continuous line going across the "fall back" EST/EDT event. You may need to switch your computer's time zone to Eastern to see this. The x-axis tick marks go from 01:00 &rarr; 01:55 and then back to 01:00.</p>
35
36 <hr/>
37 <div id="chart3"></div>
38 <p>This chart is analogous to the first, except at a "spring forward".</p>
39
40 <hr/>
41 <div id="chart4"></div>
42 <p>This chart shows a continuous series which crosses a "spring forward". The x-axis ticks should skip from 1:55AM to 3:00AM.</p>
43
44 <script type="text/javascript">
45 g = new Dygraph(
46 document.getElementById("demodiv"),
47 "Date/Time,Purchases\n" +
48 "2010-11-05 00:00:00,167082\n" +
49 "2010-11-06 00:00:00,168571\n" +
50 "2010-11-07 00:00:00,177796\n" +
51 "2010-11-08 00:00:00,165587\n" +
52 "2010-11-09 00:00:00,164380\n",
53 {
54 width: 1024
55 }
56 );
57
58 // Generate data which crosses the EST/EDT boundary.
59 var dst_data = [];
60 var base_ms = 1383454200000;
61 for (var x = base_ms; x < base_ms + 1000 * 60 * 80; x += 1000) {
62 dst_data.push([new Date(x), x]);
63 }
64
65 g2 = new Dygraph(
66 document.getElementById("chart2"),
67 dst_data,
68 { width: 1024, labels: ['Date', 'Value'] }
69 );
70
71 g3 = new Dygraph(
72 document.getElementById("chart3"),
73 "Date/Time,Purchases\n" +
74 "2011-03-11 00:00:00,167082\n" +
75 "2011-03-12 00:00:00,168571\n" +
76 "2011-03-13 00:00:00,177796\n" +
77 "2011-03-14 00:00:00,165587\n" +
78 "2011-03-15 00:00:00,164380\n",
79 {
80 width: 1024,
81 dateWindow: [1299989043119.4365, 1300080693627.4866]
82 }
83 );
84
85 var base_ms_spring = 1299999000000;
86 var dst_data_spring = [];
87 for (var x = base_ms_spring; x < base_ms_spring + 1000 * 60 * 80; x += 1000) {
88 dst_data_spring.push([new Date(x), x]);
89 }
90
91 g4 = new Dygraph(
92 document.getElementById("chart4"),
93 dst_data_spring,
94 { width: 1024, labels: ['Date', 'Value'] }
95 );
96
97 </script>
98 </body>
99 </html>