{{-- A drawn revenue dashboard on a desktop monitor, with the same figures on a phone. It is decoration made of SVG (so it stays sharp at any size): the figures are made up, the caption says so, and the drawing is hidden from screen readers. The sample numbers live in config('site.home.showcase.revenue'). Usage: --}} @props(['caption' => 'Illustrative dashboard with sample figures']) @php $r = config('site.home.showcase.revenue'); $total = $r['total']; $depts = $r['departments']; // Whole rupees in the Indian style: 542000 -> ₹5,42,000 $inr = function (int|float $n): string { $s = (string) (int) round($n); $last3 = substr($s, -3); $rest = substr($s, 0, -3); return '₹'.($rest === '' ? $last3 : preg_replace('/\B(?=(\d{2})+(?!\d))/', ',', $rest).','.$last3); }; // Growth of the total, worked out from the departments' own growth so the numbers agree with each other. $before = collect($depts)->sum(fn ($d) => $d['amount'] / (1 + $d['growth'] / 100)); $growth = round(($total / $before - 1) * 100, 1); $pct = fn ($d) => round($d['amount'] / $total * 100); $ranked = collect($depts)->sortByDesc('amount')->values(); // A smooth curve through points (Catmull-Rom turned into cubic Beziers). $curve = function (array $p): string { $d = 'M'.round($p[0][0], 1).' '.round($p[0][1], 1); for ($i = 0; $i < count($p) - 1; $i++) { [$p0, $p1, $p2, $p3] = [$p[max($i - 1, 0)], $p[$i], $p[$i + 1], $p[min($i + 2, count($p) - 1)]]; $d .= sprintf(' C%.1f %.1f %.1f %.1f %.1f %.1f', $p1[0] + ($p2[0] - $p0[0]) / 6, $p1[1] + ($p2[1] - $p0[1]) / 6, $p2[0] - ($p3[0] - $p1[0]) / 6, $p2[1] - ($p3[1] - $p1[1]) / 6, $p2[0], $p2[1]); } return $d; }; $plot = fn (array $values, float $x, float $y, float $w, float $h, float $max) => collect($values) ->map(fn ($v, $i) => [$x + $i * $w / (count($values) - 1), $y + $h - $v / $max * $h])->all(); // Monitor: the trend chart (plot box x 176..492, y 204..296; 0..30K). $trend = $plot($r['daily'], 176, 204, 316, 92, 30); $trendLine = $curve($trend); $trendArea = $trendLine.' L'.end($trend)[0].' 296 L'.$trend[0][0].' 296 Z'; $peak = 7; $peakDay = (int) round(1 + $peak * 29 / (count($trend) - 1)); $targetY = 296 - $r['target'] / 30 * 92; // Phone: last 7 days (plot box x 38..222, y 222..268; 0..30K). $week = $plot($r['week'], 38, 222, 184, 46, 30); $weekLine = $curve($week); $weekArea = $weekLine.' L'.end($week)[0].' 268 L'.$week[0][0].' 268 Z'; $nav = [['chart', 'Dashboard'], ['receipt-rupee', 'Revenue'], ['bill', 'Billing'], ['users', 'OPD'], ['bed', 'IPD'], ['pill', 'Pharmacy'], ['lab', 'Laboratory'], ['doc', 'Reports']]; $shades = ['#0284c7', '#38bdf8', '#7dd3fc', '#bae6fd']; @endphp
class('mx-auto w-full max-w-[46rem]') }}>
{{ $caption }}