Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raphaël Bug : arrow-end

Tags:

raphael

I am using Raphaël library to create a quick draw tool. But there is an error with arrow end, they are assigned same for all lines.

Say,I have lineA with an arrowhead of #raphael-marker-oval. Then, I draw lineB and assign an arrowhead of #raphael-marker-oval also. Whenever I change the arrowhead of lineA to a new color, the arrowhead of lineB will be changed to same color also.

Please help!!

like image 431
Reetika Avatar asked Jul 08 '13 07:07

Reetika


1 Answers

I'm having a similar problem, where arrowheads disappear when a containing div is hidden. This seems to be a bug in Raphael: https://github.com/DmitryBaranovskiy/raphael/pull/525 I'm just researching it and trying to figure out how to fix it ...

Looks like the problem is fixed if markerIds are unique. This is what I did to fix it: in raphael.js: Line 28:

var raphaelMarkerIdFixCount = 1;

Line 5938: replace this:

markerId = "raphael-marker-" + se + type + w + h;

with this:

markerId = "raphael-marker-" + se + type + w + h + raphaelMarkerIdFixCount;
raphaelMarkerIdFixCount++;

Since it now means that a new marker element is created every time, it may lead to memory issues if you are drawing a huge number of arrows - someone may be able to come up with a better patch, this fix is certainly in the 'quick-and-dirty' category - but it worked for me.

like image 132
Steve Moseley Avatar answered Sep 27 '22 23:09

Steve Moseley