plouc / nivo

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
https://nivo.rocks
MIT License
13.19k stars 1.03k forks source link

Can't display custom legend in line chart (label prop is missing) #948

Closed mariokandut closed 4 years ago

mariokandut commented 4 years ago

Description: The LegendProps in @nivo/legends are missing the required label prop, hence you can't use a custom legend. Found in line chart, but I assume it's in all charts.

To Reproduce Check the data prop in LegendProps.

export interface LegendProps {
data?: Array<{
            id: string | number
            value: number
            color?: string
            fill?: string
        }>

To create a custom legend in a line chart, you can simply add this to the LegendProps:

data: [{
            id: 1,
            value: 1,
},{
            id: 2,
            value: 2,
}],

It will throw an error, since the label is missing and required in SVGLegends.

Additional context Using nivo: "@nivo/core": "^0.61.0", "@nivo/line": "^0.61.1",

wyze commented 4 years ago

This should be fixed in the latest version. Looks like #802 contained the fix.