RSS

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

Advertisements
 
Leave a comment

Posted by on July 27, 2011 in RaphaelJS

 

Tags:

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

 
%d bloggers like this: