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.
The option argument is provided as a list of lists:
library(echartr)
echartr(option = list(
xAxis = list(type = "category", data = c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")),
yAxis = list(type = "value"),
series = list(
list(
name = "Example",
type = "line",
data = c(150, 230, 224, 218, 135, 147, 260),
smooth = TRUE
)
)
))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
)
)
))You can install the development version of echartr like so:
# install.packages("remotes")
remotes::install_github("meekalpha/echartr")