jquery - 制作饼图问题

标签 jquery html css pie-chart

我正在创建一个饼图,但没有变成我想要的。所以有人可以帮助我。

我想在下面的图像中制作图表。我现在想制作一个饼图作为图像。所以有人可以正确的 html css 和 js 代码

<!DOCTYPE html>
<html>

<head>
  <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
  <script src="http://cdn.bootcss.com/easy-pie-chart/2.1.4/jquery.easypiechart.min.js"></script>
</head>
<style>
  .epie-chart {
    width: 150px;
    height: 150px;
    position: re;
  }
  
  .epie-chart p {
    display: inline-block;
    position: absolute;
    line-height: 24px;
    text-align: center;
    width: 114px;
    font-size: 39px;
    color: #ff6500;
  }
</style>

<body>
  <div class="epie-chart" data-percent="75">
    <p>75%</p>
  </div>
  <div class="epie-chart" data-percent="90">
    <p>90%</p>
  </div>
  <div class="epie-chart" data-percent="69">
    <p>69%</p>
  </div>
  <div class="epie-chart" data-percent="79">
    <p>79%</p>
  </div>
</body>
<script type="text/javascript">
  $(function() {
    $('.epie-chart').easyPieChart({
      easing: 'easeInOut',
      barColor: 'white',
      trackColor: 'blue',
      scaleColor: false,
      scaleLength: 5,
      lineCap: 'butt',
      lineWidth: 55,
      size: 110,
      rotate: 360,
      animate: {
        duration: 1000,
        enabled: true
      },
      onStep: function(from, to, percent) {
        $(this.el).find('.percent').text(Math.round(percent) + '%');
      }
    });
  });
</script>

</html>

但我想成为这个形象 enter image description here

最佳答案

您需要更改lineWidth

$(function() {
  $('.epie-chart').easyPieChart({
    easing: 'easeInOut',
    barColor: 'white',
    trackColor: 'blue',
    scaleColor: false,
    scaleLength: 5,
    lineCap: 'butt',
    lineWidth: 20,
    size: 110,
    rotate: 360,
    animate: {
      duration: 1000,
      enabled: true
    },
    onStep: function(from, to, percent) {
      $(this.el).find('.percent').text(Math.round(percent) + '%');
    }
  });
});
.epie-chart {
  width: 110px;
  height: 110px;
  display: block;
  border-radius: 50%;
  border: 2px solid #EC5F51;
  position:relative;
}
.epie-chart:before{
    content: "";
    position: absolute;
    width: 75px;
    height: 70px;
    background: white;
    z-index: 0;
    border-radius: 50%;
    left: 17px;
    top: 20px;
    line-height: 114px;
    text-align: center;
    border: 1px solid;
}
.epie-chart p {
  display: inline-block;
  position: absolute;
  line-height: 24px;
  text-align: center;
  width: 114px;
  font-size: 39px;
  color: #ff6500;
}
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script src="http://cdn.bootcss.com/easy-pie-chart/2.1.4/jquery.easypiechart.min.js"></script>
<div class="epie-chart" data-percent="75">
  <p>75%</p>
</div>
<div class="epie-chart" data-percent="90">
  <p>90%</p>
</div>
<div class="epie-chart" data-percent="69">
  <p>69%</p>
</div>
<div class="epie-chart" data-percent="79">
  <p>79%</p>
</div>

关于jquery - 制作饼图问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59193170/

相关文章:

html - 将 CSS 元素与设置的宽度对齐

javascript - 如何正确使用 if/else 结构从右侧动画新内容并通过向左滑动摆脱旧内容?

css - 在 SASS 中评估像素的百分比

javascript - 单击时替换图像 SRC

javascript - 如何让这个多余的javascript更加高效?

javascript - 页面刷新子菜单上的 Accordion 垂直菜单栏隐藏

javascript - 如何防止 iframe 两次运行加载事件?

javascript - document.getElementById().innerHTML 是否不能用于插入新的 html,这会破坏其内部的括号?

javascript - 使用 fullPage.js 将事件类添加到两个/拆分菜单

javascript - 如何使用 JavaScript 获取多个 div 的背景图像并将它们用作模态图像的来源?