Skip to content
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

Closed
yeahe83 opened this issue Jul 20, 2017 · 2 comments
Closed

Cannot read property '__ecGraphicWidth' of null #6237

yeahe83 opened this issue Jul 20, 2017 · 2 comments
Labels
bug stale Inactive for a long time. Will be closed in 7 days.

Comments

@yeahe83
Copy link

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
Copy link

CWSchen commented Jul 20, 2017

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

@stale
Copy link

stale bot commented Apr 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Inactive for a long time. Will be closed in 7 days. label Apr 2, 2020
@stale stale bot closed this as completed Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale Inactive for a long time. Will be closed in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants