'use client' import { ScatterChart } from '@tremor/react' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table' import { AlertTriangle } from 'lucide-react' import { BRAND_DARK_BLUE, BRAND_RED } from './chart-theme' interface JurorMetric { userId: string name: string evaluationCount: number averageScore: number stddev: number deviationFromOverall: number isOutlier: boolean } interface JurorConsistencyProps { data: { overallAverage: number jurors: JurorMetric[] } } export function JurorConsistencyChart({ data }: JurorConsistencyProps) { if (!data?.jurors?.length) { return (

No juror consistency data available

) } const outlierCount = data.jurors.filter((j) => j.isOutlier).length const scatterData = data.jurors.map((j) => ({ 'Average Score': parseFloat(j.averageScore.toFixed(2)), 'Std Deviation': parseFloat(j.stddev.toFixed(2)), category: j.isOutlier ? 'Outlier' : 'Normal', name: j.name, evaluations: j.evaluationCount, size: Math.max(8, Math.min(20, j.evaluationCount * 2)), })) return (
{/* Scatter: Average Score vs Standard Deviation */} Juror Scoring Patterns Overall Avg: {data.overallAverage.toFixed(2)} {outlierCount > 0 && ( {outlierCount} outlier{outlierCount > 1 ? 's' : ''} )}

Dot size represents number of evaluations. Red dots indicate outlier jurors (2+ points from mean).

{/* Juror details table */} Juror Consistency Details Juror Evaluations Avg Score Std Dev Deviation from Mean Status {data.jurors.map((juror) => (

{juror.name}

{juror.evaluationCount} {juror.averageScore.toFixed(2)} {juror.stddev.toFixed(2)} {juror.deviationFromOverall.toFixed(2)} {juror.isOutlier ? ( Outlier ) : ( Normal )}
))}
) }