【发布时间】:2021-06-23 14:04:16
【问题描述】:
我需要在“绘图”、“摘要”和“表格”选项卡中添加工具提示。为此,我使用了 bsTooltip 函数。但它在这里不起作用。
library(shiny)
library(shinyBS)
ui <- fluidPage(
titlePanel("Tabsets"),
sidebarLayout(
conditionalPanel(
'input.dataset === "Plot"',
radioButtons("dist", "Distribution type:",
c("Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp")),br(),
sliderInput("n",
"Number of observations:",
value = 500,
min = 1,
max = 1000)),
mainPanel(
tabsetPanel(id = 'dataset',
tabPanel("Plot", plotOutput("plot")),
tabPanel("Summary", verbatimTextOutput("summary")),
tabPanel("Table", tableOutput("table"))))),
bsTooltip("Plot", "Information", placement = "bottom", trigger = "hover",
options = NULL),
bsTooltip("Table", "Table Summary", placement = "bottom", trigger = "hover",
options = NULL),
bsTooltip("Summary", "Summary", placement = "bottom", trigger = "hover",
options = NULL),)
server <- function(input, output)
{
d <- reactive({
dist <- switch(input$dist,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm)
dist(input$n)
})
output$plot <- renderPlot({
dist <- input$dist
n <- input$n
hist(d(),
main = paste("r", dist, "(", n, ")", sep = ""),
col = "#75AADB", border = "white")
})
output$summary <- renderPrint({
summary(d())})
output$table <- renderTable({
d()})}
shinyApp(ui, server)
如果我将 bsTooltip ID 更改为数据集,它会起作用,但不会像预期的那样
还有其他方法吗?
【问题讨论】:
-
我认为问题实际上在于
tabsetPanel和tabPanel的使用,而不是condtionalPanel。在此处查看问题和可能的解决方案 - 也许其中一个对您有用? stackoverflow.com/questions/44953873/…