Javascript 根据数据中的附加列更改d3 Sankey图中的根节点颜色

Javascript 根据数据中的附加列更改d3 Sankey图中的根节点颜色,javascript,d3.js,svg,colors,sankey-diagram,Javascript,D3.js,Svg,Colors,Sankey Diagram,我指的是这个例子: 此处的节点颜色取决于数据中的附加列。数据如下: source,target,value,nodeColorTarget DistA,Place1,1,blue DistA,Place1,3,red DistB,Place1,12,blue DistB,Place2,2,grey DistB,Place2,1,grey DistB,Place3,2,blue 现在,我需要能够为node DistB设置一些颜色。目前,上次出现的DistB中提到的颜色是设置为DistB的颜色。

我指的是这个例子:

此处的节点颜色取决于数据中的附加列。数据如下:

source,target,value,nodeColorTarget
DistA,Place1,1,blue
DistA,Place1,3,red
DistB,Place1,12,blue
DistB,Place2,2,grey
DistB,Place2,1,grey
DistB,Place3,2,blue
现在,我需要能够为node DistB设置一些颜色。目前,上次出现的DistB中提到的颜色是设置为DistB的颜色。我是否可以在不影响目标节点(此处为Place3)的情况下为DistB设置一些颜色?
谢谢

检查矩形的附加位置更改填充函数以根据算法返回颜色
node.append(“rect”).attr(“height”,函数(d){return d.dy;}).attr(“width”,sankey.nodeWidth()).style(“fill”,函数(d){/*您的算法*/})
类似的内容