Upload florentine_families_network.html
Browse files- florentine_families_network.html +349 -0
florentine_families_network.html
ADDED
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<head>
|
3 |
+
<meta charset="utf-8">
|
4 |
+
|
5 |
+
<script>function neighbourhoodHighlight(params) {
|
6 |
+
// console.log("in nieghbourhoodhighlight");
|
7 |
+
allNodes = nodes.get({ returnType: "Object" });
|
8 |
+
// originalNodes = JSON.parse(JSON.stringify(allNodes));
|
9 |
+
// if something is selected:
|
10 |
+
if (params.nodes.length > 0) {
|
11 |
+
highlightActive = true;
|
12 |
+
var i, j;
|
13 |
+
var selectedNode = params.nodes[0];
|
14 |
+
var degrees = 2;
|
15 |
+
|
16 |
+
// mark all nodes as hard to read.
|
17 |
+
for (let nodeId in allNodes) {
|
18 |
+
// nodeColors[nodeId] = allNodes[nodeId].color;
|
19 |
+
allNodes[nodeId].color = "rgba(200,200,200,0.5)";
|
20 |
+
if (allNodes[nodeId].hiddenLabel === undefined) {
|
21 |
+
allNodes[nodeId].hiddenLabel = allNodes[nodeId].label;
|
22 |
+
allNodes[nodeId].label = undefined;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
var connectedNodes = network.getConnectedNodes(selectedNode);
|
26 |
+
var allConnectedNodes = [];
|
27 |
+
|
28 |
+
// get the second degree nodes
|
29 |
+
for (i = 1; i < degrees; i++) {
|
30 |
+
for (j = 0; j < connectedNodes.length; j++) {
|
31 |
+
allConnectedNodes = allConnectedNodes.concat(
|
32 |
+
network.getConnectedNodes(connectedNodes[j])
|
33 |
+
);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
// all second degree nodes get a different color and their label back
|
38 |
+
for (i = 0; i < allConnectedNodes.length; i++) {
|
39 |
+
// allNodes[allConnectedNodes[i]].color = "pink";
|
40 |
+
allNodes[allConnectedNodes[i]].color = "rgba(150,150,150,0.75)";
|
41 |
+
if (allNodes[allConnectedNodes[i]].hiddenLabel !== undefined) {
|
42 |
+
allNodes[allConnectedNodes[i]].label =
|
43 |
+
allNodes[allConnectedNodes[i]].hiddenLabel;
|
44 |
+
allNodes[allConnectedNodes[i]].hiddenLabel = undefined;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
// all first degree nodes get their own color and their label back
|
49 |
+
for (i = 0; i < connectedNodes.length; i++) {
|
50 |
+
// allNodes[connectedNodes[i]].color = undefined;
|
51 |
+
allNodes[connectedNodes[i]].color = nodeColors[connectedNodes[i]];
|
52 |
+
if (allNodes[connectedNodes[i]].hiddenLabel !== undefined) {
|
53 |
+
allNodes[connectedNodes[i]].label =
|
54 |
+
allNodes[connectedNodes[i]].hiddenLabel;
|
55 |
+
allNodes[connectedNodes[i]].hiddenLabel = undefined;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
// the main node gets its own color and its label back.
|
60 |
+
// allNodes[selectedNode].color = undefined;
|
61 |
+
allNodes[selectedNode].color = nodeColors[selectedNode];
|
62 |
+
if (allNodes[selectedNode].hiddenLabel !== undefined) {
|
63 |
+
allNodes[selectedNode].label = allNodes[selectedNode].hiddenLabel;
|
64 |
+
allNodes[selectedNode].hiddenLabel = undefined;
|
65 |
+
}
|
66 |
+
} else if (highlightActive === true) {
|
67 |
+
// console.log("highlightActive was true");
|
68 |
+
// reset all nodes
|
69 |
+
for (let nodeId in allNodes) {
|
70 |
+
// allNodes[nodeId].color = "purple";
|
71 |
+
allNodes[nodeId].color = nodeColors[nodeId];
|
72 |
+
// delete allNodes[nodeId].color;
|
73 |
+
if (allNodes[nodeId].hiddenLabel !== undefined) {
|
74 |
+
allNodes[nodeId].label = allNodes[nodeId].hiddenLabel;
|
75 |
+
allNodes[nodeId].hiddenLabel = undefined;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
highlightActive = false;
|
79 |
+
}
|
80 |
+
|
81 |
+
// transform the object into an array
|
82 |
+
var updateArray = [];
|
83 |
+
if (params.nodes.length > 0) {
|
84 |
+
for (let nodeId in allNodes) {
|
85 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
86 |
+
// console.log(allNodes[nodeId]);
|
87 |
+
updateArray.push(allNodes[nodeId]);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
nodes.update(updateArray);
|
91 |
+
} else {
|
92 |
+
// console.log("Nothing was selected");
|
93 |
+
for (let nodeId in allNodes) {
|
94 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
95 |
+
// console.log(allNodes[nodeId]);
|
96 |
+
// allNodes[nodeId].color = {};
|
97 |
+
updateArray.push(allNodes[nodeId]);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
nodes.update(updateArray);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
function filterHighlight(params) {
|
105 |
+
allNodes = nodes.get({ returnType: "Object" });
|
106 |
+
// if something is selected:
|
107 |
+
if (params.nodes.length > 0) {
|
108 |
+
filterActive = true;
|
109 |
+
let selectedNodes = params.nodes;
|
110 |
+
|
111 |
+
// hiding all nodes and saving the label
|
112 |
+
for (let nodeId in allNodes) {
|
113 |
+
allNodes[nodeId].hidden = true;
|
114 |
+
if (allNodes[nodeId].savedLabel === undefined) {
|
115 |
+
allNodes[nodeId].savedLabel = allNodes[nodeId].label;
|
116 |
+
allNodes[nodeId].label = undefined;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
for (let i=0; i < selectedNodes.length; i++) {
|
121 |
+
allNodes[selectedNodes[i]].hidden = false;
|
122 |
+
if (allNodes[selectedNodes[i]].savedLabel !== undefined) {
|
123 |
+
allNodes[selectedNodes[i]].label = allNodes[selectedNodes[i]].savedLabel;
|
124 |
+
allNodes[selectedNodes[i]].savedLabel = undefined;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
} else if (filterActive === true) {
|
129 |
+
// reset all nodes
|
130 |
+
for (let nodeId in allNodes) {
|
131 |
+
allNodes[nodeId].hidden = false;
|
132 |
+
if (allNodes[nodeId].savedLabel !== undefined) {
|
133 |
+
allNodes[nodeId].label = allNodes[nodeId].savedLabel;
|
134 |
+
allNodes[nodeId].savedLabel = undefined;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
filterActive = false;
|
138 |
+
}
|
139 |
+
|
140 |
+
// transform the object into an array
|
141 |
+
var updateArray = [];
|
142 |
+
if (params.nodes.length > 0) {
|
143 |
+
for (let nodeId in allNodes) {
|
144 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
145 |
+
updateArray.push(allNodes[nodeId]);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
nodes.update(updateArray);
|
149 |
+
} else {
|
150 |
+
for (let nodeId in allNodes) {
|
151 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
152 |
+
updateArray.push(allNodes[nodeId]);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
nodes.update(updateArray);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
function selectNode(nodes) {
|
160 |
+
network.selectNodes(nodes);
|
161 |
+
neighbourhoodHighlight({ nodes: nodes });
|
162 |
+
return nodes;
|
163 |
+
}
|
164 |
+
|
165 |
+
function selectNodes(nodes) {
|
166 |
+
network.selectNodes(nodes);
|
167 |
+
filterHighlight({nodes: nodes});
|
168 |
+
return nodes;
|
169 |
+
}
|
170 |
+
|
171 |
+
function highlightFilter(filter) {
|
172 |
+
let selectedNodes = []
|
173 |
+
let selectedProp = filter['property']
|
174 |
+
if (filter['item'] === 'node') {
|
175 |
+
let allNodes = nodes.get({ returnType: "Object" });
|
176 |
+
for (let nodeId in allNodes) {
|
177 |
+
if (allNodes[nodeId][selectedProp] && filter['value'].includes((allNodes[nodeId][selectedProp]).toString())) {
|
178 |
+
selectedNodes.push(nodeId)
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
else if (filter['item'] === 'edge'){
|
183 |
+
let allEdges = edges.get({returnType: 'object'});
|
184 |
+
// check if the selected property exists for selected edge and select the nodes connected to the edge
|
185 |
+
for (let edge in allEdges) {
|
186 |
+
if (allEdges[edge][selectedProp] && filter['value'].includes((allEdges[edge][selectedProp]).toString())) {
|
187 |
+
selectedNodes.push(allEdges[edge]['from'])
|
188 |
+
selectedNodes.push(allEdges[edge]['to'])
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
selectNodes(selectedNodes)
|
193 |
+
}</script>
|
194 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
195 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
196 |
+
|
197 |
+
|
198 |
+
|
199 |
+
|
200 |
+
|
201 |
+
|
202 |
+
|
203 |
+
|
204 |
+
<center>
|
205 |
+
<h1></h1>
|
206 |
+
</center>
|
207 |
+
|
208 |
+
<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
|
209 |
+
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
|
210 |
+
<link
|
211 |
+
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
|
212 |
+
rel="stylesheet"
|
213 |
+
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
|
214 |
+
crossorigin="anonymous"
|
215 |
+
/>
|
216 |
+
<script
|
217 |
+
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
|
218 |
+
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
|
219 |
+
crossorigin="anonymous"
|
220 |
+
></script>
|
221 |
+
|
222 |
+
|
223 |
+
<center>
|
224 |
+
<h1></h1>
|
225 |
+
</center>
|
226 |
+
<style type="text/css">
|
227 |
+
|
228 |
+
#mynetwork {
|
229 |
+
width: 100%;
|
230 |
+
height: 750px;
|
231 |
+
background-color: #ffffff;
|
232 |
+
border: 1px solid lightgray;
|
233 |
+
position: relative;
|
234 |
+
float: left;
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
|
239 |
+
|
240 |
+
|
241 |
+
|
242 |
+
</style>
|
243 |
+
</head>
|
244 |
+
|
245 |
+
|
246 |
+
<body>
|
247 |
+
<div class="card" style="width: 100%">
|
248 |
+
|
249 |
+
|
250 |
+
<div id="mynetwork" class="card-body"></div>
|
251 |
+
</div>
|
252 |
+
|
253 |
+
|
254 |
+
|
255 |
+
|
256 |
+
<script type="text/javascript">
|
257 |
+
|
258 |
+
// initialize global variables.
|
259 |
+
var edges;
|
260 |
+
var nodes;
|
261 |
+
var allNodes;
|
262 |
+
var allEdges;
|
263 |
+
var nodeColors;
|
264 |
+
var originalNodes;
|
265 |
+
var network;
|
266 |
+
var container;
|
267 |
+
var options, data;
|
268 |
+
var filter = {
|
269 |
+
item : '',
|
270 |
+
property : '',
|
271 |
+
value : []
|
272 |
+
};
|
273 |
+
|
274 |
+
|
275 |
+
|
276 |
+
|
277 |
+
|
278 |
+
// This method is responsible for drawing the graph, returns the drawn network
|
279 |
+
function drawGraph() {
|
280 |
+
var container = document.getElementById('mynetwork');
|
281 |
+
|
282 |
+
|
283 |
+
|
284 |
+
// parsing and collecting nodes and edges from the python
|
285 |
+
nodes = new vis.DataSet([{"betweenness": 0.0, "closeness": 0.3684210526315789, "color": {"background": "hsl(30, 100%, 53.57142857142857%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.07142857142857142, "id": "Acciaiuoli", "label": "Acciaiuoli", "shape": "dot", "size": 4.398496240601504}, {"betweenness": 0.521978021978022, "closeness": 0.56, "color": {"background": "hsl(30, 100%, 71.42857142857143%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.42857142857142855, "id": "Medici", "label": "Medici", "shape": "dot", "size": 15.105494505494505}, {"betweenness": 0.09340659340659341, "closeness": 0.4375, "color": {"background": "hsl(30, 100%, 57.14285714285714%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.14285714285714285, "id": "Barbadori", "label": "Barbadori", "shape": "dot", "size": 6.737637362637363}, {"betweenness": 0.11355311355311355, "closeness": 0.5, "color": {"background": "hsl(30, 100%, 60.714285714285715%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.21428571428571427, "id": "Ridolfi", "label": "Ridolfi", "shape": "dot", "size": 8.278388278388277}, {"betweenness": 0.09157509157509157, "closeness": 0.4827586206896552, "color": {"background": "hsl(30, 100%, 60.714285714285715%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.21428571428571427, "id": "Tornabuoni", "label": "Tornabuoni", "shape": "dot", "size": 7.88619426550461}, {"betweenness": 0.21245421245421245, "closeness": 0.4827586206896552, "color": {"background": "hsl(30, 100%, 60.714285714285715%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.21428571428571427, "id": "Albizzi", "label": "Albizzi", "shape": "dot", "size": 9.09498547429582}, {"betweenness": 0.14285714285714288, "closeness": 0.3888888888888889, "color": {"background": "hsl(30, 100%, 57.14285714285714%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.14285714285714285, "id": "Salviati", "label": "Salviati", "shape": "dot", "size": 6.746031746031747}, {"betweenness": 0.05494505494505495, "closeness": 0.3888888888888889, "color": {"background": "hsl(30, 100%, 60.714285714285715%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.21428571428571427, "id": "Castellani", "label": "Castellani", "shape": "dot", "size": 6.581196581196581}, {"betweenness": 0.02197802197802198, "closeness": 0.3684210526315789, "color": {"background": "hsl(30, 100%, 60.714285714285715%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.21428571428571427, "id": "Peruzzi", "label": "Peruzzi", "shape": "dot", "size": 6.046847888953152}, {"betweenness": 0.10256410256410257, "closeness": 0.4375, "color": {"background": "hsl(30, 100%, 64.28571428571428%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.2857142857142857, "id": "Strozzi", "label": "Strozzi", "shape": "dot", "size": 8.257783882783883}, {"betweenness": 0.1043956043956044, "closeness": 0.4, "color": {"background": "hsl(30, 100%, 60.714285714285715%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.21428571428571427, "id": "Bischeri", "label": "Bischeri", "shape": "dot", "size": 7.186813186813187}, {"betweenness": 0.2545787545787546, "closeness": 0.4666666666666667, "color": {"background": "hsl(30, 100%, 64.28571428571428%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.2857142857142857, "id": "Guadagni", "label": "Guadagni", "shape": "dot", "size": 10.06959706959707}, {"betweenness": 0.0, "closeness": 0.3333333333333333, "color": {"background": "hsl(30, 100%, 53.57142857142857%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.07142857142857142, "id": "Ginori", "label": "Ginori", "shape": "dot", "size": 4.0476190476190474}, {"betweenness": 0.0, "closeness": 0.2857142857142857, "color": {"background": "hsl(30, 100%, 53.57142857142857%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.07142857142857142, "id": "Pazzi", "label": "Pazzi", "shape": "dot", "size": 3.571428571428571}, {"betweenness": 0.0, "closeness": 0.32558139534883723, "color": {"background": "hsl(30, 100%, 53.57142857142857%)", "border": "#000000", "highlight": {"background": "#FFD700", "border": "#FFFFFF"}}, "degree": 0.07142857142857142, "id": "Lamberteschi", "label": "Lamberteschi", "shape": "dot", "size": 3.970099667774086}]);
|
286 |
+
edges = new vis.DataSet([{"from": "Acciaiuoli", "to": "Medici", "width": 1}, {"from": "Medici", "to": "Barbadori", "width": 1}, {"from": "Medici", "to": "Ridolfi", "width": 1}, {"from": "Medici", "to": "Tornabuoni", "width": 1}, {"from": "Medici", "to": "Albizzi", "width": 1}, {"from": "Medici", "to": "Salviati", "width": 1}, {"from": "Castellani", "to": "Peruzzi", "width": 1}, {"from": "Castellani", "to": "Strozzi", "width": 1}, {"from": "Castellani", "to": "Barbadori", "width": 1}, {"from": "Peruzzi", "to": "Strozzi", "width": 1}, {"from": "Peruzzi", "to": "Bischeri", "width": 1}, {"from": "Strozzi", "to": "Ridolfi", "width": 1}, {"from": "Strozzi", "to": "Bischeri", "width": 1}, {"from": "Ridolfi", "to": "Tornabuoni", "width": 1}, {"from": "Tornabuoni", "to": "Guadagni", "width": 1}, {"from": "Albizzi", "to": "Ginori", "width": 1}, {"from": "Albizzi", "to": "Guadagni", "width": 1}, {"from": "Salviati", "to": "Pazzi", "width": 1}, {"from": "Bischeri", "to": "Guadagni", "width": 1}, {"from": "Guadagni", "to": "Lamberteschi", "width": 1}]);
|
287 |
+
|
288 |
+
nodeColors = {};
|
289 |
+
allNodes = nodes.get({ returnType: "Object" });
|
290 |
+
for (nodeId in allNodes) {
|
291 |
+
nodeColors[nodeId] = allNodes[nodeId].color;
|
292 |
+
}
|
293 |
+
allEdges = edges.get({ returnType: "Object" });
|
294 |
+
// adding nodes and edges to the graph
|
295 |
+
data = {nodes: nodes, edges: edges};
|
296 |
+
|
297 |
+
var options = {
|
298 |
+
"configure": {
|
299 |
+
"enabled": false
|
300 |
+
},
|
301 |
+
"edges": {
|
302 |
+
"color": {
|
303 |
+
"inherit": true
|
304 |
+
},
|
305 |
+
"smooth": {
|
306 |
+
"enabled": true,
|
307 |
+
"type": "dynamic"
|
308 |
+
}
|
309 |
+
},
|
310 |
+
"interaction": {
|
311 |
+
"dragNodes": true,
|
312 |
+
"hideEdgesOnDrag": false,
|
313 |
+
"hideNodesOnDrag": false
|
314 |
+
},
|
315 |
+
"physics": {
|
316 |
+
"enabled": true,
|
317 |
+
"stabilization": {
|
318 |
+
"enabled": true,
|
319 |
+
"fit": true,
|
320 |
+
"iterations": 1000,
|
321 |
+
"onlyDynamicEdges": false,
|
322 |
+
"updateInterval": 50
|
323 |
+
}
|
324 |
+
}
|
325 |
+
};
|
326 |
+
|
327 |
+
|
328 |
+
|
329 |
+
|
330 |
+
|
331 |
+
|
332 |
+
network = new vis.Network(container, data, options);
|
333 |
+
|
334 |
+
|
335 |
+
|
336 |
+
|
337 |
+
|
338 |
+
|
339 |
+
|
340 |
+
|
341 |
+
|
342 |
+
|
343 |
+
return network;
|
344 |
+
|
345 |
+
}
|
346 |
+
drawGraph();
|
347 |
+
</script>
|
348 |
+
</body>
|
349 |
+
</html>
|