ggiraph (version 0.8.9)

opts_selection: Selection effect settings

Description

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. Use opts_selection_inv for the effect on the rest of the geometries, while some are selected (inverted operation).

Usage

opts_selection(
  css = NULL,
  type = c("multiple", "single", "none"),
  only_shiny = TRUE,
  selected = character(0)
)

opts_selection_inv(css = NULL)

opts_selection_key( css = NULL, type = c("single", "multiple", "none"), only_shiny = TRUE, selected = character(0) )

opts_selection_theme( css = NULL, type = c("single", "multiple", "none"), only_shiny = TRUE, selected = character(0) )

Arguments

css

css to associate with elements when they are selected. It must be a scalar character. It can also be constructed with girafe_css(), to give more control over the css for different element types.

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.

See Also

girafe_css(), girafe_css_bicolor()

Other girafe animation options: girafe_defaults(), girafe_options(), init_girafe_defaults(), opts_hover(), opts_sizing(), opts_toolbar(), opts_tooltip(), opts_zoom(), set_girafe_defaults()

Examples

Run this code
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", only_shiny = FALSE,
    css = "fill:red;stroke:gray;r:5pt;") )
if( interactive() ) print(x)

Run the code above in your browser using DataLab