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.
 
 
 

298 lines
15 KiB

<!DOCTYPE html>
<html lang="en">
<head><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>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Network Examples</title>
<link rel="icon" HREF="favicon.ico">
<!-- Bootstrap -->
<link href="./css/bootstrap.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link href="./css/prettify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/prettify/prettify.js"></script>
<script src="./dist/vis.js"></script>
<link href="./dist/vis.css" rel="stylesheet" type="text/css" />
<link href="./css/examples.css" rel="stylesheet" type="text/css" />
<style>
#networkContainer {
margin:0px;
padding:0px;
position:relative;
height: 0px;
width: 100%;
z-index:0;
}
#contentContainer {
margin:0px;
padding:0px;
position:relative;
width: 100%;
z-index:2;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>
<script>
var network;
var connectedNodes = [];
var largeNode = undefined;
var NORMAL_SIZE = 60;
var LARGE_SIZE = 80;
function loadVis() {
var linksContainer = document.getElementById('contentContainer');
var networkContainer = document.getElementById('networkContainer');
var linksContainerRect = linksContainer.getBoundingClientRect();
var linksContainerHeight = linksContainerRect.bottom - linksContainerRect.top;
networkContainer.style.height = linksContainerHeight + 'px';
linksContainer.style.marginTop = '-' + linksContainerHeight + 'px';
var links = linksContainer.getElementsByTagName('a');
var nodesArray = [];
var edgesArray = [];
var idCounter = 0;
var firstLink = undefined;
for (var i = 0; i < links.length; i++) {
var link = links[i];
if (link.className === 'exampleLink') {
var linkRect = link.getBoundingClientRect();
var linkWidth = linkRect.right - linkRect.left;
if (firstLink === undefined) {
firstLink = link;
}
nodesArray.push({id:idCounter,
x:link.offsetLeft + linkWidth,
y:link.offsetTop,
color:{
background:'rgba(0,0,0,0.0)',
border:'rgba(70,158,255,0)'
},
shape:'dot',
size:2,
fixed:true
});
nodesArray.push({id:idCounter + "image",
// label:link.innerHTML,
x:link.offsetLeft + 400 + 100 + (idCounter % 3) * 150,
y:link.offsetTop,
color:{
border:'rgba(70,158,255,1)'
},
shadow:{
size:2,
x:0,
y:0
},
shape:'image',
image:'./images/exampleScreenshots/network/'+(idCounter+1)+'.png',
size:NORMAL_SIZE
});
edgesArray.push({from: idCounter, to: idCounter+"image", arrows:'from'});
idCounter += 1;
}
}
var nodes = new vis.DataSet(nodesArray);
var edges = new vis.DataSet(edgesArray);
var networkContainer = document.getElementById('networkContainer');
var data = {
nodes: nodes,
edges: edges
};
var options = {
edges:{
color:{inherit:'both'},
smooth:{enabled:false,type:'continuous'}
},
physics: false,
interaction:{
zoomView:false,
dragView: false
}
};
network = new vis.Network(networkContainer, data, options);
// get the offset
var firstLinkPos = {x:firstLink.offsetLeft, y:firstLink.offsetTop};
var firstLinkRect = firstLink.getBoundingClientRect();
var firstLinkWidth = firstLinkRect.right - firstLinkRect.left;
var firstLinkHeight = firstLinkRect.bottom - firstLinkRect.top;
var networkContainerRect = networkContainer.getBoundingClientRect();
var networkContainerWidth = networkContainerRect.right - networkContainerRect.left;
var networkContainerHeight = networkContainerRect.bottom - networkContainerRect.top;
var ydiff = linksContainer.offsetTop - networkContainer.offsetTop;
network.moveTo({
scale: 1,
position: network.getPositions([0])[0],
offset: {
x: -0.5 * networkContainerWidth + firstLinkPos.x + firstLinkWidth,
y: -0.5 * networkContainerHeight + firstLinkPos.y + ydiff + 0.5 * firstLinkHeight
},
animation: false
});
linksContainer.onclick = function (event) {
var nodeUnderCursor = network.getNodeAt({x:event.layerX, y:event.layerY+ydiff});
if (connectedNodes.length > 0) {
nodes.update([{id: connectedNodes[0], color: {border: 'rgba(70,158,255,0)'}}])
connectedNodes = []
}
if (largeNode !== undefined) {
nodes.update([{id: largeNode, size:NORMAL_SIZE}]);
largeNode = undefined;
}
if (nodeUnderCursor !== undefined) {
connectedNodes = network.getConnectedNodes(nodeUnderCursor);
largeNode = nodeUnderCursor;
nodes.update([{id:connectedNodes[0], color:{border:'rgba(70,158,255,1)'}}]);
nodes.update([{id:largeNode, size:LARGE_SIZE}]);
largeNode = nodeUnderCursor;
network.selectNodes([nodeUnderCursor]);
}
else {
network.unselectAll();
}
}
}
</script>
</head>
<body onload="loadVis();">
<div class="navbar-wrapper">
<div class="container">
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="./index.html#modules">Modules</a></li>
<li><a href="./blog.html">Blog</a></li>
<li><a href="./index.html#download_install">Download</a></li>
<li><a href="./showcase/index.html">Showcase</a></li>
<li><a href="./index.html#contribute">Contribute</a></li>
<li><a href="./featureRequests.html">Feature requests</a></li>
<li><a href="./index.html#licenses">License</a></li>
</ul>
</div>
</div>
</nav>
</div>
</div>
<div class="contentWrapper">
<div id="networkContainer"></div>
<div id="contentContainer">
<h1>Network Examples</h1>
This page contains examples which show how to use Network. For the documentation, please click the button below: <br><br>
<a class="btn btn-primary" href="./docs/network" role="button">View docs »</a>
<h3>basic usage</h3>
<a class='exampleLink' href="examples/network/basic_usage.html">basic usage</a><br />
<h3>node styles</h3>
<a class='exampleLink' href="examples/network/nodeStyles/colors.html">colors</a><br />
<a class='exampleLink' href="examples/network/nodeStyles/groups.html">groups</a><br />
<a class='exampleLink' href="examples/network/nodeStyles/customGroups.html">custom groups</a><br />
<a class='exampleLink' href="examples/network/nodeStyles/HTML_in_Nodes.html">HTML in nodes</a><br />
<a class='exampleLink' href="examples/network/nodeStyles/icons.html">icons (Fontawesome and Ionicons)</a><br />
<a class='exampleLink' href="examples/network/nodeStyles/images.html">images</a><br />
<a class='exampleLink' href="examples/network/nodeStyles/circular_images.html">circular images</a><br />
<a class='exampleLink' href="examples/network/nodeStyles/shadows.html">node shadows</a><br />
<a class='exampleLink' href="examples/network/nodeStyles/shapes.html">node shapes</a><br />
<h3>edge styles</h3>
<a class='exampleLink' href="examples/network/edgeStyles/arrows.html">arrows (also combined with dashes)</a><br />
<a class='exampleLink' href="examples/network/edgeStyles/colors.html">different colors</a><br />
<a class='exampleLink' href="examples/network/edgeStyles/dashes.html">dashes</a><br />
<a class='exampleLink' href="examples/network/edgeStyles/smooth.html">smooth curves</a><br />
<a class='exampleLink' href="examples/network/edgeStyles/smoothWorldCup.html">smooth curves in action</a><br />
<h3>labels</h3>
<a class='exampleLink' href="examples/network/labels/label_alignment.html">label alignment (for edges only)</a><br />
<a class='exampleLink' href="examples/network/labels/label_background.html">label background</a><br />
<a class='exampleLink' href="examples/network/labels/label_color_and_size.html">colors and sizes</a><br />
<a class='exampleLink' href="examples/network/labels/label_stroke.html">label stroke</a><br />
<a class='exampleLink' href="examples/network/labels/multiline_text.html">multiline text</a><br />
<h3>layout</h3>
<a class='exampleLink' href="examples/network/layout/hierarchical_layout.html">hierarchical layout</a><br />
<a class='exampleLink' href="examples/network/layout/hierarchical_layout_methods.html">hierarchical layout - different methods</a><br />
<a class='exampleLink' href="examples/network/layout/hierarchical_layout_userdefined.html">hierarchical layout - user defined</a><br />
<a class='exampleLink' href="examples/network/layout/randomSeed.html">set the random seed so every network will be the same</a><br />
<h3>events</h3>
<a class='exampleLink' href="examples/network/events/interactionEvents.html">interaction events, click, rightclick, drag etc.</a><br />
<a class='exampleLink' href="examples/network/events/physicsEvents.html">physics events, stabilization etc.</a><br />
<a class='exampleLink' href="examples/network/events/renderEvents.html">rendering events, use to draw custom items on the canvas.</a><br />
<h3>dynamic data</h3>
<a class='exampleLink' href="examples/network/data/datasets.html">dataset for dynamic data</a><br />
<a class='exampleLink' href="examples/network/data/dynamic_data.html">dynamic data, playground</a><br />
<a class='exampleLink' href="examples/network/data/importing_from_gephi.html">importing data from gephi</a><br />
<a class='exampleLink' href="examples/network/data/scaling_custom.html">scaling the nodes with the value.</a><br />
<a class='exampleLink' href="examples/network/data/scaling_nodes_edges.html">scaling the nodes and edges with the value.</a><br />
<a class='exampleLink' href="examples/network/data/scaling_nodes_edges_labels.html">scaling the nodes, edges and labels with the value.</a><br />
<h3>physics</h3>
<a class='exampleLink' href="examples/network/physics/physicsConfiguration.html">physics configuration</a><br />
<h3>example applications</h3>
<a class='exampleLink' href="examples/network/exampleApplications/les_miserables.html">les miserables cast</a><br />
<a class='exampleLink' href="examples/network/exampleApplications/loadingBar.html">loading bar during stabilization</a><br />
<a class='exampleLink' href="examples/network/exampleApplications/neighbourhood_highlight.html">neighbourhood heighlight</a><br />
<a class='exampleLink' href="examples/network/exampleApplications/nodeLegend.html">using nodes as a legend</a><br />
<a class='exampleLink' href="examples/network/exampleApplications/worldCupPerformance.html">performance test with the worldcup data</a><br />
<h3>other</h3>
<a class='exampleLink' href="examples/network/other/animationShowcase.html">animation showcase</a><br />
<a class='exampleLink' href="examples/network/other/clustering.html">clustering possibilities</a><br />
<a class='exampleLink' href="examples/network/other/clusteringByZoom.html">clustering by zoom</a><br />
<a class='exampleLink' href="examples/network/other/configuration.html">dynamic configuration</a><br />
<a class='exampleLink' href="examples/network/other/manipulation.html">manipulation interface and localization</a><br />
<a class='exampleLink' href="examples/network/other/navigation.html">navigation buttons and keyboard shortcuts</a><br />
<a class='exampleLink' href="examples/network/other/performance.html">performance test with scale free network, customize the amount of nodes</a><br />
</div>
<br />
<br />
<br />
<br />
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>