我正在尝试使用 timevis 包来创建一个交互式单日时间线构建器。进入时间轴的每个项目都会有一个以分钟为单位的“长度”属性。
我将时间线限制在今天上午 8 点到下午 5 点之间。
我希望每个项目在上午 8 点开始,但结束日期必须是
todayAM + length
如果需要,我可以更改长度的存储方式。
关于如何操纵时间的任何想法,以便我可以绘制基本块。(然后用户将它们拖到时间线上的所需位置。)
library(timevis)
today <- as.character(Sys.Date())
todayAM <- paste(today,"08:00:00")
todayPM <- paste(today, "17:00:00")
items <- data.frame(
category = c("Room","IceBreaker","Activity","Break"),
categoryid=c(1,2,3,4),
name = c("Big Room","Introductions","Red Rover","Lunch"),
length = c(480,60,120,90)
)
data <- data.frame(
id = 1:4,
start = c(todayAM, todayAM, todayAM, todayAM),
end = c(todayPM, todayPM, todayPM, todayPM),
content = items$name,
group = items$categoryid
)
groups <- data.frame(id= items$categoryid, content = items$category)
timevis(
data = data,
groups = groups,
fit = TRUE,
options = list(editable = TRUE, multiselect = TRUE, align = "center", stack = TRUE,
start = todayAM,
end = todayPM
)
)
