## the data argument: three items
dtable <- data.frame(
group = c("confirmed", "possible", "eclipse"),
content = c("Susan and Martha", "Roger", "Eclipse"),
start = c("2018-01-23", "2018-01-27", "2018-01-31"),
end = c("2018-02-03", "2018-02-01", NA),
className = c("confirmed", "possible", "eclipse"))
## the groups argument: three groups. re-use 'id' as 'className'
## (could be different)
gtable <- data.frame(
id = c("eclipse", "confirmed", "possible"),
content = c("Eclipse", "confirmed", "possible"),
title = c("Eclipse itself",
"people who are 100% (+/-) planning on coming at this time",
"people who have said they might come at this time"),
className = c("eclipse", "confirmed", "possible"))
## style for data strips' background color, group label color
styles <- "
.vis-item.possible { background-color: LightGray; }
.vis-item.confirmed { background-color: Khaki; }
.vis-item.eclipse { background-color: MediumSeaGreen; }
.vis-labelset .vis-label.possible { color: Black; }
.vis-labelset .vis-label.confirmed { color: #71670f; }
.vis-labelset .vis-label.eclipse { color: #004d00; }"
## create visualization object
tv <- timevis(data=dtable, groups=gtable)
## the object returned by timevis() is of class c("timevis",
## "htmlwidget"). one can run htmltools methods on it. so, add our
## styles to tv.
tv <- tagList(list(tags$head(tags$style(styles, type="text/css")), tv))
## (after this, tv is of class c("shiny.tag.list", "list"))
html_print(tv) # display
When not in shiny: