Reputation: 157
I draw two line using svg, but when I render it, I only view one line and the other can't be seen. I dont know how to append that two line and make it all seen. That two line supposed to be seen when I click a polygon. Can anyone help me?
Here's my code
var group = evt.target.parentNode;
// Get the bounding box of the group
var bbox = group.getBBox();
// Add a triangle to the group
var svgns = "http://www.w3.org/2000/svg";
var line = document.createElementNS(svgns, "line");
var line2 = document.createElementNS(svgns, "line");
line.setAttribute('id','line2');
line.setAttribute('x1','0');
line.setAttribute('y1','0');
line.setAttribute('x2','5');
line.setAttribute('y2','19');
line.setAttribute("stroke", "black")
line2.setAttribute('id','line2');
line2.setAttribute('x1', '7');
line2.setAttribute('y1','5');
line2.setAttribute('x2','5');
line2.setAttribute('y2','19');
line2.setAttribute("stroke", "black");
var xPos = bbox.x + bbox.width / 2;
var yPos = bbox.y + bbox.height / 2;
line2.setAttribute("transform", "translate(" + xPos + "," + yPos + ")");
group.appendChild(line2);
Upvotes: 0
Views: 36
Reputation: 101936
I see you are appending line2
to the group.
group.appendChild(line2);
But where is the appendChild()
call for the other line?
Upvotes: 1