Git Product home page Git Product logo

Comments (2)

pvictor avatar pvictor commented on May 28, 2024

Hello,

Thank you, all merit to authors of tui-calendar JS library!

You can retrieve click on calendar schedules with input$<outputId>_click, here's an example:

library(shiny)
library(tuicalendr)


calendarProps <- data.frame(
  id = c("1", "2", "3"), 
  name = c("TODO", "Meetings", "Tasks"),
  color = c("#FFF", "#FFF", "#000"), 
  bgColor = c("#E41A1C", "#377EB8", "#4DAF4A"),
  borderColor = c("#a90000", "#005288", "#0a7f1c")
)

ui <- fluidPage(
  tags$h2("Example without proxy"),
  actionButton(
    inputId = "refresh", 
    label = "Refresh data",
    icon = icon("refresh"), 
    width = "100%"
  ),
  calendarOutput(outputId = "cal"),
  verbatimTextOutput(outputId = "click")
)

server <- function(input, output, session) {
  
  output$cal <- renderCalendar({
    
    input$refresh
    
    n <- 20
    
    date_start <- sample(
      seq(from = as.POSIXct(Sys.Date()-14), by = "1 hour", length.out = 24*7*4),
      n, TRUE
    )
    date_end <- date_start + sample(1:25, n, TRUE) * 3600
    schedules <- data.frame(
      id = 1:n, 
      calendarId = as.character(sample(1:3, n, TRUE)),
      title = LETTERS[1:n],
      body = paste("Body schedule", letters[1:n]),
      start = format(date_start, format = "%Y-%m-%dT%H:%00:%00"),
      end = format(date_end, format = "%Y-%m-%dT%H:%00:%00"),
      category = sample(c("allday", "time", "task"), n, TRUE),
      stringsAsFactors = FALSE
    )
    
    calendar(defaultView = "month", taskView = TRUE, scheduleView = c("time", "allday")) %>% 
      # set_month_options(visibleWeeksCount = 2) %>%
      set_calendars_props_df(df = calendarProps) %>% 
      add_schedule_df(df = schedules)
  })
  
  output$click <- renderPrint({
    input$cal_click
  })
  
}

shinyApp(ui, server)

Victor

from tuicalendr.

sebastiz avatar sebastiz commented on May 28, 2024

Thanks great stuff. Works nicely

from tuicalendr.

Related Issues (13)

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.