首页 > 解决方案 > Shiny中的仪表板图形放置

问题描述

我的 Shiny 仪表板页面由三个主要行组成。我在前两行的图表工作正常。

但是说到第三行,我主要需要把它分成两列。然后需要将第一列分为其他列,并将我的饼图放在一个列中,将单选按钮放在另一列中。

在第二大列中,我需要放置一些信息框。我尝试放置它,以下是与我的第三行相关的部分。但这对我不起作用。有人可以帮忙吗。

    fluidRow(
      column(width = 8,

           splitLayout(
             column(width = 10,
                plotOutput("PieVaccineByGender", height = "350px", width = "700px")
             ),
                      
             column(width = 2,
                radioButtons(
                  "Vaccine",
                  "Enable or disable Grouping:",
                  c("Age" = "Age" ,
                    "Region" = "Region"),
                  inline = F
                )
                
               )
            ), 
        
      ),
    
    column(width = 4,
           infoBoxOutput('VaccineCount')
           )
  )

以下是我的仪表板现在的样子。

在此处输入图像描述

标签: rshiny

解决方案


信息框显示不正确?尝试width = 12

为什么需要使用splitLayout?您可以直接在列内添加列

见下文


library(shinydashboard)
library(shiny)
shinyApp(
    ui = dashboardPage(
        dashboardHeader(),
        dashboardSidebar(),
        dashboardBody(
            fluidRow(
                column(width = 8,
                       column(width = 10,
                              plotOutput("PieVaccineByGender", height = "350px", width = "700px")
                       ),
                       
                       column(width = 2,
                              radioButtons(
                                  "Vaccine",
                                  "Enable or disable Grouping:",
                                  c("Age" = "Age" ,
                                    "Region" = "Region"),
                                  inline = F
                              )
                              
                       )
                ),
                
                column(width = 4,
                       shinydashboard::infoBox(title = "abc", value = "123", icon = icon("exclamation-triangle"), width = 12)
                )
            )
        ),
        title = "Dashboard example"
    ),
    server = function(input, output) { output$PieVaccineByGender <- renderPlot(plot(1))}
)

截图1


推荐阅读