My giraffe rendering is very long, and I want the x-axis values to remain visible as the user scrolls down.
Below is a sample code that demonstrates this concept. I am open to different types of plots as long as they display the labels when hovering over each block. Any suggestions are welcome!
library(shiny)
library(tidyverse)
library(ggiraph)
ui <- fluidRow(girafeOutput("my_plot"))
server <- function(input, output){
output$my_plot <- renderGirafe({
data <- data.frame(
letter = rep(c(LETTERS, letters, paste0(LETTERS, letters))),
year = factor(rep_len(2000:2008, 78)),
value = floor(runif(78, 1, 6))
)
g <- ggplot(data) +
geom_tile_interactive(aes(x = year, y = letter, fill = value, tooltip = value)) +
scale_x_discrete(position = "top") +
coord_fixed() +
theme_classic() +
theme(axis.text.x = element_text(
angle = 90,
hjust = 0.5,
vjust = 0,
size = 17
))
girafe(ggobj = g,
options = list(opts_sizing(rescale = F)),
width_svg = 20,
height_svg = 50
)
})
}
shinyApp(ui = ui, server = server)