Vis.js network: how to get data and options back for saving?

后端 未结 2 474
北海茫月
北海茫月 2021-01-03 08:27

My intention is to create simple graph editor using vis.js and the first feature I\'m thinking about is to position nodes manually and save that. However, unlike setting opt

相关标签:
2条回答
  • 2021-01-03 09:05

    I've created my js functions to get all options.

    For example if I would get the group of each node id:

    function getGroup(network, id){
         var group = network.body.data.nodes._data[id].group;
         return group;
    } 
    

    UPDATE: I don't have a single function to get all options, but for ex. you can get few options value with this function:

    function getOptions(network){
         var opt = network.options;
         return opt;
    } 
    function getLocale(network){
         var locale = getOptions(network).locale;
    }
    function getClickToUse(network){
         var clickToUse = getOptions(network).clickToUse;
    }
    
    0 讨论(0)
  • 2021-01-03 09:06

    Vis.js provides a simple example to export and import networks as JSON.

    There is also an example with basic Editor-functionality like adding/removing nodes and edges

    0 讨论(0)
提交回复
热议问题