Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderChorddiag showing blank page in Shiny #46

Open
nancyzhu-plenty opened this issue Jul 6, 2023 · 1 comment
Open

renderChorddiag showing blank page in Shiny #46

nancyzhu-plenty opened this issue Jul 6, 2023 · 1 comment

Comments

@nancyzhu-plenty
Copy link

I was testing chorrdiag in a Shiny application. While there was no problem creating chorrdiag with chorrdiag function. I was getting blank page when trying to render the plot in shiny. The example I used is

library(shiny)
library(chorddiag)
library(htmlwidgets)

ui <- shinyUI(fluidPage(
  titlePanel("Hair Color Preferences"),
  
  sidebarLayout(
    
    sidebarPanel(
      sliderInput("margin", "Margin",  min = 0, max = 200, value = 100),
      sliderInput("groupnamePadding", "Group Name Padding",  min = 0, max = 100, value = 30),
      checkboxInput("showTicks", "Show Ticks", value = TRUE)
    ),
    
    mainPanel(
      chorddiagOutput('chorddiag')
    )
  )
))

server <- function(input, output){
  m <- matrix(c(11975,  5871, 8916, 2868,
                1951, 10048, 2060, 6171,
                8010, 16145, 8090, 8045,
                1013,   990,  940, 6907),
              byrow = TRUE,
              nrow = 4, ncol = 4)
  groupNames <- c("black", "blonde", "brown", "red")
  groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
  
  row.names(m) <- groupNames
  colnames(m) <- groupNames
  
  shinyServer(function(input, output) {
    output$chorddiag <- renderChorddiag(
      chorddiag(m,
                groupColors = groupColors,
                groupnamePadding = input$groupnamePadding,
                showTicks = input$showTicks,
                margin = input$margin
      ))})
  
  
}

shinyApp(ui = ui, server = server)

My session information is

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] htmlwidgets_1.6.2 chorddiag_0.1.3   shiny_1.7.3      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       digest_0.6.30    later_1.3.0      mime_0.12        R6_2.5.1         jsonlite_1.8.3   lifecycle_1.0.3  xtable_1.8-4    
 [9] magrittr_2.0.3   cachem_1.0.6     rlang_1.1.0      cli_3.4.1        rstudioapi_0.14  promises_1.2.0.1 jquerylib_0.1.4  bslib_0.4.1     
[17] ellipsis_0.3.2   tools_4.2.2      yaml_2.3.6       httpuv_1.6.6     fastmap_1.1.0    compiler_4.2.2   memoise_2.0.1    htmltools_0.5.5 
[25] sass_0.4.2

I am wondering if this issue is caused by package versions.

@denghb001
Copy link

I was testing chorrdiag in a Shiny application. While there was no problem creating chorrdiag with chorrdiag function. I was getting blank page when trying to render the plot in shiny. The example I used is

library(shiny)
library(chorddiag)
library(htmlwidgets)

ui <- shinyUI(fluidPage(
  titlePanel("Hair Color Preferences"),
  
  sidebarLayout(
    
    sidebarPanel(
      sliderInput("margin", "Margin",  min = 0, max = 200, value = 100),
      sliderInput("groupnamePadding", "Group Name Padding",  min = 0, max = 100, value = 30),
      checkboxInput("showTicks", "Show Ticks", value = TRUE)
    ),
    
    mainPanel(
      chorddiagOutput('chorddiag')
    )
  )
))

server <- function(input, output){
  m <- matrix(c(11975,  5871, 8916, 2868,
                1951, 10048, 2060, 6171,
                8010, 16145, 8090, 8045,
                1013,   990,  940, 6907),
              byrow = TRUE,
              nrow = 4, ncol = 4)
  groupNames <- c("black", "blonde", "brown", "red")
  groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
  
  row.names(m) <- groupNames
  colnames(m) <- groupNames
  
  shinyServer(function(input, output) {
    output$chorddiag <- renderChorddiag(
      chorddiag(m,
                groupColors = groupColors,
                groupnamePadding = input$groupnamePadding,
                showTicks = input$showTicks,
                margin = input$margin
      ))})
  
  
}

shinyApp(ui = ui, server = server)

My session information is

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] htmlwidgets_1.6.2 chorddiag_0.1.3   shiny_1.7.3      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       digest_0.6.30    later_1.3.0      mime_0.12        R6_2.5.1         jsonlite_1.8.3   lifecycle_1.0.3  xtable_1.8-4    
 [9] magrittr_2.0.3   cachem_1.0.6     rlang_1.1.0      cli_3.4.1        rstudioapi_0.14  promises_1.2.0.1 jquerylib_0.1.4  bslib_0.4.1     
[17] ellipsis_0.3.2   tools_4.2.2      yaml_2.3.6       httpuv_1.6.6     fastmap_1.1.0    compiler_4.2.2   memoise_2.0.1    htmltools_0.5.5 
[25] sass_0.4.2

I am wondering if this issue is caused by package versions.

library(shiny)
library(chorddiag)
library(htmlwidgets)

ui <- fluidPage(
titlePanel("Hair Color Preferences"),

sidebarLayout(
    
    sidebarPanel(
        sliderInput("margin", "Margin",  min = 0, max = 200, value = 100),
        sliderInput("groupnamePadding", "Group Name Padding",  min = 0, max = 100, value = 50),
        checkboxInput("showTicks", "Show Ticks", value = TRUE)
    ),
    
    mainPanel(
        chorddiagOutput('chorddiag', width = "100%", height = "800px")
    )
)

)

server <- function(input, output, session) {
m <- matrix(c(11975, 5871, 8916, 2868,
1951, 10048, 2060, 6171,
8010, 16145, 8090, 8045,
1013, 990, 940, 6907),
byrow = TRUE,
nrow = 4, ncol = 4)
groupNames <- c("black", "blonde", "brown", "red")
groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")

row.names(m) <- groupNames
colnames(m) <- groupNames


    output$chorddiag <- renderChorddiag(
        chorddiag(m,
                  groupColors = groupColors,
                  groupnamePadding = input$groupnamePadding,
                  showTicks = input$showTicks,
                  margin = input$margin
        ))

}

shinyApp(ui = ui, server = server)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants