【问题标题】:withSpinner not showing repeatedly when using uiOutput in Shiny在 Shiny 中使用 uiOutput 时 withSpinner 不重复显示
【发布时间】:2018-09-29 20:37:25
【问题描述】:

请帮我在反应值出现时重复显示微调器(点击动作按钮时)

UI.R

library(shinycssloaders)
ui <- fluidPage(
  titlePanel("Hello Shiny!"),
  fluidRow(
    column(width = 2, actionButton("actButton", "Click")),
    column(width = 6, withSpinner(uiOutput("htmlExample")))
  )
)

服务器.R

library(shiny)
library(shinycssloaders)

server<-function(input, output)
{
  getRandomNumber <- function() {
    Sys.sleep(1)
    randamNumber <- runif(n = 1, min = 1e-12, max = .9999999999)
    return(HTML(paste0("<h1>Hai Render Html ................",
                       randamNumber, "<h1>")))
  }
  observeEvent(input$actButton,{
    if (input$actButton == 0)
      return(0)
    isolate({
      output$htmlExample <- renderUI({
        getRandomNumber()
      })
    })
  })
}

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    如何使用 busyIndicator 包中的 shinysky 代替。

    这是一个示例代码:

    library(shinysky)
    library(shiny)
    
    ui <- fluidPage(
      titlePanel("Hello Shiny!"),
      fluidRow(
        column(width = 2, actionButton("actButton", "Click")),
        busyIndicator(text = 'Rendering HTML....'),
        column(width = 6, uiOutput("htmlExample"))
      )
    )
    
    server<-function(input, output)
    {
      getRandomNumber <- function() {
        Sys.sleep(2)
        randamNumber <- runif(n = 1, min = 1e-12, max = .9999999999)
        return(HTML(paste0("<h1>Hi Render Html ................",
                           randamNumber, "<h1>")))
      }
      observeEvent(input$actButton,{
        if (input$actButton == 0)
          return(0)
        isolate({
          output$htmlExample <- renderUI({
            getRandomNumber()
          })
        })
      })
    }
    
    shinyApp(ui, server)
    

    希望对你有帮助!

    【讨论】:

    • 我在整个项目中都使用 withSpinner。所以我需要解决方案。我真的很感谢你的回复
    • @S.Elavarasan,你有没有想过这个问题?谢谢。
    猜你喜欢
    • 2021-08-06
    • 1970-01-01
    • 2020-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-15
    • 2015-10-28
    • 2019-10-28
    相关资源
    最近更新 更多