数据可视化大屏进度条效果实例渐变色进度条

vue yekong

进度条效果:
进度条颜色是渐变色,可以通过传值自定义
进度条带有动画效果 使用gsap实现补间动画
进度条有最大宽度,给右侧留有展示数据的空间
进度条有默认背景色
进度条宽度根据总数和当前数据计算百分比

数据可视化大屏进度条效果实例渐变色进度条

使用组件

<progressBar class="wow fadeInLeft" :total="total" :data-wow-delay="1.2+0.3*index+'s'" :item="item"
                   v-for="(item,index) in list"
                   :key="index"></progressBar>

list: [{
    title: '东门',
    num: 1266,
    color: 'rgba(4, 206, 247, 1)',
    color2: 'rgba(18, 99, 255, 1)'
    }, {
    title: '北门',
    num: 10,
    color: 'rgba(4, 206, 247, 1)',
    color2: 'rgba(18, 99, 255, 1)'
    }, {
    title: '南门',
    num: 666,
    color: 'rgba(4, 206, 247, 1)',
    color2: 'rgba(18, 99, 255, 1)'
}],

组件代码

/**
* @Author: 858834013@qq.com
* @Name: progressBar
* @Date: 2023年03月27日
* @Desc: 进度条效果
*/
<template>
  <div class="progressBarBody">
    <div class="progressBarBodyTitle">{{ item.title }}</div>
    <div class="progressBar">
      <div class="progressBarInner"
           :style="{background: 'linear-gradient(180deg, '+item.color+' 0%, '+item.color2+' 100%)'}"
           ref="progressBarInner"></div>
      <div class="line"></div>
      <div class="Num">{{ item.num }}人</div>
    </div>
  </div>
</template>

<script>
import gsap from "gsap";

export default {
  name: "progressBarBody",
  props: {
    item: {
      type: Object,
      default() {
        return {}
      }
    },
    total: {
      type: Number,
      default() {
        return 0
      }
    },
  },
  data() {
    return {}
  },
  computed: {
    width: function () {
      return (this.item.num / this.total).toFixed(2) * 100
    }
  },
  mounted() {
    setTimeout(() => {
      gsap.to(this.$refs.progressBarInner, {
        duration: 1.5, width: this.width + '%', onComplete: () => {
          console.log('动画完成')
        }
      })
    }, 2500)
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
.progressBarBody {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: nowrap;
  flex-direction: column;
  align-content: flex-start;
  width: calc(100% - 20px);

  .progressBarBodyTitle {
    font-size: 13px;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: bold;
    color: #D7E7FF;
    height: 35px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
  }

  .progressBar {
    width: 100%;
    height: 10px;
    background: linear-gradient(180deg, rgba(#04CEF7, 0.2) 0%, rgba(#1263FF, 0.2) 100%);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;


    .Num {
      font-size: 14px;
      font-family: DIN-Bold, DIN;
      font-weight: bold;
      color: #FFFFFF;
      margin-left: 10px;
    }
  }
}

.progressBarInner {
  height: 10px;
  background: linear-gradient(180deg, #04CEF7 0%, #1263FF 100%);
  opacity: 1;
  width: 0%;
  max-width: calc(100% - 60px);
}

.progressBarl {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
}

.line {
  height: 12px;
  width: 2px;
  background: #04CEF7;
  opacity: 1;
  margin-left: 2px;
}
</style>

更多进度条效果实例

vue 数据可视化大屏进度条效果实例

数据大屏页面渲染效果实例

vue3 可视化数据大屏 - 数据资产大屏

喜欢