1

I have made a really nice but large using the package in . There are 173 nodes with 4 levels of (898) links. it renders well in viewer. However, when I render it in I only get a compressed diagram with very thin links without the nodes. My code example is below:

library(networkD3)
library(plyr)
library(tidyverse)

#the link data
sdg_san3 <- TY %>% group_by(Target_Conditions, SDI) %>% add_count(SDI) %>% mutate(value = n * 100)
colnames(sdg_san3) <- c("source", "target", "n", "value")

#the node data 
NOD_sdg3 <- data.frame(name = c(as.character(sdg_san3$source), as.character(sdg_san3$target)) %>% unique())

#making the Sankey
sdg_san3$sdsource <- match(sdg_san3$source, NOD_sdg3$name)-1
sdg_san3$sdtarget <- match(sdg_san3$target, NOD_sdg3$name)-1
s3 <- networkD3::sankeyNetwork(Links = sdg_san3, Nodes = NOD_sdg3, 
                         Source = 'sdsource', Target = 'sdtarget', 
                         Value = 'value', NodeID = 'name', units = 'frequency', fontSize = 12, nodeWidth = 45, height = 1500, width = 1200)
s3

In the flexdashboard, I get the image below:

enter image description here

I revised the code with the render functions as below:

output$sankey1 <- renderSankeyNetwork({
sdg_san3 <- TY %>% group_by(Target_Conditions, SDI) %>% add_count(SDI) %>% mutate(value = n * 100)
colnames(sdg_san3) <- c("source", "target", "n", "value")

#the node data 
NOD_sdg3 <- data.frame(name = c(as.character(sdg_san3$source), as.character(sdg_san3$target)) %>% unique())

#making the Sankey
sdg_san3$sdsource <- match(sdg_san3$source, NOD_sdg3$name)-1
sdg_san3$sdtarget <- match(sdg_san3$target, NOD_sdg3$name)-1
networkD3::sankeyNetwork(Links = sdg_san3, Nodes = NOD_sdg3, 
                         Source = 'sdsource', Target = 'sdtarget', 
                         Value = 'value', NodeID = 'name', units = 'frequency', fontSize = 12, nodeWidth = 45, height = 30000, width = 15000)
})
sankeyNetworkOutput("sankey1")

And I still get the same result like the image above only with wider spaces between where nodes should be. Any help to properly render in the dashboard will be appreciated. Thanks

massisenergy
  • 1,764
  • 3
  • 14
  • 25
AyDee
  • 43
  • 5
  • There’s not enough vertical space to show all the nodes. That’s why they are so small. – CJ Yetman Mar 23 '20 at 22:00
  • Thanks @CJ Yetman for the response. you know in rstudio the sankey network is rendered within a view box that one can scroll up-down, and side to side. but it does not replicate this in the dashboard. is there a way to coerce it to do that in the dashboard? – AyDee Mar 25 '20 at 00:49
  • I'm having the same issue - did you ever figure it out? – Carmen Sandoval Oct 05 '20 at 00:19

0 Answers0