apache / apache/echarts

[Bug] Using the setTheme() method will lose other updated options

Open
#21,200 2 comments 1 reaction 1 assignee Claimed by @Ovilia View on GitHub
bug en pending
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### Version

6.0.0

### Link to Minimal Reproduction

https://jsfiddle.net/sb7rk0f3/

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.