增加来自 shinyBS 的 popify 弹出窗口的宽度
Increase width of popify pop-up from shinyBS
我用 Shiny 中 shinyBS
包中的 popify
函数创建了一个弹出窗口。我想在过滤器底部弹出一个与过滤器本身一样宽的弹出窗口。我在文档中找不到任何关于此的内容。
截图:
示例代码:
library(shiny)
library(shinyBS)
shinyApp(
ui =
fluidPage(
sidebarLayout(
sidebarPanel(
tags$span(
popify(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
'a very long popup',"1. I want everything behind 1 on one line and everything that starts after<br> 2. I want to see on the second line without wrapping it to the 3rd line.")),
actionButton("tabBut", "View Table")
),
mainPanel(
plotOutput("distPlot"),
bsModal("modalExample", "Data Table", "tabBut", size = "large",
dataTableOutput("distTable"))
)
)
),
server =
function(input, output, session) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$distTable <- renderDataTable({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
tab <- hist(x, breaks = bins, plot = FALSE)
tab$breaks <- sapply(seq(length(tab$breaks) - 1), function(i) {
paste0(signif(tab$breaks[i], 3), "-", signif(tab$breaks[i+1], 3))
})
tab <- as.data.frame(do.call(cbind, tab))
colnames(tab) <- c("Bins", "Counts", "Density")
return(tab[, 1:3])
}, options = list(pageLength=10))
}
)
您可以尝试添加一些 CSS 来做到这一点。
在您的侧边栏面板中,您可以添加:
tags$style(".popover{
max-width: 100%;
}")
如果这不够大,您可以在 popify
中添加 options=list(container="body")
以使 body
成为允许弹出窗口与页面一样大的容器。
还有更多信息here,我把那个答案改编成了 R。
我用 Shiny 中 shinyBS
包中的 popify
函数创建了一个弹出窗口。我想在过滤器底部弹出一个与过滤器本身一样宽的弹出窗口。我在文档中找不到任何关于此的内容。
截图:
示例代码:
library(shiny)
library(shinyBS)
shinyApp(
ui =
fluidPage(
sidebarLayout(
sidebarPanel(
tags$span(
popify(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
'a very long popup',"1. I want everything behind 1 on one line and everything that starts after<br> 2. I want to see on the second line without wrapping it to the 3rd line.")),
actionButton("tabBut", "View Table")
),
mainPanel(
plotOutput("distPlot"),
bsModal("modalExample", "Data Table", "tabBut", size = "large",
dataTableOutput("distTable"))
)
)
),
server =
function(input, output, session) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$distTable <- renderDataTable({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
tab <- hist(x, breaks = bins, plot = FALSE)
tab$breaks <- sapply(seq(length(tab$breaks) - 1), function(i) {
paste0(signif(tab$breaks[i], 3), "-", signif(tab$breaks[i+1], 3))
})
tab <- as.data.frame(do.call(cbind, tab))
colnames(tab) <- c("Bins", "Counts", "Density")
return(tab[, 1:3])
}, options = list(pageLength=10))
}
)
您可以尝试添加一些 CSS 来做到这一点。
在您的侧边栏面板中,您可以添加:
tags$style(".popover{
max-width: 100%;
}")
如果这不够大,您可以在 popify
中添加 options=list(container="body")
以使 body
成为允许弹出窗口与页面一样大的容器。
还有更多信息here,我把那个答案改编成了 R。