|
@ -1,266 +1,265 @@ |
|
|
<!doctype html> |
|
|
<!doctype html> |
|
|
<html> |
|
|
<html> |
|
|
<head> |
|
|
<head> |
|
|
<title>Network | DataSet</title> |
|
|
|
|
|
|
|
|
<title>Network | DataSet</title> |
|
|
|
|
|
|
|
|
<style type="text/css"> |
|
|
|
|
|
html, body { |
|
|
|
|
|
font: 11pt arial; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
h1 { |
|
|
|
|
|
font-size: 150%; |
|
|
|
|
|
margin: 5px 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
<style type="text/css"> |
|
|
|
|
|
html, body { |
|
|
|
|
|
font: 11pt arial; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
h2 { |
|
|
|
|
|
font-size: 100%; |
|
|
|
|
|
margin: 5px 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
h1 { |
|
|
|
|
|
font-size: 150%; |
|
|
|
|
|
margin: 5px 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
table.view { |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
h2 { |
|
|
|
|
|
font-size: 100%; |
|
|
|
|
|
margin: 5px 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
table td { |
|
|
|
|
|
vertical-align: top; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
table.view { |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
table table { |
|
|
|
|
|
background-color: #f5f5f5; |
|
|
|
|
|
border: 1px solid #e5e5e5; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
table td { |
|
|
|
|
|
vertical-align: top; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
table table td { |
|
|
|
|
|
vertical-align: middle; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
table table { |
|
|
|
|
|
background-color: #f5f5f5; |
|
|
|
|
|
border: 1px solid #e5e5e5; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
input[type=text], pre { |
|
|
|
|
|
border: 1px solid lightgray; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
table table td { |
|
|
|
|
|
vertical-align: middle; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
pre { |
|
|
|
|
|
margin: 0; |
|
|
|
|
|
padding: 5px; |
|
|
|
|
|
font-size: 10pt; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
input[type=text], pre { |
|
|
|
|
|
border: 1px solid lightgray; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#network { |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
height: 400px; |
|
|
|
|
|
border: 1px solid lightgray; |
|
|
|
|
|
} |
|
|
|
|
|
</style> |
|
|
|
|
|
|
|
|
pre { |
|
|
|
|
|
margin: 0; |
|
|
|
|
|
padding: 5px; |
|
|
|
|
|
font-size: 10pt; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> |
|
|
|
|
|
<script type="text/javascript" src="../../../../dist/vis.js"></script> |
|
|
|
|
|
<link href="../../../../dist/vis.css" rel="stylesheet" type="text/css" /> |
|
|
|
|
|
|
|
|
#network { |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
height: 400px; |
|
|
|
|
|
border: 1px solid lightgray; |
|
|
|
|
|
} |
|
|
|
|
|
</style> |
|
|
|
|
|
|
|
|
<script type="text/javascript"> |
|
|
|
|
|
var nodes, edges, network; |
|
|
|
|
|
|
|
|
<script type="text/javascript" src="../../../../dist/vis.js"></script> |
|
|
|
|
|
<link href="../../../../dist/vis.css" rel="stylesheet" type="text/css"/> |
|
|
|
|
|
|
|
|
// convenience method to stringify a JSON object |
|
|
|
|
|
function toJSON (obj) { |
|
|
|
|
|
return JSON.stringify(obj, null, 4); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
<script type="text/javascript"> |
|
|
|
|
|
var nodes, edges, network; |
|
|
|
|
|
|
|
|
$(window).load(function () { |
|
|
|
|
|
// attach actions to the node buttons |
|
|
|
|
|
$('#node-add').click(function () { |
|
|
|
|
|
try { |
|
|
|
|
|
nodes.add({ |
|
|
|
|
|
id: $('#node-id').val(), |
|
|
|
|
|
label: $('#node-label').val() |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// convenience method to stringify a JSON object |
|
|
|
|
|
function toJSON(obj) { |
|
|
|
|
|
return JSON.stringify(obj, null, 4); |
|
|
} |
|
|
} |
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
$('#node-update').click(function () { |
|
|
|
|
|
try { |
|
|
|
|
|
nodes.update({ |
|
|
|
|
|
id: $('#node-id').val(), |
|
|
|
|
|
label: $('#node-label').val() |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
$('#node-remove').click(function () { |
|
|
|
|
|
try { |
|
|
|
|
|
var id = $('#node-id').val(); |
|
|
|
|
|
nodes.remove(id); |
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// attach actions to the edge buttons |
|
|
|
|
|
$('#edge-add').click(function () { |
|
|
|
|
|
try { |
|
|
|
|
|
edges.add({ |
|
|
|
|
|
id: $('#edge-id').val(), |
|
|
|
|
|
from: $('#edge-from').val(), |
|
|
|
|
|
to: $('#edge-to').val() |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
function addNode() { |
|
|
|
|
|
try { |
|
|
|
|
|
nodes.add({ |
|
|
|
|
|
id: document.getElementById('node-id').value, |
|
|
|
|
|
label: document.getElementById('node-label').value |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updateNode() { |
|
|
|
|
|
try { |
|
|
|
|
|
nodes.update({ |
|
|
|
|
|
id: document.getElementById('node-id').value, |
|
|
|
|
|
label: document.getElementById('node-label').value |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
$('#edge-update').click(function () { |
|
|
|
|
|
try { |
|
|
|
|
|
edges.update({ |
|
|
|
|
|
id: $('#edge-id').val(), |
|
|
|
|
|
from: $('#edge-from').val(), |
|
|
|
|
|
to: $('#edge-to').val() |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
function removeNode() { |
|
|
|
|
|
try { |
|
|
|
|
|
nodes.remove({id: document.getElementById('node-id').value}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addEdge() { |
|
|
|
|
|
try { |
|
|
|
|
|
edges.add({ |
|
|
|
|
|
id: document.getElementById('edge-id').value, |
|
|
|
|
|
from: document.getElementById('edge-from').value, |
|
|
|
|
|
to: document.getElementById('edge-to').value |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
$('#edge-remove').click(function () { |
|
|
|
|
|
try { |
|
|
|
|
|
var id = $('#edge-id').val(); |
|
|
|
|
|
edges.remove(id); |
|
|
|
|
|
|
|
|
function updateEdge() { |
|
|
|
|
|
try { |
|
|
|
|
|
edges.update({ |
|
|
|
|
|
id: document.getElementById('edge-id').value, |
|
|
|
|
|
from: document.getElementById('edge-from').value, |
|
|
|
|
|
to: document.getElementById('edge-to').value |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
|
|
|
function removeEdge() { |
|
|
|
|
|
try { |
|
|
|
|
|
edges.remove({id: document.getElementById('edge-id').value}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
alert(err); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// create an array with nodes |
|
|
|
|
|
nodes = new vis.DataSet(); |
|
|
|
|
|
nodes.on('*', function () { |
|
|
|
|
|
$('#nodes').html(toJSON(nodes.get())); |
|
|
|
|
|
}); |
|
|
|
|
|
nodes.add([ |
|
|
|
|
|
{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'} |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
function draw() { |
|
|
|
|
|
// create an array with nodes |
|
|
|
|
|
nodes = new vis.DataSet(); |
|
|
|
|
|
nodes.on('*', function () { |
|
|
|
|
|
document.getElementById('nodes').innerHTML = JSON.stringify(nodes.get(), null, 4); |
|
|
|
|
|
}); |
|
|
|
|
|
nodes.add([ |
|
|
|
|
|
{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 |
|
|
|
|
|
edges = new vis.DataSet(); |
|
|
|
|
|
edges.on('*', function () { |
|
|
|
|
|
document.getElementById('edges').innerHTML = JSON.stringify(edges.get(), null, 4); |
|
|
|
|
|
}); |
|
|
|
|
|
edges.add([ |
|
|
|
|
|
{id: '1', from: '1', to: '2'}, |
|
|
|
|
|
{id: '2', from: '1', to: '3'}, |
|
|
|
|
|
{id: '3', from: '2', to: '4'}, |
|
|
|
|
|
{id: '4', from: '2', to: '5'} |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
// create an array with edges |
|
|
|
|
|
edges = new vis.DataSet(); |
|
|
|
|
|
edges.on('*', function () { |
|
|
|
|
|
$('#edges').html(toJSON(edges.get())); |
|
|
|
|
|
}); |
|
|
|
|
|
edges.add([ |
|
|
|
|
|
{id: '1', from: '1', to: '2'}, |
|
|
|
|
|
{id: '2', from: '1', to: '3'}, |
|
|
|
|
|
{id: '3', from: '2', to: '4'}, |
|
|
|
|
|
{id: '4', from: '2', to: '5'} |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
// create a network |
|
|
|
|
|
var container = document.getElementById('network'); |
|
|
|
|
|
var data = { |
|
|
|
|
|
nodes: nodes, |
|
|
|
|
|
edges: edges |
|
|
|
|
|
}; |
|
|
|
|
|
var options = {}; |
|
|
|
|
|
network = new vis.Network(container, data, options); |
|
|
|
|
|
|
|
|
// create a network |
|
|
|
|
|
var container = $('#network').get(0); |
|
|
|
|
|
var data = { |
|
|
|
|
|
nodes: nodes, |
|
|
|
|
|
edges: edges |
|
|
|
|
|
}; |
|
|
|
|
|
var options = {}; |
|
|
|
|
|
network = new vis.Network(container, data, options); |
|
|
|
|
|
}); |
|
|
|
|
|
</script> |
|
|
|
|
|
<script src="../../../googleAnalytics.js"></script> |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
<script src="../../../googleAnalytics.js"></script> |
|
|
</head> |
|
|
</head> |
|
|
|
|
|
|
|
|
<body> |
|
|
|
|
|
|
|
|
<body onload="draw();"> |
|
|
|
|
|
|
|
|
<p> |
|
|
<p> |
|
|
This example demonstrates dynamically adding, updating and removing nodes |
|
|
|
|
|
and edges using a DataSet. |
|
|
|
|
|
|
|
|
This example demonstrates dynamically adding, updating and removing nodes |
|
|
|
|
|
and edges using a DataSet. |
|
|
</p> |
|
|
</p> |
|
|
|
|
|
|
|
|
<h1>Adjust</h1> |
|
|
<h1>Adjust</h1> |
|
|
<table> |
|
|
<table> |
|
|
<tr> |
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Node</h2> |
|
|
|
|
|
<table> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="node-id">Id</label></td> |
|
|
|
|
|
<td><input id="node-id" type="text" value="6"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="node-label">Label</label></td> |
|
|
|
|
|
<td><input id="node-label" type="text" value="Node 6"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td>Action</td> |
|
|
|
|
|
<td> |
|
|
|
|
|
<button id="node-add">Add</button> |
|
|
|
|
|
<button id="node-update">Update</button> |
|
|
|
|
|
<button id="node-remove">Remove</button> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
</table> |
|
|
|
|
|
</td> |
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Edge</h2> |
|
|
|
|
|
<table> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="edge-id">Id</label></td> |
|
|
|
|
|
<td><input id="edge-id" type="text" value="5"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="edge-from">From</label></td> |
|
|
|
|
|
<td><input id="edge-from" type="text" value="3"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="edge-to">To</label></td> |
|
|
|
|
|
<td><input id="edge-to" type="text" value="4"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td>Action</td> |
|
|
|
|
|
<td> |
|
|
|
|
|
<button id="edge-add">Add</button> |
|
|
|
|
|
<button id="edge-update">Update</button> |
|
|
|
|
|
<button id="edge-remove">Remove</button> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
</table> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
|
<tr> |
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Node</h2> |
|
|
|
|
|
<table> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="node-id">Id</label></td> |
|
|
|
|
|
<td><input id="node-id" type="text" value="6"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="node-label">Label</label></td> |
|
|
|
|
|
<td><input id="node-label" type="text" value="Node 6"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td>Action</td> |
|
|
|
|
|
<td> |
|
|
|
|
|
<button id="node-add" onclick="addNode();">Add</button> |
|
|
|
|
|
<button id="node-update" onclick="updateNode();">Update</button> |
|
|
|
|
|
<button id="node-remove" onclick="removeNode();">Remove</button> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
</table> |
|
|
|
|
|
</td> |
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Edge</h2> |
|
|
|
|
|
<table> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="edge-id">Id</label></td> |
|
|
|
|
|
<td><input id="edge-id" type="text" value="5"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="edge-from">From</label></td> |
|
|
|
|
|
<td><input id="edge-from" type="text" value="3"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td><label for="edge-to">To</label></td> |
|
|
|
|
|
<td><input id="edge-to" type="text" value="4"></td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td></td> |
|
|
|
|
|
<td>Action</td> |
|
|
|
|
|
<td> |
|
|
|
|
|
<button id="edge-add" onclick="addEdge();">Add</button> |
|
|
|
|
|
<button id="edge-update" onclick="updateEdge();">Update</button> |
|
|
|
|
|
<button id="edge-remove" onclick="removeEdge();">Remove</button> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
</table> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
|
</table> |
|
|
</table> |
|
|
|
|
|
|
|
|
<h1>View</h1> |
|
|
<h1>View</h1> |
|
|
<table class="view"> |
|
|
<table class="view"> |
|
|
<colgroup> |
|
|
|
|
|
<col width="25%"> |
|
|
|
|
|
<col width="25%"> |
|
|
|
|
|
<col width="50%"> |
|
|
|
|
|
</colgroup> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Nodes</h2> |
|
|
|
|
|
<pre id="nodes"></pre> |
|
|
|
|
|
</td> |
|
|
|
|
|
|
|
|
<colgroup> |
|
|
|
|
|
<col width="25%"> |
|
|
|
|
|
<col width="25%"> |
|
|
|
|
|
<col width="50%"> |
|
|
|
|
|
</colgroup> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Nodes</h2> |
|
|
|
|
|
<pre id="nodes"></pre> |
|
|
|
|
|
</td> |
|
|
|
|
|
|
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Edges</h2> |
|
|
|
|
|
<pre id="edges"></pre> |
|
|
|
|
|
</td> |
|
|
|
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Edges</h2> |
|
|
|
|
|
<pre id="edges"></pre> |
|
|
|
|
|
</td> |
|
|
|
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Network</h2> |
|
|
|
|
|
|
|
|
<td> |
|
|
|
|
|
<h2>Network</h2> |
|
|
|
|
|
<div id="network"></div> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
|
<div id="network"></div> |
|
|
|
|
|
</td> |
|
|
|
|
|
</tr> |
|
|
</table> |
|
|
</table> |
|
|
|
|
|
|
|
|
</body> |
|
|
</body> |
|
|