centerItem {linevis}R Documentation

Move the window such that given item or items are centered

Description

Move the window such that given item or items are centered

Usage

centerItem(id, itemId, options)

Arguments

id

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

itemId

A vector (or single value) of the item ids to center

options

Named list of options controlling mainly the animation. Most common option is "animation" = TRUE/FALSE. For a full list of options, see the "focus" method in the official graph2d documentation

Value

None, side-effect is Javascript call

Examples

## Not run: 
linevis(data.frame(
          start = c(Sys.Date() - 1, Sys.Date(), Sys.Date() + 1),
          content = c("Item 1", "Item 2", "Item 3"))
) %>%
  centerItem(1)

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    linevisOutput("graph2d"),
    actionButton("btn", "Center around item 1")
  ),
  server = function(input, output) {
    output$graph2d <- renderLinevis(
      linevis(
        data.frame(
          start = c(Sys.Date() - 1, Sys.Date(), Sys.Date() + 1),
          content = c("Item 1", "Item 2", "Item 3"))
      )
    )
    observeEvent(input$btn, {
      centerItem("graph2d", 1)
    })
  }
)
}

[Package linevis version 1.0.0 Index]