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. HashMap循环过程中删除元素发生ConcurrentModificationException的源码分析

  2. Unity---在Hierarchy视图中将选中的对象的层级目录复制到剪切板

    using UnityEditor; using UnityEngine; public class ObjPathCopyTool : ScriptableObject { [MenuItem(&q ...

  3. vue 渲染后更新数据

    this.$set(this.selGetData,level,[{},{}])this.$set(this.selGetData,1,{message:"Test add attr&quo ...

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

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

  5. vue-element-ui之弹窗重置

    遇到列表中需要给弹框赋默认值并且关闭后需要清空数据+清除验证时可以这么写:

  6. redis常用命令使用集

    redis集群:https://www.cnblogs.com/PatrickLiu/p/8435214.html Redis命令总结 1.基于内存的key-value数据库 2.基于c语言编写的,可 ...

  7. MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a raster layer

    MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a  raster layer 一.前言 MapServer不仅支持 ...

  8. winform 所遇

    主程序调用客程序: 方法一: Process.Start( System.Windows.Forms.Application.StartupPath + "\\SelfUpdate.exe& ...

  9. 软件151 王楚博 JavaEE的配置

    一.准备以下压缩包 1.JDK1.7 文件:jdk1.7.rar 2. eclipse-jee-mars-2 文件:32位系统准备eclipse-jee-mars-2-win32.zip,64位系统准 ...

  10. c#连接db2数据库

    .net项目要连接db2数据库,是要安装客户端的,否则是连接不上的: 若出现“未在本地计算机上注册‘ibmdadb2’提供程序” 解决办法: 1.先找到安装后的ibmdadb2.dll文件复制到c:\ ...