@ -0,0 +1,123 @@ | |||||
<!DOCTYPE HTML> | |||||
<html> | |||||
<head> | |||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |||||
<meta content="utf-8" http-equiv="encoding"> | |||||
<title>Graph2d | Streaming data</title> | |||||
<style type="text/css"> | |||||
body, html, select { | |||||
font: 10pt sans-serif; | |||||
} | |||||
</style> | |||||
<script src="../../dist/vis.js"></script> | |||||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||||
</head> | |||||
<body> | |||||
<h2>Graph2d | Streaming data</h2> | |||||
<p style="max-width: 700px;"> | |||||
This example demonstrates how to apply streaming data input to the Graph2d. The example shows two different ways to let the window move along with the new data, and there are more strategies for that. Note also that it is possible to disable moving and/or zooming the graph by setting options <code>moveable</code> and <code>zoomable</code> false. | |||||
</p> | |||||
<p> | |||||
<label for="strategy">Strategy:</label> | |||||
<select id="strategy"> | |||||
<option value="continuous" selected>Continuous (CPU intensive)</option> | |||||
<option value="discrete">Discrete</option> | |||||
<option value="static">Static</option> | |||||
</select> | |||||
</p> | |||||
<div id="visualization"></div> | |||||
<script type="text/javascript"> | |||||
var DELAY = 1000; // delay in ms to add new data points | |||||
var strategy = document.getElementById('strategy'); | |||||
// create a graph2d with an (currently empty) dataset | |||||
var container = document.getElementById('visualization'); | |||||
var dataset = new vis.DataSet(); | |||||
var now = vis.moment(); | |||||
// added initial set so you don't think the graph is empty | |||||
dataset.add({x: now-2000,y: y((now-2000) / 1000)}); | |||||
dataset.add({x: now-1000,y: y((now-1000) / 1000)}); | |||||
dataset.add({x: now,y: y((now) / 1000)}); | |||||
dataset.add({x: now+1000,y: y((now+1000) / 1000)}); | |||||
var options = { | |||||
start: vis.moment().add(-30, 'seconds'), // changed so its faster | |||||
end: vis.moment(), | |||||
dataAxis: { | |||||
customRange: { | |||||
left: { | |||||
min:-10, max: 10 | |||||
} | |||||
} | |||||
} | |||||
}; | |||||
var graph2d = new vis.Graph2d(container, dataset, options); | |||||
// a function to generate data points | |||||
function y(x) { | |||||
return (Math.sin(x / 2) + Math.cos(x / 4)) * 5; | |||||
} | |||||
function renderStep() { | |||||
// move the window (you can think of different strategies). | |||||
var now = vis.moment(); | |||||
var range = graph2d.getWindow(); | |||||
var interval = range.end - range.start; | |||||
switch (strategy.value) { | |||||
case 'continuous': | |||||
// continuously move the window | |||||
graph2d.setWindow(now - interval, now, {animate: false}); | |||||
requestAnimationFrame(renderStep); | |||||
break; | |||||
case 'discrete': | |||||
graph2d.setWindow(now - interval, now, {animate: false}); | |||||
setTimeout(renderStep, DELAY); | |||||
break; | |||||
default: // 'static' | |||||
// move the window 90% to the left when now is larger than the end of the window | |||||
if (now > range.end) { | |||||
graph2d.setWindow(now - 0.1 * interval, now + 0.9 * interval); | |||||
} | |||||
setTimeout(renderStep, DELAY); | |||||
break; | |||||
} | |||||
} | |||||
renderStep(); | |||||
/** | |||||
* Add a new datapoint to the graph | |||||
*/ | |||||
function addDataPoint() { | |||||
// add a new data point to the dataset | |||||
var now = vis.moment(); | |||||
dataset.add({ | |||||
x: now+2000, // changed so you dont see them appearing | |||||
y: y(now / 1000) | |||||
}); | |||||
// remove all data points which are no longer visible | |||||
var range = graph2d.getWindow(); | |||||
var interval = range.end - range.start; | |||||
var oldIds = dataset.getIds({ | |||||
filter: function (item) { | |||||
return item.x < range.start - interval; // changed so you don't see them disappearing | |||||
} | |||||
}); | |||||
dataset.remove(oldIds); | |||||
setTimeout(addDataPoint, DELAY); | |||||
} | |||||
addDataPoint(); | |||||
</script> | |||||
</body> | |||||
</html> |
@ -0,0 +1,319 @@ | |||||
<!doctype html> | |||||
<html> | |||||
<head> | |||||
<title>Network | Animation</title> | |||||
<style type="text/css"> | |||||
body { | |||||
font: 10pt sans; | |||||
} | |||||
#mynetwork { | |||||
width: 600px; | |||||
height: 600px; | |||||
border: 1px solid lightgray; | |||||
} | |||||
div.left { | |||||
position:relative; | |||||
float:left; | |||||
width:300px; | |||||
border: 1px #c7c7c7 solid; | |||||
height:590px; | |||||
padding:5px; | |||||
} | |||||
div.right { | |||||
padding-left:10px; | |||||
float:left; | |||||
width:600px; | |||||
} | |||||
div.bottom { | |||||
position:absolute; | |||||
bottom:5px; | |||||
} | |||||
</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 nodes = null; | |||||
var edges = null; | |||||
var network = null; | |||||
var doButton, focusButton, showButton; | |||||
var statusUpdateSpan; | |||||
var finishMessage = ""; | |||||
function draw() { | |||||
statusUpdateSpan = document.getElementById("statusUpdate"); | |||||
doButton = document.getElementById("btnDo"); | |||||
focusButton = document.getElementById("btnFocus"); | |||||
showButton = document.getElementById("btnShow"); | |||||
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 = {stabilizationIterations:1200}; | |||||
network = new vis.Network(container, data, options); | |||||
// add event listeners | |||||
network.on('select', function(params) { | |||||
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes; | |||||
}); | |||||
network.on('stabilized', function (params) { | |||||
document.getElementById('stabilization').innerHTML = 'Stabilization took ' + params.iterations + ' iterations.'; | |||||
}); | |||||
network.on("animationFinished", function() { | |||||
statusUpdateSpan.innerHTML = finishMessage; | |||||
}) | |||||
} | |||||
function zoomExtentAnimated() { | |||||
var offsetx = parseInt(document.getElementById("offsetx").value); | |||||
var offsety = parseInt(document.getElementById("offsety").value); | |||||
var duration = parseInt(document.getElementById("duration").value); | |||||
var easingFunction = document.getElementById("easingFunction").value; | |||||
var options = {offset: {x:offsetx,y:offsety}, | |||||
duration: duration, | |||||
easingFunction: easingFunction | |||||
} | |||||
statusUpdateSpan.innerHTML = "Doing ZoomExtent() Animation."; | |||||
finishMessage = "Animation finished." | |||||
network.zoomExtent(options); | |||||
} | |||||
function doDefaultAnimation() { | |||||
var offsetx = parseInt(document.getElementById("offsetx").value); | |||||
var offsety = parseInt(document.getElementById("offsety").value); | |||||
var scale = parseFloat(document.getElementById("scale").value); | |||||
var positionx = parseInt(document.getElementById("positionx").value); | |||||
var positiony = parseInt(document.getElementById("positiony").value); | |||||
var easingFunction = document.getElementById("easingFunction").value; | |||||
var options = { | |||||
position: {x:positionx,y:positiony}, | |||||
scale: scale, | |||||
offset: {x:offsetx,y:offsety}, | |||||
animation: true // default duration is 1000ms and default easingFunction is easeInOutQuad. | |||||
} | |||||
statusUpdateSpan.innerHTML = "Doing Animation."; | |||||
finishMessage = "Animation finished." | |||||
network.moveTo(options); | |||||
} | |||||
function doAnimation() { | |||||
var offsetx = parseInt(document.getElementById("offsetx").value); | |||||
var offsety = parseInt(document.getElementById("offsety").value); | |||||
var duration = parseInt(document.getElementById("duration").value); | |||||
var scale = parseFloat(document.getElementById("scale").value); | |||||
var positionx = parseInt(document.getElementById("positionx").value); | |||||
var positiony = parseInt(document.getElementById("positiony").value); | |||||
var easingFunction = document.getElementById("easingFunction").value; | |||||
var options = { | |||||
position: {x:positionx,y:positiony}, | |||||
scale: scale, | |||||
offset: {x:offsetx,y:offsety}, | |||||
animation: { | |||||
duration: duration, | |||||
easingFunction: easingFunction | |||||
} | |||||
} | |||||
statusUpdateSpan.innerHTML = "Doing Animation."; | |||||
finishMessage = "Animation finished." | |||||
network.moveTo(options); | |||||
} | |||||
function focusRandom() { | |||||
var nodeId = Math.floor(Math.random() * 25); | |||||
var offsetx = parseInt(document.getElementById("offsetx").value); | |||||
var offsety = parseInt(document.getElementById("offsety").value); | |||||
var duration = parseInt(document.getElementById("duration").value); | |||||
var scale = parseFloat(document.getElementById("scale").value); | |||||
var easingFunction = document.getElementById("easingFunction").value; | |||||
var options = { | |||||
// position: {x:positionx,y:positiony}, // this is not relevant when focusing on nodes | |||||
scale: scale, | |||||
offset: {x:offsetx,y:offsety}, | |||||
animation: { | |||||
duration: duration, | |||||
easingFunction: easingFunction | |||||
} | |||||
} | |||||
statusUpdateSpan.innerHTML = "Focusing on node: " + nodeId; | |||||
finishMessage = "Node: " + nodeId + " in focus."; | |||||
network.focusOnNode(nodeId, options); | |||||
} | |||||
var showInterval = false; | |||||
var showPhase = 1; | |||||
function startShow() { | |||||
if (showInterval !== false) { | |||||
showInterval = false; | |||||
showButton.value = "Start a show!"; | |||||
network.zoomExtent(); | |||||
} | |||||
else { | |||||
showButton.value = "Stop the show!"; | |||||
var duration = parseInt(document.getElementById("duration").value); | |||||
focusRandom(); | |||||
window.setTimeout(doTheShow, duration); | |||||
showInterval = true; | |||||
} | |||||
} | |||||
function doTheShow() { | |||||
if (showInterval == true) { | |||||
var duration = parseInt(document.getElementById("duration").value); | |||||
if (showPhase == 0) { | |||||
focusRandom(); | |||||
showPhase = 1; | |||||
} | |||||
else { | |||||
zoomExtentAnimated(); | |||||
showPhase = 0; | |||||
} | |||||
window.setTimeout(doTheShow, duration); | |||||
} | |||||
} | |||||
</script> | |||||
</head> | |||||
<body onload="draw();"> | |||||
<h2>Camera animations</h2> | |||||
<div style="width:700px; font-size:14px;"> | |||||
You can move the view around programmatically using the .moveTo(options) function. The options supplied to this function can | |||||
also be (partially) supplied to the .zoomExtent() and .focusOnNode() methods. These are explained in the docs. | |||||
<br /><br/> | |||||
The buttons below take the fields from the table when they can. For instance, the "Animate with default settings." takes the position, scale and offset while using | |||||
the default animation values for duration and easing function. The focusOnNode takes everything except the position and the zoomExtent takes only the duration and easing function. | |||||
<br/><br/> | |||||
Here you can see a full description of the options you can supply to moveTo: | |||||
</div> | |||||
<pre> | |||||
var moveToOptions = { | |||||
position: {x:x, y:x}, // position to animate to (Numbers) | |||||
scale: 1.0, // scale to animate to (Number) | |||||
offset: {x:x, y:y}, // offset from the center in DOM pixels (Numbers) | |||||
animation: { // animation object, can also be Boolean | |||||
duration: 1000, // animation duration in milliseconds (Number) | |||||
easingFunction: "easeInOutQuad" // Animation easing function, available are: | |||||
} // linear, easeInQuad, easeOutQuad, easeInOutQuad, | |||||
} // easeInCubic, easeOutCubic, easeInOutCubic, | |||||
// easeInQuart, easeOutQuart, easeInOutQuart, | |||||
// easeInQuint, easeOutQuint, easeInOutQuint | |||||
</pre> | |||||
<div class="left"> | |||||
<table> | |||||
<tr> | |||||
<td>position x</td><td><input type="text" value="300" id="positionx" style="width:170px;"></td> | |||||
</tr> | |||||
<tr> | |||||
<td>position y</td><td><input type="text" value="300" id="positiony" style="width:170px;"></td> | |||||
</tr> | |||||
<tr> | |||||
<td>scale</td><td><input type="text" value="1.0" id="scale" style="width:170px;"></td> | |||||
</tr> | |||||
<tr> | |||||
<td>offset x</td><td><input type="text" value="0" id="offsetx" style="width:170px;"> px</td> | |||||
</tr> | |||||
<tr> | |||||
<td>offset y</td><td><input type="text" value="0" id="offsety" style="width:170px;"> px</td> | |||||
</tr> | |||||
<tr> | |||||
<td>duration</td><td><input type="text" value="2500" id="duration" style="width:170px;"> ms</td> | |||||
</tr> | |||||
<tr> | |||||
<td>easingFunction</td><td> | |||||
<select id="easingFunction" style="width:174px;"> | |||||
<option value="linear">linear</option> | |||||
<option value="easeInQuad">easeInQuad</option> | |||||
<option value="easeOutQuad">easeOutQuad</option> | |||||
<option value="easeInOutQuad" selected="selected">easeInOutQuad</option> | |||||
<option value="easeInCubic">easeInCubic</option> | |||||
<option value="easeOutCubic">easeOutCubic</option> | |||||
<option value="easeInOutCubic">easeInOutCubic</option> | |||||
<option value="easeInQuart">easeInQuart</option> | |||||
<option value="easeOutQuart">easeOutQuart</option> | |||||
<option value="easeInOutQuart">easeInOutQuart</option> | |||||
<option value="easeInQuint">easeInQuint</option> | |||||
<option value="easeOutQuint">easeOutQuint</option> | |||||
<option value="easeInOutQuint">easeInOutQuint</option> | |||||
</select> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
<div class="bottom"> | |||||
<span id="statusUpdate"></span><br /> | |||||
Examples: | |||||
<input type="button" onclick="doAnimation();" value="Animate with above settings." style="width:300px;" id="btnDo"> <br/> | |||||
<input type="button" onclick="doDefaultAnimation();" value="Animate with default settings." style="width:300px;" id="btnDoDefault"> <br/> | |||||
<input type="button" onclick="zoomExtentAnimated();" value="Animated ZoomExtent()." style="width:300px;" id="btnZoom"> <br/> | |||||
<input type="button" onclick="focusRandom();" value="Focus on random node." style="width:300px;" id="btnFocus"><br/> | |||||
<input type="button" onclick="startShow();" value="Start a show!" style="width:300px;" id="btnShow"><br/> | |||||
</div> | |||||
</div> | |||||
<div class="right"> | |||||
<div id="mynetwork"></div> | |||||
<p id="selection"></p> | |||||
<p id="stabilization"></p> | |||||
</div> | |||||
</body> | |||||
</html> |
@ -0,0 +1,43 @@ | |||||
<!DOCTYPE HTML> | |||||
<html> | |||||
<head> | |||||
<title>Timeline | Basic demo</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> | |||||
<p> | |||||
In this example all items get an HTML attribute attached: each item gets an attribute <code>data-id</code>, and items 1 and 6 have an additional attribute <code>data-tooltip</code>. | |||||
</p> | |||||
<div id="visualization"></div> | |||||
<script type="text/javascript"> | |||||
// 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: '2014-04-20', tooltip: 'This is item 1'}, | |||||
{id: 2, content: 'item 2', start: '2014-04-14'}, | |||||
{id: 3, content: 'item 3', start: '2014-04-18'}, | |||||
{id: 4, content: 'item 4', start: '2014-04-16', end: '2014-04-19'}, | |||||
{id: 5, content: 'item 5', start: '2014-04-25'}, | |||||
{id: 6, content: 'item 6', start: '2014-04-27', type: 'point', tooltip: 'This is item 6'} | |||||
]); | |||||
// Configuration for the Timeline | |||||
var options = {dataAttributes: ['tooltip', 'id']}; | |||||
// Create a Timeline | |||||
var timeline = new vis.Timeline(container, items, options); | |||||
</script> | |||||
</body> | |||||
</html> |
@ -0,0 +1,61 @@ | |||||
<!DOCTYPE HTML> | |||||
<html> | |||||
<head> | |||||
<title>Timeline | Background areas</title> | |||||
<style> | |||||
body, html { | |||||
font-family: arial, sans-serif; | |||||
font-size: 11pt; | |||||
} | |||||
.vis.timeline .item.background.negative { | |||||
background-color: rgba(255, 0, 0, 0.2); | |||||
} | |||||
.vis.timeline .item.background.marker { | |||||
border-left: 2px solid green; | |||||
} | |||||
</style> | |||||
<script src="../../dist/vis.js"></script> | |||||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||||
</head> | |||||
<body> | |||||
<p>This example demonstrates the item type "background", see "Period A" and "Period B". The background areas can be styled with css.</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: 'A', content: 'Period A', start: '2014-01-16', end: '2014-01-22', type: 'background'}, | |||||
{id: 'B', content: 'Period B', start: '2014-01-25', end: '2014-01-30', type: 'background', className: 'negative'}, | |||||
{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 | |||||
}; | |||||
var timeline = new vis.Timeline(container, items, options); | |||||
</script> | |||||
</body> | |||||
</html> |
@ -0,0 +1,250 @@ | |||||
<!DOCTYPE HTML> | |||||
<html> | |||||
<head> | |||||
<title>Timeline | Templates</title> | |||||
<!-- load handlebars for templating, and create a template --> | |||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.4/handlebars.min.js"></script> | |||||
<script id="item-template" type="text/x-handlebars-template"> | |||||
<table class="score"> | |||||
<tr> | |||||
<td colspan="3" class="description">{{description}}</td> | |||||
</tr> | |||||
<tr> | |||||
<td>{{player1}}</td> | |||||
<th>{{score1}} - {{score2}}</th> | |||||
<td>{{player2}}</td> | |||||
</tr> | |||||
<tr> | |||||
<td><img src="http://flagpedia.net/data/flags/mini/{{abbr1}}.png" width="31" height="20" alt="{{abbr1}}"></td> | |||||
<th></th> | |||||
<td><img src="http://flagpedia.net/data/flags/mini/{{abbr2}}.png" width="31" height="20" alt="{{abbr2}}"></td> | |||||
</tr> | |||||
</table> | |||||
</script> | |||||
<script src="../../dist/vis.js"></script> | |||||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||||
<style type="text/css"> | |||||
body, html { | |||||
font-family: sans-serif; | |||||
font-size: 10pt; | |||||
} | |||||
.vis.timeline .item { | |||||
border-color: #acacac; | |||||
background-color: #efefef; | |||||
box-shadow: 5px 5px 10px rgba(128,128,128, 0.3); | |||||
} | |||||
table .description { | |||||
font-style: italic; | |||||
} | |||||
#visualization { | |||||
position: relative; | |||||
overflow: hidden; | |||||
} | |||||
.logo { | |||||
position: absolute; | |||||
right: 10px; | |||||
top: 10px; | |||||
} | |||||
.logo img { | |||||
width: 120px; | |||||
} | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<h1>WK 2014</h1> | |||||
<p style="max-width: 600px;"> | |||||
This example demonstrates using templates to format item contents. In this case <a href="http://handlebarsjs.com">handlebars</a> is used as template engine, but you can just use your favorite template engine or manually craft HTML from the data of an item. | |||||
</p> | |||||
<div id="visualization"> | |||||
<div class="logo"><img src="http://upload.wikimedia.org/wikipedia/en/e/e8/WC-2014-Brasil.svg"></div> | |||||
</div> | |||||
<script type="text/javascript"> | |||||
// create a handlebars template | |||||
var source = document.getElementById('item-template').innerHTML; | |||||
var template = Handlebars.compile(document.getElementById('item-template').innerHTML); | |||||
// 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([ | |||||
// round of 16 | |||||
{ | |||||
player1: 'Brazil', | |||||
abbr1: 'br', | |||||
score1: '1 (3)', | |||||
player2: 'Chile', | |||||
abbr2: 'cl', | |||||
score2: '1 (2)', | |||||
description: 'round of 16', | |||||
start: '2014-06-28 13:00' | |||||
}, | |||||
{ | |||||
player1: 'Colombia', | |||||
abbr1: 'co', | |||||
score1: 2, | |||||
player2: 'Uruguay', | |||||
abbr2: 'uy', | |||||
score2: 0, | |||||
description: 'round of 16', | |||||
start: '2014-06-28 17:00' | |||||
}, | |||||
{ | |||||
player1: 'Netherlands', | |||||
abbr1: 'nl', | |||||
score1: 2, | |||||
player2: 'Mexico', | |||||
abbr2: 'mx', | |||||
score2: 1, | |||||
description: 'round of 16', | |||||
start: '2014-06-29 13:00' | |||||
}, | |||||
{ | |||||
player1: 'Costa Rica', | |||||
abbr1: 'cr', | |||||
score1: '1 (5)', | |||||
player2: 'Greece', | |||||
abbr2: 'gr', | |||||
score2: '1 (3)', | |||||
description: 'round of 16', | |||||
start: '2014-06-29 17:00' | |||||
}, | |||||
{ | |||||
player1: 'France', | |||||
abbr1: 'fr', | |||||
score1: 2, | |||||
player2: 'Nigeria', | |||||
abbr2: 'ng', | |||||
score2: 0, | |||||
description: 'round of 16', | |||||
start: '2014-06-30 13:00' | |||||
}, | |||||
{ | |||||
player1: 'Germany', | |||||
abbr1: 'de', | |||||
score1: 2, | |||||
player2: 'Algeria', | |||||
abbr2: 'dz', | |||||
score2: 1, | |||||
description: 'round of 16', | |||||
start: '2014-06-30 17:00' | |||||
}, | |||||
{ | |||||
player1: 'Argentina', | |||||
abbr1: 'ar', | |||||
score1: 1, | |||||
player2: 'Switzerland', | |||||
abbr2: 'ch', | |||||
score2: 0, | |||||
description: 'round of 16', | |||||
start: '2014-07-01 13:00' | |||||
}, | |||||
{ | |||||
player1: 'Belgium', | |||||
abbr1: 'be', | |||||
score1: 2, | |||||
player2: 'USA', | |||||
abbr2: 'us', | |||||
score2: 1, | |||||
description: 'round of 16', | |||||
start: '2014-07-01 17:00' | |||||
}, | |||||
// quarter-finals | |||||
{ | |||||
player1: 'France', | |||||
abbr1: 'fr', | |||||
score1: 0, | |||||
player2: 'Germany', | |||||
abbr2: 'de', | |||||
score2: 1, | |||||
description: 'quarter-finals', | |||||
start: '2014-07-04 13:00' | |||||
}, | |||||
{ | |||||
player1: 'Brazil', | |||||
abbr1: 'br', | |||||
score1: 2, | |||||
player2: 'Colombia', | |||||
abbr2: 'co', | |||||
score2: 1, | |||||
description: 'quarter-finals', | |||||
start: '2014-07-04 17:00' | |||||
}, | |||||
{ | |||||
player1: 'Argentina', | |||||
abbr1: 'ar', | |||||
score1: 1, | |||||
player2: 'Belgium', | |||||
abbr2: 'be', | |||||
score2: 0, | |||||
description: 'quarter-finals', | |||||
start: '2014-07-05 13:00' | |||||
}, | |||||
{ | |||||
player1: 'Netherlands', | |||||
abbr1: 'nl', | |||||
score1: '0 (4)', | |||||
player2: 'Costa Rica', | |||||
abbr2: 'cr', | |||||
score2: '0 (3)', | |||||
description: 'quarter-finals', | |||||
start: '2014-07-05 17:00' | |||||
}, | |||||
// semi-finals | |||||
{ | |||||
player1: 'Brazil', | |||||
abbr1: 'br', | |||||
score1: 1, | |||||
player2: 'Germany', | |||||
abbr2: 'de', | |||||
score2: 7, | |||||
description: 'semi-finals', | |||||
start: '2014-07-08 17:00' | |||||
}, | |||||
{ | |||||
player1: 'Netherlands', | |||||
abbr1: 'nl', | |||||
score1: '0 (2)', | |||||
player2: 'Argentina', | |||||
abbr2: 'ar', | |||||
score2: '0 (4)', | |||||
description: 'semi-finals', | |||||
start: '2014-07-09 17:00' | |||||
}, | |||||
// final | |||||
{ | |||||
player1: 'Germany', | |||||
score1: 1, | |||||
abbr1: 'de', | |||||
player2: 'Argentina', | |||||
abbr2: 'ar', | |||||
score2: 0, | |||||
description: 'final', | |||||
start: '2014-07-13 16:00' | |||||
} | |||||
]); | |||||
// Configuration for the Timeline | |||||
var options = { | |||||
// specify a template for the items | |||||
template: template | |||||
}; | |||||
// Create a Timeline | |||||
var timeline = new vis.Timeline(container, items, options); | |||||
</script> | |||||
</body> | |||||
</html> |
@ -0,0 +1,58 @@ | |||||
<!DOCTYPE HTML> | |||||
<html> | |||||
<head> | |||||
<title>Timeline | External data</title> | |||||
<style type="text/css"> | |||||
body, html { | |||||
font-family: sans-serif; | |||||
} | |||||
</style> | |||||
<!-- Load jquery for ajax support --> | |||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |||||
<script src="../../dist/vis.js"></script> | |||||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||||
</head> | |||||
<body> | |||||
<h1>Load external data</h1> | |||||
<p> | |||||
This demo shows how to load external data via an ajax call. | |||||
</p> | |||||
<div id="visualization"></div> | |||||
<div id="loading">loading...</div> | |||||
<script type="text/javascript"> | |||||
// load data via an ajax request. When the data is in, load the timeline | |||||
$.ajax({ | |||||
url: 'data/basic.json', | |||||
success: function (data) { | |||||
// hide the "loading..." message | |||||
document.getElementById('loading').style.display = 'none'; | |||||
// 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(data); | |||||
// Configuration for the Timeline | |||||
var options = {}; | |||||
// Create a Timeline | |||||
var timeline = new vis.Timeline(container, items, options); | |||||
}, | |||||
error: function (err) { | |||||
console.log('Error', err); | |||||
if (err.status === 0) { | |||||
alert('Failed to load data/basic.json.\nPlease run this example on a server.'); | |||||
} | |||||
else { | |||||
alert('Failed to load data/basic.json.'); | |||||
} | |||||
} | |||||
}); | |||||
</script> | |||||
</body> | |||||
</html> |
@ -0,0 +1,34 @@ | |||||
[ | |||||
{ | |||||
"id": 1, | |||||
"content": "item 1", | |||||
"start": "2014-04-20" | |||||
}, | |||||
{ | |||||
"id": 2, | |||||
"content": "item 2", | |||||
"start": "2014-04-14" | |||||
}, | |||||
{ | |||||
"id": 3, | |||||
"content": "item 3", | |||||
"start": "2014-04-18" | |||||
}, | |||||
{ | |||||
"id": 4, | |||||
"content": "item 4", | |||||
"start": "2014-04-16", | |||||
"end": "2014-04-19" | |||||
}, | |||||
{ | |||||
"id": 5, | |||||
"content": "item 5", | |||||
"start": "2014-04-25" | |||||
}, | |||||
{ | |||||
"id": 6, | |||||
"content": "item 6", | |||||
"start": "2014-04-27", | |||||
"type": "point" | |||||
} | |||||
] |
@ -0,0 +1,152 @@ | |||||
[ | |||||
{ | |||||
"player1": "Brazil", | |||||
"abbr1": "br", | |||||
"score1": "1 (3)", | |||||
"player2": "Chile", | |||||
"abbr2": "cl", | |||||
"score2": "1 (2)", | |||||
"description": "round of 16", | |||||
"start": "2014-06-28 13:00" | |||||
}, | |||||
{ | |||||
"player1": "Colombia", | |||||
"abbr1": "co", | |||||
"score1": 2, | |||||
"player2": "Uruguay", | |||||
"abbr2": "uy", | |||||
"score2": 0, | |||||
"description": "round of 16", | |||||
"start": "2014-06-28 17:00" | |||||
}, | |||||
{ | |||||
"player1": "Netherlands", | |||||
"abbr1": "nl", | |||||
"score1": 2, | |||||
"player2": "Mexico", | |||||
"abbr2": "mx", | |||||
"score2": 1, | |||||
"description": "round of 16", | |||||
"start": "2014-06-29 13:00" | |||||
}, | |||||
{ | |||||
"player1": "Costa Rica", | |||||
"abbr1": "cr", | |||||
"score1": "1 (5)", | |||||
"player2": "Greece", | |||||
"abbr2": "gr", | |||||
"score2": "1 (3)", | |||||
"description": "round of 16", | |||||
"start": "2014-06-29 17:00" | |||||
}, | |||||
{ | |||||
"player1": "France", | |||||
"abbr1": "fr", | |||||
"score1": 2, | |||||
"player2": "Nigeria", | |||||
"abbr2": "ng", | |||||
"score2": 0, | |||||
"description": "round of 16", | |||||
"start": "2014-06-30 13:00" | |||||
}, | |||||
{ | |||||
"player1": "Germany", | |||||
"abbr1": "de", | |||||
"score1": 2, | |||||
"player2": "Algeria", | |||||
"abbr2": "dz", | |||||
"score2": 1, | |||||
"description": "round of 16", | |||||
"start": "2014-06-30 17:00" | |||||
}, | |||||
{ | |||||
"player1": "Argentina", | |||||
"abbr1": "ar", | |||||
"score1": 1, | |||||
"player2": "Switzerland", | |||||
"abbr2": "ch", | |||||
"score2": 0, | |||||
"description": "round of 16", | |||||
"start": "2014-07-01 13:00" | |||||
}, | |||||
{ | |||||
"player1": "Belgium", | |||||
"abbr1": "be", | |||||
"score1": 2, | |||||
"player2": "USA", | |||||
"abbr2": "us", | |||||
"score2": 1, | |||||
"description": "round of 16", | |||||
"start": "2014-07-01 17:00" | |||||
}, | |||||
{ | |||||
"player1": "France", | |||||
"abbr1": "fr", | |||||
"score1": 0, | |||||
"player2": "Germany", | |||||
"abbr2": "de", | |||||
"score2": 1, | |||||
"description": "quarter-finals", | |||||
"start": "2014-07-04 13:00" | |||||
}, | |||||
{ | |||||
"player1": "Brazil", | |||||
"abbr1": "br", | |||||
"score1": 2, | |||||
"player2": "Colombia", | |||||
"abbr2": "co", | |||||
"score2": 1, | |||||
"description": "quarter-finals", | |||||
"start": "2014-07-04 17:00" | |||||
}, | |||||
{ | |||||
"player1": "Argentina", | |||||
"abbr1": "ar", | |||||
"score1": 1, | |||||
"player2": "Belgium", | |||||
"abbr2": "be", | |||||
"score2": 0, | |||||
"description": "quarter-finals", | |||||
"start": "2014-07-05 13:00" | |||||
}, | |||||
{ | |||||
"player1": "Netherlands", | |||||
"abbr1": "nl", | |||||
"score1": "0 (4)", | |||||
"player2": "Costa Rica", | |||||
"abbr2": "cr", | |||||
"score2": "0 (3)", | |||||
"description": "quarter-finals", | |||||
"start": "2014-07-05 17:00" | |||||
}, | |||||
{ | |||||
"player1": "Brazil", | |||||
"abbr1": "br", | |||||
"score1": 1, | |||||
"player2": "Germany", | |||||
"abbr2": "de", | |||||
"score2": 7, | |||||
"description": "semi-finals", | |||||
"start": "2014-07-08 17:00" | |||||
}, | |||||
{ | |||||
"player1": "Netherlands", | |||||
"abbr1": "nl", | |||||
"score1": "0 (2)", | |||||
"player2": "Argentina", | |||||
"abbr2": "ar", | |||||
"score2": "0 (4)", | |||||
"description": "semi-finals", | |||||
"start": "2014-07-09 17:00" | |||||
}, | |||||
{ | |||||
"player1": "Germany", | |||||
"score1": 1, | |||||
"abbr1": "de", | |||||
"player2": "Argentina", | |||||
"abbr2": "ar", | |||||
"score2": 0, | |||||
"description": "final", | |||||
"start": "2014-07-13 16:00" | |||||
} | |||||
] |