3d-force-graph 快速开始

安装

yarn add 3d-force-graph

npm install 3d-force-graph

使用

import ForceGraph3D from '3d-force-graph';

const ForceGraph3D = require('3d-force-graph');

也可以通过网页引入

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

创建实例

const myData = {
    "nodes": [
        {
          "id": "id1",
          "name": "name1",
          "val": 1
        },
        {
          "id": "id2",
          "name": "name2",
          "val": 10
        }
    ],
    "links": [
        {
            "source": "id1",
            "target": "id2"
        }
    ]
}

const myGraph = ForceGraph3D();
myGraph(<myDOMElement>)
  .graphData(<myData>);