您可以包含一些自定义css,并将日期选择器的z-index更改为非常高。这个
z-index
基本上是html页面上的层顺序。
编辑:
我添加了一些小部件,将日期选择器向下推160像素,这样弹出窗口就不会遮挡顶部的任何框。
library(shiny)
library(bs4Dash)
df <- data.frame(
date = as.Date(c("2024-12-20", "2024-12-21")),
value = 1:2
)
ui <- dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
# Include custom CSS
tags$head(
tags$style(HTML("
/* Ensure the datepicker dropdown appears above other elements */
.datepicker.datepicker-dropdown.dropdown-menu {
z-index: 1050 !important;
}
/* Adjust placement of the date range input widget */
.shiny-date-range-input.form-group.shiny-input-container.shiny-bound-input {
margin-top: 160px !important; /* Add spacing above the widget */
}
"))
),
fluidRow(
lapply(1:4, function(x) {
infoBox(
title = paste0("Info Box ", x),
value = x,
width = 3
)
})
),
fluidRow(
box(
collapsible = FALSE,
plotOutput("examplePlot", width = "100%"),
sidebar = boxSidebar(
id = "exampleSidebar",
width = 40,
dateRangeInput(
inputId = "exampleDateRangeInput",
label = "Select Date",
format = "M dd, yyyy",
width = "100%"
),
easyClose = FALSE
)
)
)
)
)
server <- function(input, output, session) {
output$examplePlot <- renderPlot({
ggplot2::ggplot(df, ggplot2::aes(date, value)) +
ggplot2::geom_line()
})
}
shinyApp(用户界面,服务器)
正如你所看到的,这是有效的,没有什么是模糊的: