kinkajou
kinkajou

Reputation: 3728

Huge text generated using raphael

I wanted to draw text at the center of polygon and into the polygon formed by path value. I tried using this fiddle but the text is drawn on paper not polygon.

 //for writing text
        var bbox = obj.getBBox();
        var x = Math.floor(bbox.x + bbox.width/2.0); 
        var y = Math.floor(bbox.y + bbox.height/2.0);
        alert(x + " and " + y);
        r.text(x, y, "t");

Actually I wanted to write text at the center and into polygon like a label! Like country name at the center of polygon that's all!

Upvotes: 0

Views: 131

Answers (1)

Erik Dahlström
Erik Dahlström

Reputation: 60966

I'm guessing that your question really was "why is the text so huge?", and perhaps "why is it misplaced?". Something like this perhaps:

http://jsfiddle.net/nhYSr/

I'd recommend avoiding such a small viewBox, because browsers tend to have issues with very small (smaller than 1px) font-sizes.

Upvotes: 1

Related Questions