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.
 
 
 

77 lines
2.5 KiB

<!doctype html>
<html>
<head>
<title>Network | Shapes</title>
<style type="text/css">
body {
font: 10pt arial;
}
#mynetwork {
width: 100%;
height: 600px;
border: 1px solid lightgray;
}
</style>
<script type="text/javascript" src="../../dist/vis.js"></script>
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var nodes = null;
var edges = null;
var network = null;
function draw() {
nodes = [
{id: 1, label: 'circle', shape: 'circle', group: 'group_x'},
{id: 2, label: 'ellipse', shape: 'ellipse', group: 'group_x'},
{id: 3, label: 'database',shape: 'database',group: 'group_x'},
{id: 4, label: 'box', shape: 'box', group: 'group_x'},
{id: 5, label: 'diamond', shape: 'diamond', group: 'group_x'}
];
edges = [
{from: 3, to: 1, arrows: 'to'},
{from: 1, to: 4, dashes: true},
{from: 1, to: 2, dashes: true, arrows: 'to, from'},
{from: 1, to: 5, arrows: 'middle'}
];
var mainId = 6;
nodes.push({id: mainId, label: 'shapes and\nsizes', shape: 'box', group: 'group_main'});
var shapes = ['dot', 'square', 'triangle', 'triangleDown', 'star','diamond'];
var id = 7;
for (var size = 1; size < 4; size++) {
var groupId = id;
nodes.push({id: id, label: 'size ' + size, shape: 'box', group: 'group' + size});
edges.push({from: mainId, to: groupId, color: 'gray', width: size});
id++;
for (var i = 0; i < shapes.length; i++) {
nodes.push({id: id, value: size, label: shapes[i], shape: shapes[i], group: 'group' + size});
edges.push({from: groupId, to: id, color: 'gray', width: size});
id++;
}
}
// create a network
var container = document.getElementById('mynetwork');
var data = {
nodes: nodes,
edges: edges
};
var options = {
stabilize: false
};
network = new vis.Network(container, data, options);
}
</script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script></head>
<body onload="draw()">
<div id="mynetwork"></div>
<div id="info"></div>
</body>
</html>