function($prop) { $prop['id'] = !empty($prop['id']) ? $prop['id'] : 'arcgauge-'.uniqid(); $prop['scale'] = $prop['scale'] ?? array(); $prop['items'] = $prop['items'] ?? array(); ?>

$item) { $item = array_merge($prop['scale'], $item); $value = (float)first($item['value'], 0); $max = (float)first($item['max'], 100); $precision = isset($item['precision']) ? (int)$item['precision'] : 1; $pct = $max > 0 ? clamp(($value / $max) * 100, 0, 100) : 0; $arc_length = round(($pct / 100) * 157.08, 1); $display_value = number_format($value, $precision).safe((string)($item['unit'] ?? '')); $resolved_color = '#10b981'; if(isset($item['color'])) { if(is_array($item['color'])) { $color_entry = pick_entry_from_range($item['color'], $value); $resolved_color = first($color_entry['color'] ?? false, $resolved_color); } else { $resolved_color = (string)$item['color']; } } else if($pct >= 85) { $resolved_color = 'var(--error, #ef4444)'; } else if($pct >= 60) { $resolved_color = 'var(--warning, #f59e0b)'; } else { $resolved_color = 'var(--success, #10b981)'; } ?>