that the last popover overwrites all others
I want to add multiple popovers on several ValueBoxes inside shinydashboard. I am using bsPopover() with unique id for each box. However, I am writing all my popovers in a helper file, and calling the source of this file inside my ui.r problem is, that the last popover overwrites everything, on the userInterface I can see only the last popover I added.
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"),
You'll have to wrap them in a list()
for this to work:
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)
Result: