2016-11-14 9 views
4
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) 

この結果は、mininizeボタンをクリックしたときにcollpasibleボックスが折りたたま取得されていない上記の画像で折りたたみボックス

enter image description here

です。

作業ディレクトリに追加ファイルAdminLTE.cssshinydashboard.cssを追加しましたが、それでも問題は解決しません。

+1

shinyBSパッケージがあなたを助けてくれます:https://ebailey78.github.io/shinyBS/docs/Collapses.html – user5029763

答えて

0

shinydashboardの使用に制限がない場合は、ヘッダーとサイドバーなしでダッシュボードページを作成してください。それはshinydashboardのすべての機能を有効にし、それは基本的な光沢のあるアプリのように見えます。下のコードでは、最小化/最大化ボタンをクリックすると、ボックスが折りたたまれ/展開されません。

library(shiny) 
library(shinydashboard) 

ui <- dashboardPage(
    dashboardHeader(disable = TRUE), 
    dashboardSidebar(disable = TRUE), 
    dashboardBody(
    # 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) 
0

光沢のあるボックス内で折り畳み可能なボックスを使用する。必要な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"), # 
関連する問題