Closed wccd closed 1 week ago
@wccd It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗
Please search issues first, like that. Duplicate of #18198, #18540 I want to know how to switch themes while keeping the option. echart will pollute the options after toggle theme. At this time, the options obtained by using the getOption Api are unreliable.
I would recommend:
const option = {...};
chart.setOption(option);
// reset theme when necessary
chart = echarts.init(dom, 'theme-name');
chart.setOption(option, true); // Use notMerge: true to reset all options before.
I would recommend:
const option = {...}; chart.setOption(option); // reset theme when necessary chart = echarts.init(dom, 'theme-name'); chart.setOption(option, true); // Use notMerge: true to reset all options before.
For some reason, I need to record echart's options for the next render. Just like JSON.string(echart.getOption()), But this will carry theme data,So I had to find a way to remove the theme data.
JSON.string(echart.getOption())
is Okay but the returned value also contains default values from ECharts.
What problem does this feature solve?
let option = this.chart.getOption(); echarts.dispose(this.chart); this.chart = echarts.init(dom, "themeName"); this.chart.setOption(option));
当前是这样设置主题的,会导致第二次调用时option已经是前一个主题内容,从而覆盖第二次使用的主题。不确定是否我的使用方式有误。
What does the proposed API look like?
期望有一个更便捷的切换主题内置方法