New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property '__ecGraphicWidth' of null #6237

Open
yeahe83 opened this Issue Jul 20, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@yeahe83

yeahe83 commented Jul 20, 2017

One-line summary [问题简述]

在window.onresize中对graphic进行操作时,出现‘Cannot read property '__ecGraphicWidth' of null’的错误。似乎3.5.3时还正常。

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: 3.6.2
  • Browser version [浏览器类型和版本]: Chrome 59
  • OS Version [操作系统类型和版本]: win10

Expected behaviour [期望结果]

不报错

ECharts option [ECharts配置项]

var option = {
  graphic: {
    id: 'text1',
    type: 'rect',
    shape: {
      x:0,
      y:0,
      width: 100,
      height: 100,
    },
    style: {
      fill: 'red',
    }
  },
};

var myChart = echarts.init(document.getElementById('main'));
myChart.setOption(option);

window.onresize = function() {
  document.getElementById('wid').innerText = window.innerWidth;
  var option = myChart.getOption();
  if (window.innerWidth < 600) {
    option.graphic = { // 删除上例中定义的 'text1' 元素。
      id: 'text1',
      $action: 'remove'
    }
  }
  else {
    option.graphic = {
      id: 'text1',
      type: 'rect',
      shape: {
        x:0,
        y:0,
        width: 100,
        height: 100,
      },
      style: {
        fill: 'red',
      }
    }
  }
  myChart.setOption(option);
}

window.onresize();

Other comments [其他信息]

https://jsfiddle.net/yeahe83/5ue92077/

@CWSchen

This comment has been minimized.

Show comment
Hide comment
@CWSchen

CWSchen Jul 20, 2017

你可以改用 window事件监听,或是,写一个js方法,通过监听 获取到的 width 的值,如果值大于 600,再去调echarts图表试一下。

CWSchen commented Jul 20, 2017

你可以改用 window事件监听,或是,写一个js方法,通过监听 获取到的 width 的值,如果值大于 600,再去调echarts图表试一下。

@100pah 100pah added enhancement bug and removed enhancement labels Jul 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment