使用shinybs的闪亮app中的文本的弹出/工具提示

时间:2017-10-09 14:09:21

标签: r shiny shinybs

有没有办法将弹出窗口或工具提示添加到

output$Text <- renderText({ c("TestText") })元素,然后使用shinyBS?

通过renderUI呈现

2 个答案:

答案 0 :(得分:4)

这样的事情吗?

Base Shiny

rm(list=ls())
library(shiny)

ui <- basicPage(
  headerPanel("Tooltip test"),
  mainPanel(
    column(3,tags$div(title="Tooltip works",verbatimTextOutput("Text")))
  )
)

server <- shinyServer(function(input, output,session) {

  output$Text <- renderText({ c("TestText") })

})
shinyApp(ui = ui, server = server)

enter image description here

ShinyBS

rm(list=ls())
library(shiny)
library(shinyBS)

ui <- basicPage(
  headerPanel("Tooltip test"),
  bsTooltip("Text", "Tooltip works", placement = "bottom", trigger = "hover",
            options = NULL),
  mainPanel(
    column(3,verbatimTextOutput("Text"))
  )
)

server <- shinyServer(function(input, output,session) {

  output$Text <- renderText({ c("TestText") })

})
shinyApp(ui = ui, server = server)

enter image description here

答案 1 :(得分:1)

通常,您可以使用其ID在任何Input和Output对象上提供工具提示。例如,我在用户界面的ID为 downloadData downloadButton上添加了工具提示。

sidebarPanel(
  downloadButton("downloadData",
    label = "Save and check the Employee List"),
  bsTooltip("downloadData",
     'This is the tooltip where you can add double quotes "like this"'),
      placement = "bottom", trigger = "hover")
)