RaphaelJS simple text align

27 Jul

Recently I noticed lots of questions on StackOverFlow regarding text alignment in RaphaelJS.

By default RaphaelJS alignes text to the middle as you can see on the image below:

default middle text alignment

To align text to the left you set text-anchor attribute to “start”. Or to “end” to align text to the right.

R.text(50, 100, 'Some text goes here').attr({'font-size': 11, 'text-anchor': 'start'});

Result – text aligned to the left:

text aligned to the left

Leave a comment

Posted by on July 27, 2011 in RaphaelJS



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: