Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing text in RaphaelJS

Tags:

raphael

How may I change the text in a RaphaelJS-created text node? First, I am creating a new element with a text string with Raphael, and at some later point I would like to change this text. It's easier for me if I do not have to reinitialize the element as there will be a whole host of attributes attached that will be a pain to recreate. Is there a way to do this? I've got my logic below, but it doesn't work; it's there just to provide extra insight as to what I'm trying to achieve. Thanks

var R = Raphael("graph-o-matic", 1000, 1000);

var title = R.text( 10, 10, 'original text');

...

title.text.innerHTML = 'nifty new text here';
like image 486
wes Avatar asked Aug 16 '10 01:08

wes


1 Answers

Try this:

title.attr({text: 'nifty new text here'});
like image 68
robertc Avatar answered Oct 25 '22 03:10

robertc