echarts颜色渐变

myChart.setOption({
        title: {
          text: ''
        },
        tooltip : {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          },
          formatter: function(params, ticket, callback) {  
           return "时间:"+ params[0].axisValue + "<br/>"+ "上传流量:" + self.$methods.trafficSwitch(params[1].data) + "<br/>"+ "下载流量:" +self.$methods.trafficSwitch(params[0].data)
          } 
        },
        legend: {
          show:false,     
        },
        grid: {
          left: '0',
          right: '0',
          bottom: '0',
          containLabel: true
        },
        xAxis : [
          {
            type : 'category',
            splitLine:{show: false},
            boundaryGap : false,
            data : this.schedule,
            axisLine:{
              lineStyle:{
                color:"#aaa"
              }
            }
          }
        ],
        yAxis : [
          {
            type : 'value',
            splitLine:{show: false},
            show:false, 
            axisLine:{
              lineStyle:{
                color:"#aaa"
              }
            }
          }
        ],
        series : [
          {
            name:'上传流量',
            type:'line',
            smooth: true,
            areaStyle: {normal:{}},
            itemStyle: {           
              normal: {
                label : {show: false}, 
                color: new echarts.graphic.LinearGradient(
                  0, 0, 0, 1,
                  [
                    {offset: 0.2, color: ' #f8a3f2'},
                    {offset: 0.5, color: '#d4c8f0'},
                    {offset: 1, color: '#d4c8f0'}
                  ]
                )
              }
            },
            data:this.upload_traffic
          },
          {
            name:'下载流量',
            type:'line',
            smooth: true,
            areaStyle: {normal:{}},
            itemStyle: {
              normal: {
                label : {show: false},
                color: new echarts.graphic.LinearGradient(
                  0, 0, 0, 1,
                  [
                    {offset: 0.2, color: ' #2196f3'},
                    {offset: 0.5, color: '#9fdcf4'},
                    {offset: 1, color: '#9fdcf4'}
                  ]
                )
              }
            },
            data:this.download_traffic
          }
        ]
      });

猜你喜欢

转载自www.cnblogs.com/JeneryYang/p/9177437.html