Removing legend on charts with chart.js v2 Removing legend on charts with chart.js v2 javascript javascript

Removing legend on charts with chart.js v2


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.

Remove legend

Chart.defaults.global.legend.display = false;

Remove Tooltip

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                     },                  }             }});