You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
small-worlds/foursquareIT_friends.html

265 lines
250 KiB
HTML

<html>
<head>
<meta charset="utf-8">
<script src="lib/bindings/utils.js"></script>
<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" />
<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>
<center>
<h1></h1>
</center>
<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>
<center>
<h1></h1>
</center>
<style type="text/css">
#mynetwork {
width: 100%;
height: 600px;
background-color: #ffffff;
border: 1px solid lightgray;
position: relative;
float: left;
}
#loadingBar {
position:absolute;
top:0px;
left:0px;
width: 100%;
height: 600px;
background-color:rgba(200,200,200,0.8);
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
opacity:1;
}
#bar {
position:absolute;
top:0px;
left:0px;
width:20px;
height:20px;
margin:auto auto auto auto;
border-radius:11px;
border:2px solid rgba(30,30,30,0.05);
background: rgb(0, 173, 246); /* Old browsers */
box-shadow: 2px 0px 4px rgba(0,0,0,0.4);
}
#border {
position:absolute;
top:10px;
left:10px;
width:500px;
height:23px;
margin:auto auto auto auto;
box-shadow: 0px 0px 4px rgba(0,0,0,0.2);
border-radius:10px;
}
#text {
position:absolute;
top:8px;
left:530px;
width:30px;
height:50px;
margin:auto auto auto auto;
font-size:22px;
color: #000000;
}
div.outerBorder {
position:relative;
top:400px;
width:600px;
height:44px;
margin:auto auto auto auto;
border:8px solid rgba(0,0,0,0.1);
background: rgb(252,252,252); /* Old browsers */
background: -moz-linear-gradient(top, rgba(252,252,252,1) 0%, rgba(237,237,237,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(252,252,252,1)), color-stop(100%,rgba(237,237,237,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfcfc', endColorstr='#ededed',GradientType=0 ); /* IE6-9 */
border-radius:72px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
}
#config {
float: left;
width: 400px;
height: 600px;
}
</style>
</head>
<body>
<div class="card" style="width: 100%">
<div id="mynetwork" class="card-body"></div>
</div>
<div id="loadingBar">
<div class="outerBorder">
<div id="text">0%</div>
<div id="border">
<div id="bar"></div>
</div>
</div>
</div>
<div id="config"></div>
<script type="text/javascript">
// initialize global variables.
var edges;
var nodes;
var allNodes;
var allEdges;
var nodeColors;
var originalNodes;
var network;
var container;
var options, data;
var filter = {
item : '',
property : '',
value : []
};
// This method is responsible for drawing the graph, returns the drawn network
function drawGraph() {
var container = document.getElementById('mynetwork');
// parsing and collecting nodes and edges from the python
nodes = new vis.DataSet([{"color": "#97c2fc", "id": 0, "label": 0, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 902, "label": 902, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 742, "label": 742, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 340, "label": 340, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 447, "label": 447, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 590, "label": 590, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 124, "label": 124, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 888, "label": 888, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 53, "label": 53, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 801, "label": 801, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 472, "label": 472, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 660, "label": 660, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 824, "label": 824, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 486, "label": 486, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 147, "label": 147, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 1, "label": 1, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 669, "label": 669, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 624, "label": 624, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 209, "label": 209, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 69, "label": 69, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 752, "label": 752, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 907, "label": 907, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 735, "label": 735, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 9, "label": 9, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 626, "label": 626, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 217, "label": 217, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 477, "label": 477, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 726, "label": 726, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 103, "label": 103, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 664, "label": 664, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 305, "label": 305, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 160, "label": 160, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 431, "label": 431, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 833, "label": 833, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 537, "label": 537, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 286, "label": 286, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 803, "label": 803, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 696, "label": 696, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 377, "label": 377, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 153, "label": 153, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 706, "label": 706, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 138, "label": 138, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 714, "label": 714, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 933, "label": 933, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 83, "label": 83, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 2, "label": 2, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 150, "label": 150, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 593, "label": 593, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 859, "label": 859, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 939, "label": 939, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 8, "label": 8, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 965, "label": 965, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 274, "label": 274, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 105, "label": 105, "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": 6
edges = new vis.DataSet([{"from": 0, "to": 902, "width": 1}, {"from": 0, "to": 742, "width": 1}, {"from": 0, "to": 340, "width": 1}, {"from": 0, "to": 447, "width": 1}, {"from": 0, "to": 590, "width": 1}, {"from": 0, "to": 124, "width": 1}, {"from": 0, "to": 888, "width": 1}, {"from": 0, "to": 53, "width": 1}, {"from": 0, "to": 801, "width": 1}, {"from": 0, "to": 472, "width": 1}, {"from": 0, "to": 660, "width": 1}, {"from": 0, "to": 824, "width": 1}, {"from": 0, "to": 486, "width": 1}, {"from": 0, "to": 147, "width": 1}, {"from": 1, "to": 669, "width": 1}, {"from": 1, "to": 624, "width": 1}, {"from": 1, "to": 209, "width": 1}, {"from": 1, "to": 69, "width": 1}, {"from": 1, "to": 752, "width": 1}, {"from": 1, "to": 907, "width": 1}, {"from": 1, "to": 735, "width": 1}, {"from": 1, "to": 9, "width": 1}, {"from": 1, "to": 626, "width": 1}, {"from": 1, "to": 217, "width": 1}, {"from": 1, "to": 477, "width": 1}, {"from": 1, "to": 726, "width": 1}, {"from": 1, "to": 103, "width": 1}, {"from": 1, "to": 664, "width": 1}, {"from": 1, "to": 305, "width": 1}, {"from": 1, "to": 160, "width": 1}, {"from": 1, "to": 431, "width": 1}, {"from": 1, "to": 833, "width": 1}, {"from": 1, "to": 537, "width": 1}, {"from": 1, "to": 286, "width": 1}, {"from": 1, "to": 803, "width": 1}, {"from": 1, "to": 696, "width": 1}, {"from": 1, "to": 377, "width": 1}, {"from": 1, "to": 153, "width": 1}, {"from": 1, "to": 706, "width": 1}, {"from": 1, "to": 138, "width": 1}, {"from": 1, "to": 714, "width": 1}, {"from": 1, "to": 933, "width": 1}, {"from": 1, "to": 83, "width": 1}, {"from": 2, "to": 150, "width": 1}, {"from": 2, "to": 593, "width": 1}, {"from": 2, "to": 859, "width": 1}, {"from": 2, "to": 939, "width": 1}, {"from": 2, "to": 8, "width": 1}, {"from": 2, "to": 965, "width": 1}, {"from": 2, "to": 274, "width": 1}, {"from": 2, "to": 105, "width": 1}, {"from": 2, "to": 641, "width": 1}, {"from": 2, "to": 466, "width": 1}, {"from": 2, "to": 392, "width": 1}, {"from": 2, "to": 628, "width": 1}, {"from": 2, "to": 335, "width": 1}, {"from": 2, "to": 374, "width": 1}, {"from": 2, "to": 734, "width": 1}, {"from": 2, "to": 438, "width": 1}, {"from": 2, "to": 716, "width": 1}, {"from": 2, "to": 831, "width": 1}, {"from": 2, "to": 211, "width": 1}, {"from": 2, "to": 668, "width": 1}, {"from": 2, "to": 241, "width": 1}, {"from": 2, "to": 829, "width": 1}, {"from": 2, "to": 212, "width": 1}, {"from": 2, "to": 797, "width": 1}, {"from": 2, "to": 354, "width": 1}, {"from": 2, "to": 239, "width": 1}, {"from": 2, "to": 753, "width": 1}, {"from": 2, "to": 411, "width": 1}, {"from": 2, "to": 13, "width": 1}, {"from": 2, "to": 60, "width": 1}, {"from": 2, "to": 193, "width": 1}, {"from": 2, "to": 560, "width": 1}, {"from": 2, "to": 540, "width": 1}, {"from": 2, "to": 697, "width": 1}, {"from": 2, "to": 437, "width": 1}, {"from": 3, "to": 971, "width": 1}, {"from": 3, "to": 895, "width": 1}, {"from": 3, "to": 135, "width": 1}, {"from": 3, "to": 660, "width": 1}, {"from": 3, "to": 572, "width": 1}, {"from": 3, "to": 414, "width": 1}, {"from": 3, "to": 872, "width": 1}, {"from": 3, "to": 193, "width": 1}, {"from": 4, "to": 201, "width": 1}, {"from": 5, "to": 521, "width": 1}, {"from": 6, "to": 523, "width": 1}, {"from": 7, "to": 131, "width": 1}, {"from": 7, "to": 346, "width": 1}, {"from": 7, "to": 237, "width": 1}, {"from": 7, "to": 453, "width": 1}, {"from": 7, "to": 935, "width": 1}, {"from": 7, "to": 194, "width": 1}, {"from": 8, "to": 944, "width": 1}, {"from": 8, "to": 97, "width": 1}, {"from": 8, "to": 731, "width": 1}, {"from": 8, "to": 424, "width": 1}, {"from": 8, "to": 632, "width": 1}, {"from": 8, "to": 655, "width": 1}, {"from": 9, "to": 965, "width": 1}, {"from": 9, "to": 735, "width": 1}, {"from": 9, "to": 981, "width": 1}, {"from": 9, "to": 847, "width": 1}, {"from": 9, "to": 477, "width": 1}, {"from": 9, "to": 543, "width": 1}, {"from": 9, "to": 537, "width": 1}, {"from": 9, "to": 748, "width": 1}, {"from": 9, "to": 626, "width": 1}, {"from": 9, "to": 83, "width": 1}, {"from": 10, "to": 972, "width": 1}, {"from": 10, "to": 364, "width
nodeColors = {};
allNodes = nodes.get({ returnType: "Object" });
for (nodeId in allNodes) {
nodeColors[nodeId] = allNodes[nodeId].color;
}
allEdges = edges.get({ returnType: "Object" });
// adding nodes and edges to the graph
data = {nodes: nodes, edges: edges};
var options = {
"configure": {
"enabled": true,
"filter": [
"physics"
]
},
"edges": {
"color": {
"inherit": true
},
"smooth": {
"enabled": true,
"type": "dynamic"
}
},
"interaction": {
"dragNodes": true,
"hideEdgesOnDrag": false,
"hideNodesOnDrag": false
},
"physics": {
"enabled": true,
"stabilization": {
"enabled": true,
"fit": true,
"iterations": 1000,
"onlyDynamicEdges": false,
"updateInterval": 50
}
}
};
// if this network requires displaying the configure window,
// put it in its div
options.configure["container"] = document.getElementById("config");
network = new vis.Network(container, data, options);
network.on("stabilizationProgress", function(params) {
document.getElementById('loadingBar').removeAttribute("style");
var maxWidth = 496;
var minWidth = 20;
var widthFactor = params.iterations/params.total;
var width = Math.max(minWidth,maxWidth * widthFactor);
document.getElementById('bar').style.width = width + 'px';
document.getElementById('text').innerHTML = Math.round(widthFactor*100) + '%';
});
network.once("stabilizationIterationsDone", function() {
document.getElementById('text').innerHTML = '100%';
document.getElementById('bar').style.width = '496px';
document.getElementById('loadingBar').style.opacity = 0;
// really clean the dom element
setTimeout(function () {document.getElementById('loadingBar').style.display = 'none';}, 500);
});
return network;
}
drawGraph();
</script>
</body>
</html>