networkd3

Transform a dataframe into a tree structure list of lists

别说谁变了你拦得住时间么 提交于 2019-11-30 04:44:02
问题 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 <- data.frame(c("Canada","Canada","Quebec","Quebec","Ontario","Ontario"),c("Quebec","Ontario","Montreal","Quebec City","Toronto","Ottawa")) names(df) <- c("parent","child") And I want to transform it to this structure Canada_tree <- list(name = "Canada",

Place text values to right of sankey diagram

℡╲_俬逩灬. 提交于 2019-11-29 10:24:53
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 boxes get smaller it would be much easier in many cases to portray the information if the values were always visible on the side. Here is an example; I was able to kinda hack it by adding the values as part of the labels, but it would be much better to have the values displayed to the right of the diagram. library(networkD3) library(data.table) set

Change background color of networkD3 plot

给你一囗甜甜゛ 提交于 2019-11-28 08:49:17
Say I make a networkD3 plot - using the minimal example in the package # library(networkD3) # Load data data(MisLinks) data(MisNodes) # Plot forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8) If I open this in the browser, I can use developer tools to change the background color of body to e.g. background-color: #DAE3F9;" Is there a way to automatically define background color of a plot (From default white) to another color, without opening in the browser ? Basically, can we add CSS directly

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

假如想象 提交于 2019-11-27 21:28:53
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 javscript, but take care please , this function doesn't do what i want, it highlight links related to the clicked node and the links related to the target nodes. what i want is to highlight all links related to the clicked node. d3 Sankey - Highlight all connected paths from start to end Here's an example of what i need, This is the whole graph,what i

R networkD3 package: node coloring in simpleNetwork()

女生的网名这么多〃 提交于 2019-11-27 13:46:35
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", "E", "F", "G", "H", "I") networkData <- data.frame(src, target) # Plot simpleNetwork(networkData) Is there a way to specify that I want all elements in the src vector to be a certain color, while allowing all the elements in the target vector to be a different color? This would allow me to visually distinguish src nodes from target nodes in the network. This

Change background color of networkD3 plot

社会主义新天地 提交于 2019-11-27 02:33:23
问题 Say I make a networkD3 plot - using the minimal example in the package # library(networkD3) # Load data data(MisLinks) data(MisNodes) # Plot forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8) If I open this in the browser, I can use developer tools to change the background color of body to e.g. background-color: #DAE3F9;" Is there a way to automatically define background color of a plot (From