echarts仪表盘配置


export default {
  props: {
    value: {
      type: Number,
      default: 20
    },
    img: {
      type: String,
      default: ''
    },
    color: {
      type: Array,
      default: () => {
        // return ['#DAE9FF', '#0066FF']
        return ['#2EC478', '#D2FFE8']
      }
    }
  },
  computed: {
    option () {
      const img = this.img
      const value = this.value
      const radius = ['36', '44']
      return {
        graphic: {
          elements: [
            {
              type: 'image',
              z: 5,
              style: {
                image: img,
                width: 20,
                height: 20
              },
              left: 'center',
              top: 'center'
            }
          ]
        },
        series: [
          {
            type: 'pie',
            radius: ['36', '42'],
            hoverAnimation: false,
            label: {
              show: false
            },
            animation: false,
            data: [
              {
                value: 100,
                labelLine: {
                  show: false
                },
                itemStyle: {
                  width: 1,
                  color: '#fff',
                  shadowBlur: 8,
                  shadowColor: '#F2F2F4'
                },
                label: {
                  show: false
                }
              }
            ]
          },
          // 底色圈
          {
            type: 'pie',
            radius: ['28', '36'],
            hoverAnimation: false,
            animation: false,
            // clockwise: false, // 逆时针增长

            data: [
              {
                value: value,
                labelLine: {
                  show: false
                },
                itemStyle: {
                  color: {
                    x: 0,
                    y: 1,
                    x2: 1,
                    y2: 0,
                    // 完成的圆环的颜色
                    colorStops: [
                      {
                        offset: 0,
                        color: this.color[0] // 0% 处的颜色
                      },
                      {
                        offset: 1,
                        color: this.color[1] // 100% 处的颜色
                      }
                    ]
                  },
                  shadowBlur: 10,
                  shadowColor: '#F7F9FE'
                },
                label: {
                  show: false
                }
              },
              {
                value: 100 - value,
                itemStyle: {
                  // opacity: 0,
                  color: '#F4F6FA'
                },
                label: {
                  show: false
                }
              }
            ]
          },
          // 刻度线
          {
            name: '刻度2',
            z: 3,
            type: 'gauge',
            hoverAnimation: false,
            animation: false,
            startAngle: '0',
            endAngle: '360',
            splitNumber: 28,
            center: ['50%', '50%'],
            radius: '57',
            axisLine: {
              show: false
            }, // 分隔线样式。
            splitLine: {
              show: true,
              length: 10,
              lineStyle: {
                width: 2,
                color: '#fff'
              }
            },
            labelLine: {
              show: false
            },
            axisLabel: {
              show: false
            },
            axisTick: {
              show: false
            },
            detail: {
              show: false
            }
          },
          // 指针外层圈
          {
            type: 'pie',
            radius: ['23', '25'],
            hoverAnimation: false,
            label: {
              show: false
            },
            animation: false,
            data: [
              {
                value: value,
                labelLine: {
                  show: false
                },
                itemStyle: {
                  color: {
                    x: 0,
                    y: 1,
                    x2: 1,
                    y2: 0,
                    // 完成的圆环的颜色
                    colorStops: [
                      {
                        offset: 0,
                        color: this.color[0] // 100% 处的颜色
                      },
                      {
                        offset: 0.5,
                        color: '#fff' // 100% 处的颜色
                      },
                      {
                        offset: 1,
                        color: '#fff' // 100% 处的颜色
                      }
                    ]
                  },
                  shadowBlur: 10,
                  shadowColor: '#F2F2F4'
                },
                label: {
                  show: false
                }
              },
              {
                value: 100 - value,
                itemStyle: {
                  // opacity: 0,
                  color: '#fff'
                }
              }
            ]
          },
          // 指针
          {
            name: '刻度2',
            type: 'gauge',
            hoverAnimation: false,
            animation: false,
            startAngle: '90',
            endAngle: '450',
            center: ['50%', '50%'],
            radius: 100,
            // clockwise: false,
            axisLine: {
              show: false
            }, // 分隔线样式。
            splitLine: {
              show: false
            },
            labelLine: {
              show: false
            },
            axisLabel: {
              show: false
            },
            axisTick: {
              show: false
            },
            detail: {
              show: false
            },
            pointer: {
              show: true,
              width: 1,
              itemStyle: {
                // color: this.color[0]
                color: {
                  // 完成的圆环的颜色
                  colorStops: [
                    {
                      offset: 0,
                      color: '#Fff' // 100% 处的颜色
                    },
                    {
                      offset: 1,
                      color: this.color[0] // 100% 处的颜色
                    }
                  ]
                }
              },
              length: '38%'
            },
            data: [{ value: value }]
          }
        ]
      }
    }
  },
  data () {
    return {
      chart: null
    }
  }
}

2.如果需要倾斜 给父盒子 transform:rotateX(30deg)  30deg为倾斜角度

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值