While I’m mostly settled on ggplot2 for static plots, I’m always on the lookout for ways to make interactive visualizations. echarts4r is one of my new favorite packages for this. It’s intuitive, powerful, and flexible.

The echarts4r package is an R wrapper for the echarts JavaScript library, an official Apache Software Foundation project (it graduated from incubator status in December). That helps me feel confident I can rely on the JavaScript code underlying the R package.

So let’s take a look at echarts4r.

Package author John Coene explains the basics in a getting started page:

  • Every function in the package starts with e_.
  • You start coding a visualization by creating an echarts object with the e_charts() function. That takes your data frame and x-axis column as arguments.
  • Next, you add a function for the type of chart (e_line(), e_bar(), etc.) with the y-axis series column name as an argument.
  • The rest is mostly customization!

Let’s take a look.

Line charts with echarts4r

For example data, I downloaded and wrangled some housing price info by US city from Zillow. If you want to follow along, data instructions are at the end of this article.