// Horizontal-bar chart of per-partner scores for one leaderboard entry.
// CI whiskers inline; normalized-score scale 0-1 on x-axis.
import type { PerPartnerScore } from "../api/client"
type Props = {
scores: PerPartnerScore[]
mode?: "normalized" | "raw"
}
export function PerPartnerChart({ scores, mode = "normalized" }: Props) {
if (scores.length === 0) {
return
No partners evaluated.
}
const pick = (s: PerPartnerScore) => mode === "normalized"
? { v: s.normalized_mean, lo: s.normalized_ci_low, hi: s.normalized_ci_high }
: { v: s.mean, lo: s.ci_low, hi: s.ci_high }
const vals = scores.map(pick)
const maxHi = Math.max(...vals.map((v) => v.hi), 1)
const minLo = Math.min(...vals.map((v) => v.lo), 0)
const span = Math.max(1e-9, maxHi - minLo)
return (
{scores.map((s, i) => {
const { v, lo, hi } = vals[i]
const leftPct = ((lo - minLo) / span) * 100
const widthPct = ((hi - lo) / span) * 100
const markerPct = ((v - minLo) / span) * 100
return (
{s.display_name}
{v.toFixed(3)}
)
})}
)
}