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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
session_start();
require 'header.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>GRAFIK</title>
<script type="text/javascript" src="chartjs/Chart.js"></script>
</head>
<body>
<style type="text/css">
body {
font-family: roboto;
}
table {
margin: 0px auto;
width: 500px;
}
</style>
<center>
<h2>GRAFIK KESELURUHAN KELUHAN YANG DIBERIKAN USER</h2>
</center>
<div style="width: 800px;margin: 0px auto;">
<canvas id="myChart"></canvas>
</div>
<br />
<br />
<table border="1">
<thead>
<tr>
<th>No</th>
<th>Jenis Keluhan</th>
<th>Jumlah Keluhan</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
$data = mysqli_query($conn, "select * from keluhan");
?>
<?php
$jenis = query("SELECT * FROM jeniskeluhan");
?>
<?php foreach ($jenis as $key) : ?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $key['jenis']; ?></td>
<td><?php
$d = mysqli_fetch_array($data);
$a = $key['id_jenis'];
$jumlah = mysqli_query($conn, "select * from keluhan where id_jenis= $a ");
echo mysqli_num_rows($jumlah);
?>
</td>
</tr>
<?php endforeach; ?>
<?php
?>
</tbody>
</table>
<script>
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Bantuan Masyarakat", "Insfrastruktur Buruk", "Layanan Kesehatan", "Pemungutan Liar", "Petugas tidak ramah", "Tindakan KKN"],
datasets: [{
label: '',
data: [
<?php
$jumlah_1 = mysqli_query($conn, "select * from keluhan where id_jenis= 1 ");
echo mysqli_num_rows($jumlah_1);
?>,
<?php
$jumlah_2 = mysqli_query($conn, "select * from keluhan where id_jenis= 2 ");
echo mysqli_num_rows($jumlah_2);
?>,
<?php
$jumlah_3 = mysqli_query($conn, "select * from keluhan where id_jenis= 3 ");
echo mysqli_num_rows($jumlah_3);
?>,
<?php
$jumlah_4 = mysqli_query($conn, "select * from keluhan where id_jenis= 4 ");
echo mysqli_num_rows($jumlah_4);
?>,
<?php
$jumlah_5 = mysqli_query($conn, "select * from keluhan where id_jenis= 5 ");
echo mysqli_num_rows($jumlah_5);
?>,
<?php
$jumlah_6 = mysqli_query($conn, "select * from keluhan where id_jenis= 6 ");
echo mysqli_num_rows($jumlah_6);
?>
],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(75, 92, 192, 0.2)',
'rgba(75, 195, 192, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
</body>
</html>
</html>
<?php
require 'footer.php';
?>