dccInterval: Interval component

Description Usage Arguments Value Examples

View source: R/dccInterval.R

Description

A component that repeatedly increments a counter 'n_intervals' with a fixed time delay between each increment. Interval is good for triggering a component on a recurring basis. The time delay is set with the property "interval" in milliseconds.

Usage

1
2
dccInterval(id=NULL, interval=NULL, disabled=NULL, n_intervals=NULL,
max_intervals=NULL)

Arguments

id

Character. The ID of this component, used to identify dash components in callbacks. The ID needs to be unique across all of the components in an app.

interval

Numeric. This component will increment the counter 'n_intervals' every 'interval' milliseconds

disabled

Logical. If True, the counter will no longer update

n_intervals

Numeric. Number of times the interval has passed

max_intervals

Numeric. Number of times the interval will be fired. If -1, then the interval has no limit (the default) and if 0 then the interval stops running.

Value

named list of JSON elements corresponding to React.js properties and their 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
36
37
38
39
40
41
42
43
44
45
46
47
48
if (interactive() && require(dash)) {
    library(dash)
    library(dashHtmlComponents)
    library(dashCoreComponents)
    library(plotly)

    app <- Dash$new()

    app$layout(
      htmlDiv(list(
        htmlH2('3 Second Updates'),
        dccInterval(id = '3s-interval',
                    interval= 3*1000,
                    n_intervals = 0),
        htmlDiv(list(
            dccGraph(id = 'live-graph')
          )
        )
        )
      )
    )

    app$callback(
      output = list(
        output('live-graph', 'figure')
      ),
      params = list(
        input('3s-interval', 'n_intervals')
      ),

      update_graph <- function(n_intervals) {
        df <- data.frame(
          'time' = c(1:8),
          'value' = sample(1:8, 8),
          'value-2' = sample(1:8, 8)
        )

        bar <- animation_opts(plot_ly(
          data = df, x=~time, y=~value, type = "bar"),
          1000, easing = "cubic-in-out"
        )

        return(list(bar))
      }
    )

   app$run_server()
}

Example output



dashCoreComponents documentation built on July 1, 2020, 8:20 p.m.