echarts4r version 0.2.1 supports the timeline component!

Let’s create some phoney data to demonstrate.

# fake data
df <- data.frame(
  year = c(
    rep(2016, 25),
    rep(2017, 25),
    rep(2018, 25),
    rep(2019, 25)
  ),
  x = rnorm(100),
  y = rnorm(100),
  grp = c(
    rep("A", 50),
    rep("B", 50)
  )
) 

With the phoney data:

df %>%
  group_by(year) %>% 
  e_charts(x, timeline = TRUE) %>% 
  e_scatter(y)

It works with most chart types.

df %>% 
  group_by(year) %>% 
  e_charts(x, timeline = TRUE) %>% 
  e_scatter(y) %>% 
  e_loess(y ~ x)

You can pass options to the timeline with e_timeline_opts.

library(dplyr)
library(echarts4r.maps)

df <- USArrests

# scale 0 to 1
.scl <- function(x){
    (x - min(x)) / (max(x) - min(x))
}

df %>% 
  mutate(
      State = row.names(.),
      Rape = .scl(Rape),
      Murder = .scl(Murder),
      Assault = .scl(Assault)
  ) %>% 
  select(State, Rape, Murder, Assault) %>% 
  group_by(State) %>% 
  tidyr::gather("Key",  "Value", Murder, Rape, Assault) %>% 
  group_by(Key) %>% 
  e_charts(State, timeline = TRUE) %>% 
  em_map("USA") %>% 
  e_map(Value, map = "USA") %>% 
  e_visual_map(min = 0, max = 1) %>% 
  e_timeline_opts(autoPlay = TRUE) %>% 
  e_timeline_serie(
    title = list(
      list(text = "Murder", subtext = "Percentage based on arrests"),
      list(text = "Rape", subtext = "Percentage based on arrests"),
      list(text = "Assault", subtext = "Percentage based on arrests")
    )
  )

The function e_timeline_opts is used to set general options on the timeline, i.e.: auto-play like above. The full list of options is on the official website.

However, we can also set options specific to each timestep with e_timeline_serie. The arguments to this function differ quite a bit from the rest of the package. As we have to assign options to multiple timesteps at once we need to pass vectors or lists of options, the length of the timesteps.

library(quantmod)

getSymbols(c("GS", "GOOG")) # Goldman Sachs & Google
#> [1] "GS"   "GOOG"
GS <- as.data.frame(GS)
GOOG <- as.data.frame(GOOG)

colnames <- c("Open", "High", "Low", "Close", "Volume", "Adjusted")
names(GS) <- colnames
names(GOOG) <- colnames

GS$sym <- "GS"
GOOG$sym <- "GOOG"

data <- bind_rows(GS, GOOG)
data$date <- rep(row.names(GS), 2)

data %>% 
  group_by(sym) %>% 
  e_charts(date, timeline = TRUE) %>% 
  e_candle(Open, Close, Low, High, legend = FALSE) %>% 
  e_y_axis(max = 1500) %>% 
  e_tooltip(trigger = "axis") %>% 
  e_timeline_opts(
    axis_type = "category",
    playInterval = 1500,
    top = 5,
    right = 50,
    left = 200
  ) %>% 
  e_datazoom() %>% 
  e_timeline_serie(
    title = list(
      list(text = "Goldman Sachs"),
      list(text = "Google")
    )
  ) 

Connect

You can also connect timelines as shown in the connect documentation. All principles shown there still hold for timelines. However, some things might not work properly; this is not on echarts4r but the original library.

# timeline
e1 <- iris %>%
  group_by(Species) %>%
  e_charts(Sepal.Length, timeline = TRUE, height = 250) %>%
  e_line(Sepal.Width) %>%
  e_datazoom(show = FALSE) %>%
  e_timeline_opts(
    orient = "vertical",
    right = 0,
    top = 0,
    bottom = 0
  ) %>%
  e_group("connected")

e2 <- iris %>%
  group_by(Species) %>%
  e_charts(Sepal.Length, height = 250) %>%
  e_line(Sepal.Width) %>%
  e_group("connected") %>%
  e_datazoom() %>%
  e_connect_group("connected")

e_arrange(e1, e2, rows = 2)

Hopefully this will be fixed soon!