ec.init | R Documentation |
Required to build a chart. In most cases this will be the only command necessary.
ec.init(
df = NULL,
preset = TRUE,
ctype = "scatter",
...,
series.param = NULL,
tl.series = NULL,
width = NULL,
height = NULL
)
df |
A data.frame to be preset as dataset, default NULL |
preset |
Boolean (default TRUE). Build preset attributes like dataset, series, xAxis, yAxis, etc. |
ctype |
Chart type of series. Default is 'scatter'. Set to NULL to disable series preset. |
... |
List contains other attributes to pass to the widget.
|
series.param |
Additional parameters for preset series, or NULL(default). |
tl.series |
A list to build a timeline or NULL(default). The list defines options series and their attributes.
Attribute coordinateSystem is not set by default and depends on chart type. |
width, height |
A valid CSS unit (like |
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 data.frame is grouped and ctype is not null, more datasets with legend and series are also preset.
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.
Numerical indexes for series,visualMap,etc. are R-counted (1,2...)
Built-in plugins:
leaflet - Leaflet maps with customizable tiles, see source
world - world map with country boundaries, see source
lottie - support for lotties
custom - renderers for ecr.band and ecr.ebars
Plugins with one-time installation:
liquid - liquid fill, see source
gmodular - graph modularity, see source
wordcloud - cloud of words, see source
or install your own third-party plugins.
Crosstalk:
Parameter df should be of type SharedData, see more info.
Optional parameter xtKey: unique ID column name of data frame df. Must be same as key parameter used in SharedData$new(). If missing, a new column XkeyX will be appended to df.
Enabling crosstalk will also generate an additional dataset called Xtalk and bind the first series to it.
A widget to plot, or to save and expand with more features.
# basic scatter chart from a data.frame, using presets
cars |> ec.init()
# grouping, tooltips, formatting
iris |> dplyr::group_by(Species) |>
ec.init( # init with presets
tooltip= list(show= TRUE),
series.param= list(
symbolSize= ec.clmn(4, scale=7),
tooltip= list(formatter= ec.clmn('Petal.Width: %@', 4))
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.