简体   繁体   English

闪亮仪表板的加载页面

[英]Loading Page for Shiny Dashboard

I am trying to create a loading page for my dashboard but I can't seem to get it to work.我正在尝试为我的仪表板创建一个加载页面,但我似乎无法让它工作。 I followed the example here;我按照这里的例子; Shiny Dashboard - display a dedicated "loading.." page until initial loading of the data is done but it is for fluid page and not shiny dashboard and I can't figure out how to adapt it. 闪亮的仪表板 - 显示一个专用的“加载..”页面,直到数据的初始加载完成,但它是用于流体页面而不是闪亮的仪表板,我不知道如何调整它。

Any help would be appreciated!任何帮助,将不胜感激!

I would preferably like the loading page just to be a fluid page (no header or sidebar) and then have my main dashboard have the shiny dashboard aspects.我希望加载页面只是一个流畅的页面(没有标题或侧边栏),然后让我的主仪表板具有闪亮的仪表板方面。

Extra: If I could add a gif to the loading screen, that would be amazing.额外:如果我可以在加载屏幕上添加一个 gif,那就太棒了。 Something like:类似的东西:

<iframe src="https://giphy.com/embed/BlmF3MhGfa4SY" width="480" height="360" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/plane-BlmF3MhGfa4SY">via GIPHY</a></p>

[break] [休息]

library (shiny)
library (shinydashboard)
library(shinyjs)


rm(list=ls())

appCSS <- "
#loading_page {
  position: absolute;
  background: #000000;
  opacity: 0.9;
  z-index: 100;
  left: 0;
  right: 0;
  height: 100%;
  text-align: center;
  color: #FFFFFF;
}
"
header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody("It worked!")


ui <- dashboardPage(
  useShinyjs(),
  inlineCSS(appCSS),
  div(
    id = "loading_page",
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody("Loading...")
  ),
  hidden(
    div(
      id = "main_content",
      header, sidebar, body
    )
  )
)


server = function(input, output, session) {
    # Simulate work being done for 4 second
    Sys.sleep(4)

    hide("loading_page")
    show("main_content") 
  }

shinyApp(ui, server)

Try this library shinycssloaders试试这个库shinycssloaders

library(shiny)
library(shinycssloaders)
library(highcharter)

ui <- fluidPage(
        mainPanel(
                plotOutput("my_plot")  %>% withSpinner(color="#0dc5c1")
        )
)

server <- function(input, output){
        
        output$my_plot <- renderPlot({
                Sys.sleep(1)
                plot(mtcars)})
}

shinyApp(ui, server)

在此处输入图片说明

Try this library: waiter Very easy to use with minimal and clean code.试试这个库: waiter使用最少且干净的代码非常容易使用。 Comes with multiple loading animations.带有多个加载动画。

Usage:用法:

library(shiny)
library(waiter)

ui <- fluidPage(
  use_waiter(),
  actionButton("show", "Show loading for 5 seconds")
)

server <- function(input, output, session){
  observeEvent(input$show, {
    show_waiter(spin_fading_circles())
    Sys.sleep(4)
    hide_waiter()
  })
}

if(interactive()) shinyApp(ui, server)

Link: https://cran.r-project.org/web/packages/waiter/readme/README.html链接: https : //cran.r-project.org/web/packages/waiter/readme/README.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM