d3 Click to create circle and click to remove
I am trying to click on a circle to remove it, but clicking on the canvas will create a circle. I do want to actually remove the circle and it's object from the data, as opposed to just making it transparent. On click on a circle calls the function function removeElement(d) { d3.select(this) .remove(); } This function is called with a basic click on the circle, .on("click", removeElement); I think I'm not correctly distinguishing between clicking on the canvas to create a circle where none exists and clicking on an existing circle to remove it. <!DOCTYPE html> <meta charset="utf-8"> <style>