Chartjs-Charts.js DataIndex not updating based on selected datasets

1👍

Add the following lines of code inside your forEach loop, that will take care of the dataIndex updating issue :

var isDatasetVisible = chartInstance.controller.isDatasetVisible(i);
if (!isDatasetVisible) return;

Here is the working example on JSFiddle

Leave a comment