2015-05-19 117 views
1

我有一個有兩個相關分析的閃亮應用程序。在每個分析中都有一些不同類型的結果。主面板中的可摺疊輸出

界面變得非常忙碌,我想讓輸出元素可摺疊(maybe like this)。

這種類型的ui文件是否有任何示例?我目前的一個看起來是這樣的:

shinyUI(
    fluidPage(
     tabsetPanel(
     tabPanel("Analysis 1", 
       sidebarPanel(
        sliderInput("value1", "some value", 
           min=1, max=20, value=5, step=0.2) 
       ), 
       mainPanel(
        ## these two elements collapse together 
        p(textOutput("results_1_a_text")), 
        plotOutput("results_1_a_graph", height = "400px"), 
        ## these two elements collapse together 
        p(textOutput("results_1_b_text")), 
        plotOutput("results_1_b_graph", height = "400px") 
       ) 
     ), 
     tabPanel("Analysis 2", 
       sidebarPanel(
        sliderInput("value2", "some value", 
           min=1, max=20, value=5, step=0.2) 
       ), 
       mainPanel(
        ## these two elements collapse together 
        p(textOutput("results_2_a_text")), 
        plotOutput("results_2_a_graph", height = "400px"), 
        ## these two elements collapse together 
        p(textOutput("results_2_b_text")), 
        plotOutput("results_2_b_graph", height = "400px") 
       ) 
     ) 
    ) 
    ) 
) 

感謝,

最大

+0

您可摺疊的含義是什麼?我不明白這個例子。 –

+0

爲什麼不使用shinydashboard,因爲它有內置的 –

+0

這個功能上校 - [鏈接](http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_js_collapse_simple_in&stacked = h)顯示了一個摺疊內容的例子。我希望能夠摺疊由服務器文件生成的一系列結果(例如文本,圖表等)。 – topepo

回答

3

看一看的ShinyBS。從那裏取得的例子

library(shiny) 
library(shinyBS) 

shinyApp(
    ui = 
    fluidPage(
     sidebarLayout(
     sidebarPanel(HTML("This button will open Panel 1 using updateCollapse."), 
        actionButton("p1Button", "Push Me!"), 
        selectInput("styleSelect", "Select style for Panel 1", 
           c("default", "primary", "danger", "warning", "info", "success")) 
     ), 
     mainPanel(
      bsCollapse(id = "collapseExample", open = "Panel 2", 
        bsCollapsePanel("Panel 1", "This is a panel with just text ", 
            "and has the default style. You can change the style in ", 
            "the sidebar.", style = "info"), 
        bsCollapsePanel("Panel 2", "This panel has a generic plot. ", 
            "and a 'success' style.", plotOutput("genericPlot"), style = "success") 
     ) 
     ) 
    ) 
    ), 
    server = 
    function(input, output, session) { 
     output$genericPlot <- renderPlot(plot(rnorm(100))) 
     observeEvent(input$p1Button, ({ 
     updateCollapse(session, "collapseExample", open = "Panel 1") 
     })) 
     observeEvent(input$styleSelect, ({ 
     updateCollapse(session, "collapseExample", style = list("Panel 1" = input$styleSelect)) 
     })) 
    } 
)