vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

79 lines
2.2 KiB

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script type="text/javascript" src="../dist/vis.js"></script> <!-- network handling framework -->
<link href="../dist/vis.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
#network{
width: 1200px;
height: 800px;
border: 1px solid lightgray;
}
</style>
</head>
<body>
<h1>Network Test</h1>
<div id="network"></div>
<script>
var nodes = new vis.DataSet([
{id: 1, label: '1'},
{id: 2, label: '2'},
{id: 3, label: '3'},
{id: 4, label: '4'},
{id: 5, label: '5'},
{id: 6, label: '6'},
{id: 7, label: '7'},
]);
var edges = new vis.DataSet([
{id: "e1", from: 2, to: 1, label: "e1"},
{id: "e2", from: 3, to: 1, label: "e2"},
{id: "e3", from: 4, to: 1, label: "e3"},
{id: "e4", from: 5, to: 1, label: "e4"},
{id: "e5", from: 6, to: 1, label: "e5"},
{id: "e6", from: 2, to: 7, label: "e6"},
{id: "e7", from: 3, to: 7, label: "e7"},
{id: "e8", from: 4, to: 7, label: "e8"},
{id: "e9", from: 5, to: 7, label: "e9"},
{id: "e10", from: 6, to: 7, label: "e10"},
]);
// create a network
var container = document.getElementById('network');
var data = {
nodes: nodes,
edges: edges
};
var options = {
layout: {randomSeed: 8},
edges: {
arrows: {
to: {
scaleFactor: 0.5
}
},
font: {
align: "middle"
}
}
};
var network = new vis.Network(container, data, options);
var clusterOptionsByData = {
joinCondition: function(node) {
if (node.id > 1 && node.id < 7)
return true;
return false;
},
clusterNodeProperties: {id:"c1", label:'c1'}
};
network.cluster(clusterOptionsByData);
setTimeout(function() {
network.setOptions({layout: { hierarchical: { direction: "LR" }}});
},2000)
</script>
</body>
</html>