d3 .each()

Posted xuanmanstein

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了d3 .each()相关的知识,希望对你有一定的参考价值。

 

    d3.select("xxx")
        .each(function (d) {
            //this表示当前element 而 d表示绑定的数据
            something(this);
        });

 

注意each里的this,这个文档里说得明白http://rajapradhan.com/blogs/d3-js-v4-essentials/d3-selections/

The each() method

The each() method invokes the specified function for each of the selected element.

The ‘this’ inside the function refers to the current element of the selection being iterated.

 

以上是关于d3 .each()的主要内容,如果未能解决你的问题,请参考以下文章

D3数据集的过滤,排序,each更改

html D3byEX 9.6:甜甜圈片段(改编自D3.js v4)

d3.js 过渡结束事件

从基准访问 d3.js 元素属性?

d3 带鱼眼气泡图

实用代码片段将json数据绑定到html元素 (转)