I am using react and I’ve been trying to redraw the graph when the user click on checkboxes to toggle the visibility of the lines. Here is the code that I’ve made to do that :
const legendToggle = (name, index, e) => {
const isChecked = e.target.checked;
const graphDiv = document.getElementById('graphId');
if (isChecked) {
graphDiv.data[index].visible = true;
} else {
graphDiv.data[index].visible = "legendonly";
}
redraw(graphDiv);
}
But doing this gives me an error :