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.