Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref #1753
- Loading branch information
Showing
74 changed files
with
82,107 additions
and
6,451 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,29 @@ | ||
var domReady = new Promise(function(resolve) { | ||
window.addEventListener('DOMContentLoaded', function() { | ||
resolve(); | ||
}); | ||
}); | ||
|
||
var fetchData = fetch('data.json', {mode: 'no-cors'}) | ||
fetch('data.json', {mode: 'no-cors'}) | ||
.then(function(res) { | ||
return res.json() | ||
}); | ||
|
||
var initCy = function(cy3json) { | ||
return cytoscape({ | ||
container: document.getElementById('cy'), | ||
elements: cy3json.elements, | ||
layout: { | ||
name: 'preset' | ||
}, | ||
style: [{ | ||
selector: 'node', | ||
style: { | ||
'label': 'data(label)', | ||
'background-color': '#aaa' | ||
} | ||
}) | ||
.then(function(data) { | ||
var cy = window.cy = cytoscape({ | ||
container: document.getElementById('cy'), | ||
elements: data.elements, | ||
layout: { | ||
name: 'preset' | ||
}, | ||
{ | ||
selector: 'edge', | ||
style: { | ||
'opacity': 0.2, | ||
'line-color': '#ccc', | ||
'width': 3 | ||
style: [{ | ||
selector: 'node', | ||
style: { | ||
'label': 'data(label)', | ||
'background-color': '#aaa' | ||
} | ||
}, | ||
{ | ||
selector: 'edge', | ||
style: { | ||
'opacity': 0.2, | ||
'line-color': '#ccc', | ||
'width': 3 | ||
} | ||
} | ||
} | ||
] | ||
}); | ||
}; | ||
|
||
Promise.all([fetchData, domReady]) | ||
.then(function(val) { | ||
return initCy(val[0]); | ||
}) | ||
.then(function(cy) { | ||
window.cy = cy; // put it in the window so you can play with the instance | ||
] | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Cytoscape.js (6,000 elements)</title> | ||
|
||
<link href="style.css" rel="stylesheet" /> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.0.5/es6-promise.auto.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/2.0.2/fetch.min.js"></script> | ||
<script src="../../js/cytoscape.min.js"></script> | ||
<script src="code.js"></script> | ||
<!-- For loading external data files --> | ||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Promise,fetch"></script> | ||
|
||
<script src="../../js/cytoscape.min.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1>Cytoscape.js (6,000 elements)</h1> | ||
<div id="cy"></div> | ||
<!-- Load appplication code at the end to ensure DOM is loaded --> | ||
<script src="code.js"></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
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
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
Oops, something went wrong.