Created
April 22, 2015 04:25
-
-
Save RafaelCosman/7e85f3f9a2402bf68689 to your computer and use it in GitHub Desktop.
Cytoscape.js initialisation // source http://jsbin.com/naboxejebo
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="style.css" rel="stylesheet" /> | |
<meta charset=utf-8 /> | |
<title>Cytoscape.js initialisation</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://cytoscape.github.io/cytoscape.js/api/cytoscape.js-latest/cytoscape.min.js"></script> | |
<script src="code.js"></script> | |
<style id="jsbin-css"> | |
body { | |
font: 14px helvetica neue, helvetica, arial, sans-serif; | |
} | |
#cy { | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
left: 0; | |
top: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="cy"></div> | |
<script id="jsbin-javascript"> | |
$(function(){ // on dom ready | |
var cy = cytoscape({ | |
container: document.getElementById('cy'), | |
style: cytoscape.stylesheet() | |
.selector('node') | |
.css({ | |
'content': 'data(id)' | |
}) | |
.selector('edge') | |
.css({ | |
'target-arrow-shape': 'triangle', | |
'width': 4, | |
'line-color': '#ddd', | |
'target-arrow-color': '#ddd' | |
}) | |
.selector('.highlighted') | |
.css({ | |
'background-color': '#61bf0c', | |
'line-color': '#f1bffc', | |
'target-arrow-color': '#61bffc', | |
'transition-property': 'background-color, line-color, target-arrow-color', | |
'transition-duration': '0.5s' | |
}), | |
elements: { | |
nodes: [ | |
{ data: { id: 'if' } }, | |
{ data: { id: 'while' } }, | |
{ data: { id: 'functions' } }, | |
{ data: { id: 'for' } }, | |
{ data: { id: 'Games on KA' } } | |
], | |
edges: [ | |
{ data: { id: 'ab', weight: 3, source: 'if', target: 'while' } }, | |
{ data: { id: 'be', weight: 4, source: 'while', target: 'functions' } }, | |
{ data: { id: 'bc', weight: 5, source: 'while', target: 'for' } }, | |
{ data: { id: 'ce', weight: 6, source: 'functions', target: 'Games on KA' } } | |
] | |
}, | |
layout: { | |
name: 'preset', | |
positions: {'if': {x: 300, y:100}, | |
'while': {x: 300, y:200}, | |
'for': {x: 200, y:300}, | |
'functions': {x: 300, y:300}, | |
'Games on KA': {x: 300, y:400}}, | |
directed: true, | |
padding: 20 | |
} | |
}); | |
cy.zoomingEnabled(false); | |
cy.panningEnabled(false); | |
cy.on('click', '#if', function(evt){ | |
console.log( 'tap ' + evt.cyTarget.id() ); | |
window.open("http://www.w3schools.com"); | |
}); | |
cy.elements('#if').hide(); | |
}); // on dom ready | |
</script> | |
<script id="jsbin-source-css" type="text/css">body { | |
font: 14px helvetica neue, helvetica, arial, sans-serif; | |
} | |
#cy { | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
left: 0; | |
top: 0; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">$(function(){ // on dom ready | |
var cy = cytoscape({ | |
container: document.getElementById('cy'), | |
style: cytoscape.stylesheet() | |
.selector('node') | |
.css({ | |
'content': 'data(id)' | |
}) | |
.selector('edge') | |
.css({ | |
'target-arrow-shape': 'triangle', | |
'width': 4, | |
'line-color': '#ddd', | |
'target-arrow-color': '#ddd' | |
}) | |
.selector('.highlighted') | |
.css({ | |
'background-color': '#61bf0c', | |
'line-color': '#f1bffc', | |
'target-arrow-color': '#61bffc', | |
'transition-property': 'background-color, line-color, target-arrow-color', | |
'transition-duration': '0.5s' | |
}), | |
elements: { | |
nodes: [ | |
{ data: { id: 'if' } }, | |
{ data: { id: 'while' } }, | |
{ data: { id: 'functions' } }, | |
{ data: { id: 'for' } }, | |
{ data: { id: 'Games on KA' } } | |
], | |
edges: [ | |
{ data: { id: 'ab', weight: 3, source: 'if', target: 'while' } }, | |
{ data: { id: 'be', weight: 4, source: 'while', target: 'functions' } }, | |
{ data: { id: 'bc', weight: 5, source: 'while', target: 'for' } }, | |
{ data: { id: 'ce', weight: 6, source: 'functions', target: 'Games on KA' } } | |
] | |
}, | |
layout: { | |
name: 'preset', | |
positions: {'if': {x: 300, y:100}, | |
'while': {x: 300, y:200}, | |
'for': {x: 200, y:300}, | |
'functions': {x: 300, y:300}, | |
'Games on KA': {x: 300, y:400}}, | |
directed: true, | |
padding: 20 | |
} | |
}); | |
cy.zoomingEnabled(false); | |
cy.panningEnabled(false); | |
cy.on('click', '#if', function(evt){ | |
console.log( 'tap ' + evt.cyTarget.id() ); | |
window.open("http://www.w3schools.com"); | |
}); | |
cy.elements('#if').hide(); | |
}); // on dom ready</script></body> | |
</html> |
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
body { | |
font: 14px helvetica neue, helvetica, arial, sans-serif; | |
} | |
#cy { | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
left: 0; | |
top: 0; | |
} |
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
$(function(){ // on dom ready | |
var cy = cytoscape({ | |
container: document.getElementById('cy'), | |
style: cytoscape.stylesheet() | |
.selector('node') | |
.css({ | |
'content': 'data(id)' | |
}) | |
.selector('edge') | |
.css({ | |
'target-arrow-shape': 'triangle', | |
'width': 4, | |
'line-color': '#ddd', | |
'target-arrow-color': '#ddd' | |
}) | |
.selector('.highlighted') | |
.css({ | |
'background-color': '#61bf0c', | |
'line-color': '#f1bffc', | |
'target-arrow-color': '#61bffc', | |
'transition-property': 'background-color, line-color, target-arrow-color', | |
'transition-duration': '0.5s' | |
}), | |
elements: { | |
nodes: [ | |
{ data: { id: 'if' } }, | |
{ data: { id: 'while' } }, | |
{ data: { id: 'functions' } }, | |
{ data: { id: 'for' } }, | |
{ data: { id: 'Games on KA' } } | |
], | |
edges: [ | |
{ data: { id: 'ab', weight: 3, source: 'if', target: 'while' } }, | |
{ data: { id: 'be', weight: 4, source: 'while', target: 'functions' } }, | |
{ data: { id: 'bc', weight: 5, source: 'while', target: 'for' } }, | |
{ data: { id: 'ce', weight: 6, source: 'functions', target: 'Games on KA' } } | |
] | |
}, | |
layout: { | |
name: 'preset', | |
positions: {'if': {x: 300, y:100}, | |
'while': {x: 300, y:200}, | |
'for': {x: 200, y:300}, | |
'functions': {x: 300, y:300}, | |
'Games on KA': {x: 300, y:400}}, | |
directed: true, | |
padding: 20 | |
} | |
}); | |
cy.zoomingEnabled(false); | |
cy.panningEnabled(false); | |
cy.on('click', '#if', function(evt){ | |
console.log( 'tap ' + evt.cyTarget.id() ); | |
window.open("http://www.w3schools.com"); | |
}); | |
cy.elements('#if').hide(); | |
}); // on dom ready |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment