forked from dinamic/bw
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
55 lines (44 loc) · 1.5 KB
/
index.php
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
<?php
session_start();
session_destroy();
session_start();
?>
<html>
<head>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery.flot.js"></script>
<script id="source" language="javascript" type="text/javascript">
$(document).ready(function() {
var options = {
lines: { show: true },
points: { show: true },
xaxis: { mode: "time" }
};
var data = [];
var placeholder = $("#placeholder");
$.plot(placeholder, data, options);
var iteration = 0;
function fetchData() {
++iteration;
function onDataReceived(series) {
// we get all the data in one go, if we only got partial
// data, we could merge it with what we already got
data = [ series ];
$.plot($("#placeholder"), data, options);
}
$.ajax({
url: "data.php",
method: 'GET',
dataType: 'json',
success: onDataReceived
});
setTimeout(fetchData, 1060);
}
setTimeout(fetchData, 1000);
});
</script>
</head>
<body>
<div id="placeholder" style="width:600px;height:300px;"></div>
</body>
</html>