r - 在 R Shiny 中完成 100% 后,是否可以关闭或删除 shinyWidgets 的进程栏?
问题描述
流程完成后如何删除进度条?任何人都可以帮助我。我使用 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)
解决方案
完成后可以使用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)
推荐阅读
- heroku - Problem with deploying my first streamlit app on heroku
- javascript - 如何在switch语句中放置条件
- c++ - C ++逗号分隔的输入数组代码过早退出
- angular - 在构造函数中从服务接收数据时,接收到的数据不会显示在模板中
- database - Laravel 队列很长
- javascript - JS - URLSearchParams - 添加参数
- html - 为什么我的网页的宽度会根据它显示的屏幕而变化?
- guidewire - 什么是导丝中的有效实体以及我们如何创建它?
- ar.js - 如何从android webview中的资产文件夹加载ar.js自定义图像标记
- excel - 在 Excel 中删除字符串中的特定字符串