Skip to content

setOption() causes brush controls to disappear #9303

@aengl

Description

@aengl

One-line summary [问题简述]

If setOption() is called more then once, brush controls disappear.

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: 4.2.0-rc.2
  • Browser version [浏览器类型和版本]: Google Chrome 70.0.3538.77 (Official Build) (64-bit)
  • OS Version [操作系统类型和版本]: macOS Mojave 10.14

Expected behaviour [期望结果]

It should still be possible to use brushes on the graph after updating its data via setOption().

ECharts option [ECharts配置项]

var option = {
  brush: {},
  series: [
    {
      data: [[1, 1], [2, 2]],
      type: 'scatter',
    },
  ],
  xAxis: {},
  yAxis: {},
};

Other comments [其他信息]

Here is an html file that replicates the issue:

<html>

<head>
  <meta charset="utf-8">
  <script src="./node_modules/echarts/dist/echarts.min.js"></script>
</head>

<body>
  <div id="main" style="width:600px; height:400px;"></div>
  <script type="text/javascript">
    var myChart = echarts.init(document.getElementById('main'));
    var option = {
      brush: {},
      series: [
        {
          data: [[1, 1], [2, 2]],
          type: 'scatter',
        },
      ],
      xAxis: {},
      yAxis: {},
    };
    myChart.setOption(option);
    setInterval(() => {
      // Bug: this setOption() call makes the brush controls disappear!
      myChart.setOption(option);
      // If we set "notMerge" to true the controls won't disappear, but now it
      // becomes impossible to interact with the chart since the setOption()
      // call now cancels all existing brushes
      // myChart.setOption(option, true);
    }, 1000);
  </script>
</body>

</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.staleInactive for a long time. Will be closed in 7 days.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions