ec.init {echarty}R Documentation

Initialize command


Required to build a chart. In most cases this will be the only command necessary.


  df = NULL,
  preset = TRUE,
  ctype = "scatter",
  load = NULL,
  tl.series = NULL,
  width = NULL,
  height = NULL,



A data.frame to be preset as dataset, default NULL
For crosstalk df should be of type SharedData.
Timeline requires a grouped data.frame to build its options.
If grouping is on multiple columns, only the first one is used to determine settings.


Build preset xAxis,yAxis,serie for 2D, or grid3D,xAxis3D,yAxis3D,zAxis3D for 3D, default TRUE (enable).


Chart type of series. Default is 'scatter'. Set to NULL to disable series preset.


Name(s) of plugin(s) to load. Could be a character vector or comma-delimited string. default NULL.


A list to build a timeline or NULL(default). The list defines options series and their attributes.
Requires a grouped data.frame df. The only indispensable attribute is encode.
encode defines which data columns names to use for the axes:

  • set x and y for coordinateSystem cartesian2d

  • set lng and lat for coordinateSystem geo

  • set radius and angle for coordinateSystem polar

  • set value and itemName for pie chart

  • set value and name for map chart

Attribute coordinateSystem is not set by default and depends on chart type.
Auto-generated timeline and options will be preset for the chart as well.
tl.series cannot be used for hierarchical charts like graph,tree,treemap,sankey. Chart options/timeline have to be built directly, see example.

width, height

A valid CSS unit (like '100%', '500px', 'auto') or a number, which will be coerced to a string and have 'px' appended.


other arguments to pass to the widget.
Custom widget arguments include:

  • elementId - Id of the widget, default is NULL(auto-generated)

  • ask - prompt user before downloading plugins when load is present, FALSE by default

  • js - single string or a vector with JavaScript expressions to evaluate.
    First expression is evaluated before chart initialization.
    Second is evaluated with an exposed object opts.
    Third is evaluated with an exposed chart object after opts have been set.

  • renderer - 'canvas'(default) or 'svg'

  • locale - 'EN'(default) or 'ZH'. Define others like so, see definitions.

  • useDirtyRect - enable dirty rectangle rendering or not, FALSE by default, see here


Command ec.init creates a widget with createWidget, then adds some ECharts features to it.
When ec.init is chained after a data.frame, a dataset is preset.
When the data.frame is grouped and ctype is not null, more datasets with legend and series are also preset. Grouped series are preset as type scatter.
Plugin '3D' presets will not work for 'scatterGL'. Instead, use preset=FALSE and set explicitly xAxis,yAxis.
Plugins 'leaflet' and 'world' preset zoom=6 and center to the mean of all coordinates.
Users can delete or overwrite any presets as needed.
ec.plugjs will be called internally for each load entry, popup prompts controlled by parameter ask.

Built-in plugins:

Plugins with one-time installation:

or install your own third-party plugins.


A widget to plot, or to save and expand with more features.

See Also

Package information in echarty-package.


 # basic scatter chart from a data.frame, using presets
cars |> ec.init()
 # a timeline with two series and autoPlay
p <- iris |> dplyr::group_by(Species) |> ec.init(
    encode=list(x=NULL, y=c('Sepal.Width', 'Petal.Length')),
    markPoint = list(data=list(list(type='max'), list(type='min')))
p$x$opts$timeline <- append(p$x$opts$timeline, list(autoPlay=TRUE))
p$x$opts$legend <- list(list())  # add legend

[Package echarty version 1.4.5 Index]