This timeline is horizontal, use spsTimeline to define it and use updateSpsTimeline on server to update it.

spsTimeline(id, up_labels, down_labels, icons, completes)

updateSpsTimeline(
  session,
  id,
  item_no,
  complete = TRUE,
  up_label = NULL,
  down_label = NULL
)

Arguments

id

html ID of the timeline if you are using shiny modules: use namespace function to create the ID but DO NOT use namespace function on server.

up_labels

a vector of strings, text you want to display on top of each timeline item, usually like year number. If you do not want any text for a certain items, use "" to occupy the space.

down_labels

a vector of strings, text you want to display at the bottom of each timeline item.

icons

a list of icon objects. If you do not want an icon for certain items, use div() to occupy the space.

completes

a vector of TRUE or FALSE, indicating if the items are completed or not. Completed items will become green.

session

current shiny session

item_no

integer, which item number counting from left to right you want to update

complete

bool, is this item completed or not

up_label

the item_no associated up label to update

down_label

the item_no associated down label to update

Value

returns a shiny component

Details

up_labels, down_labels, icons, completes must have the same length.

Examples

if(interactive()){
    ui <- fluidPage(
        column(6,
               spsTimeline(
                   "b",
                   up_labels = c("2000", "2001"),
                   down_labels = c("step 1", "step 2"),
                   icons = list(icon("table"), icon("gear")),
                   completes = c(FALSE, TRUE)
               )
        ),
        column(6,
               actionButton("a", "complete step 1"),
               actionButton("c", "uncomplete step 1"))

    )

    server <- function(input, output, session) {
        observeEvent(input$a, {
            updateSpsTimeline(session, "b", 1, up_label = "0000", down_label = "Finish")
        })
        observeEvent(input$c, {
            updateSpsTimeline(session, "b", 1, complete = FALSE,
                              up_label = "9999", down_label = "Step 1")
        })
    }

    shinyApp(ui, server)
}