Week 21 | radialNetwork

htmlwidgets News This Week

Avid readers already know, but for all the newest and updated htmlwidgets, just do this Github search, and you’ll quickly get up to date.

This Week’s Widget - radialNetwork

When I saw Wm Leler demonstrate his radial tree on this d3.bayarea() Show and Tell, I instantly wanted it as an htmlwidget. His statement that with all the d3 examples out there very few are full-featured explains perfectly why his Radial Tree with UI is exceptional. Unfortunately, I had to remove a couple of the features temporarily due to my inability to get them to work within the constraints of a widget. I’ll try to add them back as soon as I can. Even with the removals, I think this radial tree will be a very useful addition to networkD3.

Quick Installation

radialNetwork started as a fork of networkD3, but is now its own package. To try it out, please use devtools::install_github.

devtools::install_github("timelyportfolio/radialNetworkR")

Example

While we are exploring radialNetwork, I would also like to publicize the helpful data.tree package from Christopher Glur. He has recently added the function to easily go from data.tree to the JSON network format expected by d3.js. Let’s see data.tree working with radialNetwork.

# you'll need this fork of networkD3
# devtools::install_github("timelyportfolio/radialNetworkR")
library(radialNetworkR)

# devtools::install_github( "gluc/data.tree" )
library(data.tree)

# use the acme data from data.tree
data(acme)

# unname = TRUE to get in the proper d3 format
radialNetwork( ToListExplicit(acme, unname = TRUE ) )

Of course, no d3.js network example is complete without flare.json.

# you'll need this fork of networkD3
# devtools::install_github("timelyportfolio/radialNetworkR")
library(radialNetworkR)

radialNetwork(
  jsonlite::fromJSON(
   paste0(
     readLines(
       paste0(
         "https://gist.githubusercontent.com/mbostock/"
         ,"1093025/raw/a05a94858375bd0ae023f6950a2b13fac5127637/flare.json"
       )
     )
     ,collapse = "\n"
   ),
   simplifyDataFrame = FALSE
  )
)

Thanks

Thanks so much

  • Wm Leler for his Radial Tree with UI on which this is based
  • d3.js from Mike Bostock
  • Ramnath Vaidyanathan and RStudio for htmlwidgets
  • all the contributors to R and JavaScript