gpt4 book ai didi

javascript - D3 Sunburst - 可以显示某些图层

转载 作者:行者123 更新时间:2023-11-27 22:36:42 25 4
gpt4 key购买 nike

我查看旭日图 - 即来自此示例:

https://bl.ocks.org/kerryrodden/7090426

我想问D3中是否可以控制显示的环数。那么说我只想出现第二环?

我注意到这部分代码

// For efficiency, filter nodes to keep only those large enough to see.
var nodes = partition.nodes(json)
.filter(function(d) {
return (d.dx > 0.005); // 0.005 radians = 0.29 degrees
});

我尝试按照 d.depth = 2 的方式附加到此内容,但不起作用:

// For efficiency, filter nodes to keep only those large enough to see.
var nodes = partition.nodes(json)
.filter(function(d) {
if (d.depth = 2) {
return (d.dx > 0.005); // 0.005 radians = 0.29 degrees
}
});

如有任何帮助,我们将不胜感激。

谢谢。

最佳答案

你很接近,过滤器需要返回每个元素。尝试通过逻辑 && 添加深度检查:

// For efficiency, filter nodes to keep only those large enough to see.   
var nodes = partition.nodes(json)
.filter(function(d) {
return (d.dx > 0.005 && d.depth < 3); // 0.005 radians = 0.29 degrees
});

关于javascript - D3 Sunburst - 可以显示某些图层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39058672/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com