【问题标题】:Disable the vertical scroll bar in shiny dashboard禁用闪亮仪表板中的垂直滚动条
【发布时间】:2020-03-04 09:11:53
【问题描述】:

假设我有一个闪亮的仪表板默认使用垂直滚动条,因为右侧有一个大图,但出于某种原因,即使该图没有作为一个整体显示,我也不希望它在那里。我也不想降低地块高度。可以这样做吗?

## app.R ##
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
  dashboardBody(
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(plotOutput("plot1", height = 850)),

      box(
        title = "Controls",
        sliderInput("slider", "Number of observations:", 1, 100, 50)
      )
    )
  )
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)

  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })
}

shinyApp(ui, server)

【问题讨论】:

  • 绘图过大并移除滚动条以查看它有什么意义,或者我在这里遗漏了什么?
  • 好的,现在检查一下,我将绘图高度降低到 850 像素...我可以看到全部内容,但滚动条仍然存在

标签: r shiny


【解决方案1】:

下面的 css 应该这样做:body {overflow-y: hidden;}

## app.R ##
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
  dashboardBody(
    tags$head(
      tags$style(
        "body {overflow-y: hidden;}"
      )
    ),
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(plotOutput("plot1", height = 850)),

      box(
        title = "Controls",
        sliderInput("slider", "Number of observations:", 1, 100, 50)
      )
    )
  )
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)

  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })
}

shinyApp(ui, server)

【讨论】:

    猜你喜欢
    • 2015-09-24
    • 2015-04-22
    • 1970-01-01
    • 1970-01-01
    • 2018-05-10
    • 1970-01-01
    • 2019-07-26
    • 1970-01-01
    • 2019-02-12
    相关资源
    最近更新 更多