Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.35 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"></script>
  4.     <link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css" rel="stylesheet" type="text/css"/>
  5.  
  6.     <style type="text/css">
  7.         #mynetwork {
  8.             border: 1px solid lightgray;
  9.         }
  10.     </style>
  11. </head>
  12. <body>
  13. <div id="mynetwork"></div>
  14.  
  15. <script type="text/javascript">
  16.     // create an array with nodes
  17.     var nodes = new vis.DataSet([
  18.         {id: 1, label: 'Проект 45', color:'lightgrey'},
  19.         {id: 2, label: 'Проект 46', color:'lightgrey'},
  20.         {id: 3, label: 'Проект 47', color:'lightgrey'},
  21.         {id: 4, label: 'Проект 48', color:'lightgrey'},
  22.     ]);
  23.  
  24.     // create an array with edges
  25.     var edges = new vis.DataSet([
  26.         {from: 1, to: 2},
  27.         {from: 2, to: 3},
  28.         {from: 3, to: 4},
  29.     ]);
  30.  
  31.     // create a network
  32.     var container = document.getElementById('mynetwork');
  33.  
  34.     // provide the data in the vis format
  35.     var data = {
  36.         nodes: nodes,
  37.         edges: edges
  38.     };
  39.     var options = {
  40.         clickToUse: false,
  41.         layout: {
  42.             randomSeed: 1,
  43.             hierarchical: {
  44.                 enabled: true,
  45.                 levelSeparation: 150,
  46.                 nodeSpacing: 100,
  47.                 treeSpacing: 200,
  48.                 blockShifting: true,
  49.                 edgeMinimization: true,
  50.                 parentCentralization: true,
  51.                 direction: 'LR',        // UD, DU, LR, RL
  52.                 sortMethod: 'hubsize'   // hubsize, directed
  53.             }
  54.         },
  55.  
  56.         nodes: {
  57.             fixed: true,
  58.             shadow: {
  59.                 enabled: true,
  60.                 color: 'rgba(0,0,0,0.5)',
  61.                 size: 10,
  62.                 x: 5,
  63.                 y: 5
  64.             },
  65.             shape: 'dot',
  66.             size: 20
  67.         },
  68.  
  69.         edges: {
  70.             arrows: {
  71.                 from:   {enabled: true, scaleFactor:1, type:'arrow'}
  72.             },
  73.             color: {
  74.                 color:'#000',
  75.             },
  76.         }
  77.  
  78.     };
  79.  
  80.     // initialize your network!
  81.     var network = new vis.Network(container, data, options);
  82.  
  83.     network.on('select', () => {
  84.         console.log(network.getSelection())
  85.     })
  86. </script>
  87. </body>
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement