Skip to contents

Marks rows as selected by object id. A chart draws them as its own selection; a map hands them to the view's selection manager, which highlights them and reports the new selection back as input$<output_id>$selection. Object ids are row numbers, so a chart and a map built from the same data frame select each other's rows.

Usage

set_selection(proxy, object_ids, ...)

Arguments

proxy

Defines which arc_proxy() or arc_map_proxy() to select on.

object_ids

Defines which rows to select, by object id. An empty vector clears the selection.

...

Reserved for methods.

layer

default NULL. Defines which map layer to select in, by name. NULL selects in every layer. Maps only.

mode

default "replace". Defines what these ids do to the current selection, one of "replace", "add", "remove", or "toggle". Maps only.

Value

proxy, invisibly.

Details

On a map the selection is a set that persists across calls, which is what mode operates on and what a click on a selectable layer (add_layer()) or a drawn arc_draw_selection() shape adds to. set_highlight() styles it and arc_selected() reads it.

Examples

df <- data.frame(species = c("a", "b", "c"), mass = c(1, 5, 3))

if (interactive()) {
  arc_proxy("chart", arc_col(df, species, mass)) |>
    set_selection(c(1, 2))
}