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. vjson.hpp

    //vov #ifndef VJSON_HPP #define VJSON_HPP #include <iostream> #include <string> #include ...

  2. 序列比对和构建进化树(clustalw和phylip)

    安装clustalw很简单,不提了. 找了几个蛋白序列进行比对,命名为dm.fasta 1.输入 ./clustalw2  进入交互模式 2.选择1 并输入文件名字 3.输入2, 进行多序列比对 4. ...

  3. Python第三方库的安装 --Python3

    1.使用安装包管理工具安装:easy_install .pip/pip3 easy_install:easy_install是由PEAK(Python Enterprise Application K ...

  4. node.js 生成二维码

    因为自己的项目中,想在商品详情页上 显示一个 商品优惠券的二维码. 以此为需求. node.js 后台代码 const qr_image = require("qr-image") ...

  5. 微信小程序-列表渲染多层嵌套循环

    微信小程序-列表渲染多层嵌套循环 入门教程之列表渲染多层嵌套循环,目前官方的文档里,主要是一维数组列表渲染的案例,还是比较简单单一,给刚入门的童鞋还是无从入手的感觉. <view wx:for= ...

  6. 【IDEA填坑】xml不编译

    今天在maven编译Springboot项目的时候,发现src/main/resources下的配置文件编译失败(就是war包中没有放入xml配置文件导致程序启动失败),经查询资料,发现新版本的IDE ...

  7. centos 7安装myslq

    # wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community- ...

  8. 笔记:stm32 printf重定向到UART疑点解析

    在调试过程中往往需要通过打印来看系统运行状态:在STM32平台上,打印重定向有多种实现方案:其一是编译时使用keil自带的MacroLIB,据说这个库对一些C语言基础设施做了新的实现,代码结构更加紧凑 ...

  9. nginx 基本操作及配置

    基本操作: 1.启动nginx {global}/nginx 例如:/usr/local/Cellar/nginx/1.13.12/bin/nginx 2.重启nginx {global}/nginx ...

  10. 【Redfin SDE intern】跪经

    萌新的面试第一弹 Redfin是我求职生涯中的第一家,第一个电面,第一个onsite.除了结果不好,其他过程都很好... 春节当天风风火火去西雅图面试,之前分配的五个面试官其中有两个中国人,然而全部被 ...