8GB
8GB

Reputation: 79

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?

Upvotes: 0

Views: 1176

Answers (1)

Matt Esch
Matt Esch

Reputation: 22966

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.

Upvotes: 3

Related Questions