Sometimes, we want to remove legend on charts with Chart.js v2 and JavaScript.
In this article, we’ll look at how to remove legend on charts with Chart.js v2 and JavaScript.
How to remove legend on charts with Chart.js v2 and JavaScript?
To remove legend on charts with Chart.js v2 and JavaScript, we can set the options.legend
to false
.
For instance, we write
const chart1 = new Chart(canvas, {
type: "pie",
data: data,
options: {
legend: {
display: false,
},
tooltips: {
enabled: false,
},
},
});
to create the Chart
object with the options.legend
property set to false
to disable the legend.
Conclusion
To remove legend on charts with Chart.js v2 and JavaScript, we can set the options.legend
to false
.