如何将d3 v3图形转换为v4?

时间:2020-09-06 02:22:48

标签: d3.js

我一直试图将d3 v3中的此示例转换为v4版本,但仍然遇到问题。
http://bl.ocks.org/eesur/be2abfb3155a38be4de4

这是到目前为止我掌握的JSFiddle:https://jsfiddle.net/echilee/sfbcntph/135/

我能够console.log链接和节点。我取得了一些进展,能够看到节点并单击以打开和关闭连接的节点。但是看不到链接及其应如何连接节点。

我用以下代码替换了节点,链接声明和强制函数:

// create a hierarchy from the root
const treeRoot = hierarchy(root)
tree(treeRoot)
const nodes = flatten(treeRoot.descendants())
const links = treeRoot.links()
var simulation = d3.forceSimulation()

我看不到链接。

0 个答案:

没有答案