import React, { useState } from 'react'; const BoxPlotAnatomyWidget: React.FC = () => { const [q1, setQ1] = useState(20); const [q3, setQ3] = useState(60); const [med, setMed] = useState(40); const min = 10; const max = 90; // Enforce constraints const handleMedChange = (val: number) => { setMed(Math.max(q1, Math.min(q3, val))); }; const handleQ1Change = (val: number) => { const newQ1 = Math.min(val, med); setQ1(Math.max(min, newQ1)); }; const handleQ3Change = (val: number) => { const newQ3 = Math.max(val, med); setQ3(Math.min(max, newQ3)); }; const scale = (val: number) => ((val) / 100) * 100; // 0-100 domain mapped to % return (
{/* Axis Line */}
{/* Range Line (Whiskers) */}
{/* Endpoints (Min/Max) */}
Min
Max
{/* The Box */}
{/* Median Line */}
{/* Labels below for Q1, Med, Q3 */}
Q1
Median
Q3
handleQ1Change(parseInt(e.target.value))} className="w-full h-2 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-amber-500"/>
handleMedChange(parseInt(e.target.value))} className="w-full h-2 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-amber-700"/>
handleQ3Change(parseInt(e.target.value))} className="w-full h-2 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-amber-500"/>
IQR (Box Width) = {q3 - q1}

The middle 50% of data lies inside the box.

); }; export default BoxPlotAnatomyWidget;