2
votes

I try to make a popover/tooltip for a valueBox from shinydashboard, but nothing worked so far.

I tried to use shinyBS, for example the popify function, but then I get the error Warning: Error in tagAssert: Expected an object with class 'shiny.tag'.

When I use the addTooltip or addPopover function, I get no error, but nothing appears when I hover over the valueBox. Any more suggestions?

library(shinydashboard)
library(shinyBS)

ui <- dashboardPage(
  dashboardHeader(title = 'Title', disable = TRUE),
  
  dashboardSidebar(),
  
  dashboardBody(
    
      valueBoxOutput("TestBox", width = NULL)))

server <- function(input, output, session) {
  
output$TestBox <- renderValueBox({
  
  popify(
    valueBox(
      value = "50 %",
      subtitle = "Test",
      color = "black")
  , title = "TestTitle", content = "TestContent", placement = "bottom", trigger = "hower", options = NULL)
})
# addPopover(session, id = "TestBox", title = "TestTitle", content = "TestContent", placement = "bottom", trigger = "hover", options = NULL)
}


shinyApp(ui = ui, server = server)
1

1 Answers

1
votes

You can use bsTooltip to add a tooltip to a Shiny input or output :

Here'is a minimal exemple based on what you provided :

library(shinydashboard)
library(shinyBS)

ui <- dashboardPage(
  dashboardHeader(title = 'Title', disable = TRUE),
  
  dashboardSidebar(),
  
  dashboardBody(
    valueBoxOutput("TestBox", width = 10),

    bsTooltip("TestBox", "you can choose whatever you want",
            "bottom", ),
    )
  )

server <- function(input, output, session) {
  
  output$TestBox <- renderValueBox({
    valueBox( value = "50 %",
              subtitle="Test",
              color = "black")
  })
  
}

When you hover over the box you see the tooltip appears at the bottom of it .

I recommend you checking this