'use client'
import { useState } from 'react'
import type { GuardrailData } from '@/lib/types'
import { LabLogo } from '@/components/LabLogo'
import { guardrailCreatorColor } from '@/lib/utils'
const STRIP_ROWS = [
{ key: 'recall' as const, label: 'Recall', color: '#00C0F3', fmt: (v: number) => `${(v * 100).toFixed(0)}%` },
{ key: 'f1' as const, label: 'F1 Score', color: '#F4333D', fmt: (v: number) => `${(v * 100).toFixed(0)}%` },
]
function getVal(g: GuardrailData, key: 'recall' | 'f1'): number | null {
return g[key]
}
export default function GuardrailDistribution({ guardrails }: { guardrails: GuardrailData[] }) {
const [tooltip, setTooltip] = useState<{
x: number; y: number; guardrail: string; val: string; creator: string
} | null>(null)
const VW = 800
const ROW_H = 120
const LBL_W = 85
const PAD_R = 85
const AXIS_W = VW - LBL_W - PAD_R
const DOT_R = 7
const VH = STRIP_ROWS.length * ROW_H
const TT_W = 200
const TT_H = 36
const VIOLIN_H = 40
const VIOLIN_BW = AXIS_W * 0.07
return (
{/* Logo overlays — one per row for the hovered guardrail */}
{tooltip && STRIP_ROWS.map((row, ri) => {
const g = guardrails.find(g => g.guardrail === tooltip.guardrail)
if (!g) return null
const val = getVal(g, row.key)
if (val === null) return null
const cx = LBL_W + val * AXIS_W
const yMid = ri * ROW_H + ROW_H / 2
const pctX = cx / VW * 100
const pctY = yMid / VH * 100
return (
)
})}
)
}