简体   繁体   中英

Shiny issues when rendering highchartOutput + wordcloud2Output in the same page

I'm looking for put in the same tabPanel in my ui.R : 1 highchartOutput and 1 wordcloud2Output But only my wordcloud2Output print. I try to isolate, my highchartOutput, no problem it's run without wordcloud2Output in the same tabPanel.

Exemple :

  ui <- fluidPage(
    
    navbarPage(
      "Try put Wordcloud2 and Highcharter in the same page",
      id = "main_navbar",
      
      tabPanel(
        "MytabPanel",
        fluidRow(
          width = 12,
          column(width = 7, wordcloud2Output("tdb1_wordcloud", height = 620)),
          column(width = 5, highchartOutput("tdb1_myplot", height = 620)))) ))
  
#_______________________
  
  server <- function(input, output, session) {
    
    output$tdb1_wordcloud <- renderWordcloud2({
      wordcloud2(data.table(word = c("email","phone","visit"), freq = c(10,15,4))) })
    
    output$tdb1_myplot <- renderHighchart({
      x <- c(rnorm(10000), rnorm(1000, 4, 0.5))
      hchart(x, name = "data") }) }

#_______________________
  
  runApp(list(ui = ui, server = server),launch.browser = TRUE)

shiny render with wordcloud2Output + highchartOutput

If i put my 'wordcloud2Output' in comment, my highchartOutput run

shiny render with only highchartOutput

Thanks for your help!

Using uiOutput() seems to fix the issue.

library(shiny)
library(highcharter)
library(wordcloud2)
library(data.table)

ui <- fluidPage(
    
    navbarPage(
        "Try put Wordcloud2 and Highcharter in the same page",
        id = "main_navbar",
        
        tabPanel(
            "MytabPanel",
            fluidRow(
                width = 12,
                column(width = 7, wordcloud2Output("tdb1_wordcloud", height = 620)),
                column(width = 5, uiOutput('hc')))) ))
    

#_______________________

server <- function(input, output, session) {
    
    output$hc <- renderUI({highchartOutput("tdb1_myplot", height = 600)})
    
    output$tdb1_wordcloud <- renderWordcloud2({
        wordcloud2(data.table(word = c("email","phone","visit"), freq = c(10,15,4))) })
    
    output$tdb1_myplot <- renderHighchart({
        x <- c(rnorm(10000), rnorm(1000, 4, 0.5))
        hchart(x, name = "data") })
}

#_______________________

runApp(list(ui = ui, server = server),launch.browser = TRUE)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM