{{-- Vertical bar chart, one series (Reporting). Plain HTML bars so labels stay readable on a phone. $title, $subtitle, $bars: list of ['label', 'title', 'value']; $labelEvery: show every n-th x label; $unit: word after a value in the tooltip and table ("iklan"). --}} @php $values = array_column($bars, 'value'); $peak = $values === [] ? 0 : max($values); // A round axis maximum just above the peak (e.g. 30 for 22), even so the middle line is a whole number. $axisMax = 2; if ($peak > 0) { $magnitude = 10 ** floor(log10($peak)); foreach ([1, 2, 3, 4, 5, 6, 8, 10] as $step) { $candidate = $step * $magnitude; if ($candidate >= $peak && $candidate == (int) $candidate && (int) $candidate % 2 === 0) { $axisMax = (int) $candidate; break; } } } $peakIndex = $peak > 0 ? array_search($peak, $values, true) : null; $labelEvery = max(1, (int) ($labelEvery ?? 1)); // On a phone only these stay: first, middle and last label (the others would collide). $keyLabels = [0, intdiv(count($bars) - 1, 2), count($bars) - 1]; $fmt = fn ($n) => number_format((int) $n, 0, ',', '.'); @endphp

{{ $title }}

@isset($subtitle)

{{ $subtitle }}

@endisset
@if ($peak === 0)

Belum ada iklan pada periode ini.

@else
@foreach ($bars as $index => $bar)
@if ($index === $peakIndex){{ $fmt($bar['value']) }}@endif
@endforeach
@endif
Lihat tabel @foreach ($bars as $bar)@endforeach
{{ $columnLabel ?? 'Waktu' }}Jumlah {{ $unit ?? 'iklan' }}
{{ $bar['title'] }}{{ $fmt($bar['value']) }}