Perbandingan Konsumsi BBM (Liter)
{{-- BAGIAN 1: BATANG --}}
@foreach($data as $row)
@php
$maxGraphHeightPx = 100;
$heightPx = 0;
if($maxLiters > 0 && $row['total_liters'] > 0) {
$heightPx = ($row['total_liters'] / $maxLiters) * $maxGraphHeightPx;
if($heightPx < 2) $heightPx = 2;
}
@endphp
@if($row['total_liters'] > 0)
{{ round($row['total_liters']) }}
@else
@endif
@endforeach
{{-- BAGIAN 2: LABEL --}}
@foreach($data as $row)
@php
$fullLabel = $row['identity'];
// Logic pemendekan label tetap dipakai
if(strpos($fullLabel, ' - ') !== false) {
$parts = explode(' - ', $fullLabel);
$label = $parts[0];
} elseif(strpos($fullLabel, ' (') !== false) {
$parts = explode(' (', $fullLabel);
$label = $parts[0];
} else {
$label = substr($fullLabel, 0, 15);
}
@endphp
{{ $row['chart_label'] }}
@endforeach
@endif
{{-- ========================================================= --}}
{{-- GRAFIK 2: BIAYA --}}
{{-- ========================================================= --}}
@if($data->count() > 0 && $maxCost > 0)
Perbandingan Total Biaya (Rupiah)
{{-- BAGIAN 1: BATANG --}}
@foreach($data as $row)
@php
$maxGraphHeightPx = 100;
$heightPx = 0;
if($maxCost > 0 && $row['total_cost'] > 0) {
$heightPx = ($row['total_cost'] / $maxCost) * $maxGraphHeightPx;
if($heightPx < 2) $heightPx = 2;
}
$costLabel = number_format($row['total_cost'], 0, ',', '.');
@endphp
@if($row['total_cost'] > 0)
{{ $costLabel }}
@else
@endif
@endforeach
{{-- BAGIAN 2: LABEL --}}
@foreach($data as $row)
@php
$fullLabel = $row['identity'];
if(strpos($fullLabel, ' - ') !== false) {
$parts = explode(' - ', $fullLabel);
$label = $parts[0];
} elseif(strpos($fullLabel, ' (') !== false) {
$parts = explode(' (', $fullLabel);
$label = $parts[0];
} else {
$label = substr($fullLabel, 0, 15);
}
@endphp
{{ $row['chart_label'] }}
@endforeach
@endif