Could you help me adjust the error below: as you can see when I click to choose a date, there is a part of the calendar "cut off", I would like to adjust this if I can. I will insert an executable code below
library(shiny)
library(shinythemes)
Test <- structure(
list(dat= c("2021-01-01","2021-01-02","2021-01-03"),
X= c(5,4,0)),
class = "data.frame", row.names = c(NA, -3L))
ui <- fluidPage(
shiny::navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
br(),
tabPanel("",
sidebarLayout(
sidebarPanel(
fileInput("file",h4(("Import file"),
multiple = T,accept = ".xlsx")),
uiOutput("date"),
),
mainPanel(
),
))
))
server <- function(input, output,session) {
data <- reactive(Test)
output$date <- renderUI({
req(data())
all_dates <- seq(as.Date('2021-01-01'), as.Date('2021-01-15'), by = "day")
disabled <- as.Date(setdiff(all_dates, as.Date(data()$df)), origin = "1970-01-01")
dateInput(input = "database",
label = h4("Choose"),
min = min(data()$df),
max = max(data()$df),
value = NA,
datesdisabled = disabled)
})
}
shinyApp(ui = ui, server = server)
Example:
CodePudding user response:
You can do a couple of different things that will fix it.
Swapping the fileInput
and uiOutput
around fixes the problem.
Using br()
in appropriate places can also fix this.
ui <- fluidPage(
shiny::navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
br(),
tabPanel("",
sidebarLayout(
sidebarPanel(
uiOutput("date"),
fileInput("file",h4(("Import file"),
multiple = T,accept = ".xlsx")),
),
mainPanel(
),
))
))
or
ui <- fluidPage(
shiny::navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
br(),
br(),
br(),
tabPanel("",
sidebarLayout(
sidebarPanel(
fileInput("file",h4(("Import file"),
multiple = T,accept = ".xlsx")),
uiOutput("date"),
),
mainPanel(
),
))
))