将进度条放在中心并更改R Shiny中消息框的大小

问题描述 投票:0回答:1

我正在编写一个 R 闪亮的 Web 应用程序。我正在寻找一种方法将进度条放在网页的中心并调整进度条的大小。我使用的函数是“withProgress”,但是我很难找到位置和大小的参数。有什么建议吗?

withProgress(
      message = 'Running ......',
      detail = 'This may take a while.',
      value = 0,
      {
        ......
      }
    )
r shiny progress-bar
1个回答
0
投票

使用一些 CSS 来定位进度条容器(通知面板):

#shiny-notification-panel {
    /* Position bottom-right corner in the center of the screen. */
    position: fixed;
    bottom: 50%;
    right: 50%;
    /* Shift the position to center alignment. */
    transform: translate(50%, 50%);
    width: 700px;
}

在应用程序中:

library(shiny)

ui <- fluidPage(
  tags$style(HTML(r"(
    #shiny-notification-panel {
      position: fixed;
      bottom: 50%;
      right: 50%;
      transform: translate(50%, 50%);
      width: 700px;
    }
  )")),
  titlePanel("Progress"),
  textOutput("progress"),
)

server <- function(input, output, session) {
  output$progress <- renderText({
    withProgress(
      message = 'Processing...',
      detail = 'This may take a while...',
      value = 0,
      Sys.sleep(1000)
    )
    "Done!"
  })
}

shinyApp(ui, server)
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.