| selection | R Documentation |
For complex interactions: define a named selection that can be referenced by marks and scales. This is how you build linked views, conditional encoding, and interactive legends.
selection(
spec,
name,
type = "point",
on = "click",
fields = NULL,
resolve = "global"
)
spec |
A glyph_spec |
name |
Selection name (referenced in conditional encodings) |
type |
"point", "interval", or "legend" |
on |
Event trigger: "click", "mouseover", "drag" |
fields |
Which data fields the selection projects onto |
resolve |
For composed views: "global", "union", "intersect" |
Modified glyph_spec
# Interactive legend: click legend entries to filter
glyph(mtcars, x = wt, y = mpg) |>
mark_point(color = cyl) |>
selection("legend_filter", type = "legend", fields = "cyl")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.