@ -0,0 +1,74 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Bar Graphs Side by Side Example</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> | |||
<h2>Graph2d | Bar Graphs Side by Side Example</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
When using Bar graphs, it can often be the case that there are multiple bars on the same timepoint. This may not always be the desired result. You can use the | |||
barChart.handleOverlap option to automatically plot the bars next to eachother or stacked on top of eachother if they occupy the same timeslot. By default, this option is on, the bars overlap. | |||
Use the dropdown box to experiment with the options. The stacked only really makes sense when using groups as is shown in the <a href="./11_barsSideBySideGroups.html">next example</a>. | |||
<br /><br /> | |||
Handle overlap: <select id="dropdownID"> | |||
<option value="overlap">overlap</option> | |||
<option value="sideBySide">sideBySide</option> | |||
<option value="stack">stack</option> | |||
</select><br/> | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-11', y: 10}, | |||
{x: '2014-06-12', y: 25}, | |||
{x: '2014-06-13', y: 30}, | |||
{x: '2014-06-14', y: 10}, | |||
{x: '2014-06-15', y: 15}, | |||
{x: '2014-06-16', y: 30}, | |||
{x: '2014-06-11', y: 12}, | |||
{x: '2014-06-14', y: 24}, | |||
{x: '2014-06-15', y: 5}, | |||
{x: '2014-06-16', y: 12} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
style:'bar', | |||
barChart: {width:50, align:'center'}, // align: left, center, right | |||
drawPoints: false, | |||
dataAxis: { | |||
icons:true | |||
}, | |||
orientation:'top', | |||
start: '2014-06-10', | |||
end: '2014-06-18' | |||
}; | |||
var graph2d = new vis.Graph2d(container, items, options); | |||
var dropdown = document.getElementById("dropdownID"); | |||
dropdown.onchange = update; | |||
function update() { | |||
var options = {barChart:{handleOverlap:dropdown.value}}; | |||
graph2d.setOptions(options); | |||
} | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,87 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Bar Graphs Side by Side Example with Groups</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> | |||
<h2>Graph2d | Bar Graphs Side by Side Example with Groups</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
When using Bar graphs, it can often be the case that there are multiple bars on the same timepoint. This may not always be the desired result. You can use the | |||
barChart.handleOverlap option to automatically plot the bars next to eachother or stacked on top of eachother if they occupy the same timeslot. By default, this option is on, the bars overlap. | |||
Use the dropdown box to experiment with the options. The stacked only really makes sense when using groups as is shown here. | |||
<br /><br /> | |||
Handle overlap: <select id="dropdownID"> | |||
<option value="overlap">overlap</option> | |||
<option value="sideBySide" selected="selected">sideBySide</option> | |||
<option value="stack">stack</option> | |||
</select> | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var groups = new vis.DataSet(); | |||
groups.add({id: 0, content: "group0"}) | |||
groups.add({id: 1, content: "group1"}) | |||
groups.add({id: 2, content: "group2"}) | |||
var items = [ | |||
{x: '2014-06-11', y: 10, group:0}, | |||
{x: '2014-06-12', y: 25, group:0}, | |||
{x: '2014-06-13', y: 30, group:0}, | |||
{x: '2014-06-14', y: 10, group:0}, | |||
{x: '2014-06-15', y: 15, group:0}, | |||
{x: '2014-06-16', y: 30, group:0}, | |||
{x: '2014-06-11', y: 12, group:1}, | |||
{x: '2014-06-12', y: 15, group:1}, | |||
{x: '2014-06-13', y: 34, group:1}, | |||
{x: '2014-06-14', y: 24, group:1}, | |||
{x: '2014-06-15', y: 5, group:1}, | |||
{x: '2014-06-16', y: 12, group:1}, | |||
{x: '2014-06-11', y: 22, group:2}, | |||
{x: '2014-06-12', y: 14, group:2}, | |||
{x: '2014-06-13', y: 24, group:2}, | |||
{x: '2014-06-14', y: 21, group:2}, | |||
{x: '2014-06-15', y: 30, group:2}, | |||
{x: '2014-06-16', y: 18, group:2} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
style:'bar', | |||
barChart: {width:50, align:'center', handleOverlap:'sideBySide'}, // align: left, center, right | |||
drawPoints: false, | |||
dataAxis: { | |||
icons:true | |||
}, | |||
orientation:'top', | |||
start: '2014-06-10', | |||
end: '2014-06-18' | |||
}; | |||
var graph2d = new vis.Graph2d(container, items, options,groups); | |||
var dropdown = document.getElementById("dropdownID"); | |||
dropdown.onchange = update; | |||
function update() { | |||
var options = {barChart:{handleOverlap:dropdown.value}}; | |||
graph2d.setOptions(options); | |||
} | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,94 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Bar Graph Example</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> | |||
<h2>Graph2d | Custom axis range</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
You can define a custom range for the Y axis. Since there are two Y axis, you can define both of them. You can also | |||
only define the min or max values. Since one of the Y axis is slaved to the other one (the right one is slaved to the left one), | |||
you cannot absolutely define the range of the slaved axis because it has to use the same lines. The values you supply are used as guidelines however. | |||
<pre class="prettyprint lang-js"> | |||
var options = { | |||
dataAxis: { | |||
customRange: { | |||
left: { | |||
min:-5, max:30 | |||
}, | |||
right: { | |||
min:-5 | |||
} | |||
}, | |||
} | |||
}; | |||
</pre> | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var groups = new vis.DataSet(); | |||
groups.add({id: 0, content: "group0"}) | |||
groups.add({id: 1, content: "group1"}) | |||
groups.add({id: 2, content: "group2",options:{ yAxisOrientation:'right'}}) | |||
var items = [ | |||
{x: '2014-06-11', y: 10, group:0}, | |||
{x: '2014-06-12', y: 25, group:0}, | |||
{x: '2014-06-13', y: 30, group:0}, | |||
{x: '2014-06-14', y: 10, group:0}, | |||
{x: '2014-06-15', y: 15, group:0}, | |||
{x: '2014-06-16', y: 30, group:0}, | |||
{x: '2014-06-11', y: 12, group:1}, | |||
{x: '2014-06-12', y: 15, group:1}, | |||
{x: '2014-06-13', y: 34, group:1}, | |||
{x: '2014-06-14', y: 24, group:1}, | |||
{x: '2014-06-15', y: 5, group:1}, | |||
{x: '2014-06-16', y: 12, group:1}, | |||
{x: '2014-06-11', y: 22, group:2}, | |||
{x: '2014-06-12', y: 14, group:2}, | |||
{x: '2014-06-13', y: 24, group:2}, | |||
{x: '2014-06-14', y: 21, group:2}, | |||
{x: '2014-06-15', y: 30, group:2}, | |||
{x: '2014-06-16', y: 18, group:2} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
style:'bar', | |||
barChart: {width:50, align:'center', handleOverlap:"sideBySide"}, // align: left, center, right | |||
drawPoints: true, | |||
dataAxis: { | |||
customRange: { | |||
left: { | |||
min:-5, max:30 | |||
}, | |||
right: { | |||
min:-5 | |||
} | |||
}, | |||
icons:true | |||
}, | |||
orientation:'top', | |||
start: '2014-06-10', | |||
end: '2014-06-18' | |||
}; | |||
var graph2d = new vis.Graph2d(container, items, options,groups); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,65 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |||
<meta content="utf-8" http-equiv="encoding"> | |||
<title>Graph2d | Localization</title> | |||
<style type="text/css"> | |||
body, html, select { | |||
font-family: sans-serif; | |||
font-size: 11pt; | |||
} | |||
</style> | |||
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment-with-langs.min.js"></script> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Localization</h2> | |||
<p> | |||
To localize Graph2d, one has to load a version of moment.js including locales. To set a locale, specify option <code>{locale: STRING}</code>. | |||
</p> | |||
<p> | |||
<label for="locale">Select a locale:</label> | |||
<select id="locale"> | |||
<option value="en" selected>en</option> | |||
<option value="nl">nl</option> | |||
</select> | |||
</p> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-11', y: 10}, | |||
{x: '2014-06-12', y: 25}, | |||
{x: '2014-06-13', y: 30}, | |||
{x: '2014-06-14', y: 10}, | |||
{x: '2014-06-15', y: 15}, | |||
{x: '2014-06-16', y: 30} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
start: '2014-06-10', | |||
end: '2014-06-18' | |||
}; | |||
var graph2d = new vis.Graph2d(container, dataset, options); | |||
// update the locale when changing the select box value | |||
var select = document.getElementById('locale'); | |||
select.onchange = function () { | |||
graph2d.setOptions({ | |||
locale: this.value | |||
}); | |||
}; | |||
select.onchange(); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,145 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Toggle Groups Example</title> | |||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |||
<meta content="utf-8" http-equiv="encoding"> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
div.graphs { | |||
width:300px; | |||
display:inline-block; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Groups Example</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
This example shows the groups visibility functionality within Graph2d. Groups have their own visibility option. By using this, | |||
all graph2d instances using those groups would show or hide that group. If you have multiple instances sharing the same data and groups, | |||
you can use the groups.visibility option to set it on an instance level. The graphs below all share the same groups, items and initial options. | |||
We then use a setOptions like so: | |||
<pre class="prettyprint lang-js"> | |||
graph2d1.setOptions({ | |||
groups:{ | |||
visibility:{ | |||
0:true, // group id:0 visible | |||
1:false, // group id:1 hidden | |||
2:false, // group id:2 hidden | |||
3:false, // group id:3 hidden | |||
"__ungrouped__":false // default group hidden | |||
} | |||
} | |||
}) | |||
</pre> | |||
</div> | |||
<br /> | |||
<div class="graphs" id="visualization1"></div> | |||
<div class="graphs" id="visualization2"></div> | |||
<div class="graphs" id="visualization3"></div> | |||
<div class="graphs" id="visualization4"></div> | |||
<div class="graphs" id="visualization5"></div> | |||
<div class="graphs" id="visualization6"></div> | |||
<script type="text/javascript"> | |||
// create a dataSet with groups | |||
var names = ['SquareShaded', 'Bar', 'Blank', 'CircleShaded']; | |||
var groups = new vis.DataSet(); | |||
groups.add({ | |||
id: 0, | |||
content: names[0], | |||
options: { | |||
drawPoints: { | |||
style: 'square' // square, circle | |||
}, | |||
shaded: { | |||
orientation: 'bottom' // top, bottom | |||
} | |||
}}); | |||
groups.add({ | |||
id: 1, | |||
content: names[1], | |||
options: { | |||
style:'bar' | |||
}}); | |||
groups.add({ | |||
id: 2, | |||
content: names[2], | |||
options: {drawPoints: false} | |||
}); | |||
groups.add({ | |||
id: 3, | |||
content: names[3], | |||
options: { | |||
drawPoints: { | |||
style: 'circle' // square, circle | |||
}, | |||
shaded: { | |||
orientation: 'top' // top, bottom | |||
} | |||
}}); | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-13', y: 60}, | |||
{x: '2014-06-14', y: 40}, | |||
{x: '2014-06-15', y: 55}, | |||
{x: '2014-06-16', y: 40}, | |||
{x: '2014-06-17', y: 50}, | |||
{x: '2014-06-13', y: 30, group: 0}, | |||
{x: '2014-06-14', y: 10, group: 0}, | |||
{x: '2014-06-15', y: 15, group: 1}, | |||
{x: '2014-06-16', y: 30, group: 1}, | |||
{x: '2014-06-17', y: 10, group: 1}, | |||
{x: '2014-06-18', y: 15, group: 1}, | |||
{x: '2014-06-19', y: 52, group: 1}, | |||
{x: '2014-06-20', y: 10, group: 1}, | |||
{x: '2014-06-21', y: 20, group: 2}, | |||
{x: '2014-06-22', y: 60, group: 2}, | |||
{x: '2014-06-23', y: 10, group: 2}, | |||
{x: '2014-06-24', y: 25, group: 2}, | |||
{x: '2014-06-25', y: 30, group: 2}, | |||
{x: '2014-06-26', y: 20, group: 3}, | |||
{x: '2014-06-27', y: 60, group: 3}, | |||
{x: '2014-06-28', y: 10, group: 3}, | |||
{x: '2014-06-29', y: 25, group: 3}, | |||
{x: '2014-06-30', y: 30, group: 3} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
defaultGroup: 'ungrouped', | |||
legend: false, | |||
graphHeight:200, | |||
start: '2014-06-10', | |||
end: '2014-07-04', | |||
showMajorLabels:false, | |||
showMinorLabels:false | |||
}; | |||
var graph2d1 = new vis.Graph2d(document.getElementById('visualization1'), dataset, options, groups); | |||
var graph2d2 = new vis.Graph2d(document.getElementById('visualization2'), dataset, options, groups); | |||
var graph2d3 = new vis.Graph2d(document.getElementById('visualization3'), dataset, options, groups); | |||
var graph2d4 = new vis.Graph2d(document.getElementById('visualization4'), dataset, options, groups); | |||
var graph2d5 = new vis.Graph2d(document.getElementById('visualization5'), dataset, options, groups); | |||
var graph2d6 = new vis.Graph2d(document.getElementById('visualization6'), dataset, options, groups); | |||
graph2d1.setOptions({groups:{visibility:{0:true, 1:false, 2:false, 3:false, "__ungrouped__":false}}}) | |||
graph2d2.setOptions({groups:{visibility:{0:false, 1:true, 2:false, 3:false, "__ungrouped__":false}}}) | |||
graph2d3.setOptions({groups:{visibility:{0:false, 1:false, 2:true, 3:false, "__ungrouped__":false}}}) | |||
graph2d4.setOptions({groups:{visibility:{0:false, 1:false, 2:false, 3:true, "__ungrouped__":false}}}) | |||
graph2d5.setOptions({groups:{visibility:{0:false, 1:false, 2:false, 3:false, "__ungrouped__":true}}}) | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,231 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Network | Localization</title> | |||
<style type="text/css"> | |||
body, select { | |||
font: 10pt sans; | |||
} | |||
#mynetwork { | |||
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; | |||
} | |||
#network-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 network = 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-network 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 network | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
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('network-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('network-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'; | |||
}, | |||
onConnect: function(data,callback) { | |||
if (data.from == data.to) { | |||
var r=confirm("Do you want to connect the node to itself?"); | |||
if (r==true) { | |||
callback(data); | |||
} | |||
} | |||
else { | |||
callback(data); | |||
} | |||
} | |||
}; | |||
network = new vis.Network(container, data, options); | |||
// add event listeners | |||
network.on('select', function(params) { | |||
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes; | |||
}); | |||
network.on("resize", 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('network-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('network-popUp'); | |||
data.id = idInput.value; | |||
data.label = labelInput.value; | |||
clearPopUp(); | |||
callback(data); | |||
} | |||
// update the locale when changing the select box value | |||
var select = document.getElementById('locale'); | |||
select.onchange = function () { | |||
network.setOptions({ | |||
locale: this.value | |||
}); | |||
}; | |||
select.onchange(); | |||
} | |||
</script> | |||
</head> | |||
<body onload="draw();"> | |||
<h2>Editing the dataset (localized)</h2> | |||
<p style="width: 700px; font-size:14px; text-align: justify;"> | |||
This is the same example as <a href="21_data_manipulation.html">21_data_manipulation.html</a>, except that there is a select box added which allows to switch locale. The localization is only relevant to the manipulation buttons. | |||
</p> | |||
<p> | |||
<label for="locale">Select a locale:</label> | |||
<select id="locale"> | |||
<option value="en" selected>en</option> | |||
<option value="nl">nl</option> | |||
</select> | |||
</p> | |||
<div id="network-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="mynetwork"></div> | |||
<p id="selection"></p> | |||
</body> | |||
</html> | |||
@ -0,0 +1,140 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Network | Hierarchical layout difference</title> | |||
<style type="text/css"> | |||
body { | |||
font: 10pt sans; | |||
} | |||
#mynetwork { | |||
width: 800px; | |||
height: 500px; | |||
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 network = null; | |||
var layoutMethod = "hubsize"; | |||
function draw() { | |||
var nodes = []; | |||
var edges = []; | |||
// 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 | |||
}); | |||
// create a network | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
hierarchicalLayout: { | |||
layout: layoutMethod | |||
}, | |||
edges: {style:"arrow"}, | |||
smoothCurves:false | |||
}; | |||
network = new vis.Network(container, data, options); | |||
// add event listeners | |||
network.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; text-align: justify;"> | |||
This example shows a the effect of the different hierarchical layout methods. Hubsize is based on the amount of edges connected to a node. | |||
The node with the most connections (the largest hub) is drawn at the top of the tree. The direction method is based on the direction of the edges. | |||
Try switching between the methods with the dropdown box below. | |||
</div> | |||
Layout method: | |||
<select id="layout"> | |||
<option value="hubsize">hubsize</option> | |||
<option value="direction">direction</option> | |||
</select><br/> | |||
<br /> | |||
<div id="mynetwork"></div> | |||
<p id="selection"></p> | |||
<script language="JavaScript"> | |||
var dropdown = document.getElementById("layout"); | |||
dropdown.onchange = function() { | |||
layoutMethod = dropdown.value; | |||
draw(); | |||
} | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,65 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Localization</title> | |||
<style type="text/css"> | |||
body, html, select { | |||
font-family: sans-serif; | |||
font-size: 11pt; | |||
} | |||
</style> | |||
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.1/moment-with-locales.min.js"></script> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<p> | |||
To localize the Timeline, one has to load a version of moment.js including locales. To set a locale, specify option <code>{locale: STRING}</code>. | |||
</p> | |||
<p> | |||
<label for="locale">Select a locale:</label> | |||
<select id="locale"> | |||
<option value="en" selected>en</option> | |||
<option value="nl">nl</option> | |||
</select> | |||
</p> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var DAY = 24 * 60 * 60 * 1000; | |||
// DOM element where the Timeline will be attached | |||
var container = document.getElementById('visualization'); | |||
// Create a DataSet (allows two way data-binding) | |||
var items = new vis.DataSet([ | |||
{id: 1, content: 'item 1', start: new Date(new Date().valueOf() - DAY)}, | |||
{id: 2, content: 'item 2', start: new Date(new Date().valueOf() + 2 * DAY)} | |||
]); | |||
// Configuration for the Timeline | |||
var options = { | |||
showCurrentTime: true, | |||
showCustomTime: true | |||
}; | |||
// Create a Timeline | |||
var timeline = new vis.Timeline(container, items, options); | |||
timeline.setCustomTime(new Date(new Date().valueOf() + DAY)); | |||
// update the locale when changing the select box value | |||
var select = document.getElementById('locale'); | |||
select.onchange = function () { | |||
timeline.setOptions({ | |||
locale: this.value | |||
}); | |||
}; | |||
select.onchange(); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,72 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Click to use</title> | |||
<style> | |||
body, html { | |||
font-family: arial, sans-serif; | |||
font-size: 11pt; | |||
} | |||
#main { | |||
width: 728px; | |||
margin: 0 auto; | |||
} | |||
.container { | |||
margin: 10px; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<div id="main"> | |||
<h1>Timeline click to use</h1> | |||
<p> | |||
This example demonstrates how to use the <code>clickToUse</code> option: before you can scroll and drag in the timeline, you first have to click in the timeline to activate. | |||
</p> | |||
</div> | |||
<script> | |||
// create a dataset with items | |||
// we specify the type of the fields `start` and `end` here to be strings | |||
// containing an ISO date. The fields will be outputted as ISO dates | |||
// automatically getting data from the DataSet via items.get(). | |||
var items = new vis.DataSet({ | |||
type: { start: 'ISODate', end: 'ISODate' } | |||
}); | |||
// add items to the DataSet | |||
items.add([ | |||
{id: 1, content: 'item 1<br>start', start: '2014-01-23'}, | |||
{id: 2, content: 'item 2', start: '2014-01-18'}, | |||
{id: 3, content: 'item 3', start: '2014-01-21'}, | |||
{id: 4, content: 'item 4', start: '2014-01-19', end: '2014-01-24'}, | |||
{id: 5, content: 'item 5', start: '2014-01-28', type:'point'}, | |||
{id: 6, content: 'item 6', start: '2014-01-26'} | |||
]); | |||
function createTimeline(main) { | |||
var main = document.getElementById('main'); | |||
var container = document.createElement('div'); | |||
container.className = 'container'; | |||
main.appendChild(container); | |||
var options = { | |||
editable: true, | |||
clickToUse: true | |||
}; | |||
return new vis.Timeline(container, items, options); | |||
} | |||
var timelines = []; | |||
for (var i = 0; i < 10; i++) { | |||
timelines.push(createTimeline()); | |||
} | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,65 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Select items</title> | |||
<style> | |||
body, html { | |||
font-family: arial, sans-serif; | |||
font-size: 11pt; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h1>Set selection</h1> | |||
<p style="max-width: 600px;"> | |||
Enter one or multiple ids of items, then press select to select the items. This demo uses the function <code>Timeline.setSelection(ids)</code>. Optionally, the window can be moved to the selected items. | |||
</p> | |||
<p> | |||
Select item(s): <input type="text" id="selection" value="5, 6"><input type="button" id="select" value="Select"><br> | |||
<label><input type="checkbox" id="focus" checked> Focus on selection</label> | |||
</p> | |||
<div id="visualization"></div> | |||
<script> | |||
// create a dataset with items | |||
// we specify the type of the fields `start` and `end` here to be strings | |||
// containing an ISO date. The fields will be outputted as ISO dates | |||
// automatically getting data from the DataSet via items.get(). | |||
var items = new vis.DataSet({ | |||
type: { start: 'ISODate', end: 'ISODate' } | |||
}); | |||
// add items to the DataSet | |||
items.add([ | |||
{id: 1, content: 'item 1<br>start', start: '2014-01-23'}, | |||
{id: 2, content: 'item 2', start: '2014-01-18'}, | |||
{id: 3, content: 'item 3', start: '2014-01-21'}, | |||
{id: 4, content: 'item 4', start: '2014-01-19', end: '2014-01-24'}, | |||
{id: 5, content: 'item 5', start: '2014-01-28', type:'point'}, | |||
{id: 6, content: 'item 6', start: '2014-01-26'} | |||
]); | |||
var container = document.getElementById('visualization'); | |||
var options = { | |||
editable: true | |||
}; | |||
var timeline = new vis.Timeline(container, items, options); | |||
var selection = document.getElementById('selection'); | |||
var select = document.getElementById('select'); | |||
var focus = document.getElementById('focus'); | |||
select.onclick = function () { | |||
var ids = selection.value.split(',').map(function (value) { | |||
return value.trim(); | |||
}); | |||
timeline.setSelection(ids, {focus: focus.checked}); | |||
}; | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,94 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Adjusting window</title> | |||
<style> | |||
body, html { | |||
font-family: arial, 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>This example demonstrates functions to adjust the visible window of the Timeline.</p> | |||
<input type="button" id="window1" value="Set window from 2014-01-01 to 2014-04-01"><br> | |||
<input type="button" id="window2" value="Set window from 2014-01-01 to 2014-04-01 without animation"><br> | |||
<input type="button" id="fit" value="Fit all items"><br> | |||
<input type="button" id="select" value="Select & focus items 5 and 6"><br> | |||
<input type="button" id="focus1" value="Focus item 2"><br> | |||
<input type="button" id="focus2" value="Focus items 5 and 6 (slow animation)"><br> | |||
<input type="button" id="focus3" value="Focus current selection"><br> | |||
<input type="button" id="moveTo" value="Move to 2014-02-01"><br> | |||
<div id="visualization"></div> | |||
<script> | |||
// create a dataset with items | |||
// we specify the type of the fields `start` and `end` here to be strings | |||
// containing an ISO date. The fields will be outputted as ISO dates | |||
// automatically getting data from the DataSet via items.get(). | |||
var items = new vis.DataSet({ | |||
type: { start: 'ISODate', end: 'ISODate' } | |||
}); | |||
// add items to the DataSet | |||
items.add([ | |||
{id: 1, content: 'item 1<br>start', start: '2014-01-23'}, | |||
{id: 2, content: 'item 2', start: '2014-01-18'}, | |||
{id: 3, content: 'item 3', start: '2014-01-21'}, | |||
{id: 4, content: 'item 4', start: '2014-01-19', end: '2014-01-24'}, | |||
{id: 5, content: 'item 5', start: '2014-01-28', type:'point'}, | |||
{id: 6, content: 'item 6', start: '2014-01-26'} | |||
]); | |||
var container = document.getElementById('visualization'); | |||
var options = { | |||
start: '2014-01-10', | |||
end: '2014-02-10', | |||
editable: true, | |||
showCurrentTime: true | |||
}; | |||
var timeline = new vis.Timeline(container, items, options); | |||
document.getElementById('window1').onclick = function() { | |||
timeline.setWindow('2014-01-01', '2014-04-01'); | |||
}; | |||
document.getElementById('window2').onclick = function() { | |||
timeline.setWindow('2014-01-01', '2014-04-01', { | |||
animate: false | |||
}); | |||
}; | |||
document.getElementById('fit').onclick = function() { | |||
timeline.fit(); | |||
}; | |||
document.getElementById('select').onclick = function() { | |||
timeline.setSelection([5, 6], { | |||
focus: true | |||
}); | |||
}; | |||
document.getElementById('focus1').onclick = function() { | |||
timeline.focus(2); | |||
}; | |||
document.getElementById('focus2').onclick = function() { | |||
timeline.focus([5, 6], { | |||
animate: 3000 // ms | |||
}); | |||
}; | |||
document.getElementById('focus3').onclick = function() { | |||
var selection = timeline.getSelection(); | |||
timeline.focus(selection); | |||
}; | |||
document.getElementById('moveTo').onclick = function() { | |||
timeline.moveTo('2014-02-01'); | |||
}; | |||
</script> | |||
</body> | |||
</html> |