我正在尝试使用位于此处的raphael.js示例:
但我想将饼图转换为圆环图(在所有切片的中间有一个洞).目前,使用以下代码创建每个切片:
function sector(cx, cy, r, startAngle, endAngle, params) {
//console.log(params.fill);
var x1 = cx + r * Math.cos(-startAngle * rad),
x2 = cx + r * Math.cos(-endAngle * rad),
y1 = cy + r * Math.sin(-startAngle * rad),
y2 = cy + r * Math.sin(-endAngle * rad);
return paper.path(["M", cx, cy, "L", x1, y1, "A", r, r, 0, +(endAngle - startAngle > 180), 0, x2, y2, "z"]).attr(params);
}
Run Code Online (Sandbox Code Playgroud)
如何修改这个以便从整个馅饼中移除一个固定半径的孔?我在这里看到这篇文章,这有所帮助,但我不知道如何或在何处将其应用于我的代码: