Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation about how to add custom style to timevis #45

Closed
daattali opened this issue Jan 16, 2018 · 0 comments
Closed

Add documentation about how to add custom style to timevis #45

daattali opened this issue Jan 16, 2018 · 0 comments

Comments

@daattali
Copy link
Owner

When not in shiny:

## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant