Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

asked on

Sticking text to shapes in Raphael.js

I was looking at Raphael.js to illustrate chains. I see that I have to pick up a book to really learn this, but as a start I would like to get to know how to attach text to a shape that I can drag around.

To get started I replicated this example and used it to generate the chain I wanted:
http://dmitrybaranovskiy.github.io/raphael/graffle.html

But I need text with each shape that  moves around with the shape when I drag it.

Anyone here knows how to?

Here is a fiddle to play around with:
https://jsfiddle.net/atle_holm/t7v818nk/
Avatar of HainKurt
HainKurt
Flag of Canada image

here

            shapes = [r.rect(90, 80, 60, 40, 10),
                r.rect(190, 80, 60, 40, 10),
                r.rect(290, 80, 60, 40, 10),
                r.rect(390, 80, 60, 40, 10)               
            ],
            texts = [
                r.text(110, 100, "One"),
                r.text(220, 100, "Two"),
                r.text(310, 100, "Three"),
                r.text(410, 100, "Four")
            ];

Open in new window

SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Leonidas Dosas
Leonidas Dosas
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itnifl

ASKER

Thanks! Perfect! :)