Git Product home page Git Product logo

daterangepicker's Introduction

daterangepicker

cran checks CRAN RStudio mirror downloads CRAN Downloads R build status Lifecycle: maturing Codecov test coverage

Custom Shiny input binding for a Date Range Picker.

Installation from CRAN

install.packages("daterangepicker")

or the dev version:

# install.packages("remotes")
remotes::install_github("trafficonese/daterangepicker")

Example

A basic example of a Date Range Picker:

library(shiny)
library(daterangepicker)

## UI ##########################
ui <- fluidPage(
  daterangepicker(
    inputId = "daterange",
    label = "Pick a Date",
    start = Sys.Date() - 30, end = Sys.Date(),
    style = "width:100%; border-radius:4px",
    icon = icon("calendar")
  ),
  verbatimTextOutput("print"),
  actionButton("act", "Update Daterangepicker"),
)

## SERVER ##########################
server <- function(input, output, session) {
  output$print <- renderPrint({
    req(input$daterange)
    input$daterange
  })
  observeEvent(input$act, {
    updateDaterangepicker(session, "daterange",
                          start = Sys.Date(), 
                          end = Sys.Date() - 100)
  })
}

shinyApp(ui, server)

Further examples are in /inst/examples/

Further Information

Check out the Configuration Generator for a Live-Demo of the different options.

daterangepicker's People

Contributors

ashesitr avatar trafficonese avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

takewiki ashesitr

daterangepicker's Issues

Shiny input change is getting triggered for daterangepicker before clicking on apply button.

Hello,
I have created a daterangepicker using the below code.

      daterangepicker(
        inputId = "datepicker",
        label = NULL,
        start = as.Date(Sys.time() + (5.5*60*60)) - 1,
        end = as.Date(Sys.time() + (5.5*60*60)),
        max = as.Date(Sys.time() + (5.5*60*60)),
        language = "en",
        ranges = list(
          "Today" = as.Date(Sys.time() + (5.5*60*60)),
          "Yesterday" = as.Date(Sys.time() + (5.5*60*60)) - 1,
          "Last 3 days" = c(as.Date(Sys.time() + (5.5*60*60)) - 2, as.Date(Sys.time() + (5.5*60*60))),
          "Last 7 days" = c(as.Date(Sys.time() + (5.5*60*60)) - 6, as.Date(Sys.time() + (5.5*60*60))),
          "Last 30 days" = c(as.Date(Sys.time() + (5.5*60*60)) - 29, as.Date(Sys.time() + (5.5*60*60)))
        ),
        icon = NULL
        options = daterangepickerOptions(timePicker = TRUE, timePicker24Hour = TRUE, alwaysShowCalendars = TRUE, autoApply = FALSE)
      )
observeEvent(input$datepicker, {
...
})

The datepicker works as expected for all cases other then the Custom selector part, even though autoApply is set to false, the input$datepicker is triggered as soon as the end date is selected and doesn't wait until apply button is clicked.
When we add a timepicker to the datepicker, whenever any change is made in the from time or end time, the input$datepicker is triggered immediately without having to click apply.
Is this a bug or expected behaviour ?

Release daterangepicker 0.2.0

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Check if any deprecation processes should be advanced, as described in Gradual deprecation
  • Polish NEWS
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • git push
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Button Input Option

Is there an easy way to mimic shiny::dateRangeInput's UI? I'd like to make daterangepicker look like this (with the entire container being a single button).

image

It looks like there's a way to make the original daterangepicker appear as a button (here http://www.daterangepicker.com/#ex4), but I'm having trouble getting it to work. Any help or pointers would be greatly appreciated!

show ranges as option

Hi, How do I only ranges as option and only show calendar when custom range is picked.?
Demo

| Today | Yesterday | Last Month | Custom Range |

Interaction with Shiny bookmarking is broken?

I've tried to use bookmarking on my shiny dashboard with daterangepicker, and what I observe is that other inputs get their values from the session (I use url backend), while daterangepicker is initialized to default values.

Release daterangepicker 0.2.0

Prepare for release:

  • Check current CRAN check results
  • Polish NEWS
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()

Allow specification of range names without using R names

R names (such as the keys of a named list) must be in native encoding. Under windows, this prevents names from containing unicode characters (e.g. emoji or non-ascii characters that don't fit in the current locale codepage)

It would be nice if there was a way to set the range labels in daterangepicker without using R names.
You could add a separate optional character argument rangeNames = names(ranges), or allow ranges to have a different schema, such as

ranges = list(
  list(
    label = "๐Ÿ˜Š",
    value = c("2023-01-01", "2023-12-31")
  ),
  list(
    label = "Another label",
    value = c("2022-01-01", "2022-12-31")
  )
)

update `ranges` with ? `updateDaterangepicker`

Hi @trafficonese. First of all thank you for making this package available.

I have noticed that not all arguments that one gives to daterangepicker are also updateable with updateDaterangepicker. Most notable the ranges.

Would it be possible to also have these included?

eg.:

      updateDaterangepicker(session, "daterange",
#       ranges = list("Today" = Sys.Date()), # -> Not possible. 
        options = list( linkedCalendars = FALSE)
      )

Other arguments like: language, style and class could also maybe be included to be updated.

How to set time zones?

How to setup time zones? I want dates from the 24/October so I have to select the 23/October. Then the table is subset correctly. Guessing the calendar is running on UTC? Thanks.

                ```

daterangepicker(
inputId = "Dates",
label = "Date Range",
start = as_datetime(format(Sys.time(), '%Y-%m-%d'), tz = "Australia/Sydney") - hours(24),
end = as_datetime(format(Sys.time(), '%Y-%m-%d'), tz = "Australia/Sydney") + hours(24) - seconds(1),
max = as_datetime(format(Sys.time(), '%Y-%m-%d'), tz = "Australia/Sydney") + hours(24) - seconds(1),
options = daterangepickerOptions(maxSpan = list("days" = 2),
timePicker = TRUE,
timePicker24Hour = TRUE,
timePickerIncrement = 1,
cancelIsClear = TRUE,
locale = list(format = "LL",
separator = ' โ€”โ€” ',
cancelLabel = 'Clear',
daysOfWeek = format(seq.Date(as.Date("2000-01-03"),
as.Date("2000-01-09"),
by = "days"), "%a"),
monthNames = format(seq.Date(as.Date("2000-01-01"),
as.Date("2000-12-31"),
by = "months"), "%b"))))

Display chosen range in a custom format

In my current application I use perioddaterangepicker to choose from quarters. It would be nice to have the possibility to provide a custom format in which the chosen range is displayed.

Example (using German locale):

2022Q3 โ€“ 2023Q2

instead of

01.07.2022 โ€“ 30.06.2023

Time does not match selection

I'm not sure if this is a mistake or if I missed something in the documentation. If the latter, what should I look out for?

The problem is

The time selected in the picker differs from the internal value by one hour.

How to reproduce

library(shiny)
library(daterangepicker)

## UI ##########################
ui <- fluidPage(
  verbatimTextOutput("print"),
  daterangepicker(
    inputId = "daterange",
    label = "Pick a Date",
    start = Sys.Date() - 30, end = Sys.Date(),
    style = "width:100%; border-radius:4px",
    options = list(
      showDropdowns = TRUE,
      timePicker = TRUE,
      timePicker24Hour = TRUE,
      autoApply = TRUE
    )
  ),
)

## SERVER ##########################
server <- function(input, output, session) {
  output$print <- renderPrint({
    req(input$daterange)
    input$daterange
  })
}

shinyApp(ui, server)

Screenshot

grafik

Other

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.