{{-- Reusable donut. Expects: $segs [['label','value','hex']], $centerValue, $centerLabel. Optional $total. --}} @php $r = 64; $C = 2 * M_PI * $r; $acc = 0; $tot = $total ?? collect($segs)->sum('value'); @endphp @once @endonce
@foreach($segs as $s) @php $len = $tot > 0 ? $s['value'] / $tot * $C : 0; @endphp @if($s['value'] > 0) {{ $s['label'] }}: {{ $s['value'] }} @endif @php $acc += $len; @endphp @endforeach
{{ $centerValue }} @if(!empty($centerLabel)) {{ $centerLabel }} @endif