UNPKG

2.4 kBHTMLView Raw
1<!doctype html>
2<html>
3<head>
4 <title>Network | Static smooth curves</title>
5
6 <script type="text/javascript" src="../../../dist/vis-network.min.js"></script>
7 <link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" />
8
9 <style type="text/css">
10 #mynetwork {
11 width: 500px;
12 height: 500px;
13 border: 1px solid lightgray;
14 }
15 </style>
16
17</head>
18
19<body>
20
21<h2>Smooth curves</h2>
22<div style="width:700px; font-size:14px; text-align: justify;">
23 All the smooth curves in the examples so far have been using dynamic smooth curves. This means that each curve has a
24 support node which takes part in the physics simulation. For large networks or dense clusters, this may not be the ideal
25 solution. To solve this, static smooth curves have been added. The static smooth curves are based only on the positions of the connected
26 nodes. There are multiple ways to determine the way this curve is drawn. This example shows the effect of the different
27 types. <br /> <br />
28 Drag the node around to see how the smooth curves are drawn for each setting. For animated system, we
29 recommend only the continuous mode. In the next example you can see the effect of these methods on a large network. Keep in mind
30 that the direction (the from and to) of the curve matters.
31 <br /> <br />
32 When you select the dynamic type, you can see the interaction with the fixed node and the edge, any other type will not interact with other nodes.
33 <br /> <br />
34</div>
35
36<div id="mynetwork"></div>
37
38<script type="text/javascript">
39
40 // create an array with nodes
41 var nodes = [
42 {id: 1, label: 'Fixed node', x:0, y:0, fixed:true},
43 {id: 2, label: 'Drag me', x:150, y:130, physics:false},
44 {id: 3, label: 'Obstacle', x:80, y:-80, fixed:true, mass:10}
45 ];
46
47 // create an array with edges
48 var edges = [
49 {from: 1, to: 2, arrows:'to'}
50 ];
51
52 // create a network
53 var container = document.getElementById('mynetwork');
54 var data = {
55 nodes: nodes,
56 edges: edges
57 };
58 var options = {
59 physics:true,
60 configure:function (option, path) {
61 if (path.indexOf('smooth') !== -1 || option === 'smooth') {
62 return true;
63 }
64 return false;
65 },
66 edges: {
67 smooth: {
68 type: 'continuous'
69 }
70 }
71 };
72 var network = new vis.Network(container, data, options);
73
74
75</script>
76
77</body>
78</html>