Questions tagged [networkd3]

D3 JavaScript Network Graphs from R.

This started as a port of Christopher Gandrud’s package d3Network for creating D3 network graphs to the htmlwidgets framework. The htmlwidgets framework greatly simplifies the package’s syntax for exporting the graphs, improves integration with RStudio’s Viewer Pane, RMarkdown, and Shiny web apps. See below for examples.

It currently supports the following types of network graphs:

External Links:

333 questions
14
votes
2 answers

Highlight all connected paths from start to end in Sankey graph using R

I want to highlight the whole path when i click on the node to know the whole story of specific node and here's an example- http://bl.ocks.org/git-ashish/8959771 . Please check this link and you will find the function that highlight the path in…
14
votes
1 answer

Put line break in node labels in networkD3 sankey diagram

++++++++++++++++ Update: I think the answer to my question is that you can't put line breaks in. A colleague pointed out to me the node labels are SVG blocks, which don't support line breaks. ++++++++++++++++ How do I put a line break into the node…
edsherman
  • 141
  • 4
13
votes
1 answer

Modify networkD3 sankey plot with user-defined colors

I have a sankey plot created in networkD3 package. I would like to modify the colors and transparency of both nodes and links. My data networkD3_data is appended at the end. Question 1: How to modify node colors with user-defined palette? I am not…
Djork
  • 3,319
  • 1
  • 16
  • 27
13
votes
4 answers

R networkD3 package: node coloring in simpleNetwork()

The networkD3 package (see here and here) allows a user to create simple interactive networks: # Load package library(networkD3) # Create fake data src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D") target <- c("B", "C", "D", "J", …
warship
  • 2,924
  • 6
  • 39
  • 65
11
votes
1 answer

Transform a dataframe into a tree structure list of lists

I have a data.frame with two columns representing a hierarchical tree, with parents and nodes. I want to transform its structure in a way that I can use as an input for the function d3tree, from d3Network package. Here's my data frame: df <-…
felipeformenti
  • 165
  • 1
  • 8
10
votes
2 answers

Adjusting sankey plot in tabbed section

In the r-markdown document given below, I use tabbed sections to display sankey plots. However, when a sankey plot is in a tab other than the first, adjusting (using htmlwidgets::onRender function) does not work. Does anybody know a way to overcome…
gd047
  • 29,749
  • 18
  • 107
  • 146
10
votes
2 answers

Turning relationship data into hierarchical list in R

This is my first question; so please, be gentle. I have some data that is in the form of : library('networkD3') Relationships<- data.frame(Parent=c("earth","earth","forest","forest","ocean","ocean","ocean","ocean"), …
Chris P
  • 225
  • 2
  • 10
10
votes
1 answer

Place text values to right of sankey diagram

Is there a trick to placing text on a sankey diagram rendered using networkD3? I would like to have the values of the endpoints be displayed as text to the right of their boxes. I realize that hovering over the boxes displays the value, but as the…
Rorschach
  • 31,301
  • 5
  • 78
  • 129
10
votes
2 answers

How to capture html output as png in R

I use interactive output created by networkD3 package in R. I know how to save the output as html page, but I also need to save the 'static' version of the diagram as .png file. The code looks like this: # Load package library(networkD3) # Create…
Lenka Vraná
  • 1,686
  • 2
  • 19
  • 29
9
votes
1 answer

Sankey diagram in R

Attempting to make a fairly generic Sankey diagram with the help of R's networkD3 package. Just for reference--here's the example from the package's manual library(networkD3) library(jsonlite) library(magrittr) energy <-…
tomw
  • 3,114
  • 4
  • 29
  • 51
8
votes
1 answer

How to add columnn titles in a Sankey chart networkD3

I am making a Sankey chart and I would like to add text on top of each column in order to give a brief description of what is shown. Example code taken from the r-graph galery: library(networkD3) # A connection data frame is a list of flows with…
User2321
  • 2,952
  • 23
  • 46
8
votes
1 answer

Tiny plot output from sankeyNetwork (NetworkD3) in Firefox

As per object, I get a very small plot in Firefox when using sankeyNetwork() from networkd3 in shiny but not in Chrome or RStudio. I have not included any CSS or JS in the script - the code below produces this result for me. Is there any CSS…
Andrea
  • 110
  • 6
8
votes
1 answer

Printing a sankey diagram in Shiny

I created a sankey diagram like this: #install.packages("networkD3") library(networkD3) nodes = data.frame("name" = c("Retour", # Node 0 "niet tevreden/ontevreden", # Node 1 "fout",…
Henk Straten
  • 1,365
  • 18
  • 39
8
votes
1 answer

How to sort source and/or target nodes in a sankey diagram within a shiny app?

I have a simple sankey diagram, generated using networkD3 package inside a shiny app. How can source and/or target nodes be sorted? As you can see in the MWE, by default, neither source nodes (A, B, C, D, E) nor target nodes (V, W, X, Y, Z) are…
jmjr
  • 2,090
  • 2
  • 21
  • 31
8
votes
2 answers

Creating a Sankey Diagram using NetworkD3 package in R

Currently I am trying to create an interactive Sankey with the networkD3 Package following the instructions by Chris Grandrud (https://christophergandrud.github.io/networkD3/). What I don't understand is is table-format, since he just uses two…
Phipsy
  • 81
  • 1
  • 2
1
2 3
22 23