hustcc / echarts-for-react

⛳️ Apache ECharts components for React wrapper. 一个简单的 Apache echarts 的 React 封装。
https://git.hust.cc/echarts-for-react
MIT License
4.51k stars 629 forks source link

Add support for replaceMerge option like official Echarts `setOptions` #478

Open NattapongSiri opened 2 years ago

NattapongSiri commented 2 years ago

See: https://echarts.apache.org/en/api.html#echartsInstance.setOption There's an option replaceMerge which work in combination with notMerge option.

It seem like the only place to be modified is https://github.com/hustcc/echarts-for-react/blob/master/src/types.ts because https://github.com/hustcc/echarts-for-react/blob/0ab38618567b558413edde015bcb40931eb739ed/src/core.tsx#L69-L71 will automatically set this option to underlying Echart instance.

hustcc commented 1 year ago

Are there any bugs with current code?

echarts support 2 way to config notMerge.

RogerWenXin commented 1 year ago

how can I set replaceMerge with react-echarts

toeyps commented 1 year ago

The problem with it is the lack of support for functionality like replaceMerge. I'm not sure about meaning behind "2 way to config notMerge. Do you mean that it is currently possible to simulate replaceMerge by using notMerge ?

omuelle commented 1 year ago

will this be fixed anytime soon?

fedotenko-qs commented 1 year ago

This option is really helpful to solve https://github.com/apache/echarts/issues/6202 See: https://github.com/apache/echarts/issues/6202#issuecomment-974761211

ayden-canvass commented 1 year ago

would love to see this added, it's a huge issue for my project

lebaudantoine commented 1 year ago

Partial echartInstances.setOption method's parameters are supported in react-echart mapping. Refer to the method documentation for more details.

echartInstances.setOption accepts either : parameters

(option: Object, notMerge?: boolean, lazyUpdate?: boolean)

or

(option: Object, opts?: {
    notMerge?: boolean;
    replaceMerge?: string | string[];
    lazyUpdate?: boolean;
})

As the official documentation explains :

There are two ways to remove components: Totally removal: use notMerge: true, all of the components will be removed. Partially removal: use replaceMerge: [...], the specified types of components will be removed if no id matched. This mode is useful to keep the state (e.g., highlight / animation / selected area) of the other components while make removal.

Unfortunately, the react-echart library currently lacks support for the replaceMerge parameter. You can check the component internal logic and component props for further details.