博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
echart 图例设置自定义图标?
阅读量:6928 次
发布时间:2019-06-27

本文共 2439 字,大约阅读时间需要 8 分钟。

option = {    legend: {        orient: 'horizontal', // 'vertical'        x: 'right', // 'center' | 'left' | {number},        y: 'top', // 'center' | 'bottom' | {number}        backgroundColor: '#eee',        borderColor: 'rgba(178,34,34,0.8)',        borderWidth: 4,        padding: 10,    // [5, 10, 15, 20]        itemGap: 20,        textStyle: {color: 'red'},        selected: {            '降水量' : false        },        data: [            {                name:'蒸发量',                icon : 'image://../asset/ico/favicon.png',                textStyle:{fontWeight:'bold', color:'green'}            },            '降水量','最高气温', '最低气温'        ]    },    xAxis :{        data : ['周一','周二','周三','周四','周五','周六','周日']    },    yAxis : [        {            type : 'value',            axisLabel : {                formatter: '{value} ml'            }        },        {            type : 'value',            axisLabel : {                formatter: '{value} °C'            },            splitLine : {show : false}        }    ],    series : [        {            name:'蒸发量',            type:'bar',            data:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6]        },        {            name:'最高气温',            type:'line',            yAxisIndex: 1,            data:[11, 11, 15, 13, 12, 13, 10]        },        {            name:'降水量',            type:'bar',            data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6]        }    ]};// 动态添加默认不显示的数据var ecConfig = require('echarts/config');myChart.on(ecConfig.EVENT.LEGEND_SELECTED, function (param){    var selected = param.selected;    var len;    var added;    if (selected['最低气温']) {        len = option.series.length;        added = false;        while (len--) {            if (option.series[len].name == '最低气温') {                // 已经添加                added = true;                break;            }        }        if (!added) {            myChart.showLoading({                text : '数据获取中',                effect: 'whirling'            });            setTimeout(function (){                option.series.push({                    name:'最低气温',                    type:'line',                    yAxisIndex: 1,                    data:[-2, 1, 2, 5, 3, 2, 0]                });                myChart.hideLoading();                myChart.setOption(option);            }, 2000)        }     }});

参考地址:

如果这篇文章对您有帮助,您可以打赏我

 

技术交流QQ群:15129679

转载于:https://www.cnblogs.com/yeminglong/p/9099650.html

你可能感兴趣的文章
Windows Server AppFabric(Codename:"Dublin&Velocity")介绍
查看>>
Power BI官方视频(1) Power BI Desktop 7月份更新功能概述
查看>>
多参数sp_executesql
查看>>
Sql Server中的表组织和索引组织(聚集索引结构,非聚集索引结构,堆结构)
查看>>
人人都是 DBA(XI)I/O 信息收集脚本汇编
查看>>
Orchard之Module开发
查看>>
2016年“攻防”大战:安全厂商亮出新招数
查看>>
在Windows 10更新时按住SHIFT + F10可以绕过BitLocker加密
查看>>
华为中兴为何对未来信心十足?
查看>>
IDC:2020年Windows Phone系统将消失
查看>>
Windows 10 Creators Update隐私策略变动一览
查看>>
分布式数据库和Hadoop都不够好,于是我们设计分布式SQL计算系统
查看>>
国务院推进物联网等信息技术在物流服务中的应用
查看>>
Chatsworth公司推出了一款专为RFID卡读卡器设计的高科技数据中心柜锁
查看>>
西门子将以近10亿美元收购美工程软件公司CD-adapco
查看>>
Strategy Analytics:2017年企业移动性预测
查看>>
中国开发者无条件退款被人恶意利用 跪求同胞放过
查看>>
布局混合云,互联港湾为云计算未来加码
查看>>
东芝出售NAND业务进展:博通出价179亿美元,紫光否认竞标
查看>>
AMD AM4主板首曝:A320芯片组 惠普打造
查看>>