echarts仪表盘进度条、指针动态渐变色显示

1. echarts仪表盘实现效果如下

![在这里插入图片描述](https://img-blog.csdnimg.cn/16fb476297514877b9d180c069983bbe.png

2. 配置项代码:

const option = {
  // 鼠标悬浮的提示
  tooltip: {
    formatter: '{b} : {c}'
  },
  series: [
    {
      type: 'gauge',
      min: 0, //最大值
      max: 100, //最小值
      startAngle: 200, //仪表盘起始角度。正右手侧为0度,正上方为90度,正左手侧为180度。
      endAngle: -20, //仪表盘结束角度
      splitNumber: 5, //仪表盘刻度的分割段数
      itemStyle: {
        color: '#f37215', //颜色
        shadowColor: 'rgba(0,138,255,0.45)', //阴影颜色
        shadowBlur: 10, //图形阴影的模糊大小
        shadowOffsetX: 2, //阴影水平方向上的偏移距离
        shadowOffsetY: 2 //阴影垂直方向上的偏移距离
      },
      progress: {
        show: true, //是否显示进度条
        roundCap: true, //是否在两端显示成圆形
        width: 18, //进度条宽度
        itemStyle: {
          color: {
            type: 'linear',
            x: 1,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: '#f12711' // 0% 处的颜色
              },
              {
                offset: 1,
                color: '#f5af19' // 100% 处的颜色
              }
            ],
            global: false // 缺省为 false
          }
        }
      },
      pointer: {
        show: true, //是否显示指针
        itemStyle: {
          color: {
            type: 'linear',
            x: 1,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: '#f12711' // 0% 处的颜色
              },
              {
                offset: 1,
                color: '#f5af19' // 100% 处的颜色
              }
            ],
            global: false // 缺省为 false
          }
        }
      },
      axisLine: {
        show: true, //是否显示仪表盘轴线
        roundCap: true, //是否在两端显示成圆形
        lineStyle: {
          width: 18 //轴线宽度
        }
      },
      axisTick: {
        show: true, //是否显示刻度
        distance: -29,
        itemStyle: {
          color: '#fff',
          width: 2
        }
      },
      splitLine: {
        show: true, //是否显示分隔线
        distance: -30
      },
      axisLabel: {
        show: true, //是否显示标签
        distance: -10
      },
      title: {
        show: true, //是否显示标题
        fontSize: 20
      },
      detail: {
        show: true, //是否显示详情
        valueAnimation: true, //是否开启标签的数字动画
        borderRadius: 8, //文字块的圆角
        offsetCenter: [0, '70%'], //相对于仪表盘中心的偏移位置,数组第一项是水平方向的偏移,第二项是垂直方向的偏移。可以是绝对的数值,也可以是相对于仪表盘半径的百分比
        fontSize: 50, //文字的字体大小
        fontWeight: 'bolder', //文字字体的粗细
        formatter: '{value}', //格式化函数或者字符串
        color: 'auto' //文本颜色
      },
      data: [
        {
          value: 90,
          name: '高危'
        }
      ]
    }
  ]
};

注意:echarts仪表盘不支持dataset

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值