First, you should load recharts:

library(recharts)

1 Introduction

The default position of timeline is 6 o’clock.

The recommended approach to use setTimeline is chart %>% setTimeline(...).

2 Function Call

All the function names have two forms: small camel and lowercase_underscore (endorsed by Hadley Wickham). To be lazy, we also provide short forms as well (e.g., tl for timeline).

setTimeline(chart, show = TRUE, type = c("time", "number"),
  realtime = TRUE, x = 80, y = NULL, x2 = 80, y2 = 0, width = NULL,
  height = 50, bgColor = "rgba(0,0,0,0)", borderColor = "#ccc",
  borderWidth = 0, controlPosition = c("left", "right", "none"),
  autoPlay = FALSE, loop = TRUE, playInterval = 2000, lineStyle = NULL,
  label = NULL, checkpointStyle = NULL, controlStyle = NULL,
  symbol = "emptyDiamond", symbolSize = 4, currentIndex = 0,
  data = NULL, ...)

setTL(chart, show = TRUE, type = c("time", "number"), realtime = TRUE,
  x = 80, y = NULL, x2 = 80, y2 = 0, width = NULL, height = 50,
  bgColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0,
  controlPosition = c("left", "right", "none"), autoPlay = FALSE,
  loop = TRUE, playInterval = 2000, lineStyle = NULL, label = NULL,
  checkpointStyle = NULL, controlStyle = NULL, symbol = "emptyDiamond",
  symbolSize = 4, currentIndex = 0, data = NULL, ...)

set_timeline(chart, show = TRUE, type = c("time", "number"),
  realtime = TRUE, x = 80, y = NULL, x2 = 80, y2 = 0, width = NULL,
  height = 50, bgColor = "rgba(0,0,0,0)", borderColor = "#ccc",
  borderWidth = 0, controlPosition = c("left", "right", "none"),
  autoPlay = FALSE, loop = TRUE, playInterval = 2000, lineStyle = NULL,
  label = NULL, checkpointStyle = NULL, controlStyle = NULL,
  symbol = "emptyDiamond", symbolSize = 4, currentIndex = 0,
  data = NULL, ...)

set_tl(chart, show = TRUE, type = c("time", "number"), realtime = TRUE,
  x = 80, y = NULL, x2 = 80, y2 = 0, width = NULL, height = 50,
  bgColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0,
  controlPosition = c("left", "right", "none"), autoPlay = FALSE,
  loop = TRUE, playInterval = 2000, lineStyle = NULL, label = NULL,
  checkpointStyle = NULL, controlStyle = NULL, symbol = "emptyDiamond",
  symbolSize = 4, currentIndex = 0, data = NULL, ...)
Arg Requirement

chart

Echarts object generated by echartR or echart.

show

Logical. Show the timeline or not. Default TRUE. If you want to remove timeline from the echarts object, set it NULL.

type

‘time’ or ‘number’ format of the timeline. Default ‘time’.

realtime

Logical. If or not the changes take effect in realtime manner. Default TRUE.

x

x coordinate of the upper left point of the timeline bar. Default 80.

y

y coordinate of the upper left point of the timeline bar. Default NULL (automatic).

x2

x coordinate of the upper left point of the timeline bar. Default 80.

y2

y coordinate of the upper left point of the timeline bar. Default 0.

width

Width of the timeline. Could be a number or a character in percent form. Default NULL.

height

Height of the timeline. Default 50 (px).

bgColor

Background color of the timeline. Default “rgba(0,0,0,0)” (transparent).

borderColor

Border color of the timeline. Default “#ccc”.

borderWidth

The border width of the timeline. Default 0px (not shown).

controlPosition

Position of the control of the timeline. Could be ‘left’, ‘right’ or ‘none’. Default ‘left’.

autoPlay

Logical. Whether or not the timeline auto displays. Default FALSE.

loop

Logical. Whether or not the timeline displays in loop mode. Default TRUE.

playInterval

Interval when displays each timeslice. Default 2000 (ms).

lineStyle

A list. Line style of the timeline. Default value: list(color="#666", width=1, type="dashed"). Refer to function lineStyle.

label

A list. Label style of the timeline. Default value: list(show=TRUE, interval="auto", rotate=0, formatter=NULL, textStyle=list(color="#333")). Refer to function labelStyle.

checkpointStyle

A list. Checkpoint style of the timeline. Default value: list(symbol="auto", symbolSize="auto", color="auto", borderColor="auto", borderWidth="auto", label=list(show=FALSE, textStyle=list(color="auto"))). Supports features of ‘symbol’, ‘symbolSize’, ‘color’, ‘borderColor’, ‘borderWidth’, ‘label’.

controlStyle

A list. Control style of the timeline. Default value: list(itemSize=15, itemGap=5, normal=list(color="#333"), emphasis=list(color="#1e90ff")). Supports features of ‘itemSize’, ‘itemGap’, ‘normal’, ‘emphasis’.

symbol

Character. The symbol used in timeline. Default ‘emptyDiamond’. You can use symbols in setSymbols.

symbolSize

The size of the symbols. Default 4.

currentIndex

The current index position, in correspondance with z. It is used to show specific timeline slices. Default 0.

data

The data list of the timeline, also used as timeline data label. Default NULL.

Elipsis.

3 Showcase

g <- echartr(iris, Sepal.Width, Petal.Width, t=Species)
g

Initially timeline is shown. Let’s turn if off.

g %>% setTimeline(show=FALSE)

Relocate the timeline. Note that pos argument does not apply.

g %>% setTimeline(y=40)

Enable autoPlay and change playInterval.

g %>% setTimeline(autoPlay=TRUE, playInterval=500)

Reformat and rename labels.

g %>% setTimeline(label=labelStyle(textStyle=textStyle(
    color='red', fontFamily='Courier New')),
    data=c('iris 1', 'iris 2', 'iris 3'))

Other formats.

g %>% setTimeline(bgColor='yellow', borderWidth = 1,
                  borderColor='gray') %>%
    setGrid(y2=90)

Change the symbol.

g %>% setTimeline(symbol='emptyRectangle')

Locate on the second timeslot on load. currentIndex should be 1.

g %>% setTimeline(currentIndex=1)