// health/CognitiveDetail.jsx // Push from "Cognitive impact". Uses pentagon radar chart at top // (more distinctive on detail than the horizontal bars). // Then horizontal bars per domain with description, then a 14-day trend. function Radar({ values, labels, size = 240, dark = false }) { const cx = size / 2, cy = size / 2; const radius = size / 2 - 30; const n = values.length; const angles = Array.from({ length: n }, (_, i) => -Math.PI / 2 + (i * 2 * Math.PI) / n); const point = (r, a) => [cx + Math.cos(a) * r, cy + Math.sin(a) * r]; const rings = [0.25, 0.5, 0.75, 1]; const ringStroke = dark ? 'rgba(235,235,245,0.18)' : 'rgba(60,60,67,0.18)'; const axisStroke = dark ? 'rgba(235,235,245,0.12)' : 'rgba(60,60,67,0.12)'; // value polygon (normalize 0-100 to radius) const poly = values.map((v, i) => point((v / 100) * radius, angles[i])).map(p => p.join(',')).join(' '); return ( {/* Concentric rings */} {rings.map((r, i) => ( point(radius * r, a).join(',')).join(' ')} fill={i === rings.length - 1 ? 'transparent' : 'transparent'} stroke={ringStroke} strokeWidth={0.6} /> ))} {/* Axes */} {angles.map((a, i) => { const [x, y] = point(radius, a); return ; })} {/* Value */} {/* Dots */} {values.map((v, i) => { const [x, y] = point((v / 100) * radius, angles[i]); return ; })} {/* Labels */} {angles.map((a, i) => { const [x, y] = point(radius + 18, a); const anchor = Math.abs(Math.cos(a)) < 0.3 ? 'middle' : (Math.cos(a) > 0 ? 'start' : 'end'); return ( {labels[i]} ); })} ); } function CognitiveDetail({ dark = false }) { const domains = [ { label: 'Attention', pct: 64, value: '−14%', color: 'var(--io-orange)', body: 'Sustained focus reduced after short sleep. Schedule shallow work this morning.' }, { label: 'Memory', pct: 58, value: '−18%', color: 'var(--io-orange)', body: 'Encoding new information is harder. Defer high-stakes learning until tomorrow.' }, { label: 'Executive function', pct: 72, value: '−8%', color: 'var(--io-yellow)', body: 'Decision-making mildly impacted. Avoid open-ended planning before noon.' }, { label: 'Emotional reg.', pct: 80, value: '−4%', color: 'var(--io-green)', body: 'Mood resilience near baseline. Difficult conversations are okay today.' }, { label: 'Reaction time', pct: 46, value: '−24%', color: 'var(--io-red)', body: 'Significantly slower responses. Avoid driving long distances if avoidable.' }, ]; return (
Forecast · today
Watch the next 6 hours.
Last night's 6h 12m of sleep is pulling four domains below your 14-day baseline.
{/* Radar card */}
d.pct)} labels={['Atten.', 'Mem.', 'Exec.', 'Mood', 'React.']} size={260} dark={dark} />
Today
14-day baseline
{domains.map(d => (
{d.label}
{d.value}
{d.body}
))}
); } window.CognitiveDetail = CognitiveDetail;