echart渐变折线图

效果图,以及代码。关键点在于渐变,后面代码中有注释说明。上下左右四个渐变方向,加上渐变的色彩偏移,既可以完成带渐变的折线图。需要与后端对接,只要改变X轴Y轴的数据,还有一些小的细节就可以了。比较简单实用。 

 

let option={
      color:'#38d7b7',
      tooltip: {
          trigger: 'axis',
         axisPointer: {
          type: 'line',
             lineStyle: {
             type: 'dashed',
             color: '#38d7b7'
             }
         }
      },
      grid: {
          left: '2%',
          right: '2%',
          bottom: '3%',
          containLabel: true
      },
      xAxis: {
          type: 'category',
          boundaryGap: true,
          data: ['2020-04-20', '2020-04-21', '2020-04-22', '2020-04-23', '2020-04-24', '2020-04-25', '2020-04-26'],
          axisLine:{
              lineStyle:{
                  width:1,
                  type:'dotted',
                  color:'#686868'
              }
          },
          axisTick:{
              show:false
          },
          axisLabel:{
             
          }
      },
      yAxis: {
        name:'近一周调查活动',
        nameTextStyle:{
    	    fontFamily: 'MicrosoftYaHei',
    	    fontSize: '14px',
    	    color: '#686868',
        },
        type: 'value',
        splitLine:{
            lineStyle:{
                type:'dashed'
            }
        },
        axisLine:{
           show:false
        },
          axisTick:{
              show:false
          }
    },
      series: [
          {
              type: 'line',
              smooth:true,
              data:  [15, 32, 14, 33, 9, 12, 41],
             symbolSize:1,
              itemStyle : {
                normal : {
                
              areaStyle : {
                  type : 'default',
                  //渐变色实现
              color : new echarts.graphic.LinearGradient(0, 0, 0, 1,//变化方向
                      //渐变色
                          [ { offset: 0, color: 'rgba(56, 215, 183, 0.4)' },
                          { offset: 0.89, color: 'rgba(56, 215, 183, 0.1)' }
                          ]),
              },
              lineStyle : {  //线的颜色
                  color : '#38d7b7'
              }
          },
        emphasis: { // 鼠标经过时:
            symbol: "circle",
            borderWidth:13,
            borderColor:'rgba(195,243,233,0.7)'
            // color: '#38d7b7',
            // borderColor: '#38d7b7',
            
            }
      },
          }
      ]
  };

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值