spsTimeline | R Documentation |
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
)
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 |
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 |
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 |
down_label |
the |
up_labels
, down_labels
, icons
, completes
must have the same
length.
returns a shiny component
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.