Selection effect settings
Allows customization of the rendering of
selected graphic elements.
Use opts_selection for interactive geometries in panels,
opts_selection_key for interactive scales/guides and
opts_selection_theme for interactive theme elements.
opts_selection( css = NULL, type = "multiple", only_shiny = TRUE, selected = character(0) ) opts_selection_key( css = NULL, type = "single", only_shiny = TRUE, selected = character(0) ) opts_selection_theme( css = NULL, type = "single", only_shiny = TRUE, selected = character(0) )
css |
css to associate with elements when they are selected.
It must be a scalar character. It can also be constructed with
|
type |
selection mode ("single", "multiple", "none") when widget is in a Shiny application. |
only_shiny |
disable selections if not in a shiny context. |
selected |
character vector, id to be selected when the graph will be initialized. |
IMPORTANT: When applying a fill style with the css argument,
be aware that the browser's CSS engine will apply it also to line elements,
if there are any that use the selection feature. This will cause an undesired effect.
To overcome this, supply the argument css using girafe_css,
in order to set the fill style only for the desired elements.
Other girafe animation options:
girafe_options(),
opts_hover(),
opts_sizing(),
opts_toolbar(),
opts_tooltip(),
opts_zoom()
library(ggplot2)
dataset <- mtcars
dataset$carname = row.names(mtcars)
gg <- ggplot(
data = dataset,
mapping = aes(x = wt, y = qsec, color = disp,
tooltip = carname, data_id = carname) ) +
geom_point_interactive() + theme_minimal()
x <- girafe(ggobj = gg)
x <- girafe_options(x,
opts_selection(type = "multiple",
css = "fill:red;stroke:gray;r:5pt;") )
if( interactive() ) print(x)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.