if(tab.name == 'first'){
myChart.setOption({
legend: {
selected:{
[this.playNumber]:true,
[this.coverNumber]:false,
[this.touchNumber]:false,
[this.winPrizeNum]:false,
[this.takePrizeNum]:false
}
}, })
}else if(tab.name == 'second'){
myChart.setOption({
legend: {
selected:{
[this.playNumber]:false,
[this.coverNumber]:true,
[this.touchNumber]:false,
[this.winPrizeNum]:false,
[this.takePrizeNum]:false
}
},
})
}else if(tab.name == 'third'){
myChart.setOption({
legend: {
selected:{
[this.playNumber]:false,
[this.coverNumber]:false,
[this.touchNumber]:true,
[this.winPrizeNum]:false,
[this.takePrizeNum]:false
}
},
})
}else if(tab.name == 'fourth'){
myChart.setOption({
legend: {
selected:{
[this.playNumber]:false,
[this.coverNumber]:false,
[this.touchNumber]:false,
[this.winPrizeNum]:true,
[this.takePrizeNum]:false
}
}
})
}else if(tab.name == 'five'){
myChart.setOption({
legend: {
selected:{
[this.playNumber]:false,
[this.coverNumber]:false,
[this.touchNumber]:false,
[this.winPrizeNum]:false,
[this.takePrizeNum]:true
}
}
})
}

  代码优化:

var arr = {'first':[this.playNumber],'second':[this.coverNumber],'third':[this.touchNumber],'fourth':[this.winPrizeNum],'five':[this.takePrizeNum]};
var obj = {
[this.playNumber]:false,
[this.coverNumber]:false,
[this.touchNumber]:false,
[this.winPrizeNum]:false,
[this.takePrizeNum]:false
};
Object.keys(arr).forEach(function(key){
if(tab.name == key){
obj[arr[key]] = true;
}
});
myChart.setOption({
legend: {
selected: obj
},
});

  

echarts设置option中的数据对象优化的更多相关文章

  1. oracle中的数据对象

    oracle中的数据对象有表.视图.索引.序列等 表的相关操作 1.创建表 方式一: 方式二:create table person( create table person1 id number(1 ...

  2. Redis中的数据对象

    redis对象 redis中有五种常用对象 我们所说的对象的类型大多是值的类型,键的类型大多是字符串对象,值得类型大概有以下几种,但是无论哪种都是基于redisObject实现的 redisObjec ...

  3. Tensorflow中的数据对象Dataset

    基础概念 在tensorflow的官方文档是这样介绍Dataset数据对象的: Dataset可以用来表示输入管道元素集合(张量的嵌套结构)和"逻辑计划"对这些元素的转换操作.在D ...

  4. Echarts的option中的data问题

    option = { title : { text: '某站点用户访问来源', subtext: '纯属虚构', x:'center' }, tooltip : { trigger: 'item', ...

  5. 微信小程序 setData动态设置数组中的数据

    setdata传递动态数据值必须为对象(只能是key:value) 语法如下 this.setData({ filter: 1212 }) 如果setdata要传递数组呢? 首先相到的是 this.s ...

  6. 针对vue中请求数据对象新添加的属性不能响应式的解决方法

    1.需要给对象添加属性时,不能采用传统的obj.属性=值,obj[属性]=值 来添加属性,在vue页面时需要这样使用 this.$set(obj,"propertyName",&q ...

  7. PHP 设计模式 笔记与总结(9)数据对象映射模式

    [数据对象映射模式] 是将对象和数据存储映射起来,对一个对象的操作会映射为对数据存储的操作.例如在代码中 new 一个对象,使用数据对象映射模式就可以将对象的一些操作比如设置一些属性,就会自动保存到数 ...

  8. php设计模式 数据对象映射模式

    数据对象映射模式,是将对象和数据存储映射起来,对一个对象的操作会映射为对数据存储的操作. 在代码中实现数据对象映射模式,实现一个ORM类,将复杂的sql语句映射成对象属性的操作.对象关系映射(Obje ...

  9. PHP设计模式笔记六:数据对象映射模式 -- Rango韩老师 http://www.imooc.com/learn/236

    数据对象映射模式 1.数据对象映射模式,是将对象和数据存储映射起来,对一个对象的操作会映射为对数据存储的操作 2.在代码中实现数据对象映射模式,我们将实现一个ORM类,将复杂的SQL语句映射成对象属性 ...

随机推荐

  1. c#领域驱动设计

    代码是个程序员都能写, 怎么的代码才是好的,   --------------------------------------------------------------------------- ...

  2. canvas 水波纹

    <!DOCTYPE html> <html> <head> <title>水波背景</title> <meta charset=&qu ...

  3. lua调用不同lua文件中的函数

    a.lua和b.lua在同一个目录下 a.lua调用b.lua中的test方法,注意b中test的写法 _M 和 a中调用方法: b.lua local _M = {}function _M.test ...

  4. 杂记:Django和static,Nginx配置路径,json_schema

    前记:知识无处不在,要懂得珍惜,找到适合自己的方法高效地学习有价值的知识,不念过去,不畏将来. Django对待静态资源,在非前后端分离时的常识 Django会对项目app下的static文件夹的静态 ...

  5. 《c++ concurrency in action》读书笔记2--线程管理

    一.线程的启动 1. 每个c++程序至少有一个线程,是由C++ runtime启动的 2. 在c++11中,通过一个std::thread 对象启动线程.可以向std::thread传递一个函数,或者 ...

  6. sql server 将两列数据合并到一列 拼接

    create table a( s nvarchar null, ss nvarchar null, f decimal(18,1) null, ff decimal(18,1) null,)INSE ...

  7. django面试题

    1. 对Django的认识?   #1.Django是走大而全的方向,它最出名的是其全自动化的管理后台:只需要使用起ORM,做简单的对象定义,它就能自动生成数据库结构.以及全功能的管理后台. #2.D ...

  8. time 与 datetime 模块的常用方法

    时间格式 一个名词: UTC(Coordinated Universal Time):格林威治天文时,世界标准时间.中国为东八区 UTC+8 在编程的世界中,一定要了解的几种时间格式: 1.时间戳 从 ...

  9. UnicodeEncodeError: 'gbk' codec can't encode character '\xee'

    在将爬取到的内容写入文件时候报了这个错误,解决方案是在open()的时候给encoding参数传'utf-8'就好了,因为网页的编码就是utf-8. with open('douban.html',' ...

  10. 使用contenteditable=true的div模拟textarea(vue2.0中使用,带placeholder且高度自动撑开)

    子组件: <template> <div class="item-address"> <span v-show="!hasAddress&q ...