-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path24hours.php
More file actions
50 lines (45 loc) · 1.7 KB
/
24hours.php
File metadata and controls
50 lines (45 loc) · 1.7 KB
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
<!-- Created using code from: https://github.com/hamlesh/GraphMailbox //-->
<?
$iam = "24_hours"; //set page name - needs to be unique for each
include('conf/db.php');
// get some data
$sql = "SELECT * FROM inbox
ORDER BY LTS desc
LIMIT 24";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$num_rows = mysql_num_rows($result);
$lastitemcount = $row['LogCount'];
?>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Date');
data.addColumn('number', 'Items');
data.addRows([
<?
$graphdata = "";
do {
$graphdata = $graphdata."['".$row['LogHour'].":00 ', ".$row['LogCount']."],";
} while ( $row = mysql_fetch_array($result) );
echo substr_replace($graphdata,"",-1);
?>
]);
// Set some chart options
var options = {
title:'Last 24 hours (<?=$lastitemcount?>)',
hAxis: {title: 'Last 24 hours up to <?=date(H).":00 ".date(d)."/".date(F)?>'},
vAxis: {title: 'Number of Emails'},
legend: {position: 'none'}
};
//uncomment based on the type of chart you want
//var chart = new google.visualization.ColumnChart(document.getElementById('chart_<?=$iam?>')); // bar graph
//var chart = new google.visualization.LineChart(document.getElementById('chart_<?=$iam?>')); // line graph
var chart = new google.visualization.AreaChart(document.getElementById('chart_<?=$iam?>')); // area graph
chart.draw(data, options);
}
</script>
<div id="chart_<?=$iam?>" style="width: 100%; height:100%;"></div>