YOu可以看到这个here的一个工作示例。从0到360度画圆弧,用d3.js
我的问题是关于内部的小蓝弧。我想说明的弧线从0开始打算从斜边0到360
目前M代码看起来像这样,增加了圆弧:
const hypotenuseCoords = {
x1: hypotenuseCentre,
y1: parseFloat(state.hypotenuse.attr('y1')),
x2: xTo,
y2: dy
};
const angle = Math.atan2(hypotenuseCoords.y2 - hypotenuseCoords.y1, hypotenuseCoords.x2 - hypotenuseCoords.x1);
const arc = d3.svg.arc()
.innerRadius(15)
.outerRadius(20)
.startAngle(Math.PI/2)
.endAngle(angle + Math.PI/2);
state.innerAngle
.attr('d', arc)
.attr('transform', `translate(${hypotenuseCentre}, 0)`);
的问题是,电弧唯一无二从0到π或180和180到360.我认为坐标中的startAngle是错误的。
我怎样才能让电弧从0到360的正圆?
不错。你有一个我们可以编辑的工作小提琴? – thatOneGuy