aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms-public.gathering.org/speedometer.js
blob: f301476e02a1937d5d9f8c90fe5ab3f16e29771d (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
$(function () {
	
    $('#container').highcharts({
	    exporting: {
		enabled: false
	    },	
	    chart: {
	        type: 'gauge',
	        plotBackgroundColor: null,
	        plotBackgroundImage: null,
	        plotBorderWidth: 0,
	        plotShadow: false
	    },
	    
	    title: {
	        text: ''
	    },
	    
	    pane: {
	        startAngle: -150,
	        endAngle: 150,
	        background: [{
	            backgroundColor: {
	                linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
	                stops: [
	                    [0, '#FFF'],
	                    [1, '#333']
	                ]
	            },
	            borderWidth: 0,
	            outerRadius: '109%'
	        }, {
	            backgroundColor: {
	                linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
	                stops: [
	                    [0, '#333'],
	                    [1, '#FFF']
	                ]
	            },
	            borderWidth: 1,
	            outerRadius: '107%'
	        }, {
	            // default background
	        }, {
	            backgroundColor: '#DDD',
	            borderWidth: 0,
	            outerRadius: '105%',
	            innerRadius: '103%'
	        }]
	    },
	       
	    // the value axis
	    yAxis: {
	        min: 0,
	        max: 50,
	        
	        tickPixelInterval: 30,
	        tickWidth: 2,
	        tickPosition: 'inside',
	        tickLength: 20,
	        tickColor: '#666',
	        labels: {
	            step: 2,
	            rotation: 'auto',
		    distance: -40,
		    style: {
			fontSize: '20px'
		    }
	        },
	        plotBands: [{
	            from: 0,
	            to: 20,
	            color: '#55BF3B', // green
		    thickness: 20
	        }, {
	            from: 20,
	            to: 40,
	            color: '#DDDF0D', // yellow
		    thickness: 20
	        }, {
	            from: 40,
	            to: 50,
	            color: '#DF5353', // red
		    thickness: 20
	        }]        
	    },
	    plotOptions: {
		gauge: {
			dial: {
				baseWidth: 5,
			},
			pivot: {
				radius: 8,
			},
			dataLabels: {
				borderWidth: 0,
				format: '{y} Gbps',
				style: {
					fontSize: '40px'
				},
				y: 50
			}
		}
	    },			
	
	    series: [{
	        name: 'Speed',
	        data: [0],
	        tooltip: {
	            valueSuffix: ' Gbps'
	        }
	    }]
	
	},
	// Add some life
        function (chart) {
                if (!chart.renderer.forExport) {
                    setInterval(function () {
			$.getJSON('speedometer.json', function(data) {
				var point = chart.series[0].points[0];
				if(data.speed > 1){
					point.update(data.speed);
				}
				if(data.speed > 55){
					point.update(55);
				}
			});
                    }, 1000);
                }
        });
});