I’m trying to create a draggable graph similar to http://raphaeljs.com/graffle.html (works in both 1.5.2 and 2.1), but I want to include text in the boxes.
I added the text using the suggestion in another question: How can I combine objects in the Raphael javascript library?
This solution works great with RaphaelJS 1.5.2, but it breaks in RaphaelJS 2.1.
jsFiddle Example: http://jsfiddle.net/ScBtZ/
The only difference I have found is that Element.getBBox() returns a very different result.
Sample:
In 1.5.2:
SVGRect
height: 40
width: 100
x: 526.5
y: 25
In 2.1:
Object
height: 500780.9482062537
width: 1009980
x: 526.51
x2: 1010506.51
y: -399735.94795512746
y2: 101045.00025112627
Am I missing something about the change from v1.5 to v2, or is this odd BBox a bug? Any ideas how I can fix this issue?
Thanks!
Well, it looks like there was an attempt to replace the native method
getBBoxwith a custom implementation, in Raphael.The reasons behind this might be that the native getBBox method has some bugs, and it returns improper results for some shapes. Another reason might be browser portability, I’m not sure if there is a getBBox method in VML.
However, from the values you pointed out is seems like this custom implementation has its flaws.
You can use the native getBBox in Raphael 2.x with this code:
I tested it and looks good: http://jsfiddle.net/ScBtZ/2/