echarts 折线图设置背景图

设置echarts折线图颜色渐变,配置areaStyle即可:

option = {
    title: {
        text: '折线图颜色渐变'
    },
    tooltip: {
        trigger: 'axis'
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: false
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['周一','周二','周三','周四','周五','周六','周日']
    },
    yAxis: {
        type: 'value'
    },
    series: [
        {
 
            type:'line',
            areaStyle: {normal: {
                                color: new echarts.graphic.LinearGradient(
                                        0, 0, 0, 1,
                                        [    

                        { offset: 0, color: "rgba(148,235,113,0.5)" },

                       { offset: 0.5, color: "rgba(148,235,113,0.3)" },

                          { offset: 1, color: "rgba(148,235,113,0.1)" },
                                        ]
                                )
                            }},
            data:[120, 132, 101, 134, 90, 230, 210]
        }
    ]
};


版权声明:本文为m0_59993469原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。