File size: 781 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Annotation } from '@nivo/annotations'
import { useScatterPlotAnnotations } from './hooks'
import { ScatterPlotCommonProps, ScatterPlotDatum, ScatterPlotNodeData } from './types'

interface ScatterPlotAnnotationsProps<RawDatum extends ScatterPlotDatum> {
    nodes: ScatterPlotNodeData<RawDatum>[]
    annotations: ScatterPlotCommonProps<RawDatum>['annotations']
}

export const ScatterPlotAnnotations = <RawDatum extends ScatterPlotDatum>({
    nodes,
    annotations,
}: ScatterPlotAnnotationsProps<RawDatum>) => {
    const boundAnnotations = useScatterPlotAnnotations<RawDatum>(nodes, annotations)

    return (
        <>
            {boundAnnotations.map((annotation, i) => (
                <Annotation key={i} {...annotation} />
            ))}
        </>
    )
}