javascript - Append child can not work in two circle -


when append 2 circles, have nothing result. following code. first created circle append in group ok. next small circle append in created circle shown nothing. don't know wrong. appreciate suggestions. sorry english.

function drawcirc(x, y, r, id) {  var circ = document.createelementns(svguri, 'circle'); circ.setattributens(null, 'cx', x); circ.setattributens(null, 'cy', y); circ.setattributens(null, 'r', r); circ.setattributens(null, 'fill', '#ccffcc'); circ.setattributens(null, 'stroke', '#6bc1c8'); circ.setattributens(null, 'stroke-width', '5'); circ.setattribute('id', id);  // add small circle var circstart = document.createelementns(svguri, 'circle'); circstart.setattributens(null, 'cx', (x-5)); circstart.setattributens(null, 'cy', (y-10)); circstart.setattributens(null, 'r', 8); circstart.setattributens(null, 'fill', 'blue'); circstart.setattributens(null, 'stroke', '#e6f1db'); circstart.setattributens(null, 'stroke-width', '2');  document.getelementbyid(group).appendchild(circ);  document.getelementbyid(id).appendchild(circstart);} 

you can't nest circles (or other shapes) in svg. need make them children of containers such <g> or <svg> elements.

in case want change last line of code to

document.getelementbyid(group).appendchild(circstart);} 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -