library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
includeCSS(path = "AdminLTE.css"), #added
includeCSS(path = "shinydashboard.css"), #added
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
box(plotOutput("distPlot"), solidHeader = T, collapsible = T, title = "collapsible box not collapsing", status = "primary")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
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')
})
}
# Run the application
shinyApp(ui = ui, server = server)
这个结果是
在上图中,当单击最小化按钮时,可折叠框不会折叠。
我已经在工作目录中添加了附加的 AdminLTE.css
和 shinydashboard.css
文件,但问题仍然存在。
最佳答案
仅在 shiny 内使用可折叠框。我们需要添加所需的 javascript。在添加 css 之后,我们添加 this文件也是如此。
includeCSS(path = "AdminLTE.css"), #added
includeCSS(path = "shinydashboard.css"), #added
#add this file and collapsible nature should work.
includeScript(path = "app.js"), #
关于css - Shiny 应用程序中的可折叠框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40584804/