Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SvgAnimatedString missing method indexOf

I am using d3.js together with angularjs. When use hyperlink in svg object(which rendered through angular directive), I am getting this error.

enter image description here

As per the doc here, svgAnimatedString doesn't have any specific method. How can I solve this. Can I inject a method or any other way.

Part of the code below. Thanks you.

svg.selectAll("a.node")
                        .data(data)
                        .enter().append("a")
                        .attr("class", "node")
                        .attr("xlink:href", "test")
                        .append("rect")
like image 204
bsr Avatar asked Sep 25 '12 18:09

bsr


1 Answers

If you must deal with a library which doesn't handle SVG graphics, you can use something like the following to define split on the SVGAnimatedString. Rinse and repeat for other string prototype methods.

 // Set a split prototype on the SVGAnimatedString object which will return the split of the baseVal on this
 // SVGAnimatedString instance
 SVGAnimatedString.prototype.split = function(){ return String.prototype.split.apply(this.baseVal, arguments); };
like image 132
John Hoven Avatar answered Oct 02 '22 01:10

John Hoven