Insert bspopover in Shiny

醉酒当歌 提交于 2020-06-28 03:45:01

问题


I would like to insert a bspopover next to the text: "Shapefile Import". For the Filter options I was able to insert as you can see in the code below, however for fileImput no. The executable code is below. can anybody help me?

Thank you!

library(shinyBS)
library(shiny)

popoverTempate <- 
  '<div class="popover popover-lg" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'

DES_filter1<-paste("Text text text text text text.", sep = "<br>")

ui <- fluidPage(
  
  tags$head(
    tags$style(HTML(".popover.popover-lg {width: 500px; max-width: 500px;}"))
  ),
  titlePanel("Old Faithful Geyser Data"),
  
  sidebarLayout(
    sidebarPanel(
 
      fileInput("shp", h3("Shapefile import"), multiple = TRUE, accept = c('.shp', '.dbf','.sbn', '.sbx', '.shx', '.prj')),
  
      radioButtons(
        "filter1", 
        h3("Select properties"), 
        choiceValues = c(1, 2),
        choiceNames = list(
          tagList(
            tags$span("All properties"),
            tags$span(icon("info-circle"), id = "icon1", style = "color: blue;")
          ), 
          tagList(
            tags$span("Exclude properties"),
            tags$span(icon("info-circle"), id = "icon2", style = "color: blue;")
          )
        ),
        selected = 1
      ),
      
      bsPopover("icon1", "TITLE1", DES_filter1, placement = "right", 
                options = list(template = popoverTempate)), 
      bsPopover("icon2", "TITLE2", "CONTENT2", placement = "right"), 
      
      radioButtons("filter2", h3("Select"),
                   choices = list("All" = 1, 
                                  "Exclude" = 2),
                   selected = 1),
    ),
    
    mainPanel(
      
    )
  )
)

server <- function(input, output) {
  
}

shinyApp(ui = ui, server = server) 

回答1:


You can add the icon in the fileInput title:

sidebarPanel(
    
    fileInput("shp", 
              h3(
                  span("Shapefile import"),
                  span(icon("info-circle"), id = "icon3", style = "color: blue")
                  ), 
              multiple = TRUE, 
              accept = c('.shp', '.dbf','.sbn', '.sbx', '.shx', '.prj')
              ),
    bsPopover("icon3", "TITLE3", "CONTENT3", placement = "right"),
    ...


来源:https://stackoverflow.com/questions/62598389/insert-bspopover-in-shiny

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!