Tip: To quickly remove a legend or a legend entry from a chart, you can select it, and then press DELETE. You can also right-click the legend or a legend entry, and then click Delete.
You can hide datasets labels in Chart. js by applying 'display: false' into legend option.
js (3.6. 0), you can control the Legend display with the following code: const options = { plugins: { ... legend: { position: "right", // by default it's top }, ... }, };
The chart legend displays data about the datasets that are appearing on the chart.
The options object can be added to the chart when the new Chart object is created.
var chart1 = new Chart(canvas, {
type: "pie",
data: data,
options: {
legend: {
display: false
},
tooltips: {
enabled: false
}
}
});
You can change default options by using Chart.defaults.global
in your javascript file. So you want to change legend and tooltip options.
Chart.defaults.global.legend.display = false;
Chart.defaults.global.tooltips.enabled = false;
Here is a working fiddler.
From chart.js version 3.x onwards: legend, title and tooltip namespaces are moved from options to options.plugins.
var chart1 = new Chart(canvas, {
type: "pie",
data: data,
options: {
plugins:{
legend: {
display: false
},
}
}
});
Modifying Ishan's answer
If you are using react like me,
const data = {
...
}
const options = {
plugins: {
legend: {
display: false,
},
},
};
<Bar data={data} options={options} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With