wc_rules/graph/templates/template_partitioning.html
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis.css" type="text/css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis-network.min.js"> </script>
<style type="text/css">
.container {
text-align:center;
width:100%;
}
.graph, .titlebox {
width: 30%;
display: inline-block;
}
.graph {
width: 30%;
height: 30%;
background-color: #ffffff;
border: 1px solid lightgray;
display:inline-block;
}
</style>
</head>
<body>
<div class = "container">
<div class="titlebox"> <h2> Parent </h2> </div>
<div class="titlebox"> <h2> Child </h2> </div>
<div class="titlebox"> <h2> Child </h2> </div>
{% for graph in graphs -%}
<div id = "graph{{ loop.index }}" class="graph"> </div>
{% endfor %}
</div>
<script type="text/javascript">
// initialize global variables.
var edges;
var nodes;
var network;
var container;
var options, data;
// individual graphs
nodeslist = new Array();
edgeslist = new Array();
{% for graph in graphs -%}
nodeslist[{{ loop.index }}] = new vis.DataSet({{graph.nodes|tojson}});
edgeslist[{{ loop.index }}] = new vis.DataSet({{graph.edges|tojson}});
{% endfor %}
// This method is responsible for drawing the graph, returns the drawn network
function drawGraph(id,nodes,edges) {
var container = document.getElementById(id);
// adding nodes and edges to the graph
data = {nodes: nodes, edges: edges};
var options = {
"configure": {
"enabled": false
},
"edges": {
"color": {
"inherit": true
},
"smooth": {
"enabled": false,
"type": "continuous"
}
},
"interaction": {
"dragNodes": true,
"hideEdgesOnDrag": false,
"hideNodesOnDrag": false
},
"physics": {
"enabled": true,
"stabilization": {
"enabled": true,
"fit": true,
"iterations": 1000,
"onlyDynamicEdges": false,
"updateInterval": 50
}
}
};
network = new vis.Network(container, data, options);
return network;
}
{% for graph in graphs -%}
drawGraph("graph{{ loop.index }}",nodeslist[{{loop.index}}], edgeslist[{{loop.index}}]);
{% endfor %}
</script>
</body>