Skip to contents

Turns the map into a story the reader plays step by step, with a caption for each step. Without steps, the map has one step per stage and shows no player. Adding steps brings the step player, unless stage_map() was given player = FALSE.

Usage

add_steps(map, steps, ..., changes = NULL, intro = NULL)

Arguments

map

A stage_map() widget.

steps

A data frame with one row per step, in playing order. See "Columns". NULL, or a data frame with no rows (such as data.frame()), adds no steps and no player.

...

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

changes

A data frame with one row per card per step, or NULL (or no rows) for steps that change no card. Every changes$step must be an id in steps$id, every changes$card an id in the map's cards$id, every changes$stage an id in its stages$id and every changes$status a status of the map; a card can change once at a step. An id that does not match, or a card changed twice at a step, is an error of class stagemap_error_data that names the ids or rows. changes without steps is an error of class stagemap_error_layer. See "Columns".

intro

The caption shown before the first step, as one string, or NULL for none. Added only with steps.

Value

The widget, with the steps added. A widget that has steps already is an error of class stagemap_error_layer. A stage of a step that is not a stage of the map, a step of a link that is not in steps, and an id given twice in steps, are errors of class stagemap_error_data that name the ids.

Details

A step can also change cards. changes lists, for each step, the cards whose status, stage or visibility change when the reader reaches it, and they keep the change in the steps after it. A card moved to another stage glides there, following the map's motion (see stage_map()). The change shows in the picture as a map drawn again at that step.

Columns

Required columns are marked with an asterisk.

  • steps: id*, label*, kicker, text, stage (the stage the step is about), file, code, code_lines (a file's text and the lines to mark, as for a stage).

  • changes: step* (a steps id), card* (a card id from the map's cards), status (a status id, see the "Statuses" section of stage_map()), stage (a stage id: the card moves there), hidden (TRUE hides the card, FALSE shows it again). One row per card per step. NA in status, stage or hidden leaves that property as it was; a status can be changed to another, but not cleared.

Examples

map <- stage_map(
  cards = data.frame(id = "a", label = "Draft", stage = "w", lane = "docs", status = "running"),
  stages = data.frame(id = c("w", "c"), label = c("Write", "Check")),
  lanes = data.frame(id = "docs", label = "Docs")
) |>
  add_steps(
    data.frame(id = c("one", "two"), label = c("The draft starts", "The draft moves on")),
    changes = data.frame(step = "two", card = "a", status = "done", stage = "c"),
    intro = "How the notes were written"
  )
class(map)
#> [1] "stage_map"       "stagemap_widget" "htmlwidget"     
if (FALSE) { # interactive()
map
}