christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
649 stars 269 forks source link

Empty plot when trying to customize nodes colors with version 0.3 #177

Closed sebastien-foulle closed 7 years ago

sebastien-foulle commented 7 years ago

Hi,

with networkD3 0.2.13 the following minimal example plots a gold box, and with version 0.3 the plot is empty :

Links = data.frame(Source = 0, Target = 0, Value = 1)
Nodes = data.frame(name = "a")

library("networkD3")

sankeyNetwork(Links, 
              Nodes, 
              Source = "Source",
              Target = "Target", 
              Value = "Value", 
              NodeID = "name",
              colourScale = JS("d3.scale.category20().range(['gold'])")
)
sessionInfo()

_R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] networkD3_0.2.13

loaded via a namespace (and not attached):
[1] htmlwidgets_0.8 magrittr_1.5    htmltools_0.3.5 tools_3.3.3     igraph_1.0.1    yaml_2.1.14     Rcpp_0.12.9    
[8] jsonlite_1.3    digest_0.6.12_  

Best regards, Sebastien Foulle

cjyetman commented 7 years ago

We have updated networkD3 to D3v4, which has some significant changes. You will need to change your colourScale argument to...

colourScale = JS("d3.scaleOrdinal(d3.schemeCategory20).range(['gold']);")

also, check the help file for working examples (and the new default value for colourScale)