|
|
- <!doctype html>
- <html>
- <head>
- <title>Vis Popup Example</title>
-
- <style type="text/css">
- body {
- font: 10pt sans;
- }
-
- #mynetwork {
- width: 600px;
- height: 600px;
- border: 1px solid lightgray;
- }
- </style>
-
- <script src="../dist/vis.js" type="text/javascript" ></script>
- <link href="../dist/vis.css" rel="stylesheet" type="text/css"/>
- <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" type="text/javascript"></script>
-
- <script type="text/javascript">
- var network = null;
- var network2 = null;
-
- function draw() {
- // create an array with nodes
- var nodes = [
- {id: 1, label: 'Node 1'},
- {id: 2, label: 'Node 2'},
- {id: 3, label: 'Node 3'},
- {id: 4, label: 'Node 4'},
- {id: 5, label: 'Node 5'}
- ];
-
- // create an array with edges
- var edges = [
- {from: 1, to: 2},
- {from: 2, to: 3},
- {from: 3, to: 4},
- {from: 4, to: 5}
- ];
-
- // create a network
- var container = document.getElementById('mynetwork');
- var data = {
- nodes: nodes,
- edges: edges
- };
- var options = {layout:{randomSeed:8}};
- network = new vis.Network(container, data, options);
-
- setTimeout(function() {
- var clusterOptionsByData = {
- joinCondition:function(childOptions) {
- return childOptions.id == 2 || childOptions.id == 3 || childOptions.id == 4;
- },
- clusterNodeProperties: {id:'cid1', label:'cid1'}
- }
- network.cluster(clusterOptionsByData);
- },100);
-
- setTimeout(function() {
- var itemId = 'cid1';
- network.openCluster([itemId]);
- },300);
-
- setTimeout(function() {
- var clusterOptionsByData = {
- joinCondition:function(childOptions) {
- return childOptions.id == 2 || childOptions.id == 3 || childOptions.id == 4;
- },
- clusterNodeProperties: {id:'cid2', label:'cid2'}
- }
- network.cluster(clusterOptionsByData);
- },1000);
- }
- </script>
- </head>
-
- <body onload="draw();">
- <h2>Popup Example</h2>
-
- <div id='mynetwork'></div>
-
- </body>
- </html>
|