progressSweetAlert: Progress bar in a sweet alert

Description Usage Arguments Examples

Description

Progress bar in a sweet alert

Usage

1
2
3
progressSweetAlert(session, id, value, total = NULL,
  display_pct = FALSE, size = NULL, status = NULL, striped = FALSE,
  title = NULL)

Arguments

session

The session object passed to function given to shinyServer.

id

An id used to update the progress bar.

value

Value of the progress bar between 0 and 100, if >100 you must provide total.

total

Used to calculate percentage if value > 100, force an indicator to appear on top right of the progress bar.

display_pct

logical, display percentage on the progress bar.

size

Size, ‘NULL' by default or a value in ’xxs', 'xs', 'sm', only work with package 'shinydashboard'.

status

Color, must be a valid Bootstrap status : primary, info, success, warning, danger.

striped

logical, add a striped effect.

title

character, optional title.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## Not run: 

if (interactive()) {

library("shiny")
library("shinyWidgets")


ui <- fluidPage(
  tags$h1("Progress bar in Sweet Alert"),
  useSweetAlert(), # /!\ needed with 'progressSweetAlert'
  actionButton(
    inputId = "go",
    label = "Launch long calculation !"
  )
)

server <- function(input, output, session) {

  observeEvent(input$go, {
    progressSweetAlert(
      session = session, id = "myprogress",
      title = "Work in progress",
      display_pct = TRUE, value = 0
    )
    for (i in seq_len(50)) {
      Sys.sleep(0.1)
      updateProgressBar(
        session = session,
        id = "myprogress",
         value = i*2
      )
    }
    closeSweetAlert(session = session)
    sendSweetAlert(
      session = session,
      title =" Calculation completed !",
      type = "success"
    )
  })

}

shinyApp(ui = ui, server = server)

}


## End(Not run)

dreamRs/shinyWidgets documentation built on June 5, 2019, 4:07 a.m.