【问题标题】:Trouble with spacing/padding in shinydashboard闪亮仪表板中的间距/填充问题
【发布时间】:2017-06-15 22:26:39
【问题描述】:

我是shinydashboard 的首次用户,但我无法理解页面上图表中框之间的填充是如何工作的。例如,下面示例中的填充非常混乱,并且准确地代表了我在工作中遇到的问题:

如何拉伸图表(最好将框之间的填充设置为 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')
      })
    }
)

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案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")
               )
        )
      )
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-22
      • 2017-08-17
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      • 2016-11-11
      • 1970-01-01
      相关资源
      最近更新 更多