zoom: Zoom in/out the current visible window

zoomR Documentation

Zoom in/out the current visible window

Description

Zoom in/out the current visible window

Usage

zoomIn(id, percent = 0.5, animation = TRUE)

zoomOut(id, percent = 0.5, animation = TRUE)

Arguments

id

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

percent

The amount to zoom in or out. Must be a number between 0 and 1. A value of 0.5 means that after zooming out the timeline will show 50% more content.

animation

Whether or not to animate the zoom.

Examples

## Not run: 
timevis() %>%
  zoomIn()

timevis() %>%
  zoomOut(0.3)

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    sliderInput("zoom", "Zoom by", min = 0, max = 1, value = 0.5, step = 0.1),
    checkboxInput("animate", "Animate?", TRUE),
    actionButton("zoomIn", "Zoom IN"),
    actionButton("zoomOut", "Zoom OUT")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis()
    )
    observeEvent(input$zoomIn, {
      zoomIn("timeline", percent = input$zoom, animation = input$animate)
    })
    observeEvent(input$zoomOut, {
      zoomOut("timeline", percent = input$zoom, animation = input$animate)
    })
  }
)
}

timevis documentation built on Nov. 3, 2022, 9:06 a.m.