Skip to content

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

@ay86

Description

@ay86

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.

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

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Metadata

Metadata

Assignees

Labels

bugenThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions