import type { ScaleLinear } from 'd3-scale'; import { ReactElement, useMemo } from 'react'; import type { AdditionalLineProps } from '../models'; interface Props extends AdditionalLineProps { graphWidth: number; yScale?: ScaleLinear; } const AdditionalLine = ({ yValue, color, text, graphWidth, yScale }: Props): ReactElement | null => { const positionY = useMemo(() => yScale?.(yValue), [yValue, yScale]); if (positionY === undefined) { return null; } return ( {text && ( {text} )} ); }; export default AdditionalLine;