@php $segments = $segments ?? []; $size = $size ?? 140; $thickness = $thickness ?? 16; $total = collect($segments)->sum('value'); $total = max(1, $total); $radius = ($size - $thickness) / 2; $circ = 2 * pi() * $radius; $offset = 0; @endphp {{-- background ring --}} @foreach($segments as $seg) @php $val = max(0, (int)($seg['value'] ?? 0)); $len = ($val / $total) * $circ; $dash = "{$len} " . ($circ - $len); $strokeClass = $seg['stroke'] ?? 'stroke-fuchsia-300'; @endphp @php $offset += $len; @endphp @endforeach {{-- center label --}} {{ $center ?? '' }} {{ $label ?? '' }}