The options configuration system is the core way to configure and update Apache ECharts charts. Every chart configuration, from data to styling, is defined through option objects.Documentation 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.
The setOption API
ThesetOption method is the primary way to configure a chart instance. It accepts an option object and optional configuration parameters.
Basic Usage
Method Signature
Based on the implementation in~/workspace/source/src/core/echarts.ts:643-725, setOption has two signatures:
Configuration Options
notMerge
By default,setOption merges new options with existing ones. Set notMerge: true to replace the entire configuration:
lazyUpdate
When callingsetOption frequently, use lazyUpdate to defer the update until the next animation frame:
Lazy updates are useful when calling
setOption multiple times in quick succession. The chart will only render once instead of multiple times.silent
Prevent triggering events when updating options:replaceMerge
Control how specific component types are merged. Only components with matching IDs will be merged; others are removed:transition
Configure transition animations when updating:Option Object Structure
Option objects follow a hierarchical structure. From~/workspace/source/src/core/echarts.ts:682, options are processed through the OptionManager:
Multiple Series Example
Dynamic Updates
You can update specific parts of the option without affecting others:Getting Current Option
Retrieve the current option configuration usinggetOption():
~/workspace/source/src/core/echarts.ts:799-801, this returns the complete merged option object.
Best Practices
- Use lazy update for frequent updates: When updating data rapidly (like streaming data), use
lazyUpdate: true - Specify component IDs: When using
replaceMerge, always setidon components you want to track - Partial updates: Only include the options you want to change instead of the entire configuration
- Theme first: Set themes during initialization rather than in every
setOptioncall
Related APIs
getOption()- Get current option configurationsetTheme()- Update chart themeclear()- Clear all options and reset chartdispose()- Destroy chart instance