dpmccabe / sankeyD3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

D3 JavaScript Sankey Network Graphs from R

Version 0.1

This project is based on the Sankey implementation in networkD3 and d3-sankey.

Changelog:

The inst/examples/shiny web-app exposes several of the features: image

Usage

# Recreate Bostock Sankey diagram: http://bost.ocks.org/mike/sankey/
# Load energy projection data
URL <- paste0("https://cdn.rawgit.com/christophergandrud/networkD3/",
              "master/JSONdata/energy.json")
Energy <- jsonlite::fromJSON(URL)

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

Saving to an external file

Use saveNetwork to save a network to stand alone HTML file:

library(magrittr)

simpleNetwork(networkData) %>% saveNetwork(file = 'Net1.html')

About


Languages

Language:HTML 96.6%Language:R 2.1%Language:JavaScript 1.2%