import type { CSSProperties, MouseEventHandler } from 'react'; import { useBoxPlotPosition } from '../../hooks.js'; import type { ScalarValue } from '../../types.js'; export interface AnnotationBoxPlotProps { min: ScalarValue; max: ScalarValue; q1: ScalarValue; median: ScalarValue; q3: ScalarValue; width: ScalarValue; y: ScalarValue; xAxis?: string; yAxis?: string; medianColor?: string; medianStyle?: CSSProperties; boxColor?: string; boxStyle?: CSSProperties; whiskerColor?: string; whiskerStyle?: CSSProperties; minMaxColor?: string; minMaxStyle?: CSSProperties; onMouseEnter?: MouseEventHandler; onMouseLeave?: MouseEventHandler; } export function BoxPlot(props: AnnotationBoxPlotProps) { const { medianColor = 'black', medianStyle, boxColor = 'black', boxStyle, whiskerColor = 'black', whiskerStyle, minMaxColor = 'black', minMaxStyle, onMouseEnter, onMouseLeave, xAxis = 'x', yAxis = 'y', ...position } = props; const { min, max, q1, median, q3, width, y, horizontal } = useBoxPlotPosition( { ...position, xAxis, yAxis }, ); const y1 = y - width / 2; const y2 = y + width / 2; const height = Math.abs(q3 - q1); return ( {/* whiskers */} {/* box */} {/* median */} {/* box */} {/* min */} {/* max */} ); }