Chartjs-Chart JS – Disable lines and Uncheck legends by default

1👍

After creating the chart, you can retrieve its metadata through .getDatasetMeta(index), change the hidden attribute of the desired datasets, then update the chart.

const chart = new Chart(document.getElementById('myChart'), {
  ...
});

chart.getDatasetMeta(2).hidden = true;    
chart.getDatasetMeta(3).hidden = true;    
chart.update();

Leave a comment