setGroups {linevis}R Documentation

Set the groups of a graph2d

Description

Set the groups of a graph2d

Usage

setGroups(id, data)

Arguments

id

graph2d id or a linevis object (the output from linevis())

data

A dataframe containing the groups data to use.

Value

None, side-effect is Javascript call

Examples

## Not run: 
linevis(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")))

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    linevisOutput("graph2d"),
    actionButton("btn", "Change group names")
  ),
  server = function(input, output) {
    output$graph2d <- renderLinevis(
      linevis(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("graph2d",
               data.frame(id = 1:2, content = c("Group 1", "Group 2")))
    })
  }
)
}

[Package linevis version 1.0.0 Index]