-
Notifications
You must be signed in to change notification settings - Fork 9
/
stats.php
38 lines (36 loc) · 1.12 KB
/
stats.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
<?php
require_once './lib/scrich.php';
$drawing_m = new DrawingModel();
$drawings = $drawing_m->get_all_grouped_by_date();
?><!doctype html>
<html>
<head>
<title></title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
var drawings = <?php echo json_encode($drawings); ?>;
google.load("visualization", "1", {packages:["corechart"]});
function drawChart(chart, title, megaday) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Day');
data.addColumn('number', 'Drawings');
data.addRows(drawings.length);
for (var i=0; i < drawings.length; i++) {
if (!megaday && i === 1) continue;
data.setValue(i, 0, drawings[i].date_day);
data.setValue(i, 1, drawings[i].total-0);
}
chart.draw(data, {width: window.innerWidth, height: 500, title: title});
}
function getChart(id) {
return new google.visualization.LineChart(document.getElementById(id));
}
google.setOnLoadCallback(function(){
drawChart(getChart('chart'), 'Drawings by day', true);
});
</script>
</head>
<body>
<div id="chart"></div>
</body>
</html>