echarts.init(). It provides methods for chart configuration, interaction, and lifecycle management.
Getting an Instance
Create an ECharts instance using theinit() method:
Type Definition
EChartsType interface extends the ECharts class, providing access to all instance methods.
Core Instance Methods
Configuration
- setOption() - Set chart option and render
- getOption() - Get current chart option
- setTheme() - Update theme and repaint
Dimensions
- getWidth() - Get canvas width
- getHeight() - Get canvas height
- getDom() - Get the DOM container
- resize() - Resize the chart
Interaction
- dispatchAction() - Trigger chart action
- on() - Bind event handler
- off() - Unbind event handler
Coordinate Conversion
- convertToPixel() - Convert logical coordinate to pixel coordinate
- convertFromPixel() - Convert pixel coordinate to logical coordinate
- containPixel() - Check if pixel point is in coordinate system
Export
- getDataURL() - Export chart as image data URL
- getConnectedDataURL() - Export connected charts as single image
- renderToCanvas() - Render chart to canvas element
- renderToSVGString() - Render chart to SVG string (SVG renderer only)
Loading State
- showLoading() - Display loading animation
- hideLoading() - Hide loading animation
Lifecycle
- clear() - Clear the chart (sets empty option)
- dispose() - Destroy the chart instance and release resources
- isDisposed() - Check if instance has been disposed
Data Operations
- appendData() - Append data for streaming (incremental rendering)
Advanced
- getVisual() - Get visual encoding from series or data
- getZr() - Get ZRender instance
- getId() - Get chart instance ID
- isSSR() - Check if in server-side rendering mode
Properties
Unique identifier for the chart instance
Group ID for connecting multiple charts. Charts with the same group ID will be synchronized.
Example: Basic Instance Usage
Example: Connected Charts
Important Notes
The instance methods should not be called during the main process (
setOption, resize, or dispatchAction execution). Nested calls may cause unexpected behavior.Use
isDisposed() to check if an instance is still valid before calling other methods:See Also
- echarts.init() - Initialize an ECharts instance
- echarts.dispose() - Dispose an instance
- echarts.connect() - Connect multiple instances