虽然下面的代码可以在 d3v3 中找到,但在 v4 中却失败了。
var nodes = tree.nodes(root).reverse(),
links = tree.links(nodes);
Uncaught TypeError: tree.nodes is not a function
在 v4 中它的替代方案是什么?
最佳答案
import { hierarchy, tree } from 'd3-hierarchy'
// create a hierarchy from the root
const treeRoot = hierarchy(root)
tree(treeRoot)
// nodes
const nodes = treeRoot.descendants()
// links
const links = treeRoot.links()
关于d3.js - d3js tree.nodes() 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41087568/