Creates an interactive plot using ggiraph. This function extends
gf_spoke() with interactive features like tooltips and clickable elements.
Arguments
- object
When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument.
- gformula
A formula with shape
y ~ x. Faceting can be achieved by including|in the formula.- data
The data to be displayed in this layer.
- tooltip
A formula specifying a variable for tooltips, or a character vector.
- data_id
A formula or character vector specifying data identifiers for interactive selection.
- ...
Additional arguments passed to the underlying geom.
- alpha, color, size, shape, fill, group, stroke
Aesthetics passed to the geom.
- xlab, ylab, title, subtitle, caption
Labels for the plot.
- show.legend
Logical. Should this layer be included in the legends?
- show.help
Logical. If
TRUE, display some minimal help.- inherit
Logical. If
TRUE, inherit aesthetics from previous layers.- environment
An environment in which to evaluate the formula.
Value
A gg object that can be displayed with gf_girafe().
Additional interactive features
onclick: JavaScript code (as character string) executed when clicking elements.Additional ggiraph aesthetics may be available depending on the geom.
Examples
if (require(dplyr)) {
expand.grid(x = 0:10, y = 0:10) |>
mutate(
direction = round(x * y / 100 * 2 * pi, 1),
size = (20 + x + y) / 50
) |>
gf_spoke_interactive(
y ~ x, angle = ~ direction, radius = ~ size,
tooltip = ~ paste(
"angle:", round(direction / 2 / pi * 360, 1),
"degrees; size =", size),
data_id = ~ paste(x, "-", y),
hover_nearest = TRUE
) |>
gf_point() |>
gf_girafe(
options = list(
opts_hover(css = "stroke: red; stroke-width: 2;", nearest_distance = 10)
)
)
}
