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

echartsInstance.setOption更新graphic报错 #5783

Closed
ybbdaidai opened this Issue May 19, 2017 · 0 comments

Comments

Projects
None yet
3 participants
@ybbdaidai

One-line summary [问题简述]

barChart中监听legendselectchanged事件并用echartsInstance.setOption更新graphic时报错。错误信息是Uncaught TypeError: Cannot set property '__alive' of undefined

  • 调试后发现:更新的option中只有graphic,如果换成title就不会出错。
  • 感觉和下面的逻辑相关,如果可以,我想知道下graphic与其他 type 的不同,为什么要额外判断?
zrUtil.each(option, function(o, mainType) {
    mainType !== 'graphic' && (this.__lastOnlyGraphic = false);
}, this);

/* -------------------------------------------------------------------------------------- */

if (this.__lastOnlyGraphic) {
    each(this._componentsViews, function(componentView) {
        var componentModel = componentView.__model;
        if (componentModel && componentModel.mainType === 'graphic') {
            componentView.render(componentModel, ecModel, this._api, payload);
            updateZ(componentModel, componentView);
        }
    }, this);
    this.__lastOnlyGraphic = false;
} else {
    updateMethods.update.call(this, payload);
}

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: 3.5.4
  • Browser version [浏览器类型和版本]: Chrome 58.0.3029.96 (64-bit)
  • OS Version [操作系统类型和版本]: Win7

Expected behaviour [期望结果]

更新指定 id 的graphic元素的内容。

ECharts option [ECharts配置项]

option = {
    graphic: [
    {
        "type": "group",
        "id": "MCC0",
        "children": [
	        {
	            "type": "text",
	            "id": "MCCnumber0",
	            "left": 0,
	            "style": {
	                "text": "35"
	            }
	        }, 
	        {
	            "type": "text",
	            "id": "MCCunit0",
	            "left": 24.89599609375,
	            "style": {
	                "text": "CNTR"
	            }
	        }
        ]
    }, 
    {
        "type": "group",
        "id": "VDL1",
        "children": [
	        {
	            "type": "text",
	            "id": "VDLnumber1",
	            "left": 0,
	            "style": {
	                "text": "5,849"
	            }
	        }, 
	        {
	            "type": "text",
	            "id": "VDLunit1",
	            "left": 46.59197998046875,
	            "style": {
	                "text": "CNTR"
	            }
	        }
        ]
    }, {
        "type": "group",
        "id": "CRD2",
        "children": [
	        {
	            "type": "text",
	            "id": "CRDnumber2",
	            "left": 0,
	            "style": {
	                "text": "1, 871"
	            }
	        }, 
	        {
	            "type": "text",
	            "id": "CRDunit2",
	            "left": 46.59197998046875,
	            "style": {
	                "text": "CNTR"
	            }
	        }
        ]
    }]
}

Other comments [其他信息]

报错后的 chart 中再次选中的legend的 stack 的区域颜色透明
screenshot

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