Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"></script>
- <link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css" rel="stylesheet" type="text/css"/>
- <style type="text/css">
- #mynetwork {
- border: 1px solid lightgray;
- }
- </style>
- </head>
- <body>
- <div id="mynetwork"></div>
- <script type="text/javascript">
- // create an array with nodes
- var nodes = new vis.DataSet([
- {id: 1, label: 'Проект 45', color:'lightgrey'},
- {id: 2, label: 'Проект 46', color:'lightgrey'},
- {id: 3, label: 'Проект 47', color:'lightgrey'},
- {id: 4, label: 'Проект 48', color:'lightgrey'},
- ]);
- // create an array with edges
- var edges = new vis.DataSet([
- {from: 1, to: 2},
- {from: 2, to: 3},
- {from: 3, to: 4},
- ]);
- // create a network
- var container = document.getElementById('mynetwork');
- // provide the data in the vis format
- var data = {
- nodes: nodes,
- edges: edges
- };
- var options = {
- clickToUse: false,
- layout: {
- randomSeed: 1,
- hierarchical: {
- enabled: true,
- levelSeparation: 150,
- nodeSpacing: 100,
- treeSpacing: 200,
- blockShifting: true,
- edgeMinimization: true,
- parentCentralization: true,
- direction: 'LR', // UD, DU, LR, RL
- sortMethod: 'hubsize' // hubsize, directed
- }
- },
- nodes: {
- fixed: true,
- shadow: {
- enabled: true,
- color: 'rgba(0,0,0,0.5)',
- size: 10,
- x: 5,
- y: 5
- },
- shape: 'dot',
- size: 20
- },
- edges: {
- arrows: {
- from: {enabled: true, scaleFactor:1, type:'arrow'}
- },
- color: {
- color:'#000',
- },
- }
- };
- // initialize your network!
- var network = new vis.Network(container, data, options);
- network.on('select', () => {
- console.log(network.getSelection())
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement