Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to use calendar format for numeric data input in Shiny?

Is there a way to use the calendar input layout (ala dateInput()) for non-date data?

Specifically, I want to be able to open the calendar view but instead of dates, there be a grid of possible input values to select from.

The resulting graphic, if possible, would open like this:

calendar inputDate selector

(Note: the #'s are arbitrary and random in the above picture)

I've looked at the code for dateInput, but it wasn't immediately apparent how I would start converting the code in a way to use input values instead of dates...

like image 621
theforestecologist Avatar asked Nov 08 '22 03:11

theforestecologist


1 Answers

Here's one way with fullcalendar wrapper to fullcalendar.js which unfortunately still includes the dates, but maybe that is OK if you can get your data displayed as well.

library(fullcalendar)
my.vals <- c(112,87,45,66,10,6,19,412,8,99,100,74,12,106,
      51,58,91,199,14,22,80,18,3,39,2,1,17,596,4,1003,392)
palette <- colorRampPalette(colors=c("#ff0000", "#0000ff"))
cols <- palette(31)
seqtime <- gsub( "[[:alpha:]]+$", "",
        seq(strptime("2018-07-01", format="%Y-%m-%d"),
        strptime("2018-07-31", format="%Y-%m-%d"), 
        by="1440 mins")  )
data <- data.frame(title = my.vals,
             start = seqtime,
             end = seqtime,
             color = cols)
fullcalendar(data)

It produces this. The viewer defaults to current month rather than data month, so I had to go back with < on the display to get to July. I picked July because it had a Sunday start, just like your random data above.

enter image description here

like image 165
mysteRious Avatar answered Nov 15 '22 08:11

mysteRious