Skip to content
ECharts

echarts.init & Option API Reference

Apache ECharts APIs — instance lifecycle (init/setOption/resize) and the option object driving series, axes, and tooltip.

By EZ4Code Team

echarts.init

Instance methods on an ECharts chart obtained via echarts.init(dom).

echarts.init(dom, theme?, opts?) -> ECharts

Initializes an ECharts instance on a DOM element, optionally with a registered theme and renderer/size opts.

Returns: ECharts

chart.setOption(option, opts?)

Sets (and merges) the chart configuration option. Use opts.notMerge=true to replace instead of merge.

Returns: void

chart.getOption() -> EChartsOption

Returns the current option object (a clone) of the chart, including merged and default values.

Returns: EChartsOption

chart.resize(opts?)

Resizes the chart. With no args, fits the container; with opts, sets width/height/silent explicitly.

Returns: void

chart.dispose()

Disposes the chart instance, releasing resources and removing the DOM it created.

Returns: void

Option

The setOption configuration object: series, xAxis, yAxis, and tooltip are the core of every chart.

series: [{ type, data, ... }]

Array of series definitions. Each series has a type (bar, line, pie, scatter, etc.) and a data array plus type-specific options.

Returns: option

xAxis: { type, data }

Configures the x axis. type 'category' uses data labels; 'value' is numeric; 'time' handles time axes.

Returns: option

yAxis: { type }

Configures the y axis. Most charts use one value axis; multiple axes can be declared as an array.

Returns: option

tooltip: { trigger, formatter }

Configures the hover tooltip. trigger 'item' (per data point, good for pie) or 'axis' (per axis, good for bar/line).

Returns: option

More ECharts API References