I have the following sample flexdashboard:
---
title: "Hover"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
data(iris)
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r}
iris %>% group_by(Species) %>%
summarise(mean = mean(Sepal.Length)) %>%
ggplot(aes(Species, mean)) + geom_col()
What I want is a tooltip when hovering over the bars in the plot and show its values. I read this article in SO How do I show the y value on tooltip while hover in ggplot2 but it works for Shiny. I tried this:
p <- iris %>% group_by(Species) %>%
summarise(mean = mean(Sepal.Length))
labels <- sprintf("<strong>%s</strong><br/>Mean: %f",
p$Species, p$mean) %>%
lapply(htmltools::HTML)
p %>% ggplot(aes(Species, mean)) + geom_col() + geom_text(aes(label = labels))
This creates an html tool with the specie and value, what I don't have is the hover (plot_hover maybe?) to show the tooltip.
Any help will be greatly appreciated
Regards,