【发布时间】:2020-06-09 12:45:06
【问题描述】:
我正在尝试使用此示例绘制可缩放 SUnburst 图表:https://vizhub.com/undefined/7babe7cceb394cd1bc93157a29f8c161
代码在普通 js 中运行,但是当我尝试在 Angular 中导入它时,它会抛出以下错误:
ERROR TypeError: "svg.selectAll(...).data(...).join 不是函数"
抛线错误是:
const path = svg.selectAll('path')
.data(root.descendants().slice(1))
.join('path')
.attr('fill', d => {
while (d.depth > 1) { d = d.parent; }
return color(d.data.name);
})
.attr('fill-opacity', d => arcVisible(d.current) ? (d.children ? 0.6 : 0.4) : 0)
.attr('d', d => arc(d.current));
我尝试将类添加到 svg 元素,但没有帮助。删除它不会呈现图形,并且每个连接都会引发错误。此外,更新到最新的 d3,但它没有帮助 Angular 版本是 6。
控制台日志
g.append('g')
.selectAll('path')
.data(root.descendants().slice(1))
【问题讨论】:
-
试过这个:stackoverflow.com/questions/31209939/… 不起作用
-
老兄,你解决问题了吗?
-
是的,将
join('path')替换为enter().append('path')为我工作。