The R package echartr provides an interface to the Echarts JavaScript library for creating interactive charts.
echartr aims to match the Echarts Javascript API as closely as possible so that you can refer directly to the official Echarts documentation.
This package is intended for more advanced users with Echarts familiarity. It is not intended to be a replacement for the popular echarts4r package, which is more user-friendly and provides a higher-level interface to Echarts.
Basic example
The option argument is provided as a list of lists:
Working with data frames
echartr provides helper functions for building Echart series from data frames
library(datasets)
library(echartr)
echartr(option = list(
xAxis = list(type = "value"),
yAxis = list(type = "value"),
legend = list(show = TRUE),
series = ec_scatter(iris,
# Data dimensions and series attributes are provided as expressions that can
# be evaluated for each row to build multiple series
Petal.Length, # x
Petal.Width, # y
name = as.character(Species),
symbol = if (Species == "versicolor") "circle" else "emptyCircle",
itemStyle = list(
opacity = if (Species == "setosa") 0.5 else 1
)
)
))