Data Viz with Echarts4r

R
Author

David Munoz Tord

Published

June 25, 2023

By David Munoz Tord

Goal: Learn about data visualization and familiarize yourself with some of the basic functions of the {echarts4r}.

{echarts4r} is back! And with version 4.5 the new features from version 5 of echarts.js are available now. Moreover, the morphing capabilities of echart.js have been ported to echarts4r as we will show in this post.

Read more about it

You can morph between plot like this:


library(echarts4r)
## Warning: le package 'echarts4r' a été compilé avec la version R 4.2.3

mtcars2 <- mtcars |> 
  head() |> 
  tibble::rownames_to_column("model")

e1 <- mtcars2 |> 
  e_charts(model) |> 
  e_bar(
    carb, 
    universalTransition = TRUE,
    animationDurationUpdate = 1000L
  )

e2 <- mtcars2 |> 
  e_charts(model) |> 
  e_pie(
    carb, 
    universalTransition = TRUE,
    animationDurationUpdate = 1000L
  )

cb <- "() => {
  let x = 0;
  setInterval(() => {
    x++
    chart.setOption(opts[x % 2], true);
  }, 3000);
}"



e_morph(e1, e2, callback = cb)
## Warning in e_morph(e1, e2, callback = cb): This is experimental

Morph between graphs.