first
This commit is contained in:
parent
ca7c86db06
commit
b56f5da5e5
|
@ -15,10 +15,7 @@ public function collection()
|
|||
$dataUji = DataUji::select([
|
||||
'kecamatan',
|
||||
'data_tahun',
|
||||
'jumlah_penduduk',
|
||||
'phbs',
|
||||
'imunisasi_pcv_1',
|
||||
'imunisasi_pcv_2',
|
||||
'rata_rata_imunisasi',
|
||||
'perilaku_merokok',
|
||||
'data_kasus',
|
||||
|
@ -28,11 +25,8 @@ public function collection()
|
|||
])->get()->map(function ($item) {
|
||||
return [
|
||||
$item->kecamatan,
|
||||
$item->jumlah_penduduk,
|
||||
$item->data_tahun,
|
||||
$item->phbs,
|
||||
$item->imunisasi_pcv_1,
|
||||
$item->imunisasi_pcv_2,
|
||||
$item->rata_rata_imunisasi,
|
||||
$item->perilaku_merokok,
|
||||
$item->data_kasus,
|
||||
|
@ -45,11 +39,8 @@ public function collection()
|
|||
|
||||
$hasilPengujian = HasilPengujian::select([
|
||||
'kecamatan',
|
||||
'jumlah_penduduk',
|
||||
'data_tahun',
|
||||
'phbs',
|
||||
'pcv1',
|
||||
'pcv2',
|
||||
'imunisasi',
|
||||
'merokok',
|
||||
'jumlah_kasus',
|
||||
|
@ -60,11 +51,8 @@ public function collection()
|
|||
])->get()->map(function ($item) {
|
||||
return [
|
||||
$item->kecamatan,
|
||||
$item->jumlah_penduduk,
|
||||
$item->data_tahun,
|
||||
$item->phbs,
|
||||
$item->pcv1,
|
||||
$item->pcv2,
|
||||
$item->imunisasi,
|
||||
$item->merokok,
|
||||
$item->jumlah_kasus,
|
||||
|
@ -83,11 +71,8 @@ public function headings(): array
|
|||
{
|
||||
return [
|
||||
'Kecamatan',
|
||||
'Jumlah Penduduk',
|
||||
'Data Tahun',
|
||||
'PHBS',
|
||||
'PCV1',
|
||||
'PCV2',
|
||||
'Imunisasi',
|
||||
'Merokok',
|
||||
'Jumlah Kasus',
|
||||
|
@ -97,4 +82,4 @@ public function headings(): array
|
|||
'Status Prediksi',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,21 @@ class DashboardController extends Controller
|
|||
// Fungsi default, menampilkan data untuk tahun 2023
|
||||
public function index(Request $request)
|
||||
{
|
||||
$tahunTerpilih = 2023;
|
||||
// Ambil tahun-tahun yang tersedia dari data_latih
|
||||
$tahunTersedia = DB::table('data_latih')
|
||||
->select('data_tahun')
|
||||
->distinct()
|
||||
->orderByDesc('data_tahun')
|
||||
->pluck('data_tahun');
|
||||
|
||||
// Ambil tahun dari request (GET), kalau tidak ada pakai yang paling atas (terbaru)
|
||||
$selectedYear = $request->input('tahun', $tahunTersedia->first());
|
||||
|
||||
// Hitung total kasus berdasarkan tahun yang dipilih
|
||||
$jumlahKasusDataLatih = DB::table('data_latih')
|
||||
->where('data_tahun', $selectedYear)
|
||||
->sum('kasus_2023');
|
||||
|
||||
$data_latih = DB::table('data_latih')->get();
|
||||
$stats = DB::table('data_latih')
|
||||
->selectRaw('
|
||||
|
@ -23,7 +37,10 @@ public function index(Request $request)
|
|||
')
|
||||
->first();
|
||||
|
||||
$jumlahKasusDataLatih = DB::table('data_latih')->sum('kasus_2023');
|
||||
// Ambil semua kolom dari tabel data_latih
|
||||
$columns = DB::getSchemaBuilder()->getColumnListing('data_latih');
|
||||
|
||||
$selectedYear = $request->input('tahun') ?? $tahunTersedia->first();
|
||||
|
||||
$kabupatens = DB::table('kabupatens')
|
||||
->join('data_latih', 'kabupatens.nama', '=', 'data_latih.kecamatan')
|
||||
|
@ -44,8 +61,12 @@ public function index(Request $request)
|
|||
->orderByDesc('tahun')
|
||||
->pluck('tahun');
|
||||
|
||||
// Ambil tahun yang dipilih dari input user (jika ada), jika tidak pakai default
|
||||
$selectedYear = $request->input('year') ?? $tahunTerpilih;
|
||||
if (!$selectedYear) {
|
||||
$selectedYear = DB::table('data_latih')
|
||||
->orderByDesc('data_tahun')
|
||||
->value('data_tahun'); // Ambil 1 nilai tahun terbaru
|
||||
}
|
||||
|
||||
|
||||
// Data kasus per bulan untuk tahun yang dipilih
|
||||
$kasusPerBulan = DB::table('kasus')
|
||||
|
@ -84,7 +105,8 @@ public function index(Request $request)
|
|||
'kasusPerBulanByYear',
|
||||
'availableYears',
|
||||
'selectedYear',
|
||||
'tahunTerpilih'
|
||||
'tahunTersedia',
|
||||
'selectedYear'
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -108,7 +130,10 @@ public function dashboard(Request $request)
|
|||
')
|
||||
->first();
|
||||
|
||||
$jumlahKasusDataLatih = DB::table('data_latih')->sum('kasus_2023');
|
||||
$jumlahKasusDataLatih = DB::table('data_latih')
|
||||
->where('data_tahun', $tahunTerpilih)
|
||||
->sum('kasus_2023');
|
||||
|
||||
|
||||
$kabupatens = DB::table('kabupatens')
|
||||
->join('data_latih', 'kabupatens.nama', '=', 'data_latih.kecamatan')
|
||||
|
@ -160,4 +185,4 @@ public function dashboard(Request $request)
|
|||
'selectedYear'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,23 +24,20 @@ public function import(Request $request)
|
|||
foreach ($rows as $index => $row) {
|
||||
if ($index === 0) continue; // skip header
|
||||
|
||||
$kecamatan = trim($row[1]); // Kolom ke-1: Kecamatan (index 1 karena id di kolom 0)
|
||||
$kecamatan = trim($row[1]); // Kolom ke-1: Kecamatan
|
||||
if (empty($kecamatan)) continue;
|
||||
|
||||
$dataToInsert[] = [
|
||||
'kecamatan' => $kecamatan,
|
||||
'jumlah_penduduk' => is_numeric($row[2]) ? (int)$row[2] : 0, // kolom 2
|
||||
'data_tahun' => is_numeric($row[3]) ? (int)$row[3] : 2023, // kolom 3
|
||||
'phbs' => is_numeric($row[4]) ? (float)$row[4] : 0,
|
||||
'pcv1' => is_numeric($row[5]) ? (float)$row[5] : 0,
|
||||
'pcv2' => is_numeric($row[6]) ? (float)$row[6] : 0,
|
||||
'imunisasi' => is_numeric($row[7]) ? (float)$row[7] : 0,
|
||||
'merokok' => is_numeric($row[8]) ? (float)$row[8] : 0,
|
||||
'kasus_2023' => is_numeric($row[9]) ? (int)$row[9] : 0,
|
||||
'latitude' => is_numeric($row[10]) ? (float)($row[10] / 1000000) : 0,
|
||||
'longitude' => is_numeric($row[11]) ? (float)($row[11] / 1000000) : 0,
|
||||
'prediksi_tahun' => isset($row[12]) && is_numeric($row[12]) ? (int)$row[12] : null,
|
||||
'hipotesis' => isset($row[13]) && $row[13] !== '' ? trim($row[13]) : null,
|
||||
'data_tahun' => is_numeric($row[2]) ? (int)$row[2] : 2023, // Data Tahun
|
||||
'phbs' => is_numeric($row[3]) ? (float)$row[3] : 0, // PHBS
|
||||
'imunisasi' => is_numeric($row[4]) ? (float)$row[4] : 0, // Imunisasi
|
||||
'merokok' => is_numeric($row[5]) ? (float)$row[5] : 0, // Perilaku Merokok
|
||||
'kasus_2023' => is_numeric($row[6]) ? (int)$row[6] : 0, // Data Kasus
|
||||
'latitude' => is_numeric($row[7]) ? (float)($row[7] / 1000000) : 0, // Latitude
|
||||
'longitude' => is_numeric($row[8]) ? (float)($row[8] / 1000000) : 0, // Longitude
|
||||
'prediksi_tahun' => isset($row[9]) && is_numeric($row[9]) ? (int)$row[9] : null, // Prediksi Tahun
|
||||
'hipotesis' => isset($row[10]) && $row[10] !== '' ? trim($row[10]) : null, // Status
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
|
|
|
@ -167,7 +167,7 @@ public function index()
|
|||
}
|
||||
public function proses(Request $request)
|
||||
{
|
||||
$dataLatih = DataLatih::all();
|
||||
$dataLatih = DataLatih::inRandomOrder()->get();
|
||||
$persentase = (int) $request->input('persentase');
|
||||
$total = $dataLatih->count();
|
||||
|
||||
|
@ -203,19 +203,15 @@ public function proses(Request $request)
|
|||
$hipotesisAsli = ucfirst(strtolower($data->hipotesis));
|
||||
$prediksi = $this->naiveBayes($data, $dataLatihUpdate);
|
||||
|
||||
// Prediksi tahun otomatis = data_tahun + 1, jika data_tahun ada
|
||||
$prediksiTahun = $data->data_tahun ? ((int)$data->data_tahun + 1) : null;
|
||||
$prediksiTahun = ((int)$data->data_tahun <= 2024) ? 2025 : ((int)$data->data_tahun + 1);
|
||||
|
||||
$status = $prediksi === $hipotesisAsli ? '✅ Benar' : '❌ Salah';
|
||||
|
||||
$hasil[] = [
|
||||
'id' => $data->id,
|
||||
'kabupaten' => $data->kecamatan,
|
||||
'jumlah_penduduk' => $data->jumlah_penduduk,
|
||||
'data_tahun' => $data->data_tahun,
|
||||
'phbs' => $data->phbs,
|
||||
'pcv1' => $data->pcv1,
|
||||
'pcv2' => $data->pcv2,
|
||||
'imunisasi' => $data->imunisasi,
|
||||
'merokok' => $data->merokok,
|
||||
'kasus_2023' => $data->kasus_2023,
|
||||
|
@ -231,11 +227,8 @@ public function proses(Request $request)
|
|||
if (!$hasilSudahAda) {
|
||||
HasilPengujian::create([
|
||||
'kecamatan' => $data->kecamatan,
|
||||
'jumlah_penduduk' => $data->jumlah_penduduk,
|
||||
'data_tahun' => $data->data_tahun,
|
||||
'phbs' => $data->phbs,
|
||||
'pcv1' => $data->pcv1,
|
||||
'pcv2' => $data->pcv2,
|
||||
'imunisasi' => $data->imunisasi,
|
||||
'merokok' => $data->merokok,
|
||||
'jumlah_kasus' => $data->kasus_2023 ?? 0,
|
||||
|
|
|
@ -14,11 +14,8 @@ class DataLatih extends Model
|
|||
// Tambahkan fillable agar bisa mass assignment tanpa error
|
||||
protected $fillable = [
|
||||
'kecamatan',
|
||||
'jumlah_penduduk',
|
||||
'data_tahun',
|
||||
'phbs',
|
||||
'pcv1',
|
||||
'pcv2',
|
||||
'imunisasi',
|
||||
'merokok',
|
||||
'kasus_2023',
|
||||
|
|
|
@ -11,23 +11,20 @@
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('data_latih', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kecamatan');
|
||||
$table->integer('jumlah_penduduk');
|
||||
$table->integer('data_tahun')->nullable();
|
||||
$table->float('phbs');
|
||||
$table->float('pcv1');
|
||||
$table->float('pcv2');
|
||||
$table->float('imunisasi'); // rata-rata
|
||||
$table->float('merokok');
|
||||
$table->integer('kasus_2023');
|
||||
$table->decimal('latitude', 10, 7);
|
||||
$table->decimal('longitude', 10, 7);
|
||||
$table->string('hipotesis')->nullable(); // hasil naive bayes
|
||||
$table->integer('prediksi_tahun')->nullable(); // <--- tambahkan ini
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('data_latih', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kecamatan');
|
||||
$table->integer('data_tahun')->nullable(); // sesuai: $row[2]
|
||||
$table->float('phbs'); // sesuai: $row[3]
|
||||
$table->float('imunisasi'); // sesuai: $row[4]
|
||||
$table->float('merokok'); // sesuai: $row[5]
|
||||
$table->integer('kasus_2023'); // sesuai: $row[6]
|
||||
$table->decimal('latitude', 10, 7); // sesuai: $row[7] / 1000000
|
||||
$table->decimal('longitude', 10, 7); // sesuai: $row[8] / 1000000
|
||||
$table->integer('prediksi_tahun')->nullable(); // sesuai: $row[9]
|
||||
$table->string('hipotesis')->nullable(); // sesuai: $row[10]
|
||||
$table->timestamps(); // created_at & updated_at
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,11 +14,8 @@ public function up(): void
|
|||
Schema::create('hasil_pengujian', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kecamatan');
|
||||
$table->integer('jumlah_penduduk');
|
||||
$table->integer('data_tahun')->nullable();
|
||||
$table->float('phbs');
|
||||
$table->float('pcv1');
|
||||
$table->float('pcv2');
|
||||
$table->float('imunisasi');
|
||||
$table->float('merokok');
|
||||
$table->integer('jumlah_kasus');
|
||||
|
|
|
@ -4,29 +4,31 @@
|
|||
@section('content')
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
|
||||
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesom
|
||||
<!-- Leaflet CSS -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-doughnutlabel"></script>
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster/dist/MarkerCluster.css" />
|
||||
<script src="https://unpkg.com/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
|
||||
|
||||
<style>
|
||||
.gradient-orange {
|
||||
background: linear-gradient(135deg, #ff9800, #ff5722),
|
||||
url('/assets/bg-wave-orange.svg');
|
||||
background: linear-gradient(135deg, #ff9800, #ff5722);
|
||||
}
|
||||
|
||||
.gradient-blue {
|
||||
background: linear-gradient(135deg, #2196f3, #3f51b5),
|
||||
url('/assets/bgimunisasi.png');
|
||||
background: linear-gradient(135deg, #2196f3, #3f51b5);
|
||||
}
|
||||
|
||||
.gradient-green {
|
||||
background: linear-gradient(135deg, #4caf50, #009688),
|
||||
url('/assets/bg-wave-green.svg');
|
||||
background: linear-gradient(135deg, #4caf50, #009688);
|
||||
}
|
||||
|
||||
.gradient-purple {
|
||||
background: linear-gradient(135deg, #9c27b0, #673ab7),
|
||||
url('/assets/bg-wave-purple.svg');
|
||||
background: linear-gradient(135deg, #9c27b0, #673ab7);
|
||||
}
|
||||
|
||||
.card-gradient {
|
||||
color: white;
|
||||
border-radius: 1rem;
|
||||
|
@ -117,13 +119,20 @@
|
|||
}
|
||||
</style>
|
||||
@if(session('login_success'))
|
||||
<div class="alert alert-success alert-dismissible fade show position-fixed" style="top: 60px; right: 30px; z-index: 1050; min-width: 300px; max-width: 400px;" role="alert">
|
||||
<strong>🎉 {{ session('login_success') }}</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
Swal.fire({
|
||||
title: 'Login Sukses!',
|
||||
text: '{{ session("login_success") }}',
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
setTimeout(function () {
|
||||
const alert = document.querySelector('.alert');
|
||||
if (alert) {
|
||||
alert.classList.remove('show');
|
||||
alert.classList.add('fade');
|
||||
setTimeout(() => alert.remove(), 500);
|
||||
}
|
||||
}, 3000);
|
||||
</script>
|
||||
@endif
|
||||
|
||||
|
@ -186,16 +195,35 @@
|
|||
</div>
|
||||
</div>
|
||||
<!-- Jumlah Kasus -->
|
||||
<div class="col-md-6 col-xl-3 mb-4">
|
||||
<div class="card-gradient gradient-purple h-100 d-flex flex-column justify-content-center">
|
||||
<div class="col-md-6 col-xl-3 mb-4 position-relative">
|
||||
<div class="card-gradient gradient-purple h-100 d-flex flex-column justify-content-center p-3 position-relative">
|
||||
|
||||
{{-- Dropdown Tahun di Pojok Kanan Atas --}}
|
||||
@if($tahunTersedia->count() > 1)
|
||||
<div style="position: absolute; top: 0.75rem; right: 0.75rem;">
|
||||
<form method="GET" action="{{ route('admin.dashboard') }}">
|
||||
<select name="tahun" id="tahun" class="form-select form-select-sm w-auto" style="font-size: 0.75rem;" onchange="this.form.submit()">
|
||||
@foreach($tahunTersedia as $tahun)
|
||||
<option value="{{ $tahun }}" {{ $tahun == $selectedYear ? 'selected' : '' }}>
|
||||
{{ $tahun }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="mb-3">
|
||||
<i class="fas fa-notes-medical fa-2x"></i>
|
||||
</div>
|
||||
|
||||
<h5 class="card-title">Jumlah Kasus</h5>
|
||||
<h3>{{ $jumlahKasusDataLatih }}</h3>
|
||||
<p>Total kasus Infeksi Saluran Pernapasan Akut pada balita selama 1 tahun</p>
|
||||
<p>Total kasus Infeksi Saluran Pernapasan Akut pada balita di tahun {{ $selectedYear }}</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-lg-4 mb-4">
|
||||
<div class="card shadow-sm border-0 card-custom">
|
||||
|
@ -204,7 +232,8 @@
|
|||
<canvas id="kasusChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div><div class="col-md-6 col-lg-8 mb-4">
|
||||
</div>
|
||||
<div class="col-md-6 col-lg-8 mb-4">
|
||||
<div class="card shadow-sm border-0 card-custom">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title d-flex justify-content-between align-items-center">
|
||||
|
@ -302,59 +331,73 @@
|
|||
}
|
||||
});
|
||||
</script>
|
||||
<!-- Load CSS & JS Leaflet + Cluster -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster/dist/MarkerCluster.css" />
|
||||
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
|
||||
<script src="https://unpkg.com/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
|
||||
<script>
|
||||
var map = L.map('situbondo-map').setView([-7.716, 114.016], 10);
|
||||
var map = L.map('situbondo-map').setView([-7.716, 114.016], 10);
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© OpenStreetMap contributors'
|
||||
}).addTo(map);
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© OpenStreetMap contributors'
|
||||
}).addTo(map);
|
||||
|
||||
var dataLatih = @json($data_latih);
|
||||
var dataLatih = @json($data_latih);
|
||||
|
||||
function createSimpleGradientPin(colorStart, colorEnd) {
|
||||
const svg = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="32" viewBox="0 0 24 38">
|
||||
<defs>
|
||||
<linearGradient id="grad" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="${colorStart}" />
|
||||
<stop offset="100%" stop-color="${colorEnd}" />
|
||||
</linearGradient>
|
||||
<filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
|
||||
<feDropShadow dx="0" dy="2" stdDeviation="2" flood-color="#000" flood-opacity="0.15"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<path fill="url(#grad)" filter="url(#shadow)" d="M12 0C7 0 3 6 3 12c0 7.2 9 25 9 25s9-17.8 9-25c0-6-4-12-9-12z"/>
|
||||
<circle fill="white" cx="12" cy="12" r="4" opacity="0.85"/>
|
||||
</svg>
|
||||
`;
|
||||
return L.icon({
|
||||
iconUrl: "data:image/svg+xml;base64," + btoa(svg),
|
||||
iconSize: [20, 32],
|
||||
iconAnchor: [10, 32],
|
||||
popupAnchor: [0, -32]
|
||||
var iconRawan = L.icon({
|
||||
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-red.png',
|
||||
iconSize: [25, 41],
|
||||
iconAnchor: [12, 41],
|
||||
popupAnchor: [1, -34],
|
||||
shadowUrl: 'https://unpkg.com/leaflet@1.9.3/dist/images/marker-shadow.png',
|
||||
shadowSize: [41, 41]
|
||||
});
|
||||
}
|
||||
|
||||
var iconRawan = createSimpleGradientPin('#e55353', '#b63737'); // merah gradasi
|
||||
var iconWaspada = createSimpleGradientPin('#4dbd4d', '#2d7f2d'); // hijau gradasi
|
||||
var iconWaspada = L.icon({
|
||||
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-green.png',
|
||||
iconSize: [25, 41],
|
||||
iconAnchor: [12, 41],
|
||||
popupAnchor: [1, -34],
|
||||
shadowUrl: 'https://unpkg.com/leaflet@1.9.3/dist/images/marker-shadow.png',
|
||||
shadowSize: [41, 41]
|
||||
});
|
||||
|
||||
dataLatih.forEach(function(item) {
|
||||
var statusLabel = (item.hipotesis === 'Naik') ? 'Naik' : 'Turun';
|
||||
var chosenIcon = (item.hipotesis === 'Naik') ? iconRawan : iconWaspada;
|
||||
var markers = L.layerGroup().addTo(map);
|
||||
|
||||
var marker = L.marker([item.latitude, item.longitude], { icon: chosenIcon }).addTo(map);
|
||||
dataLatih.forEach(function(item, index) {
|
||||
var lat = parseFloat(item.latitude);
|
||||
var lng = parseFloat(item.longitude);
|
||||
|
||||
var popupContent = `
|
||||
<strong>Nama Lokasi:</strong> ${item.kecamatan || 'Tidak diketahui'}<br>
|
||||
<strong>Status:</strong> ${statusLabel}<br>
|
||||
<strong>Persentase PHBS Baik:</strong> ${item.phbs !== null ? item.phbs.toFixed(2) : '0'}%<br>
|
||||
<strong>Persentase Imunisasi:</strong> ${item.imunisasi !== null ? item.imunisasi.toFixed(2) : '0'}%<br>
|
||||
<strong>Persentase Merokok:</strong> ${item.merokok !== null ? item.merokok.toFixed(2) : '0'}%<br>
|
||||
<strong>Jumlah Kasus ISPA:</strong> ${item.kasus_2023 !== null ? item.kasus_2023 : '0'}<br>
|
||||
`;
|
||||
if (isNaN(lat) || isNaN(lng)) {
|
||||
console.warn(`Koordinat tidak valid pada index ${index}:`, item);
|
||||
return;
|
||||
}
|
||||
|
||||
marker.bindPopup(popupContent);
|
||||
});
|
||||
console.log(`Menambahkan marker index ${index}:`, {
|
||||
lat: lat,
|
||||
lng: lng,
|
||||
status: item.hipotesis,
|
||||
kecamatan: item.kecamatan
|
||||
});
|
||||
|
||||
var status = (item.hipotesis || '').toLowerCase();
|
||||
var chosenIcon = (status === 'naik') ? iconRawan : iconWaspada;
|
||||
|
||||
var marker = L.marker([lat, lng], { icon: chosenIcon });
|
||||
|
||||
var popupContent = `
|
||||
<strong>Nama Lokasi:</strong> ${item.kecamatan || '-'}<br>
|
||||
<strong>Status:</strong> ${item.hipotesis || '-'}<br>
|
||||
<strong>Persentase PHBS Baik:</strong> ${Number(item.phbs || 0).toFixed(2)}%<br>
|
||||
<strong>Persentase Imunisasi:</strong> ${Number(item.imunisasi || 0).toFixed(2)}%<br>
|
||||
<strong>Persentase Merokok:</strong> ${Number(item.merokok || 0).toFixed(2)}%<br>
|
||||
<strong>Jumlah Kasus ISPA:</strong> ${item.kasus_2023 ?? 0}
|
||||
`;
|
||||
|
||||
marker.bindPopup(popupContent);
|
||||
markers.addLayer(marker);
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// Data dari controller Laravel
|
||||
|
|
|
@ -61,13 +61,10 @@
|
|||
<tr>
|
||||
<th>No</th>
|
||||
<th>Kecamatan</th>
|
||||
<th>Jumlah Penduduk</th>
|
||||
<th>Data Tahun</th>
|
||||
<th>PHBS</th>
|
||||
<th>PCV 1</th>
|
||||
<th>PCV 2</th>
|
||||
<th>Imunisasi (Rata-rata)</th>
|
||||
<th>Merokok</th>
|
||||
<th>Perilaku Hidup Bersih dan Sehat</th>
|
||||
<th>Imunisasi PCV</th>
|
||||
<th>Kebiasaan Merokok Orang Tua</th>
|
||||
<th>Kasus</th>
|
||||
<th>Latitude</th>
|
||||
<th>Longitude</th>
|
||||
|
@ -80,11 +77,8 @@
|
|||
<tr>
|
||||
<td>{{ $data_latih->firstItem() + $index }}</td>
|
||||
<td>{{ $data->kecamatan }}</td>
|
||||
<td>{{ $data->jumlah_penduduk }}</td>
|
||||
<td>{{ $data->data_tahun }}</td>
|
||||
<td>{{ $data->phbs }}</td>
|
||||
<td>{{ $data->pcv1 }}</td>
|
||||
<td>{{ $data->pcv2 }}</td>
|
||||
<td>{{ $data->imunisasi }}</td>
|
||||
<td>{{ $data->merokok }}</td>
|
||||
<td>{{ $data->kasus_2023 }}</td>
|
||||
|
|
|
@ -29,11 +29,8 @@
|
|||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Kecamatan</th>
|
||||
<th>Jumlah Penduduk</th>
|
||||
<th>Data Tahun</th>
|
||||
<th>PHBS</th>
|
||||
<th>PCV1</th>
|
||||
<th>PCV2</th>
|
||||
<th>Imunisasi</th>
|
||||
<th>Merokok</th>
|
||||
<th>Jumlah Kasus</th>
|
||||
|
@ -47,17 +44,24 @@
|
|||
@forelse($dataPrediksi as $data)
|
||||
<tr>
|
||||
<td>{{ $data->kecamatan }}</td>
|
||||
<td>{{ $data->jumlah_penduduk }}</td>
|
||||
<td>{{ $data->data_tahun }}</td>
|
||||
<td>{{ $data->phbs }}</td>
|
||||
<td>{{ $data->pcv1 ?? $data->imunisasi_pcv_1 }}</td>
|
||||
<td>{{ $data->pcv2 ?? $data->imunisasi_pcv_2 }}</td>
|
||||
<td>{{ $data->imunisasi ?? $data->rata_rata_imunisasi }}</td>
|
||||
<td>{{ $data->merokok ?? $data->perilaku_merokok }}</td>
|
||||
<td>{{ $data->jumlah_kasus ?? $data->data_kasus }}</td>
|
||||
<td>{{ $data->latitude }}</td>
|
||||
<td>{{ $data->longitude }}</td>
|
||||
<td>{{ isset($data->data_tahun) ? $data->data_tahun + 1 : '' }}</td>
|
||||
<td>
|
||||
@if(isset($data->data_tahun))
|
||||
@if(in_array((int)$data->data_tahun, [2023, 2024]))
|
||||
2025
|
||||
@else
|
||||
{{ (int)$data->data_tahun + 1 }}
|
||||
@endif
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge {{ $data->status_prediksi == 'Naik' ? 'bg-danger' : 'bg-success' }}">
|
||||
{{ $data->status_prediksi }}
|
||||
|
|
|
@ -213,11 +213,8 @@
|
|||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Kecamatan</th>
|
||||
<th>Jumlah Penduduk</th>
|
||||
<th>Data Tahun</th>
|
||||
<th>PHBS</th>
|
||||
<th>PCV1</th>
|
||||
<th>PCV2</th>
|
||||
<th>Imunisasi</th>
|
||||
<th>Merokok</th>
|
||||
<th>Jumlah Kasus</th>
|
||||
|
@ -235,17 +232,24 @@
|
|||
<tr>
|
||||
<td>{{ $item['id'] }}</td>
|
||||
<td>{{ $item['kabupaten'] }}</td>
|
||||
<td>{{ $item['jumlah_penduduk'] }}</td>
|
||||
<td>{{ $item['data_tahun'] ?? '-' }}</td>
|
||||
<td>{{ $item['phbs'] }}</td>
|
||||
<td>{{ $item['pcv1'] }}</td>
|
||||
<td>{{ $item['pcv2'] }}</td>
|
||||
<td>{{ $item['imunisasi'] }}</td>
|
||||
<td>{{ $item['merokok'] }}</td>
|
||||
<td>{{ $item['kasus_2023'] }}</td>
|
||||
<td>{{ $item['latitude'] }}</td>
|
||||
<td>{{ $item['longitude'] }}</td>
|
||||
<td>{{ isset($item['data_tahun']) ? $item['data_tahun'] + 1 : '-' }}</td>
|
||||
<td>
|
||||
@if(isset($item['data_tahun']))
|
||||
@if(in_array((int)$item['data_tahun'], [2023, 2024]))
|
||||
2025
|
||||
@else
|
||||
{{ (int)$item['data_tahun'] + 1 }}
|
||||
@endif
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
@unless ($from_excel)
|
||||
<td>{{ $item['hipotesis_asli'] }}</td>
|
||||
@endunless
|
||||
|
|
Loading…
Reference in New Issue