Adjust short delay when calendar appears in Shiny app

I would like to know if there is any possibility of adjusting a brief delay I have when I run my app. If you run it, you'll notice that the calendar appears after my two selectinput. I find this a little strange. Is there any possibility to adjust this?

Thank you very much!

Executable code below:

    library(shiny)
    library(shinythemes)
    library(dplyr)
    library(ggplot2)
    library(tidyr)
    library(lubridate)
    
    function.cl<-function(dt){
      df <- structure(
        list(date = c("01-08-2021","01-08-2021","01-08-2021","01-08-2021","01-08-2021",
                      "08-08-2021","08-08-2021","08-08-2021","08-08-2021","08-08-2021","08-08-2021",
                      "13-08-2021","13-08-2021","13-08-2021","13-08-2021","13-08-2021"),
             D1 = c(0,1,0,0,5,0,1,0,0,9,4,3,4,5,6,7), DR01 = c(2,1,0,0,3,0,1,0,1,7,2,3,4,6,7,8),
             DR02 = c(2,0,0,0,4,2,1,0,1,4,2,3,4,5,6,7),  DR03 = c(2,0,0,2,6,2,0,0,1,5,2,2,4,5,7,5),
             DR04 = c(2,0,0,5,6,2,0,0,3,7,2,3,4,5,6,4),  DR05 = c(2,0,0,5,6,2,0,0,7,7,2,3,4,5,6,7),
             DR06 = c(2,0,0,5,7,2,0,0,7,7,1,3,5,6,7,8),  DR07 = c(2,0,0,6,9,2,0,0,7,8,1,3,5,6,4,3)),
        class = "data.frame", row.names = c(NA, -16L))
      
      df$date <- parse_date_time(df$date, c('ymd', 'dmy'))
      
      scatter_date <- function(dt, dta = df) {
        dta %>%
          filter(date == ymd(dt)) %>%
          summarize(across(starts_with("DR"), sum)) %>%
          pivot_longer(everything(), names_pattern = "DR(.+)", values_to = "val") %>%
          mutate(name = as.numeric(name)) %>%
          plot(xlab = "Days", ylab = "Types", xlim = c(0, 7))
      }  
      Plot1<-scatter_date(dt)
      
      return(list(
        "Plot1" = Plot1, 
        date = df$date
      ))
    }
    
    ui <- fluidPage(
      
      ui <- shiny::navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
                              br(),
                              
                              tabPanel("",
                                       sidebarLayout(
                                         sidebarPanel(
                                          
                                            uiOutput("dated"),
                                           selectInput("day", label = h4("Week"),""),
                                           selectInput("code", label = h4("Type"),""),
                                           br(),
                                           
                                         ),
                                         
                                         mainPanel(
                                           tabsetPanel(
                                             tabPanel("",plotOutput("Graph",width = "95%", height = "600"))),
                                         ))
                              )))
    
    
    server <- function(input, output,session) {
      data <- reactive(function.cl("2021-08-01"))
      
      output$dated <- renderUI({
        all_dates <- seq(as.Date('2021-01-01'), as.Date('2021-01-15'), by = "day")
        disabled <- as.Date(setdiff(all_dates, as.Date(data()$date)), origin = "1970-01-01")
        dateInput(input = "date", 
                  label = "Select Date",
                  min = min(data()$date),
                  max = max(data()$date),
                 
                  format = "dd-mm-yyyy",
                  datesdisabled = disabled)
      })
      
      output$Graph <- renderPlot({
        req(input$date)
        function.cl(input$date)[["Plot1"]]
        
      })
    
    
    }
    
    shinyApp(ui = ui, server = server)


from Recent Questions - Stack Overflow https://ift.tt/3zmjmov
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)