D3如何获得过滤后的数据大小

D3 How to I get the size of the data after filtering

本文关键字:数据 何获得 过滤 D3      更新时间:2023-09-26

例如,如果我使用此代码来获取奇数索引数据值

d3.select("body").selectAll("div")
    .data([4, 8, 15, 16, 23, 42]
        .filter(function(d, i) { return i & 1; }))
    .enter().append("div")
        .text(function(d) { return d; });

如何在过滤操作后获得数据的大小。

为此使用selection.size()