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

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

Comments

Projects
None yet
1 participant
@z20905547

问题简述 (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 in c770b51 Sep 23, 2016

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