javascript - How to align the title in the middle? -


i'm working codepen.io , creating paragraph. graph has title.

the problem want title center-aligned.it should automatically set title in middle, not editing value of "x". can't use css this, , believe javascript job.

here 1 functions using draw title , link project goes bellow.

var text = document.createelementns(svgns,"text");     text.setattributens(null, 'x', 100);     text.setattributens(null, 'y', 15);     text.textcontent = (titel);  document.getelementbyid("bargraph").appendchild(text); 

full code:

codepen.io/cleanwater/pen/lwqyjm?editors=0010

var text = document.createelementns(svgns,"text");     text.setattributens(null, 'y', 15);     text.textcontent = (titel);  document.getelementbyid("bargraph").appendchild(text);     text.setattributens(null, 'x', 300 / 2 - text.getbbox().width /2); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

python - Error: Unresolved reference 'selenium' What is the reason? -

asp.net ajax - Jquery scroll to element just goes to top of page -