I want to change the colours of the node and links in my Sankey. Unfortunately d3.scale.Ordinal() function doesn't work for me. Do you have any idea? Idealy, the Nodes on the left hand side should have the same colours as the links leaving these.
If you have any idea, I'd be very happy. The Sankey works without the colouring . Thessie
Here is the code:
links2 <- data.frame(source=c(0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5),target=c(6,7,8,9,6,7,8,9,6,7,8,9,6,7,8,9,6,7,8,9,6,7,8,9),value=c(3,6,8,8,2,7,5,1,5,5,13,12,43,5,2,7,8,6,5,7,3,5,4,19))
nodes2 <-data.frame(name=c("Cow","Ice","Emu","Coala","Uhu","Panda","Pink","Cyan","Grey","Green"))
links2$group <- as.factor(c("type_a","type_b","type_c","type_d","type_e","type_f"))
nodes2$group <- as.factor(c("a","b","c","d","e","f","g","h","i","j"))
my_colour <- 'd3.scale.Ordinal().domain(["type_a","type_b","type_c","type_d","type_e","type_f","a","b","c","d","e","f","g","h","i","j"]), .range(["darkblue", "gray45" , "khaki4", "skyblue1", "darkgoldenrod4", "gray27", "darkblue", "gray45" , "khaki4", "skyblue1", "darkgoldenrod4", "gray27","darkgreen", "forestgreen","yellowgreen","peru"])'
Network2 <- sankeyNetwork(Links=links2, Nodes=nodes2, Source = "source", Target = "target", Value = "value", NodeID = "name", sinksRight=FALSE,fontSize= 20,iterations=0, colourScale = my_colour, LinkGroup="group", NodeGroup="group")
```