echarts柱状图、折线图颜色渐变

echarts柱状图颜色渐变

1.效果:
echarts柱状图、折线图颜色渐变_第1张图片

2.代码:

 series : [
  {
                name:'使用频率',
                type:'bar',
                barWidth: '30%',
                data:[ 52, 134, 148, 175, 104],
                itemStyle:{
                    barBorderRadius: [5,5,0,0],
                    //新建一个渐变色生成器
                    color: new echarts.graphic.LinearGradient(
                        0, 0, 0, 1,
                        [
                            {offset: 0, color: '#00d4ff'},
                            {offset: 1, color: '#8e3ff4'}
                        ]
                    )
                }
            }
        ]

3.折线图颜色渐变效果
echarts柱状图、折线图颜色渐变_第2张图片

4.代码:series中的 areaStyle如下:

areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: '#6c2054'},
                                {offset: 1, color: 'transparent'}//transparent是渐变到无色。
                            ]
                        )
                    }
                },

你可能感兴趣的:(echarts柱状图、折线图颜色渐变)