File: labelsDateUTC.html

package info (click to toggle)
dygraphs 2.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,340 kB
  • sloc: javascript: 24,842; sh: 800; python: 581; makefile: 45
file content (60 lines) | stat: -rw-r--r-- 2,058 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>UTC date labels</title>

    <link rel="stylesheet" type="text/css" href="../dist/dygraph.css" />
    <link rel="stylesheet" type="text/css" href="../common/vextlnk.css" />
    <script type="text/javascript" src="../dist/dygraph.js"></script>
  </head>
  <body>
    <h2>UTC date and time labels</h2>

    <p>This shows how date ticks and labels may be generated according to local
    time (default) or UTC with the option <code>labelsUTC</code>.</p>

    <p>72 hours of random hourly data since 2009-Jul-23 18:00 UTC
    according to local time (top) and UTC (bottom):</p>

    <div id="div_loc" style="width:600px; height:200px;"></div>
    <div id="div_utc" style="width:600px; height:200px;"></div>

    <p>Please note the offset between the respective ticks in both plots.
    It should match your local time zone offset.</p>

    <p>You can also check it by hovering over corresponding points and comparing
    the value labels.</p>

    <p>Try different zoom levels to show that ticks are always placed at nice
    time boundaries.</p>

    <script type="text/javascript"><!--//--><![CDATA[//><!--
    Dygraph.onDOMready(function onDOMready() {
      var data = (function() {
        var rand10 = function () { return Math.round(10 * Math.random()); };
        var a = []
        for (var y = 2009, m = 6, d = 23, hh = 18, n=0; n < 72; n++) {
          a.push([new Date(Date.UTC(y, m, d, hh + n, 0, 0)), rand10()]);
        }
        return a;
      })();
      gloc = new Dygraph(
                   document.getElementById("div_loc"),
                   data,
                   {
                     labels: ['local time', 'random']
                   }
                 );
      gutc = new Dygraph(
                   document.getElementById("div_utc"),
                   data,
                   {
                     labelsUTC: true,
                     labels: ['UTC', 'random']
                   }
                 );
    });
    //--><!]]></script>
  </body>
</html>