@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $k = $data['kpis']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, (is_int($v) || ((float) $v) == (int) $v) ? 0 : 1, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; // Pie geometry helper (single SVG slice path per segment). $renderPie = function (array $segments) { $cx = 70; $cy = 70; $r = 60; $total = array_sum(array_map(fn ($s) => $s['count'] ?? $s['percent'], $segments)); $slices = []; $acc = -90; foreach ($segments as $s) { $val = $s['count'] ?? $s['percent']; if ($total <= 0) break; $sweep = ($val / $total) * 360; $isFull = $sweep >= 359.999; if ($isFull) { $path = null; } else { $rad1 = deg2rad($acc); $rad2 = deg2rad($acc + $sweep); $x1 = $cx + $r * cos($rad1); $y1 = $cy + $r * sin($rad1); $x2 = $cx + $r * cos($rad2); $y2 = $cy + $r * sin($rad2); $largeArc = $sweep > 180 ? 1 : 0; $path = sprintf('M %s %s L %.2f %.2f A %s %s 0 %d 1 %.2f %.2f Z', $cx, $cy, $x1, $y1, $r, $r, $largeArc, $x2, $y2); } $slices[] = ['path' => $path, 'color' => $s['color']]; $acc += $sweep; } return ['slices' => $slices, 'cx' => $cx, 'cy' => $cy, 'r' => $r]; }; $energyPie = $renderPie($data['energy_segments']); $bodyPie = $renderPie($data['body_segments']); // Bar chart for age buckets. $bars = $data['age_buckets']; $maxBar = max(1, max(array_map(fn ($b) => $b['count'], $bars))); $barW = 480; $barH = 140; $barPad = 30; $barWidth = (int) (($barW - 2 * $barPad) / max(1, count($bars))) - 8; @endphp @section('content')
|
@foreach ($data['energy_segments'] as $s)
{{ $s['label'] }} — {{ $s['count'] }} véh. ({{ number_format($s['percent'], 1, ',', ' ') }} %)
@endforeach
|
Aucun véhicule.
@endif|
@foreach ($data['body_segments'] as $s)
{{ $s['label'] }} — {{ $s['count'] }} véh. ({{ number_format($s['percent'], 1, ',', ' ') }} %)
@endforeach
|
Donnée carrosserie non renseignée.
@endif| Marque | Véhicules | % du parc |
|---|---|---|
| {{ $b['label'] }} | {{ $b['count'] }} | {{ number_format($b['percent'], 1, ',', ' ') }} % |
Aucune marque.
@endif @endsection