Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pass through replaceMerge when using setOption. #520

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ the echarts option config, can see [https://echarts.apache.org/option.html#title

when `setOption`, not merge the data, default is `false`. See [https://echarts.apache.org/api.html#echartsInstance.setOption](https://echarts.apache.org/api.html#echartsInstance.setOption).

- **`replaceMerge`** (optional, string | string[])

when `setOption`, default is `null`. See [https://echarts.apache.org/api.html#echartsInstance.setOption](https://echarts.apache.org/api.html#echartsInstance.setOption).

- **`lazyUpdate`** (optional, object)

when `setOption`, lazy update the data, default is `false`. See [https://echarts.apache.org/api.html#echartsInstance.setOption](https://echarts.apache.org/api.html#echartsInstance.setOption).
Expand Down
13 changes: 10 additions & 3 deletions src/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class EChartsReactCore extends PureComponent<EChartsReactProps> {
}

// when these props are not isEqual, update echarts
const pickKeys = ['option', 'notMerge', 'lazyUpdate', 'showLoading', 'loadingOption'];
const pickKeys = ['option', 'notMerge', 'replaceMerge', 'lazyUpdate', 'showLoading', 'loadingOption'];
if (!isEqual(pick(this.props, pickKeys), pick(prevProps, pickKeys))) {
this.updateEChartsOption();
}
Expand Down Expand Up @@ -183,11 +183,18 @@ export default class EChartsReactCore extends PureComponent<EChartsReactProps> {
* render the echarts
*/
private updateEChartsOption(): EChartsInstance {
const { option, notMerge = false, lazyUpdate = false, showLoading, loadingOption = null } = this.props;
const {
option,
notMerge = false,
replaceMerge = null,
lazyUpdate = false,
showLoading,
loadingOption = null,
} = this.props;
// 1. get or initial the echarts object
const echartInstance = this.getEchartsInstance();
// 2. set the echarts option
echartInstance.setOption(option, notMerge, lazyUpdate);
echartInstance.setOption(option, { notMerge, replaceMerge, lazyUpdate });
// 3. set loading mask
if (showLoading) echartInstance.showLoading(loadingOption);
else echartInstance.hideLoading();
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export type EChartsReactProps = {
* notMerge config for echarts, default is `false`
*/
readonly notMerge?: boolean;
/**
* replaceMerge config for echarts, default is `null`
*/
readonly replaceMerge?: string | string[];
/**
* lazyUpdate config for echarts, default is `false`
*/
Expand Down