Skip to contents

Loading indicator to be displayed when generating screenshot

Usage

loading(
  text = "Capturing screenshot, please wait...",
  type = c("standard", "hourglass", "circle", "arrows", "dots", "pulse"),
  color = "#246abe",
  background = "rgba(0,0,0,0.8)",
  size = "80px",
  ...
)

Arguments

text

Text to be displayed below loading animation.

type

Type of loading animation.

color

Color for text and loading indicator.

background

Background color.

size

Size (in pixels).

...

Other arguments.

Value

a list that can be used in capture() or capture_pdf().

Examples

library(shiny)
library(capture)

ui <- fluidPage(
  tags$h2("Capture (loading) example"),
  capture(
    selector = "body",
    filename = "all-page",
    scale = 5,
    icon("camera"), "Auto loading indicator",
    loading = loading(
      text = "Capturing screenshot...", 
      type = "arrows",
      color = "firebrick",
      size = "160px"
    )
  ),
  tags$br(),
  fluidRow(
    column(
      width = 4,
      wellPanel(
        tags$b("Parameters :"),
        selectInput(
          inputId = "loi",
          label = "Law:",
          choices = c("normal", "uniform", "exponential")
        )
      )
    ),
    column(
      width = 8,
      tags$div(
        id = "result-block",
        tags$b("Results :"),
        plotOutput(outputId = "plot"),
        uiOutput(outputId = "mean"),
        verbatimTextOutput(outputId = "raw")
      )
    )
  )
)

server <- function(input, output, session) {
  
  distrib_r <- reactive({
    switch(
      input$loi,
      "normal" = rnorm(1000),
      "uniform" = runif(1000),
      "exponential" = rexp(1000)
    )
  })
  
  output$plot <- renderPlot({
    hist(distrib_r())
  })
  
  output$mean <- renderUI({
    tags$p(tags$b("The mean is :"), round(mean(distrib_r()), 2))
  })
  
  output$raw <- renderPrint({
    summary(distrib_r())
  })
  
}

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