React-chartjs-2: How to not show legend?

Created on 24 Dec 2016  路  7Comments  路  Source: reactchartjs/react-chartjs-2

I want to use a pie chart but without labels (legend). It is possible?

Most helpful comment

@witalobenicio you can pass an options object with structure:

options={
    legend: {
        display: false,
    },
};
<Pie
    data={this.state.NRUChartData}
    options={options}
    height="250"
    width="400"
/>

All 7 comments

@witalobenicio you can pass an options object with structure:

options={
    legend: {
        display: false,
    },
};
<Pie
    data={this.state.NRUChartData}
    options={options}
    height="250"
    width="400"
/>

@limiterCore , this doesn't work for me on [email protected].
Global setting doesn't work either:

import { defaults } from 'react-chartjs-2'
defaults.global.legend.display = false;

screen shot 2017-01-24 at 20 57 24

Is there any other way?

@roboslone I can't see any legend on your chart, therefore it works. If you are about scales labels, please add this to the options object:

scales: { xAxes: [{ display: false, }], yAxes: [{ display: false, }], },

@limiterCore , sorry, you're right. Thanks!

@limiterCore , Hey I want to show label on my X-axis and Y-axis and also want to have prefix when we hover the point.
Can you please help me in that?

How to hide one particular legend while using legend : { display : false}

@roboslone I can't see any legend on your chart, therefore it works. If you are about scales labels, please add this to the options object:

scales: { xAxes: [{ display: false, }], yAxes: [{ display: false, }], },

Was this page helpful?
0 / 5 - 0 ratings