Coder Social home page Coder Social logo

sankeyd3's Introduction

sankeyD3 - Sankey Network Graphs in R and Shiny

sankeyD3 v0.3 Build Status. Based on networkD3 and d3-sankey.

image

Installation and Usage

# Installation
# install.packages('devtools')
devtools::install_github("fbreitwieser/sankeyD3")

# Run example site directly from Github
shiny::runGitHub("fbreitwieser/sankeyD3", subdir="inst/examples/shiny")

## Run it locally
library(sankeyD3)
# Based on 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)

sankeyNetwork(Links = Energy$links, Nodes = Energy$nodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             units = "TWh", fontSize = 12, nodeWidth = 30) %>% saveNetwork(file = 'Net1.html')

Features

  • Uses D3 v4
  • Adds option numberFormat, default being ",.5g" (see , fixes christophergandrud/networkD3#147)
  • Adds option NodePosX, fixes christophergandrud/networkD3#108
  • Adds option to force node ordering to be alphabetical along a path (only works well with trees with one parent for each node, but might fix christophergandrud/networkD3#153)
  • Zooming
  • Dragging both horizontally and vertically
  • Adds option showNodeValues to show node values above nodes
  • Adds option nodeCornerRadius for rounded nodes
  • Adds option title for titles in the upper-right corner of the plot
  • Adds _hover event that is fired every second
  • Adds option doubleclickTogglesChildren to hide children/downstram nodes
  • Adds option xScalingFactor to scale width between nodes
  • Adds option xAxisDomain to make an x-axis
  • Added option linkGradient to make link a gradient (when LinkGroup is not defined)
  • Added option linkColor to specify link color
  • Added option linkOpacity to specify opacity of link
  • Added option nodeShadow to add drop shadow
  • Added option nodeLabelMargin to specify the distance between label and node

sankeyd3's People

Contributors

fbreitwieser avatar yunuuuu avatar floresfdev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.