简体   繁体   English

R Shiny valueBox with popover/tooltip

[英]R Shiny valueBox with popover/tooltip

I try to make a popover/tooltip for a valueBox from shinydashboard, but nothing worked so far.我尝试从 shinydashboard 为 valueBox 制作弹出框/工具提示,但到目前为止没有任何效果。

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'.我尝试使用shinyBS,例如popify function,但随后出现错误警告:tagAssert 中的错误:预期object 与class 'shi

When I use the addTooltip or addPopover function, I get no error, but nothing appears when I hover over the valueBox.当我使用 addTooltip 或 addPopover function 时,我没有收到任何错误,但是当我在 valueBox 上使用 hover 时,什么也没有出现。 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)

You can use bsTooltip to add a tooltip to a Shiny input or output:您可以使用bsTooltip将工具提示添加到 Shiny 输入或 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.当您在框上方使用 hover 时,您会看到工具提示出现在其底部。

I recommend you checking this我建议你检查这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM