图表的使用(3)-柱状图

在完成项目图表的时候,通过更改css样式,不借助echarts可以页面绘制出柱状图
页面详细代码如下所示

<template>
  <div>
    <div class="charts" >
     <el-card>
       <div style="font-weight: bold;margin-bottom: 15px;">Top10</div>
       <div class="service-progress" v-for="(item,index) in chartData06" :key="index"
            :value="item"  style="position: relative">
         <el-progress :percentage="(parseInt(item.value)/topNumber)*100"
                      :stroke-width="25"
                      :show-text=false
                      class="progress-bar">
         </el-progress>
         <el-row type="flex" justify="center" align="middle" class="progress-info">
           <div class="info-c-1">
             <el-tooltip class="item" effect="dark" :content="item.name" placement="top" :enterable="false">
               <span class="dataNameTxt" style="color: white">{{item.name}}</span>
             </el-tooltip>
           </div>
         </el-row>
         <div class="statistics" >
             <span style="margin-left:20px;">{{ item.value}}</span>
         </div>
       </div>
     </el-card>
    </div>
  </div>
</template>

<script>
import monitor from "../../../api/monitor";
import {countDateFn} from '@/views/utils/editTime'
export default {
  name: "topNCpmDatabase",
  props:["datetime"],
  data(){
    return{
      showTopNCpmData: true,
      chartData06:[],
      topNumber:1,
    }
  },
  methods:{
    topSlow(data){
      let arr=[]
      for(let i of data){
        arr.push(parseInt(i.value))
      }
      let max = Math.max.apply(1, arr);
      this.topNumber=max
    },

   // 请求数排行(CPM) Top10
   async getTopNCpmDatabase(start,end){
     let {step, startDate, endDate} = countDateFn(start, end);
     let params={
       end:endDate,
       start:startDate,
       step:step,
     }
     await monitor.queryTopNCpmDatabase(params).then(res => {
       if (res.data && res.status === 200) {
         if(res.data.success){
           this.chartData06 = res.data;
           this.topSlow(this.chartData06)
         }else{
           this.chartData06=[];
         }
       } else {
         this.$popError(res.data.message);
        }
      })
    },

  },
  watch:{
    datetime(){
        const {startTime,endTime}=this.datetime;
        this.getTopNCpmDatabase(startTime,endTime)
    }
  }
}
</script>

<style lang="scss" scoped>
  .charts .el-card{
    height: 310px;
  }

/*进度条样式*/
.progress-box {
  width: 100%;
  overflow: hidden;
}
.service-progress {
  padding: 1px 80px 6px 5px;
  cursor: pointer;
}
/deep/ .el-progress-bar__outer {
  border-radius: 3px !important;
  background-color: rgb(206,230,236);
}
/deep/ .el-progress-bar__inner {
  border-radius: 3px;
  background-color: rgb(36,161,193);
}
/deep/ .progress-info.el-row.is-justify-center.is-align-middle.el-row--flex{
  border-radius: 3px;
}
.progress-info {
  width: 100%;
  margin-top: -25px;
  height: 25px;
  display: flex;
  justify-content: flex-start;
}
.info-c-1 {
  width: 40%;
  text-align: left;
  padding-left: 10px;
  font-size: 10px;
  color: #495060;
}
.dataNameTxt {
  display: inline-block;
  max-width: calc(100% - 5px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.statistics {
  font-size: 10px;
  position: absolute;
  top: 4px;
  width: 120px;
  right: -45px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/deep/ .el-card__body {
  position: relative;
}
.changeChart {
  cursor: pointer;
  position: absolute;
  z-index: 100;
  right: 30px;
}
</style>

页面展示效果如下所示
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值