Skip to contents

Six verbs that act on a map already on the page, through a proxy from stage_map_proxy(). Each takes the proxy first and returns it invisibly, so calls pipe. They change what the reader sees and what input$<id>_selected and input$<id>_state report (see stage_map_output()); a verb never changes input$<id>_pick, which is the reader's.

Usage

stage_map_select(map, ids)

stage_map_highlight(map, ids, ..., links = NULL)

stage_map_show(map, ids)

stage_map_hide(map, ids)

stage_map_enable(map, ids)

stage_map_disable(map, ids, reason)

Arguments

map

A proxy made by stage_map_proxy(). stage_map_highlight() also takes a stage_map() widget.

ids

The ids of the cards, as text that is not blank or whole numbers, with none missing; NULL or a vector of length zero for none. It has no default.

...

Must stay empty. It makes every argument after it a named argument.

A data frame with the columns from and to (card ids) and, if wanted, kind, or NULL. It lights exactly those links instead of every link between two lit cards; a link with no kind lights every link of that pair. Both ends must be in ids, so links with no ids is an error; a data frame with no rows counts as NULL. The links of input$<id>_state$highlighted can be given back as they are.

reason

Why the card is disabled, shown to the reader: one string for all the ids, or one for each id. It has no default and cannot be blank.

Value

The map: a proxy is returned invisibly, a widget (stage_map_highlight() only) as it is, with the highlight set. An id that a widget does not have is an error of class stagemap_error_id, a link that does not join ids an error of class stagemap_error_data, and a map of the wrong kind an error of class stagemap_error_widget.

Details

  • stage_map_select() selects the cards in ids, the last as the lead, and lets go of what was selected before.

  • stage_map_highlight() keeps the cards in ids and the links between them clear and fades the rest.

  • stage_map_show() and stage_map_hide() show a card again and hide it.

  • stage_map_enable() and stage_map_disable() take a card out of use and put it back. A disabled card is greyed out, the reader cannot select it, and the map shows the reason.

stage_map_highlight() also takes a stage_map() widget, to light cards from the first draw: it checks the ids against the map, replaces what an earlier call lit, and returns the widget. The other five need a map that is drawn, so a widget is an error of class stagemap_error_widget.

Ids are text that is not blank, or whole numbers, and are compared as text, so 7 and "7" are one id. ids has no default, so a forgotten argument is an error and never a silent clear. NULL and a vector of length zero mean no ids: stage_map_select() and stage_map_highlight() let go, and the other four do nothing. A card the map does not have is not an error for a proxy, which does not know the map: the page writes a warning to the browser's console and changes nothing. stage_map_show(), stage_map_hide(), stage_map_enable() and stage_map_disable() send one command for each id.

[Experimental] stage_map_show(), stage_map_hide(), stage_map_enable() and stage_map_disable() may change.

See also

Other shiny: stage_map_output()

Examples

map <- stage_map(
  cards = data.frame(
    id = c("draft", "review", "publish"),
    label = c("Draft", "Review", "Publish"),
    stage = c("write", "check", "ship"),
    lane = "docs"
  )
) |>
  add_links(data.frame(from = c("draft", "review"), to = c("review", "publish")))
# Light two cards from the first draw; the link between them stays clear and the rest fades.
lit <- stage_map_highlight(map, c("draft", "review"))
class(lit)
#> [1] "stage_map"       "stagemap_widget" "htmlwidget"     
if (FALSE) { # interactive()
library(shiny)
cards <- data.frame(
  id = c("draft", "review", "publish"),
  label = c("Draft", "Review", "Publish"),
  stage = c("write", "check", "ship"),
  lane = "docs"
)
ui <- fluidPage(
  stage_map_output("map", height = "420px"),
  actionButton("hide", "Hide Review"),
  actionButton("show", "Show Review"),
  actionButton("block", "Disable Publish")
)
server <- function(input, output, session) {
  output$map <- render_stage_map(
    stage_map(cards) |>
      add_links(data.frame(from = c("draft", "review"), to = c("review", "publish")))
  )
  proxy <- stage_map_proxy("map")
  observeEvent(input$hide, stage_map_hide(proxy, "review"))
  observeEvent(input$show, stage_map_show(proxy, "review"))
  observeEvent(input$block, stage_map_disable(proxy, "publish", reason = "Waiting for the review"))
  # Light the cards that are selected, and let go when nothing is.
  observeEvent(input$map_selected, ignoreNULL = FALSE, {
    stage_map_highlight(proxy, input$map_selected)
  })
}
shinyApp(ui, server)
}