RinteRface/bs4Dash

When card is maximized, ggiraph plot tooltip not showing

ChocoTrail opened this issue · 1 comments

Really love the bs4Dash framework. Thank you for building it!

I am running into an issue when I have a ggiraph plot within a maximizable card/box. When the box is maximized the interactive tooltip doesn't work/show, but when the box is not maximized it works just fine. I have a simple reprex below that shows the issue.

library(shiny)
library(bs4Dash)
library(ggiraph)
library(ggplot2)
library(dplyr)
ui <- shiny::fluidPage(
  # add html dependencies
  bs4Dash:::add_bs4Dash_deps(htmltools::tags$body(), NULL),
  bs4Dash::box(
    width = 12,
    ggiraph::girafeOutput('example'),
    maximizable = TRUE
  )
)

server <- function(input, output, session) {
  output$example <- ggiraph::renderGirafe({
    plt_1 <- iris |> 
      dplyr::mutate(tooltip = paste0("Species: ", Species, "\n", 
                                     "Sepal Width: ", Sepal.Width)) |> 
      ggplot2::ggplot(ggplot2::aes(x = Petal.Length, y = Petal.Width, 
                                   tooltip = tooltip, color = as.factor(Species))) +
      ggiraph::geom_point_interactive(size = 2)
    
    ggiraph::girafe(ggobj = plt_1)
  })
}

shiny::shinyApp(ui, server)

Any direction would be great, thanks!

Hi @ChocoTrail,
thanks for your feedback. This is a z-index issue (when the box is maximized, the tooltip is behind the box). You can fix it with girafe_options and opts_tooltip by adding to your code (See also: https://davidgohel.github.io/ggiraph/reference/opts_tooltip.html):

ggiraph::girafe(ggobj = plt_1) |>
      girafe_options(
        opts_tooltip(zindex = 9999)
      )

As a side note, I actually don't see the plot rescaling after maximizing which removes the interest of using this maximized card.