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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -