Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬Register for the Oct 27 webinar.

Redrawing graph gives me errors

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";

But doing this gives me an error :