【问题标题】:collapsible output in main panel主面板中的可折叠输出
【发布时间】:2015-05-20 00:07:00
【问题描述】:

我有一个闪亮的应用程序,其中包含两个相关的分析。在每个分析中,都有几种不同类型的结果。

界面变得非常繁忙,我希望输出元素可以折叠 (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")
                 )
        )
      )  
    )
  )

谢谢,

最大

【问题讨论】:

  • 可折叠是什么意思?这个例子我不清楚..
  • 为什么不使用shinydashboard,因为它内置了这个功能
  • Colonel - the link 显示了折叠内容的示例。我希望能够折叠由服务器文件生成的一系列结果(例如文本、绘图等)。
  • pops - 我现在正在看,但它似乎有点矫枉过正。另外,我必须完全重写 ui 文件。我希望有更简洁的东西。
  • 好的,看看 ShinyBS 然后ebailey78.github.io/shinyBS/changes.html

标签: r shiny


【解决方案1】:

看看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))
      }))
    }
)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多