summaryrefslogtreecommitdiff
path: root/index.html
blob: 48bd6a13ea7c514fed8d2c9274d2229d08a7fac3 (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>untitled</title>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <script type="text/javascript" src="assets/javascript/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="assets/javascript/flot/excanvas.min.js"></script>
        <script type="text/javascript" src="assets/javascript/flot/jquery.flot.min.js"></script>
        <script type="text/javascript" src="assets/javascript/flot/jquery.flot.selection.min.js"></script>
        <script type="text/javascript" src="assets/javascript/javascriptrrd/binaryXHR.js"></script>
        <script type="text/javascript" src="assets/javascript/javascriptrrd/rrdFile.js"></script>
        <script type="text/javascript" src="assets/javascript/MochiKit/Base.js"></script>
        <script type="text/javascript" src="assets/javascript/MochiKit/Async.js"></script>
        <script type="text/javascript" src="jrrd.js"></script>
        <script type="text/javascript">

        var graphOptions = {
            grid: {
                clickable: true
            },
            selection: {
                mode: 'x'
            },
            series: {
                points: { show: false },
                lines: {
                    show: true,
                    steps: false,
                    shadowSize: 0,
                    lineWidth: 1
                },
                shadowSize: 0
            },
            xaxis: {
                mode: "time"
            }
        };

        function drawChart(db, startTime, endTime) {
            return db.getData(startTime, endTime)
                .addCallback(
                    function(data) {
                        var plot = $.plot($('.container'), data, graphOptions);
                    })
                .addErrback(
                    function(failure) {
                        $('.container').text('error: ' + failure.message);
                    });
        }

        var db = new jrrd.RrdQueryRemote('data/localhost/load/load.rrd');

        $(function() {
            drawChart(db, new Date('7 April 2010 09:30:00'),
                          new Date('7 April 2010 15:00:00'));

            $('.container').bind('plotclick', function(event, pos, item) {
                if (item) {
                    console.log(['X: ' + new Date(item.datapoint[0]), 'Y: ' + item.datapoint[1]]);
                }
            });

            $('.container').bind("plotselected", function(event, ranges) {
                var startTime = new Date(ranges.xaxis.from);
                var endTime = new Date(ranges.xaxis.to);
                drawChart(db, startTime, endTime);
                console.log("You selected " + startTime + " to " + endTime);
            });
        });
        </script>
    </head>

    <body>
        <div class="container" style="width:100%; height:200px;"></div>
    </body>
</html>