Echarts 背景渐变柱状图

 

var dom = document.getElementById("container");
var myChart1 = echarts.init(dom);
var app = {};
option1 = null;
 //初始化数据
    var category = ['深圳市', '东莞市', '广州市', '惠州市', '北京市', '上海市', '武汉市'];
    var barData = [7913, 4910, 3810, 2054, 988, 3979, 818]; var option1 = { title: { text: '柱状图示例', textStyle: { color: '#03a9f4' } }, legend: { data:['用户数'] }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, grid: { left: '3%', right: '16%', bottom: '3%', containLabel: true }, xAxis: { type: 'value', axisLine: { show: false, lineStyle: { color: "#ff0" } }, axisLabel: { rotate:45, //倾斜度 -90 至 90 默认为0 show: false }, axisTick: { show: false }, splitLine: { // 分隔线 show: false, // 默认显示,属性show控制显示与否  }, }, yAxis: { type: 'category', data: category, splitLine: { // 分隔线 show: false, // 默认显示,属性show控制显示与否  }, axisLine: { show: false, lineStyle: { color: "#ff0" } }, axisTick: { show: false }, offset: 10, }, series: [ { name: '数量', type: 'bar', data: barData, barWidth: 14, // barGap: 10, // smooth: true,  label: { normal: { show: true, position: 'right', offset: [5, -2], textStyle: { color: '#F68300', fontSize: 13 } } }, itemStyle: { emphasis: { barBorderRadius: 7 }, normal: { barBorderRadius: 7, color: function(params){ var colorList = [ ['#3977E6','#37BBF8'], ['#E8576C','#661C5A'] ] for(let i=0;i<barData.length;i++){ if(barData[params.dataIndex] <= 3000){ return new echarts.graphic.LinearGradient( 0, 0, 1, 0, [ {offset: 0, color: '#3977E6'}, {offset: 1, color: '#37BBF8'} ]) }else{ return new echarts.graphic.LinearGradient( 0, 0, 1, 0, [ {offset: 0, color: '#E8576C'}, {offset: 1, color: '#661C5A'} ]) } } } }, }, }, ] }; if (option1 && typeof option1 === "object") { myChart1.setOption(option1, true); }

 

转载于:https://www.cnblogs.com/minjh/p/9068261.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值