Search code examples
javascriptchap-links-libraryvis.js

vis.js - Graph2d - making group not visible


I am working with a Graph2d in the vis.js library.

I have succesfully drawn a graph but want to dynamically hide groups as a user selects a checkbox relating to that group.

I know the id number of the group in the variable id which is passed into my function, but for some reason, the group is not being hidden in the graph.

Can anyone see what I'm doing wrong here ?

function toggle_graph_item_data(id){

    // We are looking for a specific group to toggle on or off
       graph2d.setOptions({groups:{visibility:{id:false}}});
}

Solution

  • I'm the developer of the graph2d module. You seem to be using javascript objects wrong. You're not using the ID variable for its content.

    try:

    function toggle_graph_item_data(id){
        // We are looking for a specific group to toggle on or off
       var prop = {};
       prop[id] = false;
       graph2d.setOptions({groups:{visibility:prop}});
    }
    

    Please post issues on our github page in the future.