Skip to content

Instantly share code, notes, and snippets.

@biovisualize
Created September 11, 2019 22:55
Show Gist options
  • Save biovisualize/1932930d35ea61ea080cdc3519032216 to your computer and use it in GitHub Desktop.
Save biovisualize/1932930d35ea61ea080cdc3519032216 to your computer and use it in GitHub Desktop.
Network viz, 2d version
<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