Created
August 11, 2014 23:35
-
-
Save xmichaelx/3d28888d0543e2e92002 to your computer and use it in GitHub Desktop.
Simple network visualized using vis.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <title>Network | Images</title> | |
| <head> | |
| <link href="http://visjs.org/dist/vis.css" rel="stylesheet" type="text/css" /> | |
| <script src="http://visjs.org/dist/vis.js"></script> | |
| <script type="text/javascript"> | |
| function draw() { | |
| var nodes = [ | |
| {id: 1, label: 'SLR1', group: 'source', value: 10}, | |
| {id: 2, label: 'SLR2', group: 'source', value: 10}, | |
| {id: 3, label: 'Transfer node', group: 'transfer', value: 5}, | |
| {id: 4, label: 'SLR3', group: 'source', value: 10}, | |
| {id: 5, label: 'Transfer node', group: 'transfer', value: 5}, | |
| {id: 6, label: 'SLR4', group: 'source', value: 10}, | |
| {id: 7, label: 'Transfer node', group: 'transfer', value: 5}, | |
| {id: 8, label: 'Torun Center', group: 'storage', value: 10} | |
| ]; | |
| var WIDTH_SCALE = 2; | |
| var edges = [ | |
| {from: 1, to: 3, width: WIDTH_SCALE * 6, label: '0.71 mbps'}, | |
| {from: 2, to: 3, width: WIDTH_SCALE * 4, label: '0.55 mbps'}, | |
| {from: 4, to: 5, width: WIDTH_SCALE * 6, label: '0.71 mbps'}, | |
| {from: 6, to: 7, width: WIDTH_SCALE * 4, label: '0.55 mbps'}, | |
| {from: 3, to: 8, width: WIDTH_SCALE * 4, length: 200, label: '0.55 mbps'}, | |
| {from: 5, to: 8, width: WIDTH_SCALE * 6, length: 200,label: '0.71 mbps'}, | |
| {from: 7, to: 8, width: WIDTH_SCALE * 4, length: 200,label: '0.55 mbps'} | |
| ]; | |
| // create a network | |
| var container = document.getElementById('mynetwork'); | |
| var data = { | |
| nodes: nodes, | |
| edges: edges | |
| }; | |
| var options = { | |
| stabilize: false, | |
| nodes: { | |
| radiusMin: 16, | |
| radiusMax: 32, | |
| fontColor: '#2B1B17' | |
| }, | |
| edges: { | |
| color: 'gray' | |
| }, | |
| groups: { | |
| source : { | |
| shape: 'triangle', | |
| color: '#FF9900' // orange | |
| }, | |
| transfer: { | |
| shape: 'dot', | |
| color: "#2B7CE9" // blue | |
| }, | |
| storage: { | |
| shape: 'square', | |
| color: "#C5000B" // red | |
| } | |
| } | |
| }; | |
| var network = new vis.Network(container, data, options); | |
| } | |
| </script> | |
| </head> | |
| <body onload="draw()"> | |
| <div id="mynetwork" style="width:700px;height:700px;"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment