@extends('reports.pdf.layout') @section('title', $data['meta']['title']) @php $meta = $data['meta']; $kpis = $data['kpis']; $chart = $data['chart']; $rows = $data['table']; $fmtNum = function ($v, $unit = '') { if ($v === null) return '—'; $s = is_numeric($v) ? number_format((float) $v, 0, ',', ' ') : (string) $v; return trim($s . ' ' . $unit); }; $fmtPct = function ($v) { if ($v === null) return '—'; $sign = $v > 0 ? '+' : ''; return $sign . number_format((float) $v, 1, ',', ' ') . ' %'; }; $fmtUnit = function ($v, $unit) { if ($v === null) return '—'; if ($unit === '%') { return number_format((float) $v, 1, ',', ' ') . ' %'; } $s = number_format((float) $v, 0, ',', ' '); return $unit ? ($s . ' ' . $unit) : $s; }; // ── Multi-series line chart ──────────────────────────────────────── $chartW = 540; $chartH = 180; $padX = 36; $padY = 24; $labels = $chart['labels'] ?? []; $series = $chart['series'] ?? []; $count = max(count($labels), 1); $stepX = $count > 1 ? ($chartW - 2 * $padX) / ($count - 1) : 0; // Per-series scaling. $polylines = []; foreach ($series as $s) { $vals = array_filter($s['data'], fn ($v) => $v !== null); $min = !empty($vals) ? min($vals) : 0; $max = !empty($vals) ? max($vals) : 1; if ($max == $min) { $max = $min + 1; } $points = []; foreach ($s['data'] as $i => $v) { if ($v === null) continue; $x = $padX + $i * $stepX; $y = $chartH - $padY - (($v - $min) / ($max - $min)) * ($chartH - 2 * $padY); $points[] = ['x' => $x, 'y' => $y, 'v' => $v]; } $polylines[] = [ 'color' => $s['color'], 'label' => $s['label'], 'points' => $points, ]; } // ── Tone palette for impact chips ────────────────────────────────── $toneBg = ['success' => '#D1FAE5', 'warning' => '#FEF3C7', 'danger' => '#FEE2E2', 'neutral' => '#F3F4F6']; $toneColor = ['success' => '#065F46', 'warning' => '#92400E', 'danger' => '#991B1B', 'neutral' => '#374151']; $arrowFor = function ($direction) { return match ($direction) { 'up' => '▲', 'down' => '▼', default => '–', }; }; @endphp @section('content')
Pas de données mensuelles disponibles.
@endif| Indicateur | {{ $meta['period_1']['label'] }} | {{ $meta['period_2']['label'] }} | Évolution | Impact |
|---|---|---|---|---|
| {{ $r['indicator'] }} | {{ $fmtUnit($r['period_1'], $r['unit']) }} | {{ $fmtUnit($r['period_2'], $r['unit']) }} | {{ $fmtPct($r['delta_pct']) }} | {{ $arrowFor($r['direction']) }} |
Aucun indicateur calculable.
@endif @endsection