Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- adding text with whitespaces in svg text element
- var legend = document.createElementNS("http://www.w3.org/2000/svg", "text");
- var tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
- // Set any attributes as desired
- legend.setAttribute("id","legend");
- legend.setAttribute("text-anchor", "middle");
- legend.setAttribute("alignment-baseline", "hanging");
- legend.setAttribute("xml:space","preserve");
- tspan.setAttribute("xml:space","preserve");
- tspan.setAttribute("id","tspanObj");
- var myText = document.createTextNode(legendTxt);
- tspan.appendChild(myText);
- legend.appendChild(tspan);
- legend.setAttribute("x", Math.round(this.options.windowWidth/2));
- legend.setAttribute("y", this.options.upperPadding+this.options.barH+this.options.legendDist);
- this.elements.jSvgElem.append(legend);
- legend.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space","preserve");
Advertisement
Add Comment
Please, Sign In to add comment