Search code examples
rcalendarhtmlwidgetstoast-ui-editor

How to remove date from a calendar built using toastui in R


I have the created a weekly calendar in R below using toastui:

library(toastui)
calendar(view="week", defaultDate = NULL) %>% cal_week_options(workweek = TRUE, hourStart = 7.5, hourEnd = 24)

This line of the code gives the following output: enter image description here

How can I remove the dates i.e. 21, 22, 23, 24, 25 and just have Monday-Friday as the labels? I have been going through the documentation but I couldn't find a solution. Any suggestion is appreciated.


Solution

  • I found the answer to this question. It is quite simple. According to the documentation one needs to use JS in order to update the names. The code below perfectly displays how the column values are updated:

    library(toastui)
    calendar(view="week", defaultDate = NULL) %>% 
      cal_week_options(workweek = TRUE, hourStart = 7.5, hourEnd = 24) %>% 
      cal_template(
        weekDayname = JS(
          "function(model) {",
          "var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];",
          "return '<span class=\"tui-full-calendar-dayname-name\">' + days[model.day] + '</span>';",
          "}"
        )
      )