0π
β
I would suggest to use version 4.x (latest major) but I think the API https://www.chartjs.org/docs/latest/developers/api.html#toggledatavisibility-index was implemented in v3 (I donβt know exactly in which minor).
Having an updated Chart.js version, after chart creation, invoke (chart = chart instance created before)
chart.toggleDataVisibility(3);
chart.update();
Source:stackexchange.com