networkd3

R networkD3 custom node color for radialNetwork()

一个人想着一个人 提交于 2019-12-11 17:25:18
问题 The R package networkD3 provides an interface for R users to make network plots in D3, but the input data and ability to map data to network aesthetics differs over the available plots (e.g., simpleNetwork, forceNetwork). Recently I've been trying to apply custom colors to each node in a radialNetwork(), similar to this thread, but I can't figure out how the custom coloring was mapped to the nodes. The code to produce a custom coloring: library(networkD3) library(tidyverse) library(data.tree)

Reactive height for sankeyNetworkOutput from networkD3

梦想的初衷 提交于 2019-12-11 10:59:36
问题 I have a Shiny dashboard that is displaying a sankeyNetwork from the networkD3 package. I'm creating the sankeyNetwork inside of a renderSankeyNetwork function on the server and then calling it on the ui with sankeyNetworkOutput. I'd like to make the height of the created sankeynetwork be dependent on a height value I've created. I tried using renderUI with uiOutput to run the sankeyNetworkOutput on the server, but it doesn't seem to be working. The dashboard works otherwise but there is

Sankey Diagram with R library networkD3 does not show colors

帅比萌擦擦* 提交于 2019-12-11 07:14:17
问题 I am using the networkD3 library for R in order to create Sankey networks. While this works pretty well for me, I have now encountered an issue with assigning the attributes "NoteID" and/or "NoteGroup" to group and allocate colors as shown in https://christophergandrud.github.io/networkD3/#sankey The following code shows 4 examples of creating a Sankey diagram, only "Sankey4" works as designed, i.e., no colors: library(networkD3) #Unique list of nodes my_nodes = structure(list(name = c(

Adjust background picture and title for plot from networkD3's forceNetwork

故事扮演 提交于 2019-12-11 06:35:54
问题 Following the post here, Change the color of the legend text in forceNetwork for networkD3, I am trying to add a picture from a local drive as the background image, and also add a title to the graph. However, these lines do not seem to take effect: Background: .style("background-image", "url(C:\\Desktop\\BGP.png)") Title: htmlwidgets::prependContent(htmltools::tags$h1("Title")) What is the right way to add them in? Also, is there a way to adjust the font style and size of the title text as

Highlight all connected paths from start to end of a sankey diagram using networkD3

感情迁移 提交于 2019-12-11 05:31:34
问题 I would like to produce a Sankey-diagram using the networkD3 package in R that has the functionality as described in this question, and the "highlight_node_links" function in the answer: d3 Sankey - Highlight all connected paths from start to end I'm a beginner with both R and Javascript and my problem is that I cannot make the above javascript function work with my R code. I have checked Highlight all connected paths from start to end in Sankey graph using R question too, but unfortunately I

R networkD3: click action to show information from node data frame

。_饼干妹妹 提交于 2019-12-10 23:42:13
问题 I have this code: library(networkD3) # Load data data(MisLinks) data(MisNodes) new.nodes <- MisNodes new.nodes$var1 <- runif(nrow(MisNodes),1,2) new.nodes$var2 <- runif(nrow(MisNodes),1,2) # Some script to show the node index in the new.nodes data frame script <- 'alert("row: " + (d.index + 1));' # Plot forceNetwork(Links = MisLinks, Nodes = new.nodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8, clickAction = script) I figured out to

Convert a data frame to a treeNetwork compatible list

怎甘沉沦 提交于 2019-12-09 16:18:05
问题 Consider the following data frame: Country Provinces City Zone 1 Canada Newfondland St Johns A 2 Canada PEI Charlottetown B 3 Canada Nova Scotia Halifax C 4 Canada New Brunswick Fredericton D 5 Canada Quebec NA NA 6 Canada Quebec Quebec City NA 7 Canada Ontario Toronto A 8 Canada Ontario Ottawa B 9 Canada Manitoba Winnipeg C 10 Canada Saskatchewan Regina D Would there be a clever way to convert it to a treeNetwork compatible list (from the networkD3 package) in the form of: CanadaPC <- list

Change the color of the legend text in forceNetwork for networkD3

别等时光非礼了梦想. 提交于 2019-12-08 21:21:25
Using forceNetwork from the networkD3 R package, how can I change the color of the text in the legend to white? My Code: library(networkD3) forceNetwork(Links = subLinkList, Nodes = subNodes, Source = "root", Target = "children", Value = "linkValue", NodeID = "nodeName", Nodesize = "nodeSize", Group = "nodeGroup", colourScale = JS(colorScale), charge = -500, opacity = 1, opacityNoHover = 1, fontSize = 25, fontFamily = "Calibri", linkDistance = JS('function(){d3.select("body").style("background-color", "#144370");return 200;}'), linkWidth = 3, linkColour = "white", legend = TRUE, bounded = TRUE

Extracting node information from networkd3 to a reactive variable in shiny

匆匆过客 提交于 2019-12-08 10:17:36
问题 I am having a hard time working with networkd3 package in Shiny. I have plotted a graph and would like to extract node information back to shiny in a reactive manner to visualize more information concerning a certain node. E.g star graph with center node "Father" and other "Son1"..."SonN". Upon clicking on the Son node I would like to be able to access the "Son1" name in shiny to extract information from a data frame within shiny and visualize additional information (e.g job, age and so on).

linking clickAction on a node in networkD3 to a local HTML file

徘徊边缘 提交于 2019-12-08 08:59:43
问题 Hi I am trying forcenetwork function in networkD3 package in R. I get stuck with clickAction. The aim of clickAction is to open a new window to show the content of a local HTML file. But now, It is ok to add a website URL like http://www.google.com. But I get stuck with opening local HTML file. When I add the direction of local HTML file, it doesn't work and show "Not Found". I have tried to put all HTML files in www file in relative path. But it doesn't work. I was wondering if there is any