fbreitwieser / sankeyD3

D3 Sankey Network Graphs from R
65 stars 27 forks source link

Enable the use of scale_* function in `colourScale` argument #28

Open Yunuuuu opened 1 year ago

Yunuuuu commented 1 year ago

These commits provide a interface to use scaled3* function in sankeyNetwork, and imports all ggsci discrete palette.

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

# Plot
sankeyD3::sankeyNetwork(
  Links = Energy$links, Nodes = Energy$nodes, Source = "source",
  Target = "target", Value = "value", NodeID = "name",
  units = "TWh", fontSize = 12, nodeWidth = 30,
  colourScale = sankeyD3::scale_d3_igv()
)