Timevis-使不同的盒子的颜色取决于不同组中的名称

时间:2019-02-26 11:59:47

标签: r plot visualization timeline

您好,我想做的是使所有包含开放状态的范围显示为“红色”,而工作人员会议显示为蓝色。是否可以这样做,只能查看有关根据组更改颜色的文档。 我知道我可以使用样式来更改文本,但这只会更改框内文本的颜色,而不会更改框的背景阴影。

 library(timevis)
    # Data for groups example
    dataGroups <- data.frame(
      id = 1:11,
      content = c("Open", "Open",
                  "Open", "Open", "Half price entry",
                  "Staff meeting", "Open", "Adults only", "Open", "Hot tub closes",
                  "Siesta"),
      start = c("2016-05-01 07:30:00", "2016-05-01 14:00:00",
                "2016-05-01 06:00:00", "2016-05-01 14:00:00", "2016-05-01 08:00:00",
                "2016-05-01 08:00:00", "2016-05-01 08:30:00", "2016-05-01 14:00:00",
                "2016-05-01 16:00:00", "2016-05-01 19:30:00",
                "2016-05-01 12:00:00"),
      end   = c("2016-05-01 12:00:00", "2016-05-01 20:00:00",
                "2016-05-01 12:00:00", "2016-05-01 22:00:00", "2016-05-01 10:00:00",
                "2016-05-01 08:30:00", "2016-05-01 12:00:00", "2016-05-01 16:00:00",
                "2016-05-01 20:00:00", NA,
                "2016-05-01 14:00:00"),
      group = c(rep("lib", 2), rep("gym", 3), rep("pool", 5), NA),
      type = c(rep("range", 9), "point", "background")
    )

    groups <- data.frame(
      id = c("lib", "gym", "pool"),
      content = c("Library", "Gym", "Pool")
      )

    timevis(data = dataGroups, groups = groups)

1 个答案:

答案 0 :(得分:0)

您需要执行以下操作:

 tags$head(
    tags$style(HTML(".vis-item.blah { color: black; background-color: #1ac6ff; border-color: #1ac6ff; }"))

.blah是项className