简体   繁体   中英

Space between 2 widgets in R Shiny

Can someone please explain me the reason for having a big whitespace between following?

server = function(input, output){    
  
  # server code
}
ui = fluidPage(
  
  fluidRow(
    column(8, offset = 0, style='padding:0px;', # Sidebar panel
           sidebarPanel(useShinyjs(),
                         
                         dateRangeInput('dateRange',
                                        label = 'Filter crimes by date',
                                        start = as.Date('2019-01-01') , end = as.Date('2021-06-01')),
                         
                         selectInput("var", label = "1. Select the quantitative Variable", 
                                     choices = c("place_of_death"=3,"Month Name"=11, "cause_of_death"=8), selected = 8), 
                         
                         radioButtons( "dist", "Enable or disable Grouping:",
                                       c("Enable" = "enable",
                                         "Disable" = "disable" ), inline=T),
                         
                         selectInput("var2", label = "1. Select the quantitative Variable", 
                                     choices = c("cause_of_death"=8, "year"=7), selected = 7),
                         
                         
                         radioButtons( "CauseOfDeathRad", "Enable or disable Grouping:",
                                       c("Covid" = "covid",
                                         "Non-Covid" = "nonCovid" ,
                                         "Both" = "both"), inline=T),
                         
                         radioButtons( "DeathonYearRad", "Enable or disable Grouping:",
                                       c(
                                         "2020" = "2020" ,
                                         "2021" = "2021",
                                         "All" = "All"), inline=T)
                         
           )),
    column(2, offset = 0, style='padding:0px;', wellPanel(p("Column width 2"))),
    column(2, offset = 0, style='padding:0px;', wellPanel(p("Column width 2")))
    )
)
shinyApp(ui = ui, server = server)

I need my dashboard to be equally divided among different plots. But this seems really hard to be done. Appreciate if someone could help

PS. 在此处输入图像描述

When column(8,...) is set to column(3...)

My suggestion is to use the fluidRow() and column() in the mainPanel() to display the plots. Widgets for input can be kept in sidebarPanel() . Try this

server = function(input, output){    
  
  # server code
}
ui = fluidPage(
  useShinyjs(),
  sidebarLayout(
    sidebarPanel(
      
      dateRangeInput('dateRange',
                     label = 'Filter crimes by date',
                     start = as.Date('2019-01-01') , end = as.Date('2021-06-01')),
      
      selectInput("var", label = "1. Select the quantitative Variable", 
                  choices = c("place_of_death"=3,"Month Name"=11, "cause_of_death"=8), selected = 8), 
      
      radioButtons( "dist", "Enable or disable Grouping:",
                    c("Enable" = "enable",
                      "Disable" = "disable" ), inline=T),
      
      selectInput("var2", label = "1. Select the quantitative Variable", 
                  choices = c("cause_of_death"=8, "year"=7), selected = 7),
      
      
      radioButtons( "CauseOfDeathRad", "Enable or disable Grouping:",
                    c("Covid" = "covid",
                      "Non-Covid" = "nonCovid" ,
                      "Both" = "both"), inline=T),
      
      radioButtons( "DeathonYearRad", "Enable or disable Grouping:",
                    c(
                      "2020" = "2020" ,
                      "2021" = "2021",
                      "All" = "All"), inline=T)
      
    ),
    mainPanel(
      fluidRow(
        column(5, offset = 0, style='padding:0px;', wellPanel(p("Column width 5"))),
        column(5, offset = 0, style='padding:0px;', wellPanel(p("Column width 5")))
      )
    )
  )
  
)
shinyApp(ui = ui, server = server)

输出

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM