【问题标题】:dynamic colors in jquery circle-progressjquery circle-progress中的动态颜色
【发布时间】:2016-02-17 11:45:07
【问题描述】:

我正在使用 jquery circle-progress 插件,我希望颜色根据使用情况为 3 种颜色,例如颜色应该是橙色,从 0 到 10,从 10 到 90,如果为 100,则为蓝色和红色,代码如下

var c4 = $('.forth.circle');
c4.circleProgress({
    startAngle: -Math.PI / 4 * 3,
    value: 0.1,
    size: 170,
    fill: { color: '#fc5201' }

}); 

【问题讨论】:

  • 这个例子看起来并不完整。您能否编辑并添加更多详细信息,例如使用的 HTML。
  • 我根据您引用的示例创建了一个小提琴:jsfiddle.net/Twisty/yn6t6cvg

标签: javascript jquery jquery-ui jquery-plugins


【解决方案1】:

您将不得不使用渐变,它不是为圆的各个部分着色,而是为背景着色。我到了这一点:https://jsfiddle.net/yn6t6cvg/3/

这并不完全符合您的要求,但也许它会让您朝着正确的方向前进。

HTML

<div class="circles">
  <div class="forth circle">
    <strong></strong>
    <span>custom angle, <br/> value update</span>
  </div>
</div>

CSS

.circle {
  width: 100px;
  margin: 6px 6px 20px;
  display: inline-block;
  position: relative;
  text-align: center;
  line-height: 1.2;
}

.circle canvas {
  vertical-align: top;
}

body {
  background-color: #444;
  padding-top: 40px;
  font: 15px/1.3 Arial, sans-serif;
  color: #fff;
  text-align: center;
}

.circle span {
  display: block;
  color: #aaa;
  margin-top: 12px;
}

JQuery

$(document).ready(function() {
  var c4 = $('.forth.circle');

  c4.circleProgress({
    startAngle: -Math.PI / 4 * 3,
    value: .75,
    size: 170,
    fill: {
      gradient: [ 
        ["red", .3],
        ["blue", .6],
        ["orange", .3]
      ],
      gradientAngle: Math.PI / 4 * 8.5,
    }
  });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 2011-11-12
    相关资源
    最近更新 更多