@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $series = $data['monthly_series']; $perSite = $data['per_site']; $perEnergy = $data['per_energy']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; $fmtFloat = function ($v, $unit = '€') { if ($v === null) return '—'; return number_format((float) $v, 1, ',', ' ') . ' ' . $unit; }; // 6-month line chart. $chartW = 480; $chartH = 140; $padX = 30; $padY = 18; $values = array_filter(array_map(fn ($r) => $r['cost_per_100km'], $series), fn ($v) => $v !== null); $minV = !empty($values) ? min($values) : 0; $maxV = !empty($values) ? max($values) : 1; if ($minV === $maxV) { $maxV = $minV + 1; } $stepX = count($series) > 1 ? ($chartW - 2 * $padX) / (count($series) - 1) : 0; $points = []; foreach ($series as $i => $r) { if ($r['cost_per_100km'] === null) continue; $x = $padX + $i * $stepX; $y = $chartH - $padY - (($r['cost_per_100km'] - $minV) / ($maxV - $minV)) * ($chartH - 2 * $padY); $points[] = ['x' => $x, 'y' => $y, 'label' => $r['label'], 'value' => $r['cost_per_100km']]; } $polyline = implode(' ', array_map(fn ($p) => "{$p['x']},{$p['y']}", $points)); // Per-energy bars. $eBarW = 320; $eBarH = 130; $eBarPadX = 30; $eBarPadY = 18; $eVals = array_map(fn ($r) => (float) ($r['value'] ?? 0), $perEnergy); $eMax = !empty($eVals) ? max($eVals + [1]) : 1; $eSlot = ($eBarW - 2 * $eBarPadX) / max(1, count($perEnergy)); $eW = $eSlot * 0.55; $eColors = ['#3B82F6', '#F59E0B', '#10B981']; $maxSiteCost = !empty($perSite) ? max(array_filter(array_column($perSite, 'cost_per_100km'), fn ($v) => $v !== null) ?: [1]) : 1; @endphp @section('content')
Pas de mesure pour la période.
@endifAucun site avec données pour la période.
@endifPas assez de données par type d'énergie.
@endif @endsection