You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "unitrongroup-ir (via GitHub)" <gi...@apache.org> on 2026/10/06 22:29:33 UTC
[I] [Bug] setTheme() with no theme, null or an unregistered name silently keeps the current theme [echarts]
unitrongroup-ir opened a new issue, #21779:
URL: https://github.com/apache/echarts/issues/21779
### Version
6.1.0
### Steps to Reproduce
Standalone HTML, no external link:
```html
<div id="c" style="width:400px;height:300px"></div>
<script src="https://cdn.jsdelivr.net/npm/echarts@6.1.0/dist/echarts.min.js"></script>
<script>
const chart = echarts.init(document.getElementById('c'), 'dark');
chart.setOption({ xAxis: { type: 'category', data: ['a', 'b'] }, yAxis: {}, series: [{ type: 'bar', data: [1, 2] }] });
chart.setTheme(undefined); // same with null, or a name that was never registered ('light')
// the chart is still dark
chart.setTheme({}); // this one goes back to the default theme
</script>
```
### Current Behavior
`ECharts.prototype._updateTheme` only assigns `this._theme` when the argument resolves to a truthy theme, so `setTheme(undefined)`, `setTheme(null)` and `setTheme('<unregistered name>')` leave the previous theme in place, without a warning. There is no documented way to go back to the default theme; `setTheme({})` or `registerTheme('light', {})` works, but only by accident. `init(dom, undefined)` means "default theme", so `setTheme(undefined)` is expected to mean the same.
### Expected Behavior
`setTheme(undefined | null)` goes back to the default theme, and an unregistered name logs a warning in development (like other invalid arguments) instead of silently doing nothing.
### Additional Comments
A plain `chart.getDataURL()` pixel check shows that the dark background stays opaque after the three calls and turns transparent after `setTheme({})`. Related, but a different problem of the same method: #21200.
--
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] setTheme() with no theme, null or an unregistered name silently keeps the current theme [echarts]
Posted by "schizophrenicmaniac (via GitHub)" <gi...@apache.org>.
schizophrenicmaniac commented on issue #21779:
URL: https://github.com/apache/echarts/issues/21779#issuecomment-6026652405
Hi, I'd like to work on this. In _updateTheme, null/undefined would reset to the default theme like init() does, and an unregistered name would log a dev warning instead of being silently ignored. I'll add unit tests for all three cases.
--
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] setTheme() with no theme, null or an unregistered name silently keeps the current theme [echarts]
Posted by "unitrongroup-ir (via GitHub)" <gi...@apache.org>.
unitrongroup-ir commented on issue #21779:
URL: https://github.com/apache/echarts/issues/21779#issuecomment-6411895710
Friendly ping for a review of #21781 (by @schizophrenicmaniac), which fixes this issue: `setTheme(undefined | null)` goes back to the default theme and an unregistered name logs a warning in development, with unit tests for all three cases. It has been waiting for a reviewer since 2026-10-06. We work around the bug in our app until it is released and would be glad to drop the workaround. Thank you!
--
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