import React from 'react'; import { Point2D } from '../../utilities'; import { ScatterProps } from './types'; const Scatter: React.FC = ({ transform, data, pointStyle, onPointMouseOver, onPointMouseOut, onPointClick }) => { if (transform === undefined) throw new Error("Scatter component must receive a transform prop. Did you render one outside a ?"); return data.length >= 1 ? ( <> { data.map( (point: Point2D, i: number) => { const t = transform(point); const pointProps = point.svgProps || {}; return ( onPointMouseOver && onPointMouseOver(i, e)} onMouseOut={e => onPointMouseOut && onPointMouseOut(i, e)} onClick={e => onPointClick && onPointClick(i, e)} {...pointStyle} {...pointProps} /> ) })} ) : null }; export default Scatter;