@props([ 'score' => 0, 'size' => 'md', // sm, md, lg 'showValue' => true, 'showLabels' => true, 'animated' => true, 'thresholds' => [ 'danger' => 1.81, 'warning' => 2.99 ] ]) @php $sizes = [ 'sm' => ['container' => 'w-32 h-32', 'text' => 'text-xl', 'needle' => 'h-16'], 'md' => ['container' => 'w-48 h-48', 'text' => 'text-3xl', 'needle' => 'h-24'], 'lg' => ['container' => 'w-64 h-64', 'text' => 'text-4xl', 'needle' => 'h-32'], ]; $sizeConfig = $sizes[$size] ?? $sizes['md']; // Calculate angle for needle (0-180 degrees, 0 = left, 180 = right) $minScore = 0; $maxScore = 4; $angle = min(180, max(0, ($score / $maxScore) * 180)); // Determine color based on score $color = match(true) { $score > $thresholds['warning'] => 'text-success-600', $score >= $thresholds['danger'] => 'text-warning-600', default => 'text-danger-600' }; $bgColor = match(true) { $score > $thresholds['warning'] => 'bg-success-100 dark:bg-success-900/30', $score >= $thresholds['danger'] => 'bg-warning-100 dark:bg-warning-900/30', default => 'bg-danger-100 dark:bg-danger-900/30' }; @endphp
@foreach([0, 45, 90, 135, 180] as $tick) @php $tickAngle = $tick * (pi() / 180); $x1 = 50 + 40 * cos($tickAngle); $y1 = 50 + 40 * sin($tickAngle); $x2 = 50 + 45 * cos($tickAngle); $y2 = 50 + 45 * sin($tickAngle); @endphp @endforeach
@if($showValue || $showLabels)
@if($showValue)
{{ number_format($score, 3) }}
@endif @if($showLabels)
Bahaya Waspada Aman
@endif
@endif