mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2026-02-13 22:17:38 +01:00
Upload of networks and pyvis mwe
This commit is contained in:
4 files changed
+680
No files matched your search
@@ -0,0 +1,180 @@
|
||||
<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: white;
|
||||
border: 1px solid lightgray;
|
||||
position: relative;
|
||||
float: left;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#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="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([{"branche": "Branche 1", "color": " #f3e8eeff", "font": {"color": "black"}, "id": 1, "label": "Firma 1", "shape": "dot", "size": 40, "title": "Firma 1\nBranche 1", "type": "Company"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 50, "label": "Person 20", "shape": "triangle", "size": 30, "title": "Person 20\n", "type": "Person"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 41, "label": "Person 11", "shape": "triangle", "size": 40, "title": "Person 11\n", "type": "Person"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 46, "label": "Person 16", "shape": "triangle", "size": 20, "title": "Person 16\n", "type": "Person"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 48, "label": "Person 18", "shape": "triangle", "size": 25, "title": "Person 18\n", "type": "Person"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 40, "label": "Person 10", "shape": "triangle", "size": 35, "title": "Person 10\n", "type": "Person"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 37, "label": "Person 7", "shape": "triangle", "size": 35, "title": "Person 7\n", "type": "Person"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 35, "label": "Person 5", "shape": "triangle", "size": 75, "title": "Person 5\n", "type": "Person"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 38, "label": "Person 8", "shape": "triangle", "size": 30, "title": "Person 8\n", "type": "Person"}, {"branche": "Branche 2", "color": "#bacdb0ff", "font": {"color": "black"}, "id": 2, "label": "Firma 2", "shape": "dot", "size": 45, "title": "Firma 2\nBranche 2", "type": "Company"}, {"branche": "Branche 5", "color": "#2e2c2fff", "font": {"color": "black"}, "id": 5, "label": "Firma 5", "shape": "dot", "size": 30, "title": "Firma 5\nBranche 5", "type": "Company"}, {"branche": "Branche 1", "color": " #f3e8eeff", "font": {"color": "black"}, "id": 6, "label": "Firma 6", "shape": "dot", "size": 25, "title": "Firma 6\nBranche 1", "type": "Company"}, {"branche": "Branche 4", "color": "#475b63ff", "font": {"color": "black"}, "id": 4, "label": "Firma 4", "shape": "dot", "size": 25, "title": "Firma 4\nBranche 4", "type": "Company"}, {"branche": "Branche 5", "color": "#2e2c2fff", "font": {"color": "black"}, "id": 25, "label": "Firma 25", "shape": "dot", "size": 20, "title": "Firma 25\nBranche 5", "type": "Company"}, {"branche": "Branche 1", "color": " #f3e8eeff", "font": {"color": "black"}, "id": 26, "label": "Firma 26", "shape": "dot", "size": 20, "title": "Firma 26\nBranche 1", "type": "Company"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 32, "label": "Person 2", "shape": "triangle", "size": 40, "title": "Person 2\n", "type": "Person"}, {"branche": "Branche 1", "color": " #f3e8eeff", "font": {"color": "black"}, "id": 11, "label": "Firma 11", "shape": "dot", "size": 15, "title": "Firma 11\nBranche 1", "type": "Company"}, {"branche": "Branche 3", "color": "#729b79ff", "font": {"color": "black"}, "id": 23, "label": "Firma 23", "shape": "dot", "size": 10, "title": "Firma 23\nBranche 3", "type": "Company"}, {"branche": "Branche 5", "color": "#2e2c2fff", "font": {"color": "black"}, "id": 20, "label": "Firma 20", "shape": "dot", "size": 20, "title": "Firma 20\nBranche 5", "type": "Company"}, {"branche": "Branche 3", "color": "#729b79ff", "font": {"color": "black"}, "id": 28, "label": "Firma 28", "shape": "dot", "size": 20, "title": "Firma 28\nBranche 3", "type": "Company"}, {"branche": "Branche 2", "color": "#bacdb0ff", "font": {"color": "black"}, "id": 7, "label": "Firma 7", "shape": "dot", "size": 15, "title": "Firma 7\nBranche 2", "type": "Company"}, {"branche": "Branche 3", "color": "#729b79ff", "font": {"color": "black"}, "id": 18, "label": "Firma 18", "shape": "dot", "size": 15, "title": "Firma 18\nBranche 3", "type": "Company"}, {"branche": "Branche 2", "color": "#bacdb0ff", "font": {"color": "black"}, "id": 27, "label": "Firma 27", "shape": "dot", "size": 20, "title": "Firma 27\nBranche 2", "type": "Company"}, {"branche": "", "color": "", "font": {"color": "black"}, "id": 31, "label": "Person 1", "shape": "triangle", "size": 50, "title": "Person 1\n", "type": "Person"}, {"branche": "Branche 3", "color": "#729b79ff", "font": {"color": "black"}, "id": 8, "label": "Firma 8", "shape": "dot", "size": 15, "title": "Firma 8\nBranche 3", "type": "Company"}, {"branche": "Branche 3", "color": "#729b79ff", "font": {"color": "black"}, "id": 3, "label": "Firma 3", "shape": "dot", "size": 30, "title": "Firma 3\nBranche 3", "type": "Company"}, {"branche": "Branche 5", "color": "#2e2c2fff", "font": {"color": "black"}, "id": 30, "label": "Firma 30", "shape": "dot", "size": 10, "title": "Firma 30\nBranche 5", "type": "Company"}, {"branche": "Branche 4", "color": "#475b63ff", "font": {"color": "black"}, "id": 9, "label": "Firma 9", "shape": "dot", "size": 15, "title": "Firma 9\nBranche 4", "type": "CoLine truncated
|
||||
edges = new vis.DataSet([{"from": 1, "label": "AR", "to": 50, "width": 1}, {"from": 1, "label": "V", "to": 41, "width": 1}, {"from": 1, "label": "WP", "to": 46, "width": 1}, {"from": 1, "label": "WP", "to": 48, "width": 1}, {"from": 1, "label": "V", "to": 40, "width": 1}, {"from": 1, "label": "AR", "to": 37, "width": 1}, {"from": 1, "label": "AR", "to": 35, "width": 1}, {"from": 1, "label": "AR", "to": 38, "width": 1}, {"from": 50, "label": "AR", "to": 2, "width": 1}, {"from": 50, "label": "V", "to": 5, "width": 1}, {"from": 50, "label": "AR", "to": 6, "width": 1}, {"from": 50, "label": "AR", "to": 4, "width": 1}, {"from": 50, "label": "AR", "to": 25, "width": 1}, {"from": 41, "label": "V", "to": 26, "width": 1}, {"from": 41, "label": "KOLL", "to": 32, "width": 1}, {"from": 41, "label": "V", "to": 5, "width": 1}, {"from": 41, "label": "V", "to": 11, "width": 1}, {"from": 41, "label": "V", "to": 23, "width": 1}, {"from": 41, "label": "WP", "to": 6, "width": 1}, {"from": 41, "label": "V", "to": 20, "width": 1}, {"from": 46, "label": "WP", "to": 2, "width": 1}, {"from": 46, "label": "AR", "to": 28, "width": 1}, {"from": 46, "label": "AR", "to": 7, "width": 1}, {"from": 48, "label": "AR", "to": 2, "width": 1}, {"from": 48, "label": "WP", "to": 18, "width": 1}, {"from": 48, "label": "V", "to": 26, "width": 1}, {"from": 48, "label": "WP", "to": 27, "width": 1}, {"from": 40, "label": "WP", "to": 27, "width": 1}, {"from": 40, "label": "KOLL", "to": 31, "width": 1}, {"from": 40, "label": "WP", "to": 6, "width": 1}, {"from": 40, "label": "V", "to": 8, "width": 1}, {"from": 40, "label": "WP", "to": 3, "width": 1}, {"from": 40, "label": "WP", "to": 30, "width": 1}, {"from": 37, "label": "WP", "to": 9, "width": 1}, {"from": 37, "label": "WP", "to": 12, "width": 1}, {"from": 37, "label": "WP", "to": 27, "width": 1}, {"from": 37, "label": "KOLL", "to": 33, "width": 1}, {"from": 37, "label": "V", "to": 14, "width": 1}, {"from": 37, "label": "AR", "to": 19, "width": 1}, {"from": 2, "label": "V", "to": 44, "width": 1}, {"from": 2, "label": "WP", "to": 36, "width": 1}, {"from": 2, "label": "V", "to": 49, "width": 1}, {"from": 2, "label": "V", "to": 35, "width": 1}, {"from": 2, "label": "V", "to": 43, "width": 1}, {"from": 2, "label": "V", "to": 39, "width": 1}, {"from": 44, "label": "AR", "to": 16, "width": 1}, {"from": 44, "label": "WP", "to": 21, "width": 1}, {"from": 44, "label": "WP", "to": 12, "width": 1}, {"from": 44, "label": "WP", "to": 15, "width": 1}, {"from": 44, "label": "V", "to": 17, "width": 1}, {"from": 44, "label": "AR", "to": 25, "width": 1}, {"from": 36, "label": "V", "to": 14, "width": 1}, {"from": 36, "label": "V", "to": 29, "width": 1}, {"from": 36, "label": "AR", "to": 13, "width": 1}, {"from": 49, "label": "WP", "to": 18, "width": 1}, {"from": 49, "label": "V", "to": 20, "width": 1}, {"from": 49, "label": "AR", "to": 22, "width": 1}, {"from": 49, "label": "WP", "to": 30, "width": 1}, {"from": 14, "label": "V", "to": 35, "width": 1}, {"from": 14, "label": "V", "to": 34, "width": 1}, {"from": 15, "label": "WP", "to": 38, "width": 1}, {"from": 15, "label": "WP", "to": 35, "width": 1}, {"from": 15, "label": "WP", "to": 32, "width": 1}, {"from": 38, "label": "WP", "to": 21, "width": 1}, {"from": 38, "label": "V", "to": 11, "width": 1}, {"from": 38, "label": "AR", "to": 13, "width": 1}, {"from": 38, "label": "WP", "to": 12, "width": 1}, {"from": 16, "label": "AR", "to": 35, "width": 1}, {"from": 16, "label": "AR", "to": 31, "width": 1}, {"from": 16, "label": "AR", "to": 45, "width": 1}, {"from": 17, "label": "V", "to": 35, "width": 1}, {"from": 35, "label": "V", "to": 8, "width": 1}, {"from": 35, "label": "AR", "to": 13, "width": 1}, {"from": 35, "label": "V", "to": 29, "width": 1}, {"from": 35, "label": "AR", "to": 4, "width": 1}, {"from": 35, "label": "WP", "to": 9, "width": 1}, {"from": 35, "label": "V", "to": 11, "width": 1}, {"from": 35, "label": "AR", "to": 22, "width": 1}, {"from": 35, "label": "V", "to": 10, "width": 1}, {"from": 35, "label": "WP", "to": 24, "width": 1}, {"from": 18, "label": "WP", "to": 5, "width": 1}, {"from": 19, "label": "AR", "to": 31, "width": 1}, {"from": 19, "label": "AR", "to": 47, "width": 1}, {"from": 19, "label": "AR", "to": 32, "width": 1}, {"from": 31, "label": "AR", "to": 22, "width": 1}, {"from": 31, "label": "WP", "to": 6, "width": 1}, {"from": 31, "label": "V", "to": 26, "width": 1}, {"from": 31, "label": "WP", "to": 3, "width": 1}, {"from": 31, "label": "AR", "to": 4, "width": 1}, {"from": 31, "label": "V", "to": 8, "width": 1}, {"from": 31, "label": "AR", "to": 10, "width": 1}, {"from": 20, "label": "V", "to": 45, "width": 1}, {"from": 20, "label": "V", "to": 34, "width": 1}, {"from": 21, "label": "WP", "to": 39, "width": 1}, {"from": 21, "label": "WP", "to": 43, "width": 1}, {"from": 22, "label": "AR", "to": 45, "width": 1}, {"from": 23, "label": "V", "to": 32, "width": 1}, {"from": 32, "label": "AR", "to": 10, "width": 1}, {"from": 32, "label"Line truncated
|
||||
|
||||
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": false
|
||||
},
|
||||
"smooth": {
|
||||
"enabled": true,
|
||||
"type": "dynamic"
|
||||
}
|
||||
},
|
||||
"interaction": {
|
||||
"dragNodes": true,
|
||||
"hideEdgesOnDrag": false,
|
||||
"hideNodesOnDrag": false
|
||||
},
|
||||
"physics": {
|
||||
"enabled": true,
|
||||
"repulsion": {
|
||||
"centralGravity": 0.2,
|
||||
"damping": 0.09,
|
||||
"nodeDistance": 250,
|
||||
"springConstant": 0.05,
|
||||
"springLength": 150
|
||||
},
|
||||
"solver": "repulsion",
|
||||
"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("click", neighbourhoodHighlight);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return network;
|
||||
|
||||
}
|
||||
drawGraph();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user