echarts-进度条


在这里插入图片描述

基本演示

  option = {
       title: {
           text:"xxxx统计",
           left: '1%',
           top: '0%',
           textStyle: {
               color: "#2E3033",
               fontSize:18,
           },
       },
       tooltip: {
           axisPointer: {
               type: "shadow",
           },
       },
       grid: {
           top: '9%',
           left: "12%",
           right:"22%",
           bottom:"0%",
       },
       xAxis: {
           type: 'value',
           splitLine: {
               show: false //去掉辅助线
           },
           axisLine: {
               show: false,
           },
           axisLabel: {
               show: false,
           }

       },
       yAxis: {
           type: 'category',
           data: ['栋','xx','xx','xx','xx','xx','xx'],//y轴数据
           splitLine: {
               show: false //去掉辅助线
           },
           axisLine: {
               show: false,
           },
           axisTick: {
               show: false
           },
           axisLabel: {
               color: '#2E3033',
               fontSize:14,
           }
       },
       series: [{
           data: [566228.07,877228.07,955228.07,436228.07,498228.07,326228.07,854228.07],
           type: 'bar',
           showBackground: true,
           backgroundStyle: {
               color: '#BDE2EF',
               borderRadius:5,
           },
           barWidth: 10,
           itemStyle: {
               normal: {
                   color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                           offset: 0,
                           color: '#25B9EB'
                       },
                       {
                           offset: 1,
                           color: '#25B9EB'
                       }
                   ], false),
                   barBorderRadius: [5, 5, 5, 5],
               }
           },
           label: {
               normal: {
                   show: true,
                   position: [270, 0],   //value的位置
                   color: '#8E949D', //值的颜色
                   fontSize: 14,
               }
           }
       }]
   };


这里数值位于右侧,但是是固定宽度,所以在不同尺寸电脑上看到的有所差别,不能自适应
在这里插入图片描述

进度条动态固定到右侧

下面方法可以做到label自适应到右侧
思路:动态获取整个标签宽度,减去一个固定值即可

 var chartW=$("#Chart").width();
 chartW=chartW-0.30*chartW;
 
 position:[chartW,0],//重点是这里!!!!
var chartW=$("#Chart").width();
chartW=chartW-0.30*chartW;
option = {
     title: {
         text:"xxxx统计",
         left: '1%',
         top: '0%',
         textStyle: {
             color: "#2E3033",
             fontSize:18,
         },
     },
     tooltip: {
         axisPointer: {
             type: "shadow",
         },
     },
     grid: {
         top: '9%',
         left: "12%",
         right:"22%",
         bottom:"0%",
     },
     xAxis: {
         type: 'value',
         splitLine: {
             show: false //去掉辅助线
         },
         axisLine: {
             show: false,
         },
         axisLabel: {
             show: false,
         }

     },
     yAxis: {
         type: 'category',
         data: ['栋','xx','xx','xx','xx','xx','xx'],//y轴数据
         splitLine: {
             show: false //去掉辅助线
         },
         axisLine: {
             show: false,
         },
         axisTick: {
             show: false
         },
         axisLabel: {
             color: '#2E3033',
             fontSize:14,
         }
     },
     series: [{
         data: [566228.07,877228.07,955228.07,436228.07,498228.07,326228.07,854228.07],
         type: 'bar',
         showBackground: true,
         backgroundStyle: {
             color: '#BDE2EF',
             borderRadius:5,
         },
         barWidth: 10,
         itemStyle: {
             normal: {
                 color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                         offset: 0,
                         color: '#0077D5'
                     },
                     {
                         offset: 1,
                         color: '#0077D5'
                     }
                 ], false),
                 barBorderRadius: [5, 5, 5, 5],
             }
         },
         label: {
             normal: {
                 show: true,
                 // position: [270, 0],   //value的位置
                 // position: 'right',
                 position:[chartW,0],//重点是这里!!!!
                 color: '#8E949D', //值的颜色
                 fontSize: 14,
             }
         }
     }]
 };
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值