pgPaneUpdate: A draggable progress panel

Description Usage Arguments Value Examples

Description

Creates a panel that displays multiple progress items. Use pgPaneUI on UI side and use pgPaneUpdate to update it.

A overall progress is automatically calculated on the bottom.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
pgPaneUI(
  pane_id,
  titles,
  pg_ids,
  title_main = NULL,
  opened = FALSE,
  top = "3%",
  right = "2%"
)

pgPaneUpdate(pane_id, pg_id, value, session = getDefaultReactiveDomain())

Arguments

pane_id

Progress panel main ID, use ns wrap it on pgPaneUI but not on pgPaneUpdate if using shiny module

titles

labels to display for each progress, must have the same length as pg_ids

pg_ids

a character vector of IDs for each progress. Don't forget to use ns wrap each ID.

title_main

If not specified and pane_id contains 'plot', title will be 'Plot Prepare'; has 'df' will be 'Data Prepare', if neither will be "Progress"

opened

bool, if this panel is opened at start

top

css style off set to the current windown top

right

css style off set to the current windown right

pg_id

a character string of ID indicating which progress within this panel you want to update. Do not use ns(pg_id) to wrap it on server

value

0-100 number to update the progress you use pg_id to choose

session

current shiny session

Value

returns HTML elements

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
if(interactive()){
    # try to slide c under 0
    ui <- fluidPage(
        h4("Use your mouse to drag it"),
        actionButton("a", "a"),
        actionButton("b", "b"),
        sliderInput("c", min = -100,
                    max = 100, value = 0,
                    label = "c"),
        pgPaneUI(
            pane_id = "thispg",
            titles = c("this a", "this b", " this c"),
            pg_ids = c("a", "b", "c"),
            title_main = "Example Progress",
            opened = TRUE,
            top = "30%",
            right = "50%"
        )

    )
    server <- function(input, output, session) {
        observeEvent(input$a, {
            for(i in 1:10){
                pgPaneUpdate("thispg", "a", i*10)
                Sys.sleep(0.3)
            }
        })
        observeEvent(input$b, {
            for(i in 1:10){
                pgPaneUpdate("thispg", "b", i*10)
                Sys.sleep(0.3)
            }
        })
        observeEvent(input$c, pgPaneUpdate("thispg", "c", input$c))
    }
    shinyApp(ui, server)
}

spsComps documentation built on Feb. 3, 2022, 1:07 a.m.