christophergandrud / networkD3

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

sankeyNetwork in blank in R 4.4.0 #302

Open Pablo-Sar opened 2 months ago

Pablo-Sar commented 2 months ago

I followed the example in https://r-charts.com/flow/sankey-diagram-ggplot2/ to plot the sankey diagram but in the viewer just appeared in blank without any error in the console. Captura de pantalla (1589)

Pablo-Sar commented 2 months ago

I pasted the screenshot in R 4.3.3 since I change the version to plot the diagram.

In R 4.3.3 works just fine.

cjyetman commented 2 months ago

can you copy-paste the reproducible code here?

Pablo-Sar commented 2 months ago

can you copy-paste the reproducible code here?

Sorry I put another example in my description.

Load package library(networkD3)

Load energy projection data URL <- "https://cdn.rawgit.com/christophergandrud/networkD3/master/JSONdata/energy.json" Energy <- jsonlite::fromJSON(URL)

Now we have 2 data frames: a 'links' data frame with 3 columns (from, to, value), and a 'nodes' data frame that gives the name of each node. head( Energy$links ) head( Energy$nodes )

Thus we can plot it sankeyNetwork(Links = Energy$links, Nodes = Energy$nodes, Source = "source", Target = "target", Value = "value", NodeID = "name", units = "TWh", fontSize = 12, nodeWidth = 30)