仪表盘制作

时间:2019-05-18 04:13:31

标签: shiny shinydashboard action-button

我正在尝试将仪表板放置在名为加载场景的操作操作按钮内。在这里,当按两次加载场景按钮时,可以看到仪表板。但是,我想在加载场景按钮后立即显示仪表板页面被按下(不是两次)。这是我的示例代码。

 library("shiny")
 library("shinydashboard")
 ui <- fluidPage(


  actionButton("create_scenario", "Create Scenario"),
  actionButton("load_scenario","load scenario"),
 uiOutput("input"),
  uiOutput("inputs")
 )

 server <- function(input, output,session) {

  observeEvent(input$create_scenario,{

    output$input <- renderUI({
     textInput("txtInput","Enter Scenario Name","Enter name as scenario         
              (number of senario created +1)")
    })


   })

  observeEvent(input$load_scenario,{

    output$inputs <- renderUI({
     # textInput("txtInput","Enter Scenario Name","Enter name as scenario  
     #(number of senario created +1)")
      dashboardPage(
       dashboardHeader(title = "Basic dashboard"),
       dashboardSidebar(),
      dashboardBody(
      # Boxes need to be put in a row (or column)
      fluidRow(
        box(plotOutput("plot1", height = 250)),

        box(
          title = "Controls",
          sliderInput("slider", "Number of observations:", 1, 100, 50)
        ))))


} )

histdata <- rnorm(500)
output$plot1 <- renderPlot({
  data <- histdata[seq_len(input$slider)]
  hist(data)
    })


  })
}
shinyApp(ui, server)

请忽略创建场景按钮。我已使用renderUI函数执行此任务。如果我可以通过其他方法将仪表板放置在操作按钮中,请告诉我

0 个答案:

没有答案