Hi all I have created a fully interactive SVG chart that has individual paths that are clickable and rewrite a div with info based on the JSON file I have that matches the id of the path. Currently I am writing this in JQuery but I need to have a function that will add circles onto the path that is clicked. The circles will individually have their own id's and fill that div with info from the object in the JSON that matches the id. I have tried the append method to append a SVG element to the SVG that is loaded into the document but it looks like that might not be the correct way to do it.
This what a section of the SVG looks like before clicked
This is what the goal is to look like after it is clicked
The code I tried was to add a .append() with a template literal of the circle SVG code to add to the path that was clicked. The function would actually append and add to the SVG but it won't render it. This is an example of the code I was using
function addPath(clickedPath){
$(clickedPath).append(`
<circle cx="50" cy="50" r="50" />
`)
}
function svgLoad(){
$("#SVG").load("/src/test.svg", function(){
$("#SVG").css("width", "50vw");
$("path").on("click", function(evt) {
addPath($(this));
})
}
)}
Is this even possible with Jquery or would this be better in something like React?