8

What's the best way to get the bounding box of several Raphael objects as a whole?

Can I put them all in a set and call mySet.getBBox()?

Or do I need to loop through them all, get bbox for each one and calculate the overall height and width?

(Also, I can't use SVG directly - I need VML support.)

peteorpeter
  • 4,037
  • 2
  • 29
  • 47

1 Answers1

11

Uh. It's really easy. (Thanks @Dylan):

var paper = Raphael ('test', 100, 100);

var circles = paper.set();

var c1 = paper.circle(70,30,10);
var c2 = paper.circle(50,10,10);
var c3 = paper.circle(10,80,10);

circles.push(c1, c2, c3);

alert(c3.getBBox().width); // --> 20

alert(circles.getBBox().width); // --> 80
peteorpeter
  • 4,037
  • 2
  • 29
  • 47