我有一个闪亮的应用程序,使用shinydashboard和shinydashboardPlus。在标题中,我能够添加一个switchInput,以允许用户在两个选项之间切换。当选项改变时,整个UI (相当复杂)被更新以根据用户选择改变各种标签。这个过程需要几秒钟,导致应用程序没有响应,所以我想在switchInput旁边添加一个进度指示器或微调器,但我所有的尝试都失败了。(我尝试添加来自shinydashboardPlus的progressBar和shinyWidgets,但它们实际上都没有出现在标题中。)
编辑:也许关于我的用例的更多细节会有所帮助。当用户单击切换时,我调用了一个在多个步骤中操作的函数,整个函数大约需要20秒。在每个步骤之后,我希望更新进度条或微调器,以提示用户正在发生某些事情。此外,在单击之前和函数返回后,我希望隐藏进度条或微调器。
下面是一些非常简单的代码,它的头部包含switchInput。
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyWidgets)
# Define UI for application that draws a histogram
ui <- dashboardPage(skin = 'blue',
shinydashboardPlus::dashboardHeader(title = 'Example',
leftUi = tagList(
switchInput(inputId = 'swtLabels', label = 'Labels', value = TRUE,
onLabel = 'Label 1', offLabel = 'Label 2',
onStatus = 'info', offStatus = 'info', size = 'mini',
handleWidth = 230)
)
),
dashboardSidebar(),
dashboardBody()
)
server <- function(input, output) {}
# Run the application
shinyApp(ui = ui, server = server)发布于 2021-11-02 18:40:38
这接近你的预期吗?progress bar on dashboard header
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyWidgets)
# Define UI for application that draws a histogram
ui <- dashboardPage(skin = 'blue',
shinydashboardPlus::dashboardHeader(title = 'Example',
leftUi = tagList(
switchInput(inputId = 'swtLabels', label = 'Labels', value = TRUE,
onLabel = 'Label 1', offLabel = 'Label 2',
onStatus = 'info', offStatus = 'info', size = 'mini',
handleWidth = 230),
shinydashboardPlus::progressBar(
value = 100,
striped = TRUE,
animated = TRUE,
label = "loading...100%"
)
)
),
dashboardSidebar(),
dashboardBody()
)
server <- function(input, output) {}
# Run the application
shinyApp(ui = ui, server = server)https://stackoverflow.com/questions/69812166
复制相似问题