首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Shiny (shinydashboard/shinydashboardplus)标题中添加进度指示器

在Shiny (shinydashboard/shinydashboardplus)标题中添加进度指示器
EN

Stack Overflow用户
提问于 2021-11-02 14:35:08
回答 1查看 56关注 0票数 0

我有一个闪亮的应用程序,使用shinydashboard和shinydashboardPlus。在标题中,我能够添加一个switchInput,以允许用户在两个选项之间切换。当选项改变时,整个UI (相当复杂)被更新以根据用户选择改变各种标签。这个过程需要几秒钟,导致应用程序没有响应,所以我想在switchInput旁边添加一个进度指示器或微调器,但我所有的尝试都失败了。(我尝试添加来自shinydashboardPlus的progressBar和shinyWidgets,但它们实际上都没有出现在标题中。)

编辑:也许关于我的用例的更多细节会有所帮助。当用户单击切换时,我调用了一个在多个步骤中操作的函数,整个函数大约需要20秒。在每个步骤之后,我希望更新进度条或微调器,以提示用户正在发生某些事情。此外,在单击之前和函数返回后,我希望隐藏进度条或微调器。

下面是一些非常简单的代码,它的头部包含switchInput。

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2021-11-02 18:40:38

这接近你的预期吗?progress bar on dashboard header

代码语言:javascript
复制
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)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69812166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档