c_update: Update

Description Usage Arguments Examples

View source: R/api.R

Description

Update a chart.

Usage

1
c_update(c, duration = NULL, lazy = FALSE, easing = NULL)

Arguments

c

A proxy for a chart as returned by charter_proxy.

duration

Time for the animation of the redraw in milliseconds.

lazy

If TRUE the animation can be interrupted by other animations.

easing

The animation easing function. See Animation Easing for possible values.

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
33
34
35
library(shiny)

ui <- fluidPage(
 actionButton("add", "Add z serie"),
 actionButton("update", "Update chart"),
 charterOutput("chart")
)

server <- function(input, output){

 df <- data.frame(
   x = 1:100,
   y = runif(100),
   z = runif(100)
 )

 output$chart <- render_charter({
   chart(df, caes(x, y)) %>% 
     c_scatter()
 })

 observeEvent(input$add, {
   charter_proxy("chart") %>% 
     c_line(data = df, caes(x, z), update = FALSE)
 })

 observeEvent(input$update, {
   charter_proxy("chart") %>% 
     c_update()
 })

}

if(interactive())
 shinyApp(ui, server)

JohnCoene/charter documentation built on Feb. 20, 2022, 11:07 p.m.