gpt4 book ai didi

javascript - 如何更改 D3.js 中路径的颜色?

转载 作者:行者123 更新时间:2023-11-29 19:40:07 25 4
gpt4 key购买 nike

我正在 D3 中的 TreeMap 中创建一些路径,我想更改线条(路径)的颜色,但我无法使我的代码工作:

 // Enter any new links at the parent's previous position.
link.enter().insert("svg:path", "g")
.attr("class", "link")
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
})
.transition()
.duration(duration)
.attr("d", diagonal);

// Transition links to their new position.
link.transition()
.duration(duration)
.attr("d", diagonal);

// Transition exiting nodes to the parent's new position.
link.exit().transition()
.duration(duration)
.attr("d", function(d) {
var o = {x: source.x, y: source.y};
return diagonal({source: o, target: o});
})
.remove();

我尝试使用以下方法进行更改,并且查找了一些其他解决方案,但我真的不明白我需要在更新选择中选择什么来更改它。

  link.selectAll("path")
.attr("stroke", "#000000");

提前感谢您的帮助。

最佳答案

我自己刚开始使用 d3,但我认为您需要使用 link.style("stroke",#xxxxxx)。

关于javascript - 如何更改 D3.js 中路径的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23632848/

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