aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/speedometer/index.html
blob: 6cd92fdf4ae343d0ec0370f9a7bcbd6b409cedd3 (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
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
    <head>
        <meta charset=utf-8 />
        <title></title>
        <link rel="stylesheet" type="text/css" href="default.css" />
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
        
        
        
        <!-- Load c3.css -->
        <link href="c3-master/c3.css" rel="stylesheet" type="text/css">

        <!-- Load d3.js and c3.js -->
        <script src="http://d3js.org/d3.v3.min.js"></script>
        <script src="c3-master/c3.min.js"></script>
        
        
    </head>
    <body>
        <div id="data" style="color: #fff;">
        
        </div>
        
        <script>
            var chart = c3.generate({
                bindto: '#data',
                data: {
                    columns: [
                        ['data', 0]
                    ],
                    type: 'gauge',
                    onclick: function (d, i) { console.log("onclick", d, i); },
                    onmouseover: function (d, i) { console.log("onmouseover", d, i); },
                    onmouseout: function (d, i) { console.log("onmouseout", d, i); }
                },
                gauge: {
                //        label: {
                //            format: function(value, ratio) {
                //                return value;
                //            },
                //            show: false // to turn off the min/max labels.
                //        },
                //    min: 0, // 0 is default, //can handle negative min e.g. vacuum / voltage / current flow / rate of change
                //    max: 100, // 100 is default
                //    units: ' %',
                //    width: 39 // for adjusting arc thickness
                    width: 30,
                    min: 0,
                    max: 100
                },
                color: {
                    pattern: ['#00D185', '#F7AB7D', '#FF6929', '#E81417'], // the three color levels for the percentage values.
                    threshold: {
                    // unit: 'value', // percentage is default
                    // max: 400, // 100 is default
                        values: [100, 200, 300, 400]
                    }
                },
                size: {
                    height: 800
                }
            });

            setInterval(function () {
            
                $.getJSON("../aggregated_traffic.pl", function(result){
                    // var sum = Math.round((parseInt(result.sum_in/8)+parseInt(result.sum_out/8))/(1024*1024*1 024));
                    
                    var sum = Math.round(parseInt(result.sum_in)/(1024*1024*1024));
                    console.log(sum);
                    /*
                    $.each(result, function(i, field){
                        $("div").append(field + " ");
                    });
                    */
                    chart.load({
                        columns: [['data', sum]]
                    });
                });
            
            

            }, 3000);
        </script>
    </body>
</html>