Method Signature
Description
ThesetOption() method is the primary way to configure and update an ECharts instance. It accepts a configuration object that defines all aspects of the chart including series data, axes, visual components, and animations.
Parameters
The complete chart configuration object. This can include series, xAxis, yAxis, title, legend, tooltip, and all other chart components.
When
false (default), the new option will be merged with the previous option. When true, all components in the previous option will be removed and new components will be created according to the new option.When
true, the chart will not be updated immediately. The update will be performed in the next animation frame. This is useful when calling setOption frequently to improve performance.Alternative: Using Options Object
An options object that provides more control over the update behavior.
Return Value
void - This method does not return a value.
Examples
Basic Usage
Updating Data Without Merge
Lazy Update for Performance
Using replaceMerge
Silent Update
With Transition Animation
Important Notes
When using
lazyUpdate: true, the chart update will be deferred to the next animation frame. This can significantly improve performance when calling setOption multiple times in quick succession.The
replaceMerge option is particularly useful when you want to replace all instances of a component type but still want to merge other components. For example, you might want to replace all series while keeping the existing axis configurations.Related Methods
- getOption() - Retrieve the current chart option
- resize() - Resize the chart
- dispatchAction() - Trigger chart actions
Source Reference
Implementation:src/core/echarts.ts:646-725