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

问题描述 投票:0回答:1

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

 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)
r plot visualization timeline
1个回答
0
投票

你需要做这样的事情:

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

其中.blah是一个item className

© www.soinside.com 2019 - 2024. All rights reserved.