-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdualChartDaily.php
More file actions
71 lines (66 loc) · 2.5 KB
/
dualChartDaily.php
File metadata and controls
71 lines (66 loc) · 2.5 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
error_reporting(0);
include('session.php');
include('redirectGraphData.php');
if(!isset($_SESSION['login_user'])){
header("location: index.php"); // Redirecting To Home Page
}
$servername = "localhost";
$username = "p_f21_16";
$password = "e3m6rq";
$dbname = "p_f21_16_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
?>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawStuff);
function drawStuff() {
var data = new google.visualization.arrayToDataTable([
['Time Entered', 'People Entered', 'People Exited'],
<?php
$sql = "SELECT * FROM DailyReportData INNER JOIN DailyReportDataExited ON TimeEntered=TimeExited";
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result)){
echo "['".$row['TimeEntered']."','".$row['PeopleEntered']."',".$row['PeopleExited']."],";
if(((int)$row['PeopleEntered'])>$max){
$max = ((int)$row['PeopleEntered']);
$maxtime = $row['TimeEntered'];
}
if(((int)$row['PeopleEntered'])<=$min){
$min = ((int)$row['PeopleEntered']);
$mintime = $row['TimeEntered'];
}
}
?>
]);
var options = {
width: 800,
chart: {
title: 'Daily Traffic Report Enter/Exit',
subtitle: 'People entered on the left, people exited on the right'
},
bars: 'vertical', // Required for Material Bar Charts.
series: {
0: { axis: 'entered' }, // Bind series 0 to an axis named 'distance'.
1: { axis: 'exited' } // Bind series 1 to an axis named 'brightness'.
},
axes: {
x: {
entered: {label: 'people'}, // Bottom x-axis.
exited: {side: 'top', label: 'Daily Traffic data of enter/exit'} // Top x-axis.
}
}
};
var chart = new google.charts.Bar(document.getElementById('dual_x_div'));
chart.draw(data, options);
};
</script>
</head>
<body>
<div id="dual_x_div" style="width: 900px; height: 500px;"></div>
</body>
</html>