Created
June 4, 2012 18:04
-
-
Save mariuz/2869910 to your computer and use it in GitHub Desktop.
simple example with 3 nodes vivagraphjs test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="./dist/vivagraph.js"></script> | |
<script type='text/javascript'> | |
function onLoad() { | |
var g = Viva.Graph.graph(); | |
g.addNode('1','User name 1'); | |
g.addNode('2','User name 2'); | |
g.addNode('3','User name 3'); | |
g.addLink('1', '2'); | |
g.addLink('2', '3'); | |
g.addLink('3', '1'); | |
var renderer = Viva.Graph.View.renderer(g); | |
renderer.run(); | |
//list each nodes from the graph | |
g.forEachNode(function(node){ | |
console.log(node.id, node.data); | |
}); | |
// show the connected nodes with user id 1 | |
g.forEachLinkedNode('1', function(linkedNode, link){ | |
console.log("Connected node: ", linkedNode.id, linkedNode.data); | |
console.dir(link); // link object itself | |
}); | |
} | |
</script> | |
</head> | |
<body onload="onLoad()"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this does not seem to be working on chrome.