<?php $__env->startSection('page_title', 'Grafik Prestasi'); ?>
<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-md-6 col-lg-5">
        <div class="card-flat">
            <h6 class="fw-bold mb-3" style="font-size:14px;"><i class="bi bi-pie-chart me-2"></i>Grafik Prestasi Siswa</h6>
            <canvas id="chartPrestasi"></canvas>
        </div>
    </div>
    <div class="col-md-6 col-lg-7">
        <div class="card-flat">
            <h6 class="fw-bold mb-3" style="font-size:14px;">Ringkasan Prestasi</h6>
            <div class="d-flex justify-content-between align-items-center py-2" style="border-bottom:1px solid #f1f5f9; font-size:13px;">
                <span class="text-muted">Total Prestasi</span>
                <span class="fw-bold"><?php echo e(count($data)); ?></span>
            </div>
            <?php $tingkatGroup = $data->groupBy('tingkat'); ?>
            <?php $__currentLoopData = $tingkatGroup; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tingkat => $items): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="d-flex justify-content-between align-items-center py-2" style="border-bottom:1px solid #f1f5f9; font-size:13px;">
                <span class="text-muted"><?php echo e($tingkat ?: 'Lainnya'); ?></span>
                <span class="badge bg-primary" style="font-size:11px;"><?php echo e(count($items)); ?></span>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php $juaraGroup = $data->groupBy('juara'); ?>
            <?php $__currentLoopData = $juaraGroup; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $juara => $items): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="d-flex justify-content-between align-items-center py-2" style="border-bottom:1px solid #f1f5f9; font-size:13px;">
                <span class="text-muted">Juara <?php echo e($juara ?: '-'); ?></span>
                <span class="badge bg-warning text-dark" style="font-size:11px;"><?php echo e(count($items)); ?></span>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
    const dataPrestasi = <?php echo json_encode($data, 15, 512) ?>;
    const tingkatCount = {};
    dataPrestasi.forEach(item => {
        const tingkat = item.tingkat || 'Lainnya';
        tingkatCount[tingkat] = (tingkatCount[tingkat] || 0) + 1;
    });
    const labels = Object.keys(tingkatCount);
    const values = Object.values(tingkatCount);
    const colors = ['#0284c7','#10b981','#f59e0b','#ef4444','#6366f1','#8b5cf6','#ec4899'];

    new Chart(document.getElementById('chartPrestasi'), {
        type: 'doughnut',
        data: {
            labels: labels,
            datasets: [{ data: values, backgroundColor: colors.slice(0, labels.length), borderWidth: 2, borderColor: '#fff' }]
        },
        options: {
            responsive: true,
            maintainAspectRatio: true,
            aspectRatio: 1.4,
            plugins: { legend: { position: 'bottom', labels: { font: { size: 11 } } } }
        }
    });
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Samsul Arifin\Downloads\absensismkn1prajekan\resources\views/admin/pages/grafik-prestasi.blade.php ENDPATH**/ ?>