Currently, I am working on codepen.io and have been tasked with creating a paragraph that includes a title. However, my dilemma lies in the fact that I need this title to be center-aligned without directly altering the "x" value. Unfortunately, CSS is not an option for me, so I am looking towards javascript for a solution.
In order to achieve this, I am utilizing a particular function to draw the title onto the graph. Below is the snippet of code I am using:
var text = document.createElementNS(svgNS,"text");
text.setAttributeNS(null, 'x', 100);
text.setAttributeNS(null, 'y', 15);
text.textContent = (titel);
document.getElementById("bargraph").appendChild(text);
If you are interested in viewing the full code or project, please click on the following link: codepen.io/Cleanwater/pen/LWQyJm?editors=0010