升级到d3.js v4.1.1后,此行:
d3.layout.tree()
产生错误:
Cannot read property 'tree' of undefined
似乎已从v4中删除了树形布局? https://github.com/d3/d3/blob/master/API.md
示例仍然使用v3 API: http://bl.ocks.org/mbostock/1093025
布局真的消失了还是重命名了?
答案 0 :(得分:19)
似乎树名布局刚重命名。参见:
https://github.com/d3/d3/blob/master/CHANGES.md#hierarchies-d3-hierarchy
根据伟大的命名空间扁平化:
- d3.layout.cluster↦d3.cluster
- d3.layout.hierarchy↦d3.hierarchy
- d3.layout.pack↦d3.pack
- d3.layout.partition↦d3.partition
- d3.layout.tree↦d3.tree
- d3.layout.treemap↦d3.treemap