setGroups: Set the groups of a timeline

Description Usage Arguments Examples

View source: R/api.R

Description

Set the groups of a timeline

Usage

1

Arguments

id

Timeline id or a timevis object (the output from timevis())

data

A dataframe containing the groups data to use.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
timevis(data = data.frame(
  start = c(Sys.Date(), Sys.Date(), Sys.Date() + 1, Sys.Date() + 2),
  content = c("one", "two", "three", "four"),
  group = c(1, 2, 1, 2)),
  groups = data.frame(id = 1:2, content = c("G1", "G2"))
) %>%
  setGroups(data.frame(id = 1:2, content = c("Group 1", "Group 2")))


if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    actionButton("btn", "Change group names")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis(data = data.frame(
               start = c(Sys.Date(), Sys.Date(), Sys.Date() + 1, Sys.Date() + 2),
                         content = c("one", "two", "three", "four"),
                         group = c(1, 2, 1, 2)),
              groups = data.frame(id = 1:2, content = c("G1", "G2")))

    )
    observeEvent(input$btn, {
      setGroups("timeline",
               data.frame(id = 1:2, content = c("Group 1", "Group 2")))
    })
  }
)
}

westdana/Timeline documentation built on July 28, 2017, 12:13 a.m.