– Introduction – | R Documentation |
echarty provides a lean interface between R and Javascript library ECharts.
With only two major commands (ec.init and ec.upd), it can trigger multiple native ECharts options to build a chart.
The benefits - learn a very limited set of commands, and enjoy the full functionality of ECharts.
echarty provides a lean interface between R and Javascript library ECharts. We encourage users to follow the original ECharts API documentation to construct charts with echarty. The main command ec.init can set multiple native ECharts options to build a chart. The benefits - learn a very limited set of commands, and enjoy the full functionality of ECharts.
pipe-friendly - supports both %>% and |> commands have three prefixes to help with auto-completion:
ec. for general functions, like ec.init
ecs. for Shiny functions, like ecs.output
ecr. for rendering functions, like ecr.band
Event handling is usually necessary only in Shiny. See code in
eshiny.R,
run as demo(eshiny)
.
echarty has three built-in event callbacks - click, mouseover,
mouseout. All other ECharts
events could be
initialized through p$x$capture
. Another option is to use p$x$on
with JavaScript handlers, see code in
ec.examples.
These are htmlwidget and ECharts initialization parameters supported by echarty. There are code samples for most of them in ec.examples:
capture = event name(s), to monitor events, usually in Shiny
on = define JavaScript code for event handling, see ECharts
registerMap = define a map from a geoJSON file, see ECharts
group = group-name of a chart, see ECharts
connect = command to connect charts with same group-name, see ECharts
locale = EN(default) or ZH, set from locale parameter of ec.init, see ECharts.
renderer = canvas(default) or svg, set from renderer in ec.init, see ECharts.
jcode = custom JavaScript code to execute, set from js parameter of ec.init
R indexes are counted starting from 1. JS indexes are counted starting from 0. echarty supports R-counting in series-encode x,y,tooltip and visualMap-continuous dimension when set through ec.init. All other indexes like xAxisIndex, gridIndex, etc. need to be set in JS-counting (for now).
Here is the complete list of sample code locations:
code in Github tests
command examples, like in ec.init
Shiny code is in
eshiny.R,
run with demo(eshiny)
demos on RPubs
searchable gists
answers to Github issues
Options are set with R command options. Echarty uses the following options:
echarty.theme = name of theme file, without extension, from folder
/inst/themes
echarty.font = font family name
echarty.urlTiles = tiles URL template for leaflet maps
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.