[solved] SVG Retrieval Failed - Generic JavaScript View (2.12.0)

Hi,

I am trying out the new Generic JavaScript View (2.12.0)  and I am having diffculties generating the SVG Image in the output port.

I am guessing the code to fetch the svgElement is incorrect?

 

//Make an SVG Container
 var svgContainer = d3.select("body").append("svg")
                                     .attr("width", 200)
                                     .attr("height", 200);
 
 //Draw the Rectangle
 var rectangle = svgContainer.append("rect")
                             .attr("x", 10)
                             .attr("y", 10)
                            .attr("width", 50)
                            .attr("height", 100);
            

 

#var svgElement = document.getElementById("mySVG");

var svgElement = document.getElementsByTagName('svg')[0];

return (new XMLSerializer()).serializeToString(svgElement);

 

I have attached my workflow.

Problem solved.

The Image Generation code should be:

var svg = d3.select("svg")[0][0];

return (new XMLSerializer()).serializeToString(svg);

 

1 Like

Great, I set your topic to solved :)