networkd3

Implementing tooltip for networkD3 app

我是研究僧i 提交于 2019-12-04 18:08:12
I want to implement a tooltip in Shiny-hosted networkD3 plot similar to the ggvis function, e.g: require(ggvis); require(shiny) all_values = function(x){ "<a href='#'>Option 1</a><br/><a href='#'>Option 2</a>"} server = function(input, output, session) { observe({ ggvis(mtcars, ~disp, ~mpg) %>% layer_points() %>% add_tooltip(all_values, 'click') %>% bind_shiny('ggvis_plot', 'ggvis_ui') }) } ui = fluidPage( uiOutput("ggvis_ui"), ggvisOutput("ggvis_plot")) shinyApp(ui, server) Is there an elegant Shiny or D3/javascript way to achieve this for a simple networkD3 plot - such as below? library

How to plot a directed Graph in R with networkD3?

99封情书 提交于 2019-12-04 17:11:45
when I am ploting a directed graph with NetworkD3 , The edges are not directed , how can I fix it ? an Example : library(networkD3) data(MisLinks) data(MisNodes) forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8) I want the result to be directed This is the definetion of directed Graph: "A directed graph is graph, i.e., a set of objects (called vertices or nodes) that are connected together, where all the edges are directed from one vertex to another. A directed graph is sometimes called a

Modify networkD3 sankey plot with user-defined colors

点点圈 提交于 2019-12-04 13:27:55
问题 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 sure how to modify the colors with user-defined palette. It is necessary for me to use the same color palette specific to each node source to keep consistent with other plots I have. Currently I am able to have each source node be a different color

Going crazy with forceNetwork in R: no edges displayed

♀尐吖头ヾ 提交于 2019-12-04 04:17:21
问题 I've been trying to plot a network using networkD3 package in R for a week now. The simpleNetwork function works normally, but it doesn't allow much control over the appearance of the graph. The forceNetwork function is there for this purpose: display graph with enriched visual features. The problem I have is pretty much the same exposed in this question. I have carefully read the package documentation, and tried the solution proposed in the above thread, with no luck: all I get is a cloud of

Put line break in node labels in networkD3 sankey diagram

故事扮演 提交于 2019-12-04 02:34:34
++++++++++++++++ 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 labels for a sankey diagram produced using the networkD3 R package? Borrowing the example from Place text values to right of sankey diagram I can add values to the lables: library(networkD3) library(data.table) set.seed(1999) links <- data.table( src = rep(0:4, times=c(1,1,2,3,5)), target = sample(1:11, 12, TRUE), value = sample(100, 12) )[src <

Adjusting sankey plot in tabbed section

最后都变了- 提交于 2019-12-04 01:43:42
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 that problem? Related question: How to control node labels in Sankey diagram --- title: "Untitled" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) library(networkD3) library(htmlwidgets) nodes <- data.frame('name' = c('Node0','Node1','Node2','Node3','Node4','Node5','Node6', 'Node7','Node8','Node9','Node10',

Modify networkD3 sankey plot with user-defined colors

别等时光非礼了梦想. 提交于 2019-12-03 07:40:20
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 sure how to modify the colors with user-defined palette. It is necessary for me to use the same color palette specific to each node source to keep consistent with other plots I have. Currently I am able to have each source node be a different color and all target nodes to be same color by defining the NodeGroup . The plot below is close to what I

how to define nodes and links data frame for sankeyNetwork()

一世执手 提交于 2019-12-02 23:07:59
问题 I have a file with export from source country to target country, the value of the trade is in Before_value dimension. My data is in a data.table with dimensions source and target as character (list of country codes) and beofre_value numeric. I would like to generate a sankey diagram, using sankeyNetwork() from networkd3, with the source countries on the left and the target countries on the right and the flows represented. How do I define the nodes and links data frames properly? I have these

forceNetwork is not zero indexed

混江龙づ霸主 提交于 2019-12-02 00:12:20
I am trying to create a simple forceNetwork , but the plot won't render. I keep getting the following warning: Warning message: It looks like Source/Target is not zero-indexed. This is required in JavaScript and so your plot may not render. How do I fix this? Note that simpleNetwork works fine so the problem seems to be in how I am specifying my data. library(igraph) library(networkD3) set.seed(42) temp<-data.frame(source=c(1,2,3,4),target=c(2,3,4,4))#csv[1:500,] links<-data.frame(source=temp$source,target=temp$target) g<-graph.data.frame(cbind(temp$source,temp$target), directed=T) nodes<-data

Going crazy with forceNetwork in R: no edges displayed

此生再无相见时 提交于 2019-12-01 21:21:56
I've been trying to plot a network using networkD3 package in R for a week now. The simpleNetwork function works normally, but it doesn't allow much control over the appearance of the graph. The forceNetwork function is there for this purpose: display graph with enriched visual features. The problem I have is pretty much the same exposed in this question. I have carefully read the package documentation, and tried the solution proposed in the above thread, with no luck: all I get is a cloud of nodes with no edges linking them. Here my data.frame s: edg Gene1 Gene2 Prob 1 22 3 2 22 6 3 22 6 4 22