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

原框架使用Prototype的方式直接扩展原型,导致了图表不能使用。 #4129

Closed
z20905547 opened this issue Sep 21, 2016 · 0 comments

Comments

@z20905547
Copy link

问题简述 (One-line summary)

使用标签式单文件引入老项目中,报data.slice not a function。

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version): ECharts 2.2.7
  • 浏览器类型和版本 (Browser version):Chromium 51.0.2704.79
  • 操作系统类型和版本 (OS Version): Ubuntu 14.04 (64-bit)

重现步骤 (Steps to reproduce)

1.使用标签式单文件引入
2.在实例化前扩展原型 Object.prototype.toTestECharts=function(){ console.log("test echarts");}
3.硬编码实例化一个最简单的报表

期望结果 (Expected behaviour)

报表能像demo中一样显示

可能哪里有问题 (What went wrong)

源码中大量遍历对象的操作,将原型链中定义的函数也遍历出来了,但预期代码里没对函数做例外处理。

ECharts配置项 (ECharts option)

if(!Object.prototype.tojsonstring)Object.prototype.tojsonstring=function(){console.log("abc");}
option = {
                 tooltip: {
                        show: true
                    },
                    legend: {
                        data:['销量']
                    },
                    xAxis : [
                        {
                            type : 'category',
                            data : ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            "name":"销量",
                            "type":"bar",
                            "data":[5, 20, 40, 10, 10, 20]
                        }
                    ]
}

其他信息 (Other comments)

@100pah 100pah closed this as completed in c770b51 Sep 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant