To create interactive facets, use gf_facet_wrap_interactive() or
gf_facet_grid_interactive() and use gf_labeller_interactive()
to create the labeller.
Arguments
- object
a ggplot graphic
- ...
additional arguments passed to
labellerand to the ggplot2 faceting function (ggplot2::facet_wrap()orggplot2::facet_grid()).- labeller
a labeller created using
gf_labeller_interactive()- interactive_on
one of "text" (strip text is made interactive), "rect" (strip rectangles are made interactive), or "both". Can be abbreviated.
Examples
mosaicData::Weather |>
gf_line_interactive(
high_temp ~ date,
color = ~city,
show.legend = FALSE,
tooltip = ~city,
data_id = ~city
) |>
gf_facet_wrap_interactive(
~year,
ncol = 1,
scales = "free_x",
labeller = gf_labeller_interactive(
data_id = ~year,
tooltip = ~ glue::glue("This is the year {year}")
)
) |>
gf_theme(theme_facets_interactive()) |>
gf_girafe(
options = list(
opts_hover_inv(css = "opacity:0.2;"),
opts_hover(css = "stroke-width:2;", nearest_distance = 40),
opts_tooltip(use_cursor_pos = FALSE, offx = 0, offy = -30)
)
)
