如何在不覆盖的情况下在 Rstudio 中添加多个 bsPopover?

How to add multiple bsPopovers in Rstudio without overwriting?

最后一个弹出窗口会覆盖所有其他弹出窗口

我想在 shinydashboard 内的几个 ValueBox 上添加多个弹出窗口。我正在使用 bsPopover(),每个盒子都有唯一的 ID。但是,我将所有的弹出框都写在一个帮助文件中,并在我的 ui.r 中调用该文件的源代码 问题是,最后一个弹出窗口覆盖了所有内容,在用户界面上我只能看到我添加的最后一个弹出窗口。

helper.r

bsPopover(
  id = "one", title = "ONE",
  content = "blah blah blah 1",
  trigger = "hover",
  placement = "right",
  options = list(container="body"))


bsPopover(
  id = "two", title = "TWO",
  content = "blah blah blah 2",
  trigger = "hover",
  placement = "right",
  options = list(container="body"))


bsPopover(
  id = "three", title = "THREE",
  content = "blah blah blah 3",
  trigger = "hover",
  placement = "bottom",
  options = list(container="body"))

ui.r

source("helper.r"),

您必须将它们包裹在 list() 中才能正常工作:

library(shiny)
library(shinydashboard)
library(shinyBS)

writeLines(text = 'myPopovers = list(
  bsPopover(
  id = "one", title = "ONE",
  content = "blah blah blah 1",
  trigger = "hover",
  placement = "right",
  options = list(container="body")),
  bsPopover(
    id = "two", title = "TWO",
    content = "blah blah blah 2",
    trigger = "hover",
    placement = "right",
    options = list(container="body")),
  bsPopover(
    id = "three", title = "THREE",
    content = "blah blah blah 3",
    trigger = "hover",
    placement = "bottom",
    options = list(container="body"))
  )', con = "helper.R")

source("helper.R")

ui <- dashboardPage(
  dashboardHeader(title = "Value boxes"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      valueBoxOutput("one"),
      valueBoxOutput("two"),
      valueBoxOutput("three"),
      myPopovers
    )
  )
)

server <- function(input, output) {
  output$one <- renderValueBox({
    valueBox(
      "25%", "Progress", icon = icon("list"),
      color = "purple"
    )
  })

  output$two <- renderValueBox({
    valueBox(
      "80%", "Approval", icon = icon("thumbs-up", lib = "glyphicon"),
      color = "yellow"
    )
  })

  output$three <- renderValueBox({
    valueBox(
      "90%", "Approval", icon = icon("thumbs-up", lib = "glyphicon"),
      color = "green"
    )
  })
}

shinyApp(ui, server)

结果: