javascript - D3 : Unable to get property 'weight' of undefined or null reference -
d3 svg graph stops working when assign link.source , link.target integer values retrieved db. if assign index starting 0 graph works fine, fails above error when assign link.source , .target identifier values retrieved db.
var edges = []; json.links.foreach(function(e) { var sourcenode = json.nodes.filter(function(n) { return n.id === e.source; })[0], targetnode = json.nodes.filter(function(n) { return n.id === e.target; })[0]; edges.push({ source: sourcenode, target: targetnode, value: e.value }); }); force .nodes(json.nodes) .links(edges) .start(); var link = svg.selectall(".link") .data(edges)
Comments
Post a Comment