-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetailstestmessage.php
More file actions
115 lines (99 loc) · 4.27 KB
/
detailstestmessage.php
File metadata and controls
115 lines (99 loc) · 4.27 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="wordcloud.js"></script>
<?php
require("station.php");
require("db.php");
if (isset($_GET['station'])) {
$station = htmlspecialchars($_GET['station']);
$sql = "SELECT * FROM `responses` WHERE `station` = '".$station."';";
$result = mysqli_query($con, $sql);
$rows = mysqli_num_rows($result);
if ($rows != 0) {
//echo '<script type="text/javascript" src="wordcloud.js"></script>';
$station = new Station($station);
$sql = "SELECT COUNT(*) as freq FROM `responses` WHERE feedback = 1 AND station = '".$station->name."'";
$result = mysqli_query($con, $sql);
$value = mysqli_fetch_object($result);
$station->positive = $value->freq;;
$sql = "SELECT COUNT(*) as freq FROM `responses` WHERE feedback = 0 AND station = '".$station->name."'";
$result = mysqli_query($con, $sql);
$value = mysqli_fetch_object($result);
$station->negative = $value->freq;;
// HI KENNETH. IMPT VARS HERE
$yes = $station->positive;
$no = $station->negative;
$total = $station->getTotal();
$stationName = $station->name;
//echo "<br /> Positive: " . $yes;
//echo "<br /> Negative: " . $no;
$rowsString = "[['Positive (".$yes.")',".$yes."],['Negative (".$no.")',".$no."]]";
// WORD CLOUD??
// Messages
$sql = "SELECT * FROM `responses` WHERE station = '".$station->name."';";
$result = mysqli_query($con, $sql);
$rows = mysqli_num_rows($result);
$messages = array();
while($array = mysqli_fetch_array($result)) {
if (!$array['message'] == "") {
array_push($messages, $array['message']);
}
}
echo '<input id="list" value="'.implode($messages, ' ').'"></input>';
$rowsTables = "[['".implode($messages, "'],['")."']]";
}
}
?>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart','table']});
google.setOnLoadCallback(drawChart);
google.setOnLoadCallback(drawTableMessage);
var canvas = document.getElementById('canvvas');
var list = document.getElementById('list').value.split(' ');
drawCanvas();
function drawCanvas(){
if (WordCloud.isSupported) {
var options = {'color':'rgb(0,0,0)',
'backgroundColor':'rgb(255,255,255)'};
WordCloud(canvas, options)
}
}
function drawTableMessage() {
var datas = new google.visualization.DataTable();
datas.addColumn('string', 'Response');
datas.addRows(<?php echo $rowsTables; ?>);
// Set chart options
var optiones = {'showRowNumber':true,
'alternatingRowStyle':true,
'width':700};
var charts = new google.visualization.Table(document.getElementById('table_div'));
charts.draw(datas, optiones);
}
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Response');
data.addColumn('number', 'Number');
data.addRows(<?php echo $rowsString; ?>);
// Set chart options
var options = {'title':'<?php echo $stationName; ?>',
'width':500,
'height':500,
'is3D':true,
'colors': ['#29d629','#FF0000'],
'backgroundColor':'black',
'titleTextStyle':{color:'white',fontName:'cursive',fontSize:'50'},
'legendTextStyle':{color:'white',fontName:'Gadget'},
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div"></div>
<div><canvas id="canvvas"></canvas></div>
Messages: <br />
<div id="table_div"></div>
</body>
</html>