@extends($layout) @section('content') @php $hiddenRelatesLabels = $relatesLabels ?? []; // Metric preview — from the SAVED values; re-renders on save. $mType = $canvasItem['metricType'] ?: 'number'; // new goals default to # (no math) $mStart = (float) ($canvasItem['startValue'] ?? 0); $mCur = (float) ($canvasItem['currentValue'] ?? 0); $mGoal = (float) ($canvasItem['endValue'] ?? 0); $mPct = ($mGoal - $mStart) != 0 ? max(0, min(100, (($mCur - $mStart) / ($mGoal - $mStart)) * 100)) : 0; $fmtM = function ($v) use ($mType) { $v = (float) $v; if ($mType === 'percent') return rtrim(rtrim(number_format($v, 2), '0'), '.') . '%'; if ($mType === 'currency') return '$' . number_format($v, $v == floor($v) ? 0 : 2); return rtrim(rtrim(number_format($v, 2), '0'), '.'); }; @endphp