1 | <!doctype html>
|
2 | <html>
|
3 | <head>
|
4 | <title>Network | Sizing</title>
|
5 |
|
6 | <style type="text/css">
|
7 | html, body {
|
8 | font: 10pt arial;
|
9 | }
|
10 | #mynetwork {
|
11 | width: 600px;
|
12 | height: 600px;
|
13 | border: 1px solid lightgray;
|
14 | }
|
15 | </style>
|
16 |
|
17 | <script type="text/javascript" src="../../../dist/vis-network.min.js"></script>
|
18 | <link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" />
|
19 |
|
20 | <script type="text/javascript">
|
21 | var nodes = null;
|
22 | var edges = null;
|
23 | var network = null;
|
24 |
|
25 | function draw() {
|
26 |
|
27 |
|
28 | nodes = [
|
29 | {id: 1, value: 2, label: 'Algie' },
|
30 | {id: 2, value: 31, label: 'Alston'},
|
31 | {id: 3, value: 12, label: 'Barney'},
|
32 | {id: 4, value: 16, label: 'Coley' },
|
33 | {id: 5, value: 17, label: 'Grant' },
|
34 | {id: 6, value: 15, label: 'Langdon'},
|
35 | {id: 7, value: 6, label: 'Lee'},
|
36 | {id: 8, value: 5, label: 'Merlin'},
|
37 | {id: 9, value: 30, label: 'Mick'},
|
38 | {id: 10, value: 18, label: 'Tod'},
|
39 | ];
|
40 |
|
41 |
|
42 |
|
43 | edges = [
|
44 | {from: 2, to: 8, value: 3},
|
45 | {from: 2, to: 9, value: 5},
|
46 | {from: 2, to: 10,value: 1},
|
47 | {from: 4, to: 6, value: 8},
|
48 | {from: 5, to: 7, value: 2},
|
49 | {from: 4, to: 5, value: 1},
|
50 | {from: 9, to: 10,value: 2},
|
51 | {from: 2, to: 3, value: 6},
|
52 | {from: 3, to: 9, value: 4},
|
53 | {from: 5, to: 3, value: 1},
|
54 | {from: 2, to: 7, value: 4}
|
55 | ];
|
56 |
|
57 |
|
58 | var container = document.getElementById('mynetwork');
|
59 | var data = {
|
60 | nodes: nodes,
|
61 | edges: edges
|
62 | };
|
63 | var options = {
|
64 | nodes: {
|
65 | shape: 'dot',
|
66 | scaling: {
|
67 | customScalingFunction: function (min,max,total,value) {
|
68 | return value/total;
|
69 | },
|
70 | min:5,
|
71 | max:150
|
72 | }
|
73 | }
|
74 | };
|
75 | network = new vis.Network(container, data, options);
|
76 | }
|
77 | </script>
|
78 |
|
79 | </head>
|
80 | <body onload="draw()">
|
81 | <p>
|
82 | Scale nodes and edges depending on their value. Hover over nodes and edges to get more information.
|
83 | </p>
|
84 | <div id="mynetwork"></div>
|
85 | </body>
|
86 | </html>
|