【问题标题】:Is it Possible to close or remove processbar of shinyWidgets after complete 100% in R shiny?在 R 闪亮完成 100% 后,是否可以关闭或删除闪亮小部件的进程栏?
【发布时间】:2020-07-08 08:16:57
【问题描述】:

进程完成后如何移除进度条?任何人都可以帮助我。我使用 ShinyWidgets 添加了一个进度条。

界面部分

ui <- fluidPage(
              column(
                width = 7,
                tags$b("Other options"), be(),
    
       progressBar(
              id = "pb2",
              value = 0,
              total = 100,
              title = "",
              display_pct = TRUE,
              status = "custom"
                ),
                tags$style(".progress-bar-custom {background-color: #25c484;}"),
       
                DTOutput("intTable")
              )
            )
            

服务器部分

        server <- function(input, output, session) {
          adae<-read_sas("DATAPATH")## data
        
            for (i in 1:100) {
              updateProgressBar(
                session = session,
                id = "pb2",
                value = i, total = 100
              )
              Sys.sleep(0.1)
            }
        ####==Here I want to close this ProgressBar==######
            output$intTable<-renderDT({adae %>%
                datatable(rownames = FALSE, options = list(dom = 't', pageLength = 200))
            })
        
        }
shinyApp(ui = ui, server = server)

【问题讨论】:

    标签: r shiny shinydashboard shinyapps


    【解决方案1】:

    完成后可以使用shinyjs包隐藏

    library(shiny)
    library(shinyjs)
    library(DT)
    
    ui <- fluidPage(
        useShinyjs(),
        column(
            width = 7,
            tags$b("Other options"),
            div(id = "pb2_vis",
                progressBar(
                    id = "pb2",
                    value = 0,
                    total = 100,
                    title = "",
                    display_pct = TRUE,
                    status = "custom"
                )
            ),
            tags$style(".progress-bar-custom {background-color: #25c484;}"),
            
            DTOutput("intTable")
        )
    )
    
    server <- function(input, output, session) {
        
        for (i in 1:10) {
            updateProgressBar(
                session = session,
                id = "pb2",
                value = i, total = 10
            )
            Sys.sleep(0.2)
        }
        ####==Here I want to close this ProgressBar==######
        
        data <- reactive({
            head(mtcars)
        })
        
        observeEvent(data(),{
            hide("pb2_vis")
        })
        
        output$intTable<- renderDT({data() %>%
                datatable(rownames = FALSE, options = list(dom = 't', pageLength = 200))
        })
        
    }
    
    shinyApp(ui = ui, server = server)
    

    【讨论】:

    • 我们也可以改变条的宽度吗?
    猜你喜欢
    • 2021-01-14
    • 1970-01-01
    • 2019-01-04
    • 2018-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-05
    • 1970-01-01
    相关资源
    最近更新 更多