filter _.any() function doesn't work underscore.js

774 views Asked by At

I have a problem with collection functions filter_.any() from underscore.js. the part of code with filter() will never execute. I can't understand why? I took this code from this example http://blog.pixelingene.com/demos/d3_tree_clipPath/ and I included the same underscore-min.js library into my project but it didn't help to resolve my problem

can someone please help me how to resolve this issue? or may be some alternative way ? Thanks

function setupMouseEvents()
{           
    ui.nodeGroup.on('mouseover', function (d, i)
    {
        d3.select(this).select("rect").classed("hover", true);
    })
            .on('mouseout', function (d, i)
            {  
                d3.select(this).select("rect").classed("hover", false);
            })
            .on('click', function (nd, i)
            {
                // Walk parent chain
                var ancestors = [];
                var parent = nd;
                while (!_.isUndefined(parent)) {
                    ancestors.push(parent);
                    parent = parent.parent;
                }
                // Get the matched links
                var matchedLinks = [];
                console.log(ancestors);   
                ui.linkGroup.selectAll('path.link')
                        .filter(function (d, i)
                        {               
                            return _.any(ancestors, function (p)
                            {
                                return p === d.target;
                            });
                        })
                        .each(function (d)
                        {
                            matchedLinks.push(d);
                        });
                        console.log(matchedLinks);
                animateParentChain(matchedLinks);
            });
}
0

There are 0 answers