I'm probably missing something really, really obvious... In Example 2 the hovertext show '1', the first value of the assigned tooltip column and does not change
I want to have a changing hover text like in example 1 without assinging f.e. color to y (like in example 2)
- with color = y
testdf <- data.frame(
"x" = c(1:10),
"y" = c(1:10))
test <- testdf %>%
ggplot2::ggplot() +
ggiraph::geom_line_interactive(
ggplot2::aes(x = x,
y = y,
color = y,
tooltip = y)
)
ggiraph::girafe(ggobj = test,
height_svg = 3.5,
options = list(
opts_sizing(rescale = T),
# Gestaltung des tooltips
opts_tooltip(css= "font-family: Helvetica; padding:3pt; color:white; background-color:#15253F; border-radius:5px"),
# Zoom
opts_zoom(max = 5),
# Hover Optionen
opts_hover(css = "stroke-width:2;"),
opts_hover_inv(css = "opacity:0.8"),
opts_toolbar(position = "topright", saveaspng = F)
))
- Without color = y
testdf <- data.frame(
"x" = c(1:10),
"y" = c(1:10))
test <- testdf %>%
ggplot2::ggplot() +
ggiraph::geom_line_interactive(
ggplot2::aes(x = x,
y = y,
tooltip = x)
)
ggiraph::girafe(ggobj = test,
height_svg = 3.5,
options = list(
opts_sizing(rescale = T),
# Gestaltung des tooltips
opts_tooltip(css= "font-family: Helvetica; padding:3pt; color:white; background-color:#15253F; border-radius:5px"),
# Zoom
opts_zoom(max = 5),
# Hover Optionen
opts_hover(css = "stroke-width:2;"),
opts_hover_inv(css = "opacity:0.8"),
opts_toolbar(position = "topright", saveaspng = F)
))
One solution would be to add a
geom_point_interactive
to represent the values. You can hide them by making the point very small (size = 0.05
).If you also want to have some information on the overall line, you can add this as a different variable in the
geom_line_interactive aes()
i.e.tooltip = "My line"
: