File size: 826 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 25 26 27 28 | import { BoxLegendSvg, LegendProps } from '@nivo/legends'
import { LegendData } from './types'
interface BoxPlotLegendsProps {
width: number
height: number
legends: [LegendProps, LegendData[]][]
}
export const BoxPlotLegends = ({ width, height, legends }: BoxPlotLegendsProps) => (
<>
{legends.map(([legend, data], i) => {
// Advanced feature:
// Allow a legend spec to carry its own custom content via 'legend.data'
// Or fallback on content provided via 'data'
return (
<BoxLegendSvg
key={i}
{...legend}
containerWidth={width}
containerHeight={height}
data={legend.data ?? data}
/>
)
})}
</>
)
|