【圆形容器实现进度条功能的图表组件】

圆形容器实现进度条功能的图表

组件内容

组件详情

<template>
  <div class="Garden_div" :style="{'height': getaddPx(radius)+'px'}">
    <div class="Garden" :style="{'background-position-y': '-'+getPx(percentage)+'px','height': radius+'px','width': radius+'px'}">
      <div class="Garden_msg">
        <div><span>{{titleval}}</span></div>
        <div class="percentage"><span>{{percentage}}</span><span>%</span></div>
      </div>
    </div>
  </div>
</template>

<script>
export default{
  name:'Garden',
  props:{
    titleval:String,
    percentage:Number,
    radius:Number,
  },
  methods: {
    getaddPx(e){
      console.log(e)
      return Number(e)+Number(20);
    },
    getPx(e){
      console.log(e)
      console.log(this.radius)
      return (e*this.radius)/100;
    },
    accMul(arg1,arg2)
    {
        var m=0,s1=arg1.toString(),s2=arg2.toString();
        try{m+=s1.split(".")[1].length}catch(e){}
        try{m+=s2.split(".")[1].length}catch(e){}
        return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
    },
  },
}
</script>
<style lang="less" scoped>
.Garden_div {
  // height: 260px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  .Garden {
    height: 240px;
    width: 240px;
    background-color: #1890FF;
    border:#1890FF 2px solid;
    border-radius: 1000px;

    display: flex;
    align-items: center;
    justify-content: center;

    background-image: url('../../../assets/img/Picture1.png');
    background-repeat: no-repeat;
    background-position: bottom;
    background-size: 110% 110%;
    .Garden_msg{
      .percentage{
        text-align: center;
        margin-top: 15px;
        >span:nth-child(1){
          font-size: 22px;
        }
        >span:nth-child(2){
          font-size: 14px;
        }
      }
    }
  }
}
</style>

注意

background-image: url(‘…/…/…/assets/img/Picture1.png’);图片自己定义,和背景色颜色不一致就行
入参分别是标题内容,圆形大小,和当前进度百分比

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值