我正在学习 D3 并尝试根据 D3 v5 中的度数来缩放节点的半径。我的代码就像
nodes.forEach(function(d){
d.degree=0;});
links.forEach(function(d){
nodes[d.source].degree += 1;
nodes[d.target].degree += 1;});
Run Code Online (Sandbox Code Playgroud)
它返回错误
Uncaught TypeError: nodes.forEach is not a function
Run Code Online (Sandbox Code Playgroud)
谁能提供一个好的解决方案吗?
d3.js ×1