Day 23: 3D Force Layout

I found this 3D Force Layout really cool to play with. It’s very easy to set up as well.

Add the following to the <head> in the HTML file.

<script src="//unpkg.com/3d-force-graph"></script>

After reading the file, use the following code to generate a D3 force layout.

const Graph = ForceGraph3D()
    (document.getElementById('chart-area'))
      .nodeColor('colorHex')
      .nodeLabel(node => node.first_name + ' ' + node.last_name)
      .graphData(graph)
      .backgroundColor("#1A120B")

Codes.

Leave a comment