Timevis - 使不同的框具有取决于不同组中名称的颜色 [英] Timevis - make different boxes have colour dependent on name in different groups

查看:75
本文介绍了Timevis - 使不同的框具有取决于不同组中名称的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Hi So what i'd like to be able to do is make all the ranges which contain open appear say "red" and Staff meeting appear blue. Is it possible to do this, could only see documentation on changing the colour based off the group. I know I can use style to change the text but that only changes the colour of the text inside the box and not the background shading of the box.

 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)

推荐答案

你需要做这样的事情:

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

其中 .blah 是一个项目类名

where .blah is an items className

这篇关于Timevis - 使不同的框具有取决于不同组中名称的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆