Skip to content Skip to sidebar Skip to footer

D3 - Add A Raw Symbol

I have a D3 code. I want to add a svg symbol 'as is'! to the D3 svg. I dont want to create the symbol dynamically using D3, I have the symbols already made from our designer and i

Solution 1:

Just add previous definded symbol to your SVG:

svg.append("g")
   .attr("transform","translate(0,0)")
   .attr("class","mySymbol")
   .append("use")
   .attr("xlink:href","#md_file")

Here the working code

After append use your can tweak their attributes, like so:

svg.append("g")
   .attr("transform","translate(0,0)")
   .attr("class","mySymbol")
   .append("use")
   .attr("width",20)
   .attr("heigth", 20)
   .style("fill", "red")
       .
       .
       .
   .attr("xlink:href","#md_file")

Post a Comment for "D3 - Add A Raw Symbol"