-
Notifications
You must be signed in to change notification settings - Fork 4
/
lastmonth.html
61 lines (58 loc) · 2.09 KB
/
lastmonth.html
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
<?xml version="1.0" encoding="UTF-8"?>
<!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>Powergraph last month</title>
<!--[if IE]><script type="text/javascript" src="excanvas.js"></script><![endif]-->
</head>
<body>
<h1>Powergraph last month</h1>
<div id="graph" style="width:800px;height:400px;"></div>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.flot.js"></script>
<script type="text/javascript">
/*global jQuery:false, $:false */
/*jslint whitespace:false, indent:4, onevar:false, browser:true */
var showDevice;
$(function () {
var options = {
lines: { show: true },
xaxis: { mode: 'time' },
yaxis: {
tickFormatter: function (val, axis) {
return val.toFixed(axis.tickDecimals);
}
},
colors: [ 'red' ]
},
data,
graph = $('#graph'),
timezoneOffset = (new Date()).getTimezoneOffset() * 60000,
fillGraph,
endTime = (new Date()).getTime();
startTime = endTime - 86400*7*1000;
startTimeMonth = endTime - 86400*30*1000;
startTimeYear = endTime - 86400*365*1000;
fillGraph = function (values) {
newValues = [ ];
for (i = 0; i < values.length - 1; i++) {
newValues.push([values[i][0] - timezoneOffset,
values[i][2]]);
newValues.push([values[i+1][0] - timezoneOffset,
values[i][2]]);
}
data = newValues;
$.plot(graph, [ data ], options);
};
$.ajax({
url: '/hourly/' + startTimeMonth + '/' + endTime,
method: 'GET',
dataType: 'json',
success: fillGraph
});
});
</script>
</body>
</html>