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:
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
Post a Comment