javascript - D3 cannot append to SVG from within function -
i attempting append shapes on svg block within function call using following code...
function generatenodes(){ var data = [[0,0],[100,100]]; d3.select("svg").selectall("circle") .data(data) .enter().append("circle") .attr("class","test") .attr("r", 5) .attr("cx", function(d){ return d[0]; }) .attr("cy", function(d){ return d[1]; }); }
however nothing appearing in svg after call generatenodes() in console. when try..
d3.selectall(".test")
it returns array of length 0 implying nothing has been inserted dom.
this leads me presume issue either .enter() or .data() functions not being used correctly.
i tried coding example in jsfiddle seems working, makes above code more confusing. http://jsfiddle.net/llbf3x0c/
any or advice appreciated.
Comments
Post a Comment