A d3.select… equivalent to jQuery.children()

后端 未结 5 1853
感动是毒
感动是毒 2021-01-07 21:03

I\'m using d3 to append some elements on enter() and then update them later. However, the next time i try to select those elements the selection is much larger than the orig

5条回答
  •  遥遥无期
    2021-01-07 21:05

    Like says Lars, there is no equivalent to 'children()' method in D3, but here left a little extension to d3.selection prototype i wrote. I hope must help you (so late).

    d3.selection.prototype.children = function(d){
        var that = this.node();
        return this
            .selectAll(d)
            .filter(function(){ return that == this.parentNode; });
    };
    

提交回复
热议问题