echarts实现颜色渐变的折线图(包括自定义各种配置项的属性)

效果图:

实现代码:

option = {
    backgroundColor: 'rgba(255,255,255,0)',
    title: {
        show: false,
        text: '近半年各月新入驻企业情况',
        subtext: '纯属虚构'
    },
    tooltip: {
        trigger: 'axis',
        textStyle: {
            fontSize: 18
        }
    },
    legend: {
        icon: 'rect',
        textStyle: {
            color: '#000',
            fontSize: 18
        },
        data: ['累积企业数', '新增企业数']
    },
    toolbox: {
        show: false,
        feature: {
            mark: {
                show: true
            },
            dataView: {
                show: true,
                readOnly: false
            },
            magicType: {
                show: true,
                type: ['line', 'bar', 'stack', 'tiled']
            },
            restore: {
                show: true
            },
            saveAsImage: {
                show: true
            }
        }
    },
    calculable: true,
    xAxis: [{
        nameTextStyle: {
            color: '#000'
        },
        type: 'category',
        boundaryGap: false,
        asisLine: {
            show: true,
            onZero: true,
            lineStyle: {
                width: 1,
                type: 'solid',
                color: '#000'
            }
        },
        splitLine: {
            show: true,
            lineStyle: {
                color: 'black'
            }
        },
        axisLabel: {
            show: true,
            textStyle: {
                color: '#000',
                fontSize: '18'
            }
        },
        data: ['2013', '2014', '2015', '2016', '2017', '2018']
    }],
    yAxis: [{
        type: 'value',
        asisLine: {
            show: true,
            onZero: true,
            lineStyle: {
                width: 1,
                type: 'solid',
                color: '#000'
            }
        },
        splitLine: {
            show: true,
            lineStyle: {
                color: 'black'
            }
        },
        axisLabel: {
            textStyle: {
                color: '#000',
                fontSize: '18'
            }
        },
    }],
    series: [{
        z: 3,
        name: '累积企业数',
        type: 'line',
        smooth: false,
        itemStyle: {
            normal: {
                color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                    offset: 0,
                    color: '#8F89EB'
                },
                {
                    offset: 0.9,
                    color: '#ffffff'
                }]),
                areaStyle: {
                    type: 'default'
                }
            }
        },
        data: [150, 160, 270, 460, 280, 540]
    },
    {
        name: '新增企业数',
        type: 'line',
        smooth: false,
        itemStyle: {
            normal: {
                color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                    offset: 0,
                    color: '#2FE0D4'
                },
                {
                    offset: 0.9,
                    color: '#ffffff'
                }]),
                areaStyle: {

                    type: 'default'
                }
            }
        },
        data: [350, 450, 520, 620, 690, 550]
    }]
};

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MrZhouGx

觉得对你有用的话可以支持一下

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值