在shiny
的应用程序中,我有一个曲线图,有时需要一些时间才能计算出来.我想用waiter
包中的进度条来显示此计算的进度.有没有办法把waitress
加到modalDialog
上?下面是一个MWE,其中waitress
应用于整个页面,但我会发现,如果我只在modalDialog
上有一个栏,它会更好.
我已经判断了Demo的可能性:将其应用于actionButton
在我的实际应用程序中不起作用.将它显示为通知是可行的,但我不知道有什么方法可以将通知显示在屏幕的中心而不是角落.我猜"on Elements"就是我要找的,但是我的modalDialog
没有输入或输出id.
library(shiny)
library(shinipsum)
library(waiter)
library(plotly)
complicated_function <- function(){
waitress <- Waitress$new(theme = "overlay",min = 0,max = 20)
for(i in 1:20){
waitress$inc(1)
Sys.sleep(0.2)
}
waitress$close()
return(random_ggplotly())
}
ui <- fluidPage(
useWaitress(),
actionButton("plotButton", "Generate Plot")
)
server <- function(input,output,session){
modal1 <- modalDialog(
renderPlotly({
complicated_function()
})
)
observeEvent(input$plotButton,{
showModal(modal1)
})
}
shinyApp(ui, server)