TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/apache/echarts/llms.txt
Use this file to discover all available pages before exploring further.
echarts.init() method creates and initializes an ECharts instance on a specified DOM element.
Signature
Parameters
The DOM element to mount the chart. Must have width and height (except for canvas elements or when width/height specified in opts).
In SSR mode (
opts.ssr = true), the dom parameter can be null.Theme to apply. Can be:
- A registered theme name (string)
- A theme object
nullfor default theme
Initialization options.
EChartsInitOpts Properties
Renderer type. Canvas is more performant, SVG provides better scalability and smaller file size for simple charts.
Device pixel ratio for high-DPI displays. Defaults to
window.devicePixelRatio.Explicit width in pixels. Can be a number or ‘auto’. By default uses the DOM element’s
clientWidth.Explicit height in pixels. Can be a number or ‘auto’. By default uses the DOM element’s
clientHeight.Locale for internationalization. Can be a locale name string or a complete locale object.
Enable dirty rectangle optimization for better rendering performance. Only redraws changed areas.
Whether to use coarse pointer (larger hit test areas for touch devices).
true: Always use coarse pointerfalse: Never use coarse pointer'auto': Auto-detect based on device
Pointer size for hit testing when using coarse pointer mode.
Enable server-side rendering mode. When true, the chart can be rendered without a DOM element.
Returns
An ECharts instance with methods for configuration, interaction, and lifecycle management.See ECharts Instance for available methods.
Examples
Basic Initialization
Using SVG Renderer
With Theme and High DPI
Server-Side Rendering
Responsive Chart with Dirty Rect Optimization
Important Behaviors
DOM Requirements: The DOM element should have explicit width and height set via CSS or inline styles. Zero-width or zero-height elements will trigger a warning.
Canvas Elements: When using a
<canvas> element as the DOM, width and height requirements are more flexible as they can be specified in the opts parameter.Performance Considerations
Canvas vs SVG
- Canvas: Better for charts with large amounts of data points or frequent updates
- SVG: Better for charts with fewer elements, or when you need to manipulate individual elements via DOM
Dirty Rectangle Rendering
EnableuseDirtyRect for better performance with frequent updates:
See Also
- ECharts Instance - Instance methods and properties
- echarts.dispose() - Dispose an instance
- echarts.getInstanceByDom() - Get instance by DOM element