echarts柱状图带渐变边框

echarts柱状图

在这里插入图片描述

var chartDom = document.getElementById('meiti');
var myChart = echarts.init(chartDom);
var option;
option = {
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow'
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [{
        type: 'category',
        data: ['抖音', '微信', '安防交易网', '今日头条', '快手', '西瓜视频', '搜狐新闻', '小红书', '百度百家', '百度贴吧'],
        axisTick: {
            alignWithLabel: true
        },
        axisLabel: {
            interval:0,
            textStyle: {
                fontSize: 14,
                color: '#abc7ff'
            },
            formatter: function (value) {
                // x轴两个字换行
                if (value.length >= 4) {
                    return value.substring(0,2) + '\n' + value.substring(2)
                } else {
                    return value
                }
            }
        },
    }, ],
    yAxis: [{
        type: 'value',
        name: '单位:量',
        nameLocation: 'end',
        offset:'-10',
        nameTextStyle: {
            color: '#abc7ff',
            fontSize: 14,
        },
        splitLine: {
            lineStyle: {
                color: '#293e60'
            }
        },
        axisLabel: {
            textStyle: {
                fontSize: 14,
                color: '#abc7ff'
            }
        },
        axisLine: {
            show: false
        }
    }],
    series: [{
        name: 'Direct',
        type: 'bar',
        barWidth: '30%',
        data: [10, 52, 200, 334, 390, 330, 220,390,390,390],
        itemStyle: {
            normal: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: '#004552'
                }, {
                    offset: 0.8,
                    color: '#002859'
                    }], false),
                // 边框渐变
                borderColor:new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: '#00ebb1'
                }, {
                    offset: 0.8,
                    color: '#001330'
                    }], false)
            },
        },
        label: {
            normal: {
                show: true,
                fontSize: 14,
                color: '#abc7ff',
                position: 'top',
            }
        },
    }]
};
//自适应
window.onresize = myChart.resize;
option && myChart.setOption(option);
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值