Created
September 11, 2019 22:55
-
-
Save biovisualize/1932930d35ea61ea080cdc3519032216 to your computer and use it in GitHub Desktop.
Network viz, 2d version
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="//unpkg.com/force-graph"></script> | |
<style> | |
body { margin: 0; } | |
</style> | |
</head> | |
<body> | |
<div id="graph"></div> | |
<script> | |
function drawGraph(_data) { | |
const elem = document.getElementById('graph') | |
const distance = 800 | |
let highlightNodes = []; | |
const Graph = ForceGraph()(elem) | |
.graphData(_data) | |
.nodeLabel(node => node.id) | |
.backgroundColor("#121212") | |
.enableZoomPanInteraction(false) | |
.zoom(1.2) | |
window.addEventListener("resize", () => Graph.width(window.innerWidth)); | |
} | |
fetch("https://gist.githubusercontent.com/biovisualize/18118a0df56f25136eb6c2440ce4472f/raw/e0a230e0e6942770d52b88064a422ff023850afa/top20b_airports.js") | |
.then(response => response.text()) | |
.then((data) => { | |
drawGraph(JSON.parse(data)) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment