85 lines
3.0 KiB
PHP
85 lines
3.0 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Dashboard')
|
|
|
|
@section('content')
|
|
<div class="container mt-5">
|
|
<h1 class="mb-4">Dashboard RSAB Harapan Kita</h1>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 mb-4">
|
|
<h4>Jumlah Pasien per Hari</h4>
|
|
<canvas id="pasienChart"></canvas>
|
|
</div>
|
|
<div class="col-md-6 mb-4">
|
|
<h4>Pendapatan per Hari</h4>
|
|
<canvas id="pendapatanChart"></canvas>
|
|
</div>
|
|
|
|
<div class="col-md-6 mb-4">
|
|
<h4>Distribusi Jenis Kelamin Pasien</h4>
|
|
<canvas id="genderChart"></canvas>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@section('scripts')
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<script>
|
|
// Data Pasien per Hari
|
|
const pasienLabels = {!! $pasienPerHari->isNotEmpty() ? json_encode($pasienPerHari->pluck('tanggal')->toArray()) : json_encode(['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu']) !!};
|
|
const pasienData = {!! $pasienPerHari->isNotEmpty() ? json_encode($pasienPerHari->pluck('jumlah')->toArray()) : json_encode([12, 19, 3, 5, 2, 3, 7]) !!};
|
|
|
|
const pasienCtx = document.getElementById('pasienChart').getContext('2d');
|
|
new Chart(pasienCtx, {
|
|
type: 'bar',
|
|
data: {
|
|
labels: pasienLabels,
|
|
datasets: [{
|
|
label: 'Jumlah Pasien',
|
|
data: pasienData,
|
|
backgroundColor: 'rgba(54, 162, 235, 0.7)',
|
|
}]
|
|
}
|
|
});
|
|
|
|
// Data Pendapatan per Hari
|
|
const pendapatanLabels = {!! $pendapatanPerHari->isNotEmpty() ? json_encode($pendapatanPerHari->pluck('tanggal')->toArray()) : json_encode(['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu']) !!};
|
|
const pendapatanData = {!! $pendapatanPerHari->isNotEmpty() ? json_encode($pendapatanPerHari->pluck('total')->toArray()) : json_encode([1200000, 1900000, 300000, 500000, 200000, 300000, 700000]) !!};
|
|
|
|
const pendapatanCtx = document.getElementById('pendapatanChart').getContext('2d');
|
|
new Chart(pendapatanCtx, {
|
|
type: 'line',
|
|
data: {
|
|
labels: pendapatanLabels,
|
|
datasets: [{
|
|
label: 'Pendapatan (Rp)',
|
|
data: pendapatanData,
|
|
backgroundColor: 'rgba(255, 99, 132, 0.7)',
|
|
borderColor: 'rgba(255, 99, 132, 1)',
|
|
borderWidth: 2,
|
|
fill: false
|
|
}]
|
|
}
|
|
});
|
|
|
|
// Data Gender Pasien
|
|
const genderLabels = {!! isset($genderData) ? json_encode(array_keys($genderData)) : json_encode(['Laki-laki', 'Perempuan']) !!};
|
|
const genderData = {!! isset($genderData) ? json_encode(array_values($genderData)) : json_encode([120, 100]) !!};
|
|
|
|
const genderCtx = document.getElementById('genderChart').getContext('2d');
|
|
new Chart(genderCtx, {
|
|
type: 'pie',
|
|
data: {
|
|
labels: genderLabels,
|
|
datasets: [{
|
|
data: genderData,
|
|
backgroundColor: ['rgba(54, 162, 235, 0.7)', 'rgba(255, 99, 132, 0.7)'],
|
|
}]
|
|
}
|
|
});
|
|
|
|
</script>
|
|
@endsection
|