gpt4 book ai didi

r - 将弹出窗口添加到 Shiny 的应用程序?

转载 作者:行者123 更新时间:2023-12-04 13:47:54 28 4
gpt4 key购买 nike

我想在小部件标题旁边添加一个(?),以便用户可以悬停或单击它并获取额外信息和他们可以单击的链接。

这就是我现在所拥有的:

## app.R ##
library(shiny)
library(shinydashboard)
library(shinyBS)
# Header
header <- dashboardHeader()
# Sidebar
sidebar <- dashboardSidebar(fileInput("chosenfile", label = h4("File input"),
accept = ".csv"),
bsButton("q1", label = "", icon = icon("question"),
style = "info", size = "extra-small"),
bsPopover(id = "q1", title = "Tidy data",
content = paste0("You should read the ",
a("tidy data paper",
href = "http://vita.had.co.nz/papers/tidy-data.pdf",
target="_blank")),
placement = "right",
trigger = "click",
options = list(container = "body")
)
)
# Body
body <- dashboardBody()
# ui
ui <- dashboardPage(header, sidebar, body)
# server
server <- function(input, output) {

}
# run
shinyApp(ui, server)

popover

但它远非完美。例如,(?) 的位置不在“文件输入”旁边,要关闭弹出框,您必须再次单击问号,而不是在弹出框中有 (x)。

最佳答案

这个答案可能不是您最初想要的,但它仍然可以为您工作。

你说你想要标签旁边的工具提示问号,所以我把它放在标签里。使用正确的对齐方式。
其次,您希望在再次单击按钮之前不打开工具提示,因为这很烦人。那么弹出选项“焦点”可能对您来说是正确的。

## app.R ##
library(shiny)
library(shinydashboard)
library(shinyBS)
# Header
header <- dashboardHeader()
# Sidebar
sidebar <- dashboardSidebar(
fileInput("chosenfile",
label = h4("File input ",
tags$style(type = "text/css", "#q1 {vertical-align: top;}"),
bsButton("q1", label = "", icon = icon("question"), style = "info", size = "extra-small")
),
accept = ".csv"),
bsPopover(id = "q1", title = "Tidy data",
content = paste0("You should read the ",
a("tidy data paper",
href = "http://vita.had.co.nz/papers/tidy-data.pdf",
target="_blank")
),
placement = "right",
trigger = "focus",
options = list(container = "body")
)
)
# Body
body <- dashboardBody()
# ui
ui <- dashboardPage(header, sidebar, body)
# server
server <- function(input, output) {}
# run
shinyApp(ui, server)

关于r - 将弹出窗口添加到 Shiny 的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37051631/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com