gpt4 book ai didi

r - 禁用 Shiny 仪表板中的垂直滚动条

转载 作者:行者123 更新时间:2023-12-02 03:06:53 25 4
gpt4 key购买 nike

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

## 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)

最佳答案

下面的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)

关于r - 禁用 Shiny 仪表板中的垂直滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58754648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com