How could I change the node color in this sankey diagram
I wanted the two bottom central nodes to be the same color as the previous link color (in this case the bottom node red and the one above it orange) Noob here, thanks in advance for your help.
It seems that you want just those two specific nodes getting their colour from the source links, but none of the others (by looking at the rest of the logic and assuming that that code is yours). If that's correct, the ad hoc solution is just...
if (d.depth === 1 && (d.name === "2 ou + retenções" || d.name === "1 retenção")) return d.targetLinks[0].color;
..., right at the beginning of the callback.