【问题标题】:How to add tooltips to html widgets in shiny dashboard如何在闪亮的仪表板中向 html 小部件添加工具提示
【发布时间】:2018-10-26 00:22:47
【问题描述】:

我正在努力为 Rshiny 中的 html 小部件添加工具提示。来自library(flexdashboard)bs_embed_tooltip 为一些闪亮的小部件完成了这项工作,但在将其应用于html 小部件时返回​​以下错误:

Error in .tag_validate(.) : 
  tag is not a shiny.tag - tag must be generated using htmltools or shiny

这是我的最小工作示例(从 shinydashboard 修改示例代码):

## app.R ##
library(shinydashboard)
library(flexdashboard)
library(bsplus) # For shiny tooltips

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
  dashboardBody(
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(plotOutput("plot1", height = 250) %>%
            bs_embed_tooltip("This is the output chart.", placement = 'bottom')
      ),

      box(title = "Controls",
          sliderInput("slider", "Number of observations:", 1, 100, 50) %>%
            bs_embed_tooltip("Use this slider to select the number of observations.", placement = 'bottom')
      ),
      box(title = "Guage",
          gaugeOutput("guage_value") # %>% bs_embed_tooltip("This gauge shows the input value from the slider.", placement = 'bottom')
      )
    )
  )
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)

  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })

  output$guage_value <- renderGauge({

    gauge(input$slider, min = 0, max = 100, symbol = '', gaugeSectors(
      danger = c(0, 30), warning = c(31, 70), success = c(71, 100) ))

  })
}

shinyApp(ui, server)

非常感谢您帮助解决评论中的代码。

【问题讨论】:

  • 这段代码对我有用,没有错误,工具提示会显示在它们的放置位置。
  • 我需要在 gaugeOutput("guage_value") 上显示工具提示。请关闭评论中的代码段。

标签: shiny shinydashboard


【解决方案1】:

试试这个新的仪表盒:

  box(title = "Guage",
      gaugeOutput("guage_value"),
      bsTooltip(id = "guage_value", title = "This gauge shows the input value from the slider.", placement = "bottom")
  )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-15
    • 2015-04-22
    • 2019-09-26
    • 2021-04-09
    相关资源
    最近更新 更多