【问题标题】:Shiny issues when rendering highchartOutput + wordcloud2Output in the same page在同一页面中呈现 highchartOutput + wordcloud2Output 时的闪亮问题
【发布时间】:2021-09-01 15:30:42
【问题描述】:

我正在寻找在我的 ui.R 中放入相同的 tabPanel :1 highchartOutput 和 1 wordcloud2Output 但只有我的 wordcloud2Output 打印。 我尝试隔离,我的 highchartOutput,没问题它在同一个 tabPanel 中没有 wordcloud2Output 运行。

示例:

  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

如果我将我的“wordcloud2Output”放在评论中,我的 highchartOutput 就会运行

shiny render with only highchartOutput

感谢您的帮助!

【问题讨论】:

    标签: r shiny shinydashboard r-highcharter wordcloud2


    【解决方案1】:

    使用uiOutput() 似乎可以解决问题。

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-13
      • 2020-03-01
      • 2022-06-24
      • 1970-01-01
      • 2017-10-21
      • 2020-07-27
      • 1970-01-01
      • 2016-06-09
      相关资源
      最近更新 更多