| interact | R Documentation |
Add interactive behaviors to a glyph spec
interact(
spec,
tooltip = FALSE,
zoom = FALSE,
brush = FALSE,
hover = NULL,
click = NULL,
crossfilter = FALSE,
nearest = FALSE
)
spec |
A glyph_spec |
tooltip |
Show values on hover. TRUE for auto-generated, or a glue-style template string like "{x}: {y} ({color})". |
zoom |
Enable scroll-to-zoom and pan. The scroll wheel, a trackpad
pinch, a two-finger pinch and a double-click/double-tap always zoom;
dragging pans (see |
brush |
Enable rectangular brush selection. When |
hover |
Highlight mark on hover ("enlarge", "brighten", "outline", or NULL) |
click |
Action on click: "select", "filter", "url", or a callback name |
crossfilter |
Link this plot's selections to other plots in a layout |
nearest |
Snap selection to nearest point (useful for line charts) |
Modified glyph_spec
glyph(mtcars, x = wt, y = mpg) |>
mark_point(color = cyl) |>
interact(
tooltip = "{cyl} cylinders\n{mpg} mpg at {wt} tons",
zoom = TRUE,
hover = "enlarge",
brush = TRUE,
crossfilter = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.