283 lines
11 KiB
PHP
283 lines
11 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
$this->load->view('dist/_partials/header');
|
|
?>
|
|
<!-- Main Content -->
|
|
<div class="main-content">
|
|
<section class="section">
|
|
<div class="section-header">
|
|
<h1>Data Hasil Iterasi Tahun <?php $d = $_GET['tahun'];
|
|
echo $d; ?></h1>
|
|
<div class="section-header-breadcrumb">
|
|
<div class="breadcrumb-item active"><a href="#">Dashboard</a></div>
|
|
<div class="breadcrumb-item">Hasil Iterasi</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section-body">
|
|
<div class="container margin-b70">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<?php error_reporting(0); ?>
|
|
|
|
<div id="body">
|
|
<a class="btn btn-primary" href="<?php echo base_url(); ?>cluster/awal">Mulai Awal</a>
|
|
<?php $d = $_GET['tahun'];
|
|
if ($d == 1) {
|
|
$tahun = "?tahun=$d";
|
|
} else {
|
|
$tahun = "?tahun=$d";
|
|
}
|
|
?>
|
|
<a class="btn btn-warning" href="<?php echo base_url(); ?>dist/tampil_peta<?php echo $tahun ?>">Lihat
|
|
Peta</a><br><br>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card" style="color:black;padding:20px 20px">
|
|
<?php
|
|
$SqlDataCentroid = "SELECT * FROM centroid_data where tahun='$d' limit 1";
|
|
$Chasil = $this->db->query($SqlDataCentroid);
|
|
foreach ($Chasil->result_array() as $ok) {
|
|
?>
|
|
<center>
|
|
<h3>Centroid Awal</h3>
|
|
</center>
|
|
<div class="table-responsive">
|
|
<table class="table table-striped" id="table-1">
|
|
<tr>
|
|
<td align="center" style="width: 200px;color:black;background-color:green;font-weight: 800;">
|
|
C1
|
|
</td>
|
|
<td><?php echo $ok['x1']; ?></td>
|
|
<td><?php echo $ok['y1']; ?></td>
|
|
<td><?php echo $ok['y1']; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" style="width: 200px;color:black;background-color:yellow;font-weight: 800;">
|
|
C2</td>
|
|
<td><?php echo $ok['x2']; ?></td>
|
|
<td><?php echo $ok['y2']; ?></td>
|
|
<td><?php echo $ok['y2']; ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" style="width: 200px;color:black;background-color:red;font-weight: 800;">
|
|
C3</td>
|
|
<td><?php echo $ok['x3']; ?></td>
|
|
<td><?php echo $ok['y3']; ?></td>
|
|
<td><?php echo $ok['z3']; ?></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</div>
|
|
<?php } ?>
|
|
<?php
|
|
$SqlCentroid = "SELECT * FROM centroid where tahun='$d'";
|
|
$Chasil = $this->db->query($SqlCentroid);
|
|
$no = 1;
|
|
foreach ($Chasil->result_array() as $ok) {
|
|
?>
|
|
<center>
|
|
<h3>Centroid Iterasi ke-<?php echo $no++; ?></h3>
|
|
</center>
|
|
<div class="table-responsive">
|
|
<table class="table table-striped" id="table-1">
|
|
<tr>
|
|
<td align="center" style="width: 200px;color:black;background-color:green;font-weight: 800;">
|
|
C1
|
|
</td>
|
|
<td><?php echo round($ok['x1'], 6); ?></td>
|
|
<td><?php echo round($ok['x2'], 6); ?></td>
|
|
<td><?php echo round($ok['x3'], 6); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" style="width: 200px;color:black;background-color:yellow;font-weight: 800;">
|
|
C2</td>
|
|
<td><?php echo round($ok['y1'], 6); ?></td>
|
|
<td><?php echo round($ok['y2'], 6); ?></td>
|
|
<td><?php echo round($ok['y3'], 6); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" style="width: 200px;color:black;background-color:red;font-weight: 800;">
|
|
C3</td>
|
|
<td><?php echo round($ok['z1'], 6); ?></td>
|
|
<td><?php echo round($ok['z2'], 6); ?></td>
|
|
<td><?php echo round($ok['z3'], 6); ?></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card" style="color:black;padding:20px 20px">
|
|
<?php foreach ($q->result_array() as $hq) { ?>
|
|
<center>
|
|
<h3>Iterasi ke-<?php echo $hq['iterasi']; ?></h3>
|
|
</center>
|
|
<div class="table-responsive">
|
|
<table id="table_data" class="table table-bordered table-admin" style="color:white;">
|
|
<thead>
|
|
<tr align="center">
|
|
<th>C1</th>
|
|
<th>C2</th>
|
|
<th>C3</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$q2 = $this->db->query('select * from centroid_temp where iterasi=' . $hq['iterasi'] . '');
|
|
foreach ($q2->result() as $tq) {
|
|
$warna1 = "";
|
|
$warna2 = "";
|
|
$warna3 = "";
|
|
if ($tq->c1 == 1) {
|
|
$warna1 = '#008000';
|
|
} else {
|
|
$warna1 = '#D3D3D3';
|
|
}
|
|
if ($tq->c2 == 1) {
|
|
$warna2 = '#008000';
|
|
} else {
|
|
$warna2 = '#D3D3D3';
|
|
}
|
|
if ($tq->c3 == 1) {
|
|
$warna3 = '#008000';
|
|
} else {
|
|
$warna3 = '#D3D3D3';
|
|
}
|
|
|
|
?>
|
|
<tr align="center">
|
|
<td bgcolor="<?php echo $warna1; ?>"><?php echo $tq->c1; ?></td>
|
|
<td bgcolor="<?php echo $warna2; ?>"><?php echo $tq->c2; ?></td>
|
|
<td bgcolor="<?php echo $warna3; ?>"><?php echo $tq->c3; ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</tbody>
|
|
|
|
</table>
|
|
</div>
|
|
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped" id="table-1">
|
|
<thead>
|
|
<tr align="center">
|
|
<th>Kode kecamatan</th>
|
|
<th>Nama Kecamatan</th>
|
|
<th>Predikat</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<?php
|
|
$count_aman = 0;
|
|
$count_rawan = 0;
|
|
$count_sangat_rawan = 0;
|
|
|
|
foreach ($data_hasil->result() as $h) {
|
|
?>
|
|
|
|
<tr align="center">
|
|
<td><?php echo $h->alternatif_kode; ?></td>
|
|
<td><?php echo $h->alternatif_nama; ?></td>
|
|
|
|
<?php
|
|
// Periksa nilai hasil dan tingkatkan counter yang sesuai
|
|
if ($h->hasil == 'Aman') {
|
|
$warn = 'green';
|
|
$count_aman++;
|
|
}
|
|
if ($h->hasil == 'Rawan') {
|
|
$warn = 'yellow';
|
|
$count_rawan++;
|
|
}
|
|
if ($h->hasil == 'Sangat Rawan') {
|
|
$warn = 'red';
|
|
$count_sangat_rawan++;
|
|
}
|
|
?>
|
|
<td style="color:black;" bgcolor="<?php echo $warn; ?>">
|
|
<?php
|
|
echo $h->hasil;
|
|
?>
|
|
</td>
|
|
</tr>
|
|
|
|
<?php
|
|
}
|
|
?>
|
|
<script>
|
|
// Data dari PHP ke JavaScript
|
|
var countAman = <?php echo $count_aman; ?>;
|
|
var countRawan = <?php echo $count_rawan; ?>;
|
|
var countSangatRawan = <?php echo $count_sangat_rawan; ?>;
|
|
</script>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<canvas id="myChart" width="400" height="200"></canvas>
|
|
|
|
</div>
|
|
<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<script>
|
|
var ctx = document.getElementById('myChart').getContext('2d');
|
|
var myChart = new Chart(ctx, {
|
|
type: 'bar',
|
|
data: {
|
|
labels: ['Aman', 'Rawan', 'Sangat Rawan'],
|
|
datasets: [{
|
|
label: 'GRAFIK HASIL CLUSTERING DATA DAERAH RAWAN PENCURIAN TERNAK DI KABUPATEN LUMAJANG MENGGUNAKAN METODE K-MEANS',
|
|
data: [countAman, countRawan, countSangatRawan],
|
|
backgroundColor: [
|
|
'green',
|
|
'yellow',
|
|
'red'
|
|
],
|
|
borderColor: [
|
|
'rgba(0, 128, 0, 1)',
|
|
'rgba(255, 255, 0, 1)',
|
|
'rgba(255, 0, 0, 1)'
|
|
],
|
|
borderWidth: 1
|
|
}]
|
|
},
|
|
options: {
|
|
scales: {
|
|
y: {
|
|
beginAtZero: true
|
|
}
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<?php $this->load->view('dist/_partials/footer'); ?>
|