perbaiki database agar semua tabel +8 utc, perbaiki admin_index dengan menambah line chart submit/update penelitian
This commit is contained in:
1 parent
31eb35c090
commit
218f8ce063
3 files changed
+162
-70
No files matched your search
@@ -127,6 +127,17 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row small-spacing">
|
||||
<div class="col-lg-12 col-xs-12">
|
||||
<div class="box-content card">
|
||||
<h4 class="box-title">Statistik Penelitian</h4>
|
||||
<div class="card-content">
|
||||
<canvas id="penelitianChart" style="width: 100%; height: 400px;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row small-spacing">
|
||||
<div class="col-lg-7 col-xs-12">
|
||||
<div class="box-content card">
|
||||
@@ -175,6 +186,9 @@
|
||||
<script src="assets/plugin/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
|
||||
<script src="assets/plugin/datatables/extensions/Responsive/js/responsive.bootstrap.min.js"></script>
|
||||
|
||||
<!-- chart.js Chart -->
|
||||
<script src="assets/plugin/chart/chartjs/Chart.bundle.min.js"></script>
|
||||
|
||||
<script src="assets/scripts/main.min.js"></script>
|
||||
<script src="assets/color-switcher/color-switcher.min.js"></script>
|
||||
|
||||
@@ -204,6 +218,61 @@
|
||||
});
|
||||
}
|
||||
|
||||
// --- CHART RENDERING FUNCTION ---
|
||||
function renderChart() {
|
||||
$.get('/api/laporan/stats/daily', function(data) {
|
||||
const labels = [];
|
||||
const counts = [];
|
||||
|
||||
// Extract dates and counts
|
||||
data.forEach(item => {
|
||||
// Format date from YYYY-MM-DD to DD MMM
|
||||
const dateObj = new Date(item.date);
|
||||
const formattedDate = dateObj.toLocaleDateString('id-ID', { day: '2-digit', month: 'short' });
|
||||
labels.push(formattedDate);
|
||||
counts.push(item.total);
|
||||
});
|
||||
|
||||
const ctx = document.getElementById('penelitianChart').getContext('2d');
|
||||
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Jumlah Submit/Update Penelitian',
|
||||
data: counts,
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
borderWidth: 2,
|
||||
pointBackgroundColor: 'rgba(54, 162, 235, 1)',
|
||||
pointRadius: 4,
|
||||
fill: true,
|
||||
tension: 0.3 // Makes the line slightly curved
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
stepSize: 1 // Ensure integers on Y axis
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
display: true,
|
||||
position: 'top'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
document.body.style.display = 'block';
|
||||
|
||||
@@ -280,6 +349,9 @@
|
||||
$('#h_jumlah_dosen').text('0');
|
||||
}
|
||||
});
|
||||
|
||||
// 4. Render the Chart
|
||||
renderChart();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user