css画饼图

 

<template slot-scope="scope">

          <div class="pie" :style="{'--p': scope.row.rate}" style="--p:10;--b:10px;--c:#FFAB79;">

            <!--

              --p:这个变量应该包含百分比值作为一个数字(不带%符号)。它应该与内容相同。

              --b:这个变量将定义边框的粗细。

              --c:这个变量将定义主要颜色。

            -->

            <!-- 60% -->

          </div>

          <!-- <el-progress

            type="circle"

            :percentage="scope.row.rate"

            :width="40"

            :show-text="false"

          ></el-progress> -->

        </template>

<style lang="scss" scoped>

  .pie {

   --w:50px;

   width: var(--w);

   aspect-ratio: 1; // aspect-ratio: 1用来确保元素保持方形

   position: relative;

   display: inline-grid;

   place-content: center;

   margin: 5px;

   font-size: 12px;

   font-weight: bold;

   font-family: sans-serif;

 }

 .pie:before {

   content: "";

   position: absolute;

   border-radius: 50%;

   inset: 0;

   background: conic-gradient(var(--c) calc(var(--p)*1%),rgba(28, 157, 255, 1) 0);

  //  -webkit-mask:radial-gradient(farthest-side,#0000 calc(99% - var(--b)),#000 calc(100% - var(--b)));

  //          mask:radial-gradient(farthest-side,#0000 calc(99% - var(--b)),#000 calc(100% - var(--b)));

 }

</style>

 参考文章:手把手教你使用CSS制作动态饼图(附代码)(点晴免费OA系统(国内永久免费OA协同办公管理软件)最好的官网下载)

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值