tumultous_rooster
tumultous_rooster

Reputation: 12550

Using dates with the ion.RangeSlider sliderInput in Shiny

How can we use dates with sliderInput in Shiny?

I know it has been difficult with Bootstrap 2.0, but now that Shiny is using the ion slider, there is hope:

According to the documentation,

Slider supports date and time

For now, something like

sliderInput("date",label="date", min=as.Date("1934-06-29"), max=as.Date("1940-03-04"))

is still a dream.

I've found some Javascript that seems to be relevant, but I'm not sure hot to implement this in the UI. Has anyone who knows Javascript incorportated this into any Shiny apps yet?

$("#range_39").ionRangeSlider({
    min: +moment().subtract(1, "years").format("X"),
    max: +moment().format("X"),
    from: +moment().subtract(6, "months").format("X"),
    prettify: function (num) {
        return moment(num, "X").format("LL");
    }
});

Thanks for reading this far.

Upvotes: 3

Views: 607

Answers (1)

DeanAttali
DeanAttali

Reputation: 26313

Looks like Winston very recently added support for dates to the rangeslider, but it just hasn't been incorporated into shiny yet.

https://github.com/rstudio/shiny/pull/885

It should probably be finalized soon

Upvotes: 2

Related Questions