graphics - RaphaelJs : How to add some text to an area defined by a path? -


i have svg image of united states i've drawn little bit of raphaël js:

http://jsfiddle.net/zcrkg/2/

what want place text right of each state when hover on it. problem that, since each state path, quite difficult determine x & y coordinates place label.

so, know way of calculating centre of path using raphaël? if failing know how given array of vectors?

what you're looking getbbox function in raphaël. give bounding box object can use calculate central point of path:

var bbox = st.getbbox(); var text = r.text(bbox.x + bbox.width/2, bbox.y + bbox.height/2, "foo"); 

i forked fiddle , made show static text in middle of each state on hover. picking state name data left exercise.


Comments

Popular posts from this blog

Python __call__ special method practical example -

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -