user3789200
user3789200

Reputation: 1186

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. enter image description here

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

Upvotes: 0

Views: 2218

Answers (1)

YBS
YBS

Reputation: 21349

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)

output

Upvotes: 3

Related Questions