import { useCallback } from 'react'; import type { CouplingLink } from '../../../data/data1d/Spectrum1D/generateJGraphData.js'; import { useScaleChecked } from '../../context/ScaleContext.js'; import { useJGraph } from './JGraphContext.js'; interface JsCouplingLinksProps { links: CouplingLink[]; } export default function JsCouplingLinks(props: JsCouplingLinksProps) { const { links } = props; const { scaleX } = useScaleChecked(); const { scaleY, maxValue } = useJGraph(); const generatePath = useCallback( (link: CouplingLink): string => { if (!scaleY) return ''; const { from, to, couplings } = link; const paths: string[] = []; for (const coupling of couplings) { paths.push( `M${scaleX()(from)},${scaleY(coupling.coupling)} L${scaleX()( to, )},${scaleY(coupling.coupling)}`, ); } return paths.join(' '); }, [scaleX, scaleY], ); return ( {links .filter((link) => link.couplings.length > 1) .map((link) => { return ( ); })} ); }