@ -62,8 +62,8 @@ data.add([ | |||
]); | |||
// subscribe to any change in the DataSet | |||
data.subscribe('*', function (event, params, senderId) { | |||
console.log('event', event, params); | |||
data.on('*', function (event, properties, senderId) { | |||
console.log('event', event, properties); | |||
}); | |||
// update an existing item | |||
@ -545,8 +545,8 @@ var items = data.get({ | |||
<p> | |||
One can subscribe on changes in a DataSet. | |||
A subscription can be created using the method <code>subscribe</code>, | |||
and removed with <code>unsubscribe</code>. | |||
A subscription can be created using the method <code>on</code>, | |||
and removed with <code>off</code>. | |||
</p> | |||
<pre class="prettyprint lang-js"> | |||
@ -554,8 +554,8 @@ var items = data.get({ | |||
var data = new vis.DataSet(); | |||
// subscribe to any change in the DataSet | |||
data.subscribe('*', function (event, params, senderId) { | |||
console.log('event:', event, 'params:', params, 'senderId:', senderId); | |||
data.on('*', function (event, properties, senderId) { | |||
console.log('event:', event, 'properties:', properties, 'senderId:', senderId); | |||
}); | |||
// add an item | |||
@ -565,14 +565,14 @@ data.remove(1); // triggers an 'remove' event | |||
</pre> | |||
<h3 id="Subscribe">Subscribe</h3> | |||
<h3 id="On">On</h3> | |||
<p> | |||
Subscribe to an event. | |||
</p> | |||
Syntax: | |||
<pre class="prettyprint lang-js">DataSet.subscribe(event, callback)</pre> | |||
<pre class="prettyprint lang-js">DataSet.on(event, callback)</pre> | |||
Where: | |||
<ul> | |||
@ -587,17 +587,17 @@ Where: | |||
</li> | |||
</ul> | |||
<h3 id="Unsubscribe">Unsubscribe</h3> | |||
<h3 id="Off">Off</h3> | |||
<p> | |||
Unsubscribe from an event. | |||
</p> | |||
Syntax: | |||
<pre class="prettyprint lang-js">DataSet.unsubscribe(event, callback)</pre> | |||
<pre class="prettyprint lang-js">DataSet.off(event, callback)</pre> | |||
Where <code>event</code> and <code>callback</code> correspond with the | |||
parameters used to <a href="#Subscribe">subscribe</a> to the event. | |||
parameters used to <a href="#On">subscribe</a> to the event. | |||
<h3 id="Events">Events</h3> | |||
@ -650,7 +650,7 @@ parameters used to subscribe to the event. | |||
</p> | |||
<pre class="prettyprint lang-js"> | |||
function (event, params, senderId) { | |||
function (event, properties, senderId) { | |||
// handle the event | |||
}); | |||
</pre> | |||
@ -674,13 +674,13 @@ function (event, params, senderId) { | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>params</td> | |||
<td>properties</td> | |||
<td>Object | null</td> | |||
<td> | |||
Optional parameters providing more information on the event. | |||
Optional properties providing more information on the event. | |||
In case of the events <code>add</code>, | |||
<code>update</code>, and <code>remove</code>, | |||
<code>params</code> is always an object containing a property | |||
<code>properties</code> is always an object containing a property | |||
items, which contains an array with the ids of the affected | |||
items. | |||
</td> | |||
@ -0,0 +1,213 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Graph | Navigation</title> | |||
<style type="text/css"> | |||
body { | |||
font: 10pt sans; | |||
} | |||
#mygraph { | |||
position:relative; | |||
width: 600px; | |||
height: 600px; | |||
border: 1px solid lightgray; | |||
} | |||
table.legend_table { | |||
font-size: 11px; | |||
border-width:1px; | |||
border-color:#d3d3d3; | |||
border-style:solid; | |||
} | |||
table.legend_table,td { | |||
border-width:1px; | |||
border-color:#d3d3d3; | |||
border-style:solid; | |||
padding: 2px; | |||
} | |||
div.table_content { | |||
width:80px; | |||
text-align:center; | |||
} | |||
div.table_description { | |||
width:100px; | |||
} | |||
#operation { | |||
font-size:28px; | |||
} | |||
#graph-popUp { | |||
display:none; | |||
position:absolute; | |||
top:350px; | |||
left:170px; | |||
z-index:299; | |||
width:250px; | |||
height:120px; | |||
background-color: #f9f9f9; | |||
border-style:solid; | |||
border-width:3px; | |||
border-color: #5394ed; | |||
padding:10px; | |||
text-align: center; | |||
} | |||
</style> | |||
<script type="text/javascript" src="../../dist/vis.js"></script> | |||
<link type="text/css" rel="stylesheet" href="../../dist/vis.css"> | |||
<script type="text/javascript"> | |||
var nodes = null; | |||
var edges = null; | |||
var graph = null; | |||
function draw() { | |||
nodes = []; | |||
edges = []; | |||
var connectionCount = []; | |||
// randomly create some nodes and edges | |||
var nodeCount = 25; | |||
for (var i = 0; i < nodeCount; i++) { | |||
nodes.push({ | |||
id: i, | |||
label: String(i) | |||
}); | |||
connectionCount[i] = 0; | |||
// create edges in a scale-free-graph way | |||
if (i == 1) { | |||
var from = i; | |||
var to = 0; | |||
edges.push({ | |||
from: from, | |||
to: to | |||
}); | |||
connectionCount[from]++; | |||
connectionCount[to]++; | |||
} | |||
else if (i > 1) { | |||
var conn = edges.length * 2; | |||
var rand = Math.floor(Math.random() * conn); | |||
var cum = 0; | |||
var j = 0; | |||
while (j < connectionCount.length && cum < rand) { | |||
cum += connectionCount[j]; | |||
j++; | |||
} | |||
var from = i; | |||
var to = j; | |||
edges.push({ | |||
from: from, | |||
to: to | |||
}); | |||
connectionCount[from]++; | |||
connectionCount[to]++; | |||
} | |||
} | |||
// create a graph | |||
var container = document.getElementById('mygraph'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
edges: { | |||
length: 50 | |||
}, | |||
stabilize: false, | |||
dataManipulation: true, | |||
onAdd: function(data,callback) { | |||
var span = document.getElementById('operation'); | |||
var idInput = document.getElementById('node-id'); | |||
var labelInput = document.getElementById('node-label'); | |||
var saveButton = document.getElementById('saveButton'); | |||
var cancelButton = document.getElementById('cancelButton'); | |||
var div = document.getElementById('graph-popUp'); | |||
span.innerHTML = "Add Node"; | |||
idInput.value = data.id; | |||
labelInput.value = data.label; | |||
saveButton.onclick = saveData.bind(this,data,callback); | |||
cancelButton.onclick = clearPopUp.bind(); | |||
div.style.display = 'block'; | |||
}, | |||
onEdit: function(data,callback) { | |||
var span = document.getElementById('operation'); | |||
var idInput = document.getElementById('node-id'); | |||
var labelInput = document.getElementById('node-label'); | |||
var saveButton = document.getElementById('saveButton'); | |||
var cancelButton = document.getElementById('cancelButton'); | |||
var div = document.getElementById('graph-popUp'); | |||
span.innerHTML = "Edit Node"; | |||
idInput.value = data.id; | |||
labelInput.value = data.label; | |||
saveButton.onclick = saveData.bind(this,data,callback); | |||
cancelButton.onclick = clearPopUp.bind(); | |||
div.style.display = 'block'; | |||
} | |||
}; | |||
graph = new vis.Graph(container, data, options); | |||
// add event listeners | |||
graph.on('select', function(params) { | |||
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes; | |||
}); | |||
graph.on("frameResize", function(params) {console.log(params.width,params.height)}); | |||
function clearPopUp() { | |||
var saveButton = document.getElementById('saveButton'); | |||
var cancelButton = document.getElementById('cancelButton'); | |||
saveButton.onclick = null; | |||
cancelButton.onclick = null; | |||
var div = document.getElementById('graph-popUp'); | |||
div.style.display = 'none'; | |||
} | |||
function saveData(data,callback) { | |||
var idInput = document.getElementById('node-id'); | |||
var labelInput = document.getElementById('node-label'); | |||
var div = document.getElementById('graph-popUp'); | |||
data.id = idInput.value; | |||
data.label = labelInput.value; | |||
clearPopUp(); | |||
callback(data); | |||
} | |||
} | |||
</script> | |||
</head> | |||
<body onload="draw();"> | |||
<h2>Editing the dataset</h2> | |||
<div style="width: 700px; font-size:14px;"> | |||
In this example we have enabled the data manipulation setting. If the dataManipulation option is set to true, the edit button will appear. | |||
If you prefer to have the toolbar visible initially, you can set the initiallyVisible option to true. The exact method is described in the docs. | |||
<br /><br /> | |||
The data manipulation allows the user to add nodes, connect them, edit them and delete any selected items. In this example we have created trigger functions | |||
for the add and edit operations. By settings these trigger functions the user can direct the way the data is manipulated. In this example we have created a simple | |||
pop-up that allows us to edit some of the properties. | |||
</div> | |||
<br /> | |||
<div id="graph-popUp"> | |||
<span id="operation">node</span> <br> | |||
<table style="margin:auto;"><tr> | |||
<td>id</td><td><input id="node-id" value="new value"></td> | |||
</tr> | |||
<tr> | |||
<td>label</td><td><input id="node-label" value="new value"> </td> | |||
</tr></table> | |||
<input type="button" value="save" id="saveButton"></button> | |||
<input type="button" value="cancel" id="cancelButton"></button> | |||
</div> | |||
<br /> | |||
<div id="mygraph"></div> | |||
<p id="selection"></p> | |||
</body> | |||
</html> | |||
@ -0,0 +1,373 @@ | |||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |||
<html> | |||
<head> | |||
<title>Graph | Multiline text</title> | |||
<style type="text/css"> | |||
#mygraph { | |||
width: 900px; | |||
height: 900px; | |||
border: 1px solid lightgray; | |||
} | |||
</style> | |||
<script type="text/javascript" src="../../dist/vis.js"></script> | |||
<script type="text/javascript"> | |||
function draw() { | |||
// create some nodes | |||
var nodes = [ | |||
{id:0,"labelIGNORE":"Myriel","group":1}, | |||
{id:1,"labelIGNORE":"Napoleon","group":1}, | |||
{id:2,"labelIGNORE":"Mlle.Baptistine","group":1}, | |||
{id:3,"labelIGNORE":"Mme.Magloire","group":1}, | |||
{id:4,"labelIGNORE":"CountessdeLo","group":1}, | |||
{id:5,"labelIGNORE":"Geborand","group":1}, | |||
{id:6,"labelIGNORE":"Champtercier","group":1}, | |||
{id:7,"labelIGNORE":"Cravatte","group":1}, | |||
{id:8,"labelIGNORE":"Count","group":1}, | |||
{id:9,"labelIGNORE":"OldMan","group":1}, | |||
{id:10,"labelIGNORE":"Labarre","group":2}, | |||
{id:11,"labelIGNORE":"Valjean","group":2}, | |||
{id:12,"labelIGNORE":"Marguerite","group":3}, | |||
{id:13,"labelIGNORE":"Mme.deR","group":2}, | |||
{id:14,"labelIGNORE":"Isabeau","group":2}, | |||
{id:15,"labelIGNORE":"Gervais","group":2}, | |||
{id:16,"labelIGNORE":"Tholomyes","group":3}, | |||
{id:17,"labelIGNORE":"Listolier","group":3}, | |||
{id:18,"labelIGNORE":"Fameuil","group":3}, | |||
{id:19,"labelIGNORE":"Blacheville","group":3}, | |||
{id:20,"labelIGNORE":"Favourite","group":3}, | |||
{id:21,"labelIGNORE":"Dahlia","group":3}, | |||
{id:22,"labelIGNORE":"Zephine","group":3}, | |||
{id:23,"labelIGNORE":"Fantine","group":3}, | |||
{id:24,"labelIGNORE":"Mme.Thenardier","group":4}, | |||
{id:25,"labelIGNORE":"Thenardier","group":4}, | |||
{id:26,"labelIGNORE":"Cosette","group":5}, | |||
{id:27,"labelIGNORE":"Javert","group":4}, | |||
{id:28,"labelIGNORE":"Fauchelevent","group":0}, | |||
{id:29,"labelIGNORE":"Bamatabois","group":2}, | |||
{id:30,"labelIGNORE":"Perpetue","group":3}, | |||
{id:31,"labelIGNORE":"Simplice","group":2}, | |||
{id:32,"labelIGNORE":"Scaufflaire","group":2}, | |||
{id:33,"labelIGNORE":"Woman1","group":2}, | |||
{id:34,"labelIGNORE":"Judge","group":2}, | |||
{id:35,"labelIGNORE":"Champmathieu","group":2}, | |||
{id:36,"labelIGNORE":"Brevet","group":2}, | |||
{id:37,"labelIGNORE":"Chenildieu","group":2}, | |||
{id:38,"labelIGNORE":"Cochepaille","group":2}, | |||
{id:39,"labelIGNORE":"Pontmercy","group":4}, | |||
{id:40,"labelIGNORE":"Boulatruelle","group":6}, | |||
{id:41,"labelIGNORE":"Eponine","group":4}, | |||
{id:42,"labelIGNORE":"Anzelma","group":4}, | |||
{id:43,"labelIGNORE":"Woman2","group":5}, | |||
{id:44,"labelIGNORE":"MotherInnocent","group":0}, | |||
{id:45,"labelIGNORE":"Gribier","group":0}, | |||
{id:46,"labelIGNORE":"Jondrette","group":7}, | |||
{id:47,"labelIGNORE":"Mme.Burgon","group":7}, | |||
{id:48,"labelIGNORE":"Gavroche","group":8}, | |||
{id:49,"labelIGNORE":"Gillenormand","group":5}, | |||
{id:50,"labelIGNORE":"Magnon","group":5}, | |||
{id:51,"labelIGNORE":"Mlle.Gillenormand","group":5}, | |||
{id:52,"labelIGNORE":"Mme.Pontmercy","group":5}, | |||
{id:53,"labelIGNORE":"Mlle.Vaubois","group":5}, | |||
{id:54,"labelIGNORE":"Lt.Gillenormand","group":5}, | |||
{id:55,"labelIGNORE":"Marius","group":8}, | |||
{id:56,"labelIGNORE":"BaronessT","group":5}, | |||
{id:57,"labelIGNORE":"Mabeuf","group":8}, | |||
{id:58,"labelIGNORE":"Enjolras","group":8}, | |||
{id:59,"labelIGNORE":"Combeferre","group":8}, | |||
{id:60,"labelIGNORE":"Prouvaire","group":8}, | |||
{id:61,"labelIGNORE":"Feuilly","group":8}, | |||
{id:62,"labelIGNORE":"Courfeyrac","group":8}, | |||
{id:63,"labelIGNORE":"Bahorel","group":8}, | |||
{id:64,"labelIGNORE":"Bossuet","group":8}, | |||
{id:65,"labelIGNORE":"Joly","group":8}, | |||
{id:66,"labelIGNORE":"Grantaire","group":8}, | |||
{id:67,"labelIGNORE":"MotherPlutarch","group":9}, | |||
{id:68,"labelIGNORE":"Gueulemer","group":4}, | |||
{id:69,"labelIGNORE":"Babet","group":4}, | |||
{id:70,"labelIGNORE":"Claquesous","group":4}, | |||
{id:71,"labelIGNORE":"Montparnasse","group":4}, | |||
{id:72,"labelIGNORE":"Toussaint","group":5}, | |||
{id:73,"labelIGNORE":"Child1","group":10}, | |||
{id:74,"labelIGNORE":"Child2","group":10}, | |||
{id:75,"labelIGNORE":"Brujon","group":4}, | |||
{id:76,"labelIGNORE":"Mme.Hucheloup","group":8} | |||
]; | |||
// create some edges | |||
var edges = [ | |||
{"from":1,"to":0,"valueIGNORED":1}, | |||
{"from":2,"to":0,"valueIGNORED":8}, | |||
{"from":3,"to":0,"valueIGNORED":10}, | |||
{"from":3,"to":2,"valueIGNORED":6}, | |||
{"from":4,"to":0,"valueIGNORED":1}, | |||
{"from":5,"to":0,"valueIGNORED":1}, | |||
{"from":6,"to":0,"valueIGNORED":1}, | |||
{"from":7,"to":0,"valueIGNORED":1}, | |||
{"from":8,"to":0,"valueIGNORED":2}, | |||
{"from":9,"to":0,"valueIGNORED":1}, | |||
{"from":11,"to":10,"valueIGNORED":1}, | |||
{"from":11,"to":3,"valueIGNORED":3}, | |||
{"from":11,"to":2,"valueIGNORED":3}, | |||
{"from":11,"to":0,"valueIGNORED":5}, | |||
{"from":12,"to":11,"valueIGNORED":1}, | |||
{"from":13,"to":11,"valueIGNORED":1}, | |||
{"from":14,"to":11,"valueIGNORED":1}, | |||
{"from":15,"to":11,"valueIGNORED":1}, | |||
{"from":17,"to":16,"valueIGNORED":4}, | |||
{"from":18,"to":16,"valueIGNORED":4}, | |||
{"from":18,"to":17,"valueIGNORED":4}, | |||
{"from":19,"to":16,"valueIGNORED":4}, | |||
{"from":19,"to":17,"valueIGNORED":4}, | |||
{"from":19,"to":18,"valueIGNORED":4}, | |||
{"from":20,"to":16,"valueIGNORED":3}, | |||
{"from":20,"to":17,"valueIGNORED":3}, | |||
{"from":20,"to":18,"valueIGNORED":3}, | |||
{"from":20,"to":19,"valueIGNORED":4}, | |||
{"from":21,"to":16,"valueIGNORED":3}, | |||
{"from":21,"to":17,"valueIGNORED":3}, | |||
{"from":21,"to":18,"valueIGNORED":3}, | |||
{"from":21,"to":19,"valueIGNORED":3}, | |||
{"from":21,"to":20,"valueIGNORED":5}, | |||
{"from":22,"to":16,"valueIGNORED":3}, | |||
{"from":22,"to":17,"valueIGNORED":3}, | |||
{"from":22,"to":18,"valueIGNORED":3}, | |||
{"from":22,"to":19,"valueIGNORED":3}, | |||
{"from":22,"to":20,"valueIGNORED":4}, | |||
{"from":22,"to":21,"valueIGNORED":4}, | |||
{"from":23,"to":16,"valueIGNORED":3}, | |||
{"from":23,"to":17,"valueIGNORED":3}, | |||
{"from":23,"to":18,"valueIGNORED":3}, | |||
{"from":23,"to":19,"valueIGNORED":3}, | |||
{"from":23,"to":20,"valueIGNORED":4}, | |||
{"from":23,"to":21,"valueIGNORED":4}, | |||
{"from":23,"to":22,"valueIGNORED":4}, | |||
{"from":23,"to":12,"valueIGNORED":2}, | |||
{"from":23,"to":11,"valueIGNORED":9}, | |||
{"from":24,"to":23,"valueIGNORED":2}, | |||
{"from":24,"to":11,"valueIGNORED":7}, | |||
{"from":25,"to":24,"valueIGNORED":13}, | |||
{"from":25,"to":23,"valueIGNORED":1}, | |||
{"from":25,"to":11,"valueIGNORED":12}, | |||
{"from":26,"to":24,"valueIGNORED":4}, | |||
{"from":26,"to":11,"valueIGNORED":31}, | |||
{"from":26,"to":16,"valueIGNORED":1}, | |||
{"from":26,"to":25,"valueIGNORED":1}, | |||
{"from":27,"to":11,"valueIGNORED":17}, | |||
{"from":27,"to":23,"valueIGNORED":5}, | |||
{"from":27,"to":25,"valueIGNORED":5}, | |||
{"from":27,"to":24,"valueIGNORED":1}, | |||
{"from":27,"to":26,"valueIGNORED":1}, | |||
{"from":28,"to":11,"valueIGNORED":8}, | |||
{"from":28,"to":27,"valueIGNORED":1}, | |||
{"from":29,"to":23,"valueIGNORED":1}, | |||
{"from":29,"to":27,"valueIGNORED":1}, | |||
{"from":29,"to":11,"valueIGNORED":2}, | |||
{"from":30,"to":23,"valueIGNORED":1}, | |||
{"from":31,"to":30,"valueIGNORED":2}, | |||
{"from":31,"to":11,"valueIGNORED":3}, | |||
{"from":31,"to":23,"valueIGNORED":2}, | |||
{"from":31,"to":27,"valueIGNORED":1}, | |||
{"from":32,"to":11,"valueIGNORED":1}, | |||
{"from":33,"to":11,"valueIGNORED":2}, | |||
{"from":33,"to":27,"valueIGNORED":1}, | |||
{"from":34,"to":11,"valueIGNORED":3}, | |||
{"from":34,"to":29,"valueIGNORED":2}, | |||
{"from":35,"to":11,"valueIGNORED":3}, | |||
{"from":35,"to":34,"valueIGNORED":3}, | |||
{"from":35,"to":29,"valueIGNORED":2}, | |||
{"from":36,"to":34,"valueIGNORED":2}, | |||
{"from":36,"to":35,"valueIGNORED":2}, | |||
{"from":36,"to":11,"valueIGNORED":2}, | |||
{"from":36,"to":29,"valueIGNORED":1}, | |||
{"from":37,"to":34,"valueIGNORED":2}, | |||
{"from":37,"to":35,"valueIGNORED":2}, | |||
{"from":37,"to":36,"valueIGNORED":2}, | |||
{"from":37,"to":11,"valueIGNORED":2}, | |||
{"from":37,"to":29,"valueIGNORED":1}, | |||
{"from":38,"to":34,"valueIGNORED":2}, | |||
{"from":38,"to":35,"valueIGNORED":2}, | |||
{"from":38,"to":36,"valueIGNORED":2}, | |||
{"from":38,"to":37,"valueIGNORED":2}, | |||
{"from":38,"to":11,"valueIGNORED":2}, | |||
{"from":38,"to":29,"valueIGNORED":1}, | |||
{"from":39,"to":25,"valueIGNORED":1}, | |||
{"from":40,"to":25,"valueIGNORED":1}, | |||
{"from":41,"to":24,"valueIGNORED":2}, | |||
{"from":41,"to":25,"valueIGNORED":3}, | |||
{"from":42,"to":41,"valueIGNORED":2}, | |||
{"from":42,"to":25,"valueIGNORED":2}, | |||
{"from":42,"to":24,"valueIGNORED":1}, | |||
{"from":43,"to":11,"valueIGNORED":3}, | |||
{"from":43,"to":26,"valueIGNORED":1}, | |||
{"from":43,"to":27,"valueIGNORED":1}, | |||
{"from":44,"to":28,"valueIGNORED":3}, | |||
{"from":44,"to":11,"valueIGNORED":1}, | |||
{"from":45,"to":28,"valueIGNORED":2}, | |||
{"from":47,"to":46,"valueIGNORED":1}, | |||
{"from":48,"to":47,"valueIGNORED":2}, | |||
{"from":48,"to":25,"valueIGNORED":1}, | |||
{"from":48,"to":27,"valueIGNORED":1}, | |||
{"from":48,"to":11,"valueIGNORED":1}, | |||
{"from":49,"to":26,"valueIGNORED":3}, | |||
{"from":49,"to":11,"valueIGNORED":2}, | |||
{"from":50,"to":49,"valueIGNORED":1}, | |||
{"from":50,"to":24,"valueIGNORED":1}, | |||
{"from":51,"to":49,"valueIGNORED":9}, | |||
{"from":51,"to":26,"valueIGNORED":2}, | |||
{"from":51,"to":11,"valueIGNORED":2}, | |||
{"from":52,"to":51,"valueIGNORED":1}, | |||
{"from":52,"to":39,"valueIGNORED":1}, | |||
{"from":53,"to":51,"valueIGNORED":1}, | |||
{"from":54,"to":51,"valueIGNORED":2}, | |||
{"from":54,"to":49,"valueIGNORED":1}, | |||
{"from":54,"to":26,"valueIGNORED":1}, | |||
{"from":55,"to":51,"valueIGNORED":6}, | |||
{"from":55,"to":49,"valueIGNORED":12}, | |||
{"from":55,"to":39,"valueIGNORED":1}, | |||
{"from":55,"to":54,"valueIGNORED":1}, | |||
{"from":55,"to":26,"valueIGNORED":21}, | |||
{"from":55,"to":11,"valueIGNORED":19}, | |||
{"from":55,"to":16,"valueIGNORED":1}, | |||
{"from":55,"to":25,"valueIGNORED":2}, | |||
{"from":55,"to":41,"valueIGNORED":5}, | |||
{"from":55,"to":48,"valueIGNORED":4}, | |||
{"from":56,"to":49,"valueIGNORED":1}, | |||
{"from":56,"to":55,"valueIGNORED":1}, | |||
{"from":57,"to":55,"valueIGNORED":1}, | |||
{"from":57,"to":41,"valueIGNORED":1}, | |||
{"from":57,"to":48,"valueIGNORED":1}, | |||
{"from":58,"to":55,"valueIGNORED":7}, | |||
{"from":58,"to":48,"valueIGNORED":7}, | |||
{"from":58,"to":27,"valueIGNORED":6}, | |||
{"from":58,"to":57,"valueIGNORED":1}, | |||
{"from":58,"to":11,"valueIGNORED":4}, | |||
{"from":59,"to":58,"valueIGNORED":15}, | |||
{"from":59,"to":55,"valueIGNORED":5}, | |||
{"from":59,"to":48,"valueIGNORED":6}, | |||
{"from":59,"to":57,"valueIGNORED":2}, | |||
{"from":60,"to":48,"valueIGNORED":1}, | |||
{"from":60,"to":58,"valueIGNORED":4}, | |||
{"from":60,"to":59,"valueIGNORED":2}, | |||
{"from":61,"to":48,"valueIGNORED":2}, | |||
{"from":61,"to":58,"valueIGNORED":6}, | |||
{"from":61,"to":60,"valueIGNORED":2}, | |||
{"from":61,"to":59,"valueIGNORED":5}, | |||
{"from":61,"to":57,"valueIGNORED":1}, | |||
{"from":61,"to":55,"valueIGNORED":1}, | |||
{"from":62,"to":55,"valueIGNORED":9}, | |||
{"from":62,"to":58,"valueIGNORED":17}, | |||
{"from":62,"to":59,"valueIGNORED":13}, | |||
{"from":62,"to":48,"valueIGNORED":7}, | |||
{"from":62,"to":57,"valueIGNORED":2}, | |||
{"from":62,"to":41,"valueIGNORED":1}, | |||
{"from":62,"to":61,"valueIGNORED":6}, | |||
{"from":62,"to":60,"valueIGNORED":3}, | |||
{"from":63,"to":59,"valueIGNORED":5}, | |||
{"from":63,"to":48,"valueIGNORED":5}, | |||
{"from":63,"to":62,"valueIGNORED":6}, | |||
{"from":63,"to":57,"valueIGNORED":2}, | |||
{"from":63,"to":58,"valueIGNORED":4}, | |||
{"from":63,"to":61,"valueIGNORED":3}, | |||
{"from":63,"to":60,"valueIGNORED":2}, | |||
{"from":63,"to":55,"valueIGNORED":1}, | |||
{"from":64,"to":55,"valueIGNORED":5}, | |||
{"from":64,"to":62,"valueIGNORED":12}, | |||
{"from":64,"to":48,"valueIGNORED":5}, | |||
{"from":64,"to":63,"valueIGNORED":4}, | |||
{"from":64,"to":58,"valueIGNORED":10}, | |||
{"from":64,"to":61,"valueIGNORED":6}, | |||
{"from":64,"to":60,"valueIGNORED":2}, | |||
{"from":64,"to":59,"valueIGNORED":9}, | |||
{"from":64,"to":57,"valueIGNORED":1}, | |||
{"from":64,"to":11,"valueIGNORED":1}, | |||
{"from":65,"to":63,"valueIGNORED":5}, | |||
{"from":65,"to":64,"valueIGNORED":7}, | |||
{"from":65,"to":48,"valueIGNORED":3}, | |||
{"from":65,"to":62,"valueIGNORED":5}, | |||
{"from":65,"to":58,"valueIGNORED":5}, | |||
{"from":65,"to":61,"valueIGNORED":5}, | |||
{"from":65,"to":60,"valueIGNORED":2}, | |||
{"from":65,"to":59,"valueIGNORED":5}, | |||
{"from":65,"to":57,"valueIGNORED":1}, | |||
{"from":65,"to":55,"valueIGNORED":2}, | |||
{"from":66,"to":64,"valueIGNORED":3}, | |||
{"from":66,"to":58,"valueIGNORED":3}, | |||
{"from":66,"to":59,"valueIGNORED":1}, | |||
{"from":66,"to":62,"valueIGNORED":2}, | |||
{"from":66,"to":65,"valueIGNORED":2}, | |||
{"from":66,"to":48,"valueIGNORED":1}, | |||
{"from":66,"to":63,"valueIGNORED":1}, | |||
{"from":66,"to":61,"valueIGNORED":1}, | |||
{"from":66,"to":60,"valueIGNORED":1}, | |||
{"from":67,"to":57,"valueIGNORED":3}, | |||
{"from":68,"to":25,"valueIGNORED":5}, | |||
{"from":68,"to":11,"valueIGNORED":1}, | |||
{"from":68,"to":24,"valueIGNORED":1}, | |||
{"from":68,"to":27,"valueIGNORED":1}, | |||
{"from":68,"to":48,"valueIGNORED":1}, | |||
{"from":68,"to":41,"valueIGNORED":1}, | |||
{"from":69,"to":25,"valueIGNORED":6}, | |||
{"from":69,"to":68,"valueIGNORED":6}, | |||
{"from":69,"to":11,"valueIGNORED":1}, | |||
{"from":69,"to":24,"valueIGNORED":1}, | |||
{"from":69,"to":27,"valueIGNORED":2}, | |||
{"from":69,"to":48,"valueIGNORED":1}, | |||
{"from":69,"to":41,"valueIGNORED":1}, | |||
{"from":70,"to":25,"valueIGNORED":4}, | |||
{"from":70,"to":69,"valueIGNORED":4}, | |||
{"from":70,"to":68,"valueIGNORED":4}, | |||
{"from":70,"to":11,"valueIGNORED":1}, | |||
{"from":70,"to":24,"valueIGNORED":1}, | |||
{"from":70,"to":27,"valueIGNORED":1}, | |||
{"from":70,"to":41,"valueIGNORED":1}, | |||
{"from":70,"to":58,"valueIGNORED":1}, | |||
{"from":71,"to":27,"valueIGNORED":1}, | |||
{"from":71,"to":69,"valueIGNORED":2}, | |||
{"from":71,"to":68,"valueIGNORED":2}, | |||
{"from":71,"to":70,"valueIGNORED":2}, | |||
{"from":71,"to":11,"valueIGNORED":1}, | |||
{"from":71,"to":48,"valueIGNORED":1}, | |||
{"from":71,"to":41,"valueIGNORED":1}, | |||
{"from":71,"to":25,"valueIGNORED":1}, | |||
{"from":72,"to":26,"valueIGNORED":2}, | |||
{"from":72,"to":27,"valueIGNORED":1}, | |||
{"from":72,"to":11,"valueIGNORED":1}, | |||
{"from":73,"to":48,"valueIGNORED":2}, | |||
{"from":74,"to":48,"valueIGNORED":2}, | |||
{"from":74,"to":73,"valueIGNORED":3}, | |||
{"from":75,"to":69,"valueIGNORED":3}, | |||
{"from":75,"to":68,"valueIGNORED":3}, | |||
{"from":75,"to":25,"valueIGNORED":3}, | |||
{"from":75,"to":48,"valueIGNORED":1}, | |||
{"from":75,"to":41,"valueIGNORED":1}, | |||
{"from":75,"to":70,"valueIGNORED":1}, | |||
{"from":75,"to":71,"valueIGNORED":1}, | |||
{"from":76,"to":64,"valueIGNORED":1}, | |||
{"from":76,"to":65,"valueIGNORED":1}, | |||
{"from":76,"to":66,"valueIGNORED":1}, | |||
{"from":76,"to":63,"valueIGNORED":1}, | |||
{"from":76,"to":62,"valueIGNORED":1}, | |||
{"from":76,"to":48,"valueIGNORED":1}, | |||
{"from":76,"to":58,"valueIGNORED":1} | |||
]; | |||
// create a graph | |||
var container = document.getElementById('mygraph'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = {nodes: {shape:'circle'},stabilize: false}; | |||
var graph = new vis.Graph(container, data, options); | |||
} | |||
</script> | |||
</head> | |||
<body onload="draw()"> | |||
<div id="mygraph"></div> | |||
</body> | |||
</html> |
@ -0,0 +1,113 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Graph | Random nodes</title> | |||
<style type="text/css"> | |||
body { | |||
font: 10pt sans; | |||
} | |||
#mygraph { | |||
width: 600px; | |||
height: 600px; | |||
border: 1px solid lightgray; | |||
} | |||
</style> | |||
<script type="text/javascript" src="../../dist/vis.js"></script> | |||
<script type="text/javascript"> | |||
var nodes = null; | |||
var edges = null; | |||
var graph = null; | |||
function draw() { | |||
nodes = []; | |||
edges = []; | |||
var connectionCount = []; | |||
// randomly create some nodes and edges | |||
var nodeCount = document.getElementById('nodeCount').value; | |||
for (var i = 0; i < nodeCount; i++) { | |||
nodes.push({ | |||
id: i, | |||
label: String(i) | |||
}); | |||
connectionCount[i] = 0; | |||
// create edges in a scale-free-graph way | |||
if (i == 1) { | |||
var from = i; | |||
var to = 0; | |||
edges.push({ | |||
from: from, | |||
to: to | |||
}); | |||
connectionCount[from]++; | |||
connectionCount[to]++; | |||
} | |||
else if (i > 1) { | |||
var conn = edges.length * 2; | |||
var rand = Math.floor(Math.random() * conn); | |||
var cum = 0; | |||
var j = 0; | |||
while (j < connectionCount.length && cum < rand) { | |||
cum += connectionCount[j]; | |||
j++; | |||
} | |||
var from = i; | |||
var to = j; | |||
edges.push({ | |||
from: from, | |||
to: to | |||
}); | |||
connectionCount[from]++; | |||
connectionCount[to]++; | |||
} | |||
} | |||
// create a graph | |||
var container = document.getElementById('mygraph'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
edges: { | |||
}, | |||
stabilize: false, | |||
hierarchicalLayout:true | |||
}; | |||
graph = new vis.Graph(container, data, options); | |||
// add event listeners | |||
graph.on('select', function(params) { | |||
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes; | |||
}); | |||
} | |||
</script> | |||
</head> | |||
<body onload="draw();"> | |||
<h2>Hierarchical Layout - Scale-Free-Graph</h2> | |||
<div style="width:700px; font-size:14px;"> | |||
This example shows the randomly generated <b>scale-free-graph</b> set of nodes and connected edges from example 2. | |||
In this example, hierarchical layout has been enabled and the vertical levels are determined automatically. | |||
</div> | |||
<br /> | |||
<form onsubmit="draw(); return false;"> | |||
<label for="nodeCount">Number of nodes:</label> | |||
<input id="nodeCount" type="text" value="25" style="width: 50px;"> | |||
<input type="submit" value="Go"> | |||
</form> | |||
<br> | |||
<div id="mygraph"></div> | |||
<p id="selection"></p> | |||
</body> | |||
</html> |
@ -0,0 +1,139 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Graph | Random nodes</title> | |||
<style type="text/css"> | |||
body { | |||
font: 10pt sans; | |||
} | |||
#mygraph { | |||
width: 600px; | |||
height: 600px; | |||
border: 1px solid lightgray; | |||
} | |||
</style> | |||
<script type="text/javascript" src="../../dist/vis.js"></script> | |||
<script type="text/javascript"> | |||
var nodes = null; | |||
var edges = null; | |||
var graph = null; | |||
function draw() { | |||
nodes = []; | |||
edges = []; | |||
var connectionCount = []; | |||
// randomly create some nodes and edges | |||
for (var i = 0; i < 15; i++) { | |||
nodes.push({ | |||
id: i, | |||
label: String(i) | |||
}); | |||
} | |||
edges.push({ | |||
from: 0, | |||
to: 1 | |||
}); | |||
edges.push({ | |||
from: 0, | |||
to: 6 | |||
}); | |||
edges.push({ | |||
from: 0, | |||
to: 13 | |||
});edges.push({ | |||
from: 0, | |||
to: 11 | |||
}); | |||
edges.push({ | |||
from: 1, | |||
to: 2 | |||
}); | |||
edges.push({ | |||
from: 2, | |||
to: 3 | |||
}); | |||
edges.push({ | |||
from: 2, | |||
to: 4 | |||
}); | |||
edges.push({ | |||
from: 3, | |||
to: 5 | |||
}); | |||
edges.push({ | |||
from: 1, | |||
to: 10 | |||
}); | |||
edges.push({ | |||
from: 1, | |||
to: 7 | |||
}); | |||
edges.push({ | |||
from: 2, | |||
to: 8 | |||
}); | |||
edges.push({ | |||
from: 2, | |||
to: 9 | |||
}); | |||
edges.push({ | |||
from: 3, | |||
to: 14 | |||
}); | |||
edges.push({ | |||
from: 1, | |||
to: 12 | |||
}); | |||
nodes[0]["level"] = 0; | |||
nodes[1]["level"] = 1; | |||
nodes[2]["level"] = 3; | |||
nodes[3]["level"] = 4; | |||
nodes[4]["level"] = 4; | |||
nodes[5]["level"] = 5; | |||
nodes[6]["level"] = 1; | |||
nodes[7]["level"] = 2; | |||
nodes[8]["level"] = 4; | |||
nodes[9]["level"] = 4; | |||
nodes[10]["level"] = 2; | |||
nodes[11]["level"] = 1; | |||
nodes[12]["level"] = 2; | |||
nodes[13]["level"] = 1; | |||
nodes[14]["level"] = 5; | |||
// create a graph | |||
var container = document.getElementById('mygraph'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
hierarchicalLayout:true | |||
}; | |||
graph = new vis.Graph(container, data, options); | |||
// add event listeners | |||
graph.on('select', function(params) { | |||
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes; | |||
}); | |||
} | |||
</script> | |||
</head> | |||
<body onload="draw();"> | |||
<h2>Hierarchical Layout - User-defined</h2> | |||
<div style="width:700px; font-size:14px;"> | |||
This example shows a user-defined hierarchical layout. If the user defines levels for nodes but does not do so for all nodes, an alert will show up and hierarchical layout will be disabled. Either all or none can be defined. | |||
</div> | |||
<br /> | |||
<div id="mygraph"></div> | |||
<p id="selection"></p> | |||
</body> | |||
</html> |
@ -0,0 +1,65 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Show current and custom time bars</title> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
font-size: 11pt; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<p> | |||
<input type="text" id="setTime" value="2014-02-07" /> | |||
<input type="button" id="set" value="Set custom time" /> | |||
</p> | |||
<p> | |||
<input type="button" id="get" value="Get custom time" /> | |||
<span id="getTime"></span> | |||
</p> | |||
<p> | |||
<code>timechange</code> event: <span id="timechangeEvent"></span> | |||
</p> | |||
<p> | |||
<code>timechanged</code> event: <span id="timechangedEvent"></span> | |||
</p> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var items = []; | |||
var options = { | |||
showCurrentTime: true, | |||
showCustomTime: true, | |||
start: new Date(Date.now() - 1000 * 60 * 60 * 24), | |||
end: new Date(Date.now() + 1000 * 60 * 60 * 24 * 6) | |||
}; | |||
var timeline = new vis.Timeline(container, items, options); | |||
document.getElementById('set').onclick = function () { | |||
var time = document.getElementById('setTime').value; | |||
timeline.setCustomTime(time); | |||
}; | |||
document.getElementById('setTime').value = new Date().toISOString().substring(0, 10); | |||
document.getElementById('get').onclick = function () { | |||
document.getElementById('getTime').innerHTML = timeline.getCustomTime(); | |||
}; | |||
timeline.on('timechange', function (properties) { | |||
document.getElementById('timechangeEvent').innerHTML = properties.time; | |||
}); | |||
timeline.on('timechanged', function (properties) { | |||
document.getElementById('timechangedEvent').innerHTML = properties.time; | |||
}); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,91 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Edit items</title> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<div id="visualization"></div> | |||
<p></p> | |||
<div id="log"></div> | |||
<script type="text/javascript"> | |||
var items = new vis.DataSet(); | |||
items.add([ | |||
{id: 1, content: 'item 1', start: new Date(2013, 3, 20)}, | |||
{id: 2, content: 'item 2', start: new Date(2013, 3, 14)}, | |||
{id: 3, content: 'item 3', start: new Date(2013, 3, 18)}, | |||
{id: 4, content: 'item 4', start: new Date(2013, 3, 16), end: new Date(2013, 3, 19)}, | |||
{id: 5, content: 'item 5', start: new Date(2013, 3, 25)}, | |||
{id: 6, content: 'item 6', start: new Date(2013, 3, 27)} | |||
]); | |||
var container = document.getElementById('visualization'); | |||
var options = { | |||
editable: true, | |||
onAdd: function (item, callback) { | |||
item.content = prompt('Enter text content for new item:', item.content); | |||
if (item.content != null) { | |||
callback(item); // send back adjusted new item | |||
} | |||
else { | |||
callback(null); // cancel item creation | |||
} | |||
}, | |||
onMove: function (item, callback) { | |||
if (confirm('Do you really want to move the item to\n' + | |||
'start: ' + item.start + '\n' + | |||
'end: ' + item.end + '?')) { | |||
callback(item); // send back item as confirmation (can be changed | |||
} | |||
else { | |||
callback(null); // cancel editing item | |||
} | |||
}, | |||
onUpdate: function (item, callback) { | |||
item.content = prompt('Edit items text:', item.content); | |||
if (item.content != null) { | |||
callback(item); // send back adjusted item | |||
} | |||
else { | |||
callback(null); // cancel updating the item | |||
} | |||
}, | |||
onRemove: function (item, callback) { | |||
if (confirm('Remove item ' + item.content + '?')) { | |||
callback(item); // confirm deletion | |||
} | |||
else { | |||
callback(null); // cancel deletion | |||
} | |||
} | |||
}; | |||
var timeline = new vis.Timeline(container, items, options); | |||
items.on('*', function (event, properties) { | |||
logEvent(event, properties); | |||
}); | |||
function logEvent(event, properties) { | |||
var log = document.getElementById('log'); | |||
var msg = document.createElement('div'); | |||
msg.innerHTML = 'event=' + JSON.stringify(event) + ', ' + | |||
'properties=' + JSON.stringify(properties); | |||
log.firstChild ? log.insertBefore(msg, log.firstChild) : log.appendChild(msg); | |||
} | |||
</script> | |||
</body> | |||
</html> |