d3js tree.nodes() is not a function

不问归期 提交于 2020-01-23 06:09:18

问题


While the below piece of code works find in d3v3, it fails in v4.

 var nodes = tree.nodes(root).reverse(),
      links = tree.links(nodes);

Uncaught TypeError: tree.nodes is not a function

What is the alternative for it in v4?


回答1:


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()


来源:https://stackoverflow.com/questions/41087568/d3js-tree-nodes-is-not-a-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!