Skip to content

Instantly share code, notes, and snippets.

@biovisualize
Last active September 11, 2019 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biovisualize/b3b7b1d618670a5500c64bad2ced25fd to your computer and use it in GitHub Desktop.
Save biovisualize/b3b7b1d618670a5500c64bad2ced25fd to your computer and use it in GitHub Desktop.
Network viz
<html>
<head>
<script src="//unpkg.com/3d-force-graph"></script>
<style>
body { margin: 0; }
</style>
</head>
<body>
<div id="3d-graph"></div>
<script>
function drawGraph(_data) {
const elem = document.getElementById('3d-graph')
const distance = 800
let highlightNodes = [];
const Graph = ForceGraph3D()(elem)
.graphData(_data)
.nodeLabel(node => node.id)
.enableNavigationControls(false)
.cameraPosition({ z: distance })
.backgroundColor("#121212")
window.addEventListener("resize", () => Graph.width(window.innerWidth));
}
fetch("https://gist.githubusercontent.com/biovisualize/4f4a0fc62e3bc81076e001eb7a6443bc/raw/a0248a0e85c7d803373e3c733a1b3f490a67237b/top20_airports.json")
.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