@php /** * Shared analytics chart card body (heading + optional period pills + the * ApexCharts mount consumed by dashboard-charts.js). Wrap it in a * .qm-chart-card grid cell. * * @var string $heading card title * @var string $sub short caption describing what the chart measures; * drawn by ApexCharts on the chart's own toolbar row * @var array $cfg chart config JSON for [data-chart] * @var array $meta ['has' => bool, 'label' => accessible summary] * @var string|null $icon no-data icon AND, when $accent is set, the header chip icon (default fa-chart-line) * @var string|null $accent when set, renders a .qm-head-chip beside the heading (blue|green|violet|teal|rose|amber) * @var array|null $opts instant period pills: ['id','ranges','selected','options'] */ $icon = $icon ?? 'fa-chart-line'; $accent = $accent ?? null; $opts = $opts ?? null; $hasData = !empty($meta['has']); $label = (string) ($meta['label'] ?? ($heading ?? '')); $id = $opts['id'] ?? ''; // The caption rides on the chart's own toolbar row — left-aligned, opposite the export // button (the "breadcrumb") on the right — NOT stacked under the title. Capped to 16 // characters so a long caption can't wrap on a narrow card and push that row out of // alignment; ApexCharts then places it natively, identically on every card. $subCap = trim((string) ($sub ?? '')); if ($subCap !== '') { // Room for a real sentence fragment: 16 chars clipped almost every caption // ("Across all serv…"); the caption row spans the plot width less the export // menu, which holds ~30 comfortably even in a half-width card. if (mb_strlen($subCap) > 30) { $subCap = rtrim(mb_substr($subCap, 0, 29)) . '…'; } $cfg['subtitle'] = $subCap; } // Range picker wiring on the mount: a lazy `url` (fetch one window on demand — the // preferred, lean path) OR a legacy `ranges` blob (all windows shipped up front). $rangeAttrs = ''; if ($opts) { if (!empty($opts['url'])) { $rangeAttrs = ' data-range-url="' . e((string) $opts['url']) . '" data-range-selected="' . e((string) ($opts['selected'] ?? '')) . '"'; } elseif (isset($opts['ranges'])) { $rangeAttrs = ' data-ranges="' . e(json_encode($opts['ranges'])) . '"'; } } @endphp