Javascript 带拉斐尔的圆圈内文字
我试图用拉斐尔复制以下图像: 到目前为止,我只是设法让这个圈子运作起来。如何获得圆圈内微弱的灰色轮廓(显示剩余部分)和文本Javascript 带拉斐尔的圆圈内文字,javascript,css,raphael,Javascript,Css,Raphael,我试图用拉斐尔复制以下图像: 到目前为止,我只是设法让这个圈子运作起来。如何获得圆圈内微弱的灰色轮廓(显示剩余部分)和文本 var score = 883 var amount = score/1000 * 100; var archtype = Raphael("canvas", 200, 100); archtype.customAttributes.arc = function (xloc, yloc, value, total, R) { var alpha = 360 /
var score = 883
var amount = score/1000 * 100;
var archtype = Raphael("canvas", 200, 100);
archtype.customAttributes.arc = function (xloc, yloc, value, total, R) {
var alpha = 360 / total * value,
a = (90 - alpha) * Math.PI / 180,
x = xloc + R * Math.cos(a),
y = yloc - R * Math.sin(a),
path;
if (total == value) {
path = [
["M", xloc, yloc - R],
["A", R, R, 0, 1, 1, xloc - 0.01, yloc - R]
];
} else {
path = [
["M", xloc, yloc - R],
["A", R, R, 0, +(alpha > 180), 1, x, y]
];
}
return {
path: path
};
};
var my_arc = archtype.path().attr({
"stroke": "#00BB7B",
"stroke-width": 7,
arc: [50, 50, 0, 100, 30]
});
my_arc.animate({
arc: [50, 50, amount, 100, 30]
}, 1500, "bounce");
jshiddle here:1)您可以显示天平,只需将其置于绿色弧闭合灰色弧下即可:
var remainder = archtype.path().attr({
"stroke": "#eeeeee",
"stroke-width": 7,
arc: [50, 50, 100, 100, 30]
});
2) 要设置文本计数器的动画,还可以使用“手动”属性:
archtype.customAttributes.counter = function (counter) {
return { text: counter, counter: counter }
}
[]