I'm new at using svg as you can see and i have a problem connecting dots.
What I want to do is to connect this 2 dots with a line no matter their position.
As you can see in the image bellow when i change the cx="50" to cx="510" the line still in the same postion but i want the line to "follow" the second circle no matter the position.
Resuming:
In my case I have a static line what I want its to have a dinamic line that connects with the other dot when I change my coordinates(cx or cy).
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<svg width="1000" height="1000">
<circle id="circle0" cx="50" cy="50" r="20" stroke="black" stroke-width="3" fill="grey" onClick="dotClick(0)"></circle>
<circle id="circle1" cx="50" cy="110" r="20" stroke="black" stroke-width="3" fill="grey" onClick="dotClick(1)"></circle>
<line id="line0" x1="50" y1="50" x2="50" y2="100" />
</svg>
<script>
var buttons = {};
function dotClick(width) {
(width === 0) ? buttons.one = !buttons.one : buttons.two = !buttons.two;
document.getElementById("line0").setAttribute("stroke", (buttons.one && buttons.two) ? "red" : "");
document.getElementById("circle0").setAttribute("fill", (buttons.one ? "red" : "grey"));
document.getElementById("circle1").setAttribute("fill", (buttons.two ? "red" : "grey"));
}
</script>
</body>
</html>