You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "ay86 (via GitHub)" <gi...@apache.org> on 2025/08/14 10:00:54 UTC
[I] [Bug] Using the setTheme() method will lose other updated options [echarts]
ay86 opened a new issue, #21200:
URL: https://github.com/apache/echarts/issues/21200
### Version
6.0.0
### Link to Minimal Reproduction
https://jsfiddle.net/plainheart/e46ozpqj/7/
### Steps to Reproduce
Click the setTheme button and observe the changes in the chart data. It loses the updated series.
### Current Behavior
setOption() can merge new options and is often used when dynamically updating data. However, when setTheme() is executed, the later updated options will be lost.
```js
const chart = echarts.init(document.getElementById("chart-container"));
// first option
chart.setOption({
xAxis: {
type: "category",
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
},
yAxis: {
type: "value",
},
series: [],
});
// update option
chart.setOption({
series: [
{
data: [120, 200, 150, 80, 70, 110, 130],
type: "bar",
showBackground: true,
backgroundStyle: {
color: "rgba(180, 180, 180, 0.2)",
},
},
],
});
// run this method will lose updated options
function setDark() {
// set theme
chart.setTheme("dark");
}
```
### Expected Behavior
I hope to update the theme normally after executing setTheme() without losing the current options.
### Environment
```markdown
- OS:
- Browser:
- Framework:
```
### Any additional comments?
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] Using the setTheme() method will lose other updated options [echarts]
Posted by "Jogai (via GitHub)" <gi...@apache.org>.
Jogai commented on issue #21200:
URL: https://github.com/apache/echarts/issues/21200#issuecomment-4612800319
Hitting this too on **6.0.0 and 6.1.0**. A few extra signals that might help narrow down where it goes wrong, since the existing repro already shows the symptom:
**It's `setTheme` itself, not the framework around it.** Calling `chart.setTheme('dark')` directly on an instance that already has data is enough to break it — no Vue/React/wrapper involved. After the call, the populated series come back empty: data points go `null` and at least one whole series disappears from `getOption().series`.
**The option still holds the data.** Immediately re-applying the same option with `{ notMerge: true }` after `setTheme` restores every series and data point. So `setTheme` isn't dropping the option you passed — the internal update it triggers is discarding the already-built series.
**A layout warning fires synchronously during the call:**
```
[ECharts] Can't get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.
```
The container is a normal, non-zero size before and after, so this looks like the update pass kicked off by `setTheme` runs against a zero-size/!prepared state and throws away the series geometry.
**Where to look:** `ECharts.prototype.setTheme` → `prepare(this)` + `updateMethods.update.call(this, { type: 'setTheme' })`. The `type: 'setTheme'` update path is where things go off the rails.
Observed with the **SVG renderer**; I didn't bisect canvas vs svg, so can't say whether it's renderer-specific.
Workaround for anyone blocked: re-init the instance on theme change (dispose + `init`) instead of calling `setTheme`, or re-apply the option with `notMerge: true` right after.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] Using the setTheme() method will lose other updated options [echarts]
Posted by "mustcanbedo (via GitHub)" <gi...@apache.org>.
mustcanbedo commented on issue #21200:
URL: https://github.com/apache/echarts/issues/21200#issuecomment-3190669985
It's here, it's here, the bug fix you've been looking forward to is here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] Using the setTheme() method will lose other updated options [echarts]
Posted by "amad3v (via GitHub)" <gi...@apache.org>.
amad3v commented on issue #21200:
URL: https://github.com/apache/echarts/issues/21200#issuecomment-6087693269
Real-world use cases and a correction to the workaround in #21201 are in https://github.com/apache/echarts/pull/21201#discussion_r4233735446
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org