2017-06-15 112 views
0

我是shinydashboard的第一次使用者,我無法理解填充如何在頁面上的圖表之間進行填充。例如,在下面的例子中填充相當搞砸了,而且我正在與我的工作問題的精確表示:shinydashboard中的間距/填充的問題

enter image description here

如何伸展整個圖表(理想的設置框之間的填充爲0)?

下面是用於創建圖像上面的代碼:

library(shinydashboard) 

header <- dashboardHeader() 

sidebar <- dashboardSidebar(
    sidebarMenu(
     sliderInput("bins", 
        "Number of bins:", 
        min = 1, 
        max = 50, 
        value = 30) 
    ) 
    ) 

body <- dashboardBody(
    fluidRow(
     column(
      width = 4, 
     box(title = "Chart1", 
       plotOutput("distPlot") 
      ) 
     ), 
     column(
      width = 6, 
      tabBox(
       tabPanel(id = "tabBox1", 
         title = "Chart2", 
         plotOutput("distPlot2") 
         ), 
       tabPanel(id = "tabBox2", 
         title = "Chart3", 
         plotOutput("distPlot3") 
         ), 
       tabPanel(id = "tabBox3", 
         title = "Chart4", 
         plotOutput("distPlot4") 
         ) 
       ) 
      ), 
     column(width = 2, 
        box(title = "Chart5", 
         plotOutput("distPlot5") 
         ) 
        ) 
     ) 
    ) 

shinyApp(
    ui = dashboardPage(header, sidebar, body), 
    server = function(input, output) { 
     output$distPlot <- renderPlot({ 
     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 
     hist(x, breaks = bins, col = 'darkgray', border = 'white') 
     }) 

     output$distPlot2 <- renderPlot({ 
     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 

     hist(x, breaks = bins, col = 'darkgray', border = 'white') 
     }) 

     output$distPlot3 <- renderPlot({ 
     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 
     hist(x, breaks = bins, col = 'darkgray', border = 'white') 
     }) 

     output$distPlot4 <- renderPlot({ 
     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 
     hist(x, breaks = bins, col = 'darkgray', border = 'white') 
     }) 

     output$distPlot5 <- renderPlot({ 
     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 
     hist(x, breaks = bins, col = 'darkgray', border = 'white') 
     }) 
    } 
) 

回答

1

可以通過指定的框的寬度,以及(12)做到這一點:

body <- dashboardBody(
    fluidRow(
    column(
     width = 4, 
     box(title = "Chart1", width = 12, 
      plotOutput("distPlot") 
    ) 
    ), 
    column(
     width = 6, 
     tabBox(width = 12, 
     tabPanel(id = "tabBox1", 
       title = "Chart2", 
       plotOutput("distPlot2") 
     ), 
     tabPanel(id = "tabBox2", 
       title = "Chart3", 
       plotOutput("distPlot3") 
     ), 
     tabPanel(id = "tabBox3", 
       title = "Chart4", 
       plotOutput("distPlot4") 
     ) 
    ) 
    ), 
    column(width = 2, 
      box(title = "Chart5", width = 12, 
       plotOutput("distPlot5") 
      ) 
    ) 
) 
)