echart 漸變內置生成器echarts.graphic.LinearGradient


const option = {
  title:{
    text:'▎商家銷售統計',
    textStyle:{
      fontSize:30
    },
    left:20,
    top:20
  },
  // 配置圖標的位置  不包含坐標軸中的文字
  grid:{
    top:'20%',
    left:'3%',
    bottom:'3%',
    right:'6%',
    containLabel:true // 包含坐標軸中的文字
  },
  xAxis:{
    type:'value',
  },
  yAxis:{
    type:'category',
    data:sellerName
  },
  series:[
    {
      type:'bar', // 柱狀圖
      data:sellerValue,
      barWidth:66,
      label:{
        show:true, // 顯示數值
        position:'right',
        textStyle:{
          color:'#fff'
        }
      },
      itemStyle:{
        barBorderRadius:[0,33,33,0],
        // 指明顏色漸變的方向
        color:new this.$echarts.graphic.LinearGradient(0,0,1,0,[
          {
            offset:0,
            color:'#5052EE'
          },
          {
            offset:1,
            color:'#AB6EE5'
          }
        ])
      }
    }
  ]
}

前4個參數用於配置漸變色的起止位置, 這4個參數依次對應右/下/左/上四個方位. 而0 0 0 1則代表漸變色從正上方開始.

第5個參數則是一個數組, 用於配置顏色的漸變過程. 包含offset和color兩個參數. offset的范圍是0 ~ 1, 用於表示顏色過渡位置, color表示顏色


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM