简体   繁体   中英

How to make a text to be centered in Raphael js?

I have a png graphic that is put in the web page using raphael js and I have legend underneath it. The footer of this graphic has name of the grpahic and it keeps changing dynamically. I want to center this footer text. I am not sure How I can calucate the width in pixels for this text and try to divide it in such a way thaty x and y are center cordinates of the paper.text(x,y,text). Can anyone help me with this?

Text is anchored to the centre by default, so as long as you have positioned your text in the centre of the image, you don't need to calculate any difficult positioning from the inserted text.

http://jsfiddle.net/mcByE/

It might help if you show some code though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM