How to format timelines with formattable in R
library(formattable) library(htmltools) timeline_widget <- function(start, duration, label, error_message, is_outgoing_call) { mapply(function(start, duration, label, error_message, is_outgoing_call) { doRenderTags( div(class = "timeline-widget", style = style(display = "grid", `grid-template-columns` = "fit-content(100px) fit-content(1500px)", `grid-column-gap` = "5px"), list( span(class = "timeline-marker", style = style(`margin-left` = paste0(round(start * 3) + 10, "px"), `min-width` = '1px', width = paste0(round(duration * 3), "px"), `background-color` = csscolor("#FA614B66")), HTML(" ")), span(class = "timeline-label", style = style(`marging-left` = "5px", `font-weight` = ifelse(!is_outgoing_call, "bold", NA), color = ifelse(!is.na(error_message), "red", NA)), label)))) }, start, duration, label, error_message, is_outgoing_call, SIMPLIFY = FALSE) }
data %>% formattable(list( timeline = ~timeline_widget(timeline_start, timeline_duration, timeline_label, error, outgoing), ) )















