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: [
        {
            name:'郵件營銷',
            type:'line',
            areaStyle: {normal: {
                                color: new echarts.graphic.LinearGradient(
                                        0, 0, 0, 1,
                                        [
                                            {offset: 0, color: 'red'},
                                            {offset: 0.5, color: 'pink'},
                                            {offset: 1, color: '#ddd'}
                                        ]
                                )
                            }},
            data:[120, 132, 101, 134, 90, 230, 210]
        }
    ]
};

效果圖如下:


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章