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
|
function update_view() {
var time1 = $("#time1").val();
var time2 = $("#time2").val();
var stat = $("#stat").val();
//var resolution = $("#resolution").val(); // seems to do nothing
var resolution = 604800;
var stat_obj = stat.split('.')[0]
var stat_type = stat.split('.')[1]
$("body").css("cursor", "progress");
$.ajax({
url: "http://node.sugarlabs.org/",
data: {
cmd: "stats",
start: time1,
end: time2,
source: stat,
resolution: resolution
},
success: function( data ) {
$("body").css("cursor", "default");
fixed_data = data[stat_obj].reduce( function(a,b,c) {
a.push( [new Date ( b[0] * 1000 ) , b[1][stat_type]]);
return a
}, []
);
$('#chartdiv').empty();
$.jqplot('chartdiv', [fixed_data], {
title:stat,
axes: {
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
min:new Date( time1 * 1000),
max:new Date( time2 * 1000),
tickInterval: '1 month',
tickOptions:{formatString:'%Y/%m/%d'}
},
yaxis: {
min:0
}
},
cursor:{
show: true,
zoom:true,
showTooltip:false
}
}
);
},
error: function() {
$("body").css("cursor", "default");
alert("Error fetching statistics from node.");
}
});
}
$(function() {
// Make second input now
$("#time2").val(Math.round((new Date()).getTime()/1000));
$("#update_btn").click(update_view)
});
|