import { CartesianGrid, ResponsiveContainer, Scatter, ScatterChart, Tooltip, XAxis, YAxis } from 'recharts' import { INK, ORDER, SERIES } from '@/lib/chart' import { percent } from '@/lib/format' import type { EvalsFile, SystemId } from '@/lib/types' import { Legend } from './Section' /** If each system declined every answer below a confidence threshold: the share of * questions it would still answer (x) against the mean error cost per question (y), * one line per system, each point one threshold. Lower is better; moving left trades * answered questions for fewer costly mistakes. */ export function ThresholdChart({ data }: { data: EvalsFile }) { const names = Object.fromEntries(ORDER.map((s) => [s, data.systems[s].name])) as Record return (
percent(v)} tickLine={false} axisLine={{ stroke: INK.axis }} tick={{ fill: INK.muted, fontSize: 11 }} label={{ value: 'Share of questions answered', position: 'insideBottom', offset: -10, fill: INK.muted, fontSize: 11 }} /> } /> {ORDER.map((s) => ( ({ s, t: p.t, ...p[s] }))} fill={SERIES[s]} line={{ stroke: SERIES[s], strokeWidth: 2 }} lineJointType="linear" shape={(props: { cx?: number; cy?: number }) => } isAnimationActive={false} /> ))}
) } type Props = { active?: boolean; payload?: { payload: { s: SystemId; t: number; answered: number; cost: number } }[] } function ThresholdTooltip({ active, payload }: Props) { if (!active || !payload?.length) return null const p = payload[0].payload return (

System {p.s.toUpperCase()} · declining below confidence {p.t.toFixed(2)}

answers {percent(p.answered)} of questions · mean error cost {p.cost.toFixed(2)}

) }